Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for version 201 #1820

Merged
merged 6 commits into from
Feb 21, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix bounding box issue with multiple layers
Make the full extent set using the top layer bounding box;
When reorder layers in MapLayerSettings dialog, set map extent using top layer bounding box automatically;
lixun910 committed Feb 19, 2019
commit b11ee74b530b30f006f03d7708230f6d1687741a
15 changes: 15 additions & 0 deletions Explore/Basemap.cpp
Original file line number Diff line number Diff line change
@@ -286,6 +286,21 @@ void Basemap::Reset(int map_type)
SetupMapType(basemap_item);
}

void Basemap::Extent(double _n, double _w, double _s, double _e,
OGRCoordinateTransformation *_poCT)
{
if (poCT!= NULL) {
poCT->Transform(1, &_w, &_n);
poCT->Transform(1, &_e, &_s);
}
map->north = _n;
map->south= _s;
map->west= _w;
map->east= _e;
GetEasyZoomLevel();
SetupMapType(basemap_item);
}

void Basemap::ResizeScreen(int _width, int _height)
{
if (screen) {
3 changes: 2 additions & 1 deletion Explore/Basemap.h
Original file line number Diff line number Diff line change
@@ -397,7 +397,8 @@ namespace Gda {
wxString GetTilePath(int x, int y);

bool Draw(wxBitmap* buffer);

void Extent(double _n, double _w, double _s, double _e,
OGRCoordinateTransformation *_poCT);
void ResizeScreen(int _width, int _height);
void ZoomIn(int mouseX, int mouseY);
void ZoomOut(int mouseX, int mouseY);
6 changes: 6 additions & 0 deletions Explore/MapLayer.cpp
Original file line number Diff line number Diff line change
@@ -56,6 +56,12 @@ BackgroundMapLayer::~BackgroundMapLayer()
}
}

void BackgroundMapLayer::GetExtent(double &minx, double &miny, double &maxx,
double &maxy)
{
layer_proxy->GetExtent(minx, miny, maxx, maxy);
}

void BackgroundMapLayer::CleanMemory()
{
// shapes and geoms will be not deleted until the map destroyed
4 changes: 3 additions & 1 deletion Explore/MapLayer.hpp
Original file line number Diff line number Diff line change
@@ -51,7 +51,8 @@ class AssociateLayerInt

virtual GdaShape* GetShape(int i) = 0;
//virtual vector<GdaShape*> GetShapes() = 0;
//virtual wxRect GetExtent() = 0;
virtual void GetExtent(double &minx, double &miny, double &maxx,
double &maxy) = 0;

virtual void SetLayerAssociation(wxString my_key, AssociateLayerInt* layer,
wxString key, bool show_connline=true) = 0;
@@ -105,6 +106,7 @@ class BackgroundMapLayer : public AssociateLayerInt
virtual bool IsAssociatedWith(AssociateLayerInt* layer);
virtual void RemoveAssociatedLayer(AssociateLayerInt* layer);
virtual int GetHighlightRecords();
virtual void GetExtent(double &minx, double &miny, double &maxx, double &maxy);

// clone all except shapes and geoms, which are owned by Project* instance;
// so that different map window can configure the multi-layers
54 changes: 47 additions & 7 deletions Explore/MapNewView.cpp
Original file line number Diff line number Diff line change
@@ -259,6 +259,11 @@ MapCanvas::~MapCanvas()
}
}

void MapCanvas::GetExtent(double &minx, double &miny, double &maxx, double &maxy)
{
project->GetMapExtent(minx, miny, maxx, maxy);
}

Shapefile::Main& MapCanvas::GetGeometryData()
{
return project->main_data;
@@ -551,16 +556,40 @@ void MapCanvas::deleteLayerBms()
TemplateCanvas::deleteLayerBms();
}

void MapCanvas::ExtentMap()
{
double minx, miny, maxx, maxy;
if (fg_maps.empty()) {
this->GetExtent(minx, miny, maxx, maxy);
} else {
// if multi layers are loaded, use top layer to extent map
BackgroundMapLayer* top_layer = fg_maps[0];
top_layer->GetExtent(minx, miny, maxx, maxy);
}
if (basemap) {
OGRCoordinateTransformation *poCT = NULL;
if (project->sourceSR != NULL) {
OGRSpatialReference destSR;
destSR.importFromEPSG(4326);
poCT = OGRCreateCoordinateTransformation(project->sourceSR,
&destSR);
}
basemap->Extent(miny, minx, maxy, maxx, poCT);
}
last_scale_trans.SetData(minx, miny, maxx, maxy);
}

void MapCanvas::ResetShapes()
{
if (faded_layer_bm) {
delete faded_layer_bm;
faded_layer_bm = NULL;
}
if (basemap) {
basemap->Reset();
}
last_scale_trans.Reset();

// extent map
ExtentMap();

// other rest
is_pan_zoom = false;
ResetBrushing();
SetMouseMode(select);
@@ -748,8 +777,16 @@ bool MapCanvas::InitBasemap()
poCT = OGRCreateCoordinateTransformation(project->sourceSR,&destSR);
}
Gda::Screen* screen = new Gda::Screen(screenW, screenH);
Gda::MapLayer* current_map = new Gda::MapLayer(last_scale_trans.data_y_max, last_scale_trans.data_x_min, last_scale_trans.data_y_min, last_scale_trans.data_x_max, poCT);
Gda::MapLayer* orig_map = new Gda::MapLayer(last_scale_trans.orig_data_y_max, last_scale_trans.orig_data_x_min, last_scale_trans.orig_data_y_min, last_scale_trans.orig_data_x_max, poCT);
Gda::MapLayer* current_map = new Gda::MapLayer(last_scale_trans.data_y_max,
last_scale_trans.data_x_min,
last_scale_trans.data_y_min,
last_scale_trans.data_x_max,
poCT);
Gda::MapLayer* orig_map = new Gda::MapLayer(last_scale_trans.orig_data_y_max,
last_scale_trans.orig_data_x_min,
last_scale_trans.orig_data_y_min,
last_scale_trans.orig_data_x_max,
poCT);
if (poCT == NULL && !orig_map->IsWGS84Valid()) {
isDrawBasemap = false;
wxStatusBar* sb = 0;
@@ -762,7 +799,9 @@ bool MapCanvas::InitBasemap()
}
return false;
} else {
basemap = new Gda::Basemap(basemap_item, screen, current_map, orig_map, GenUtils::GetBasemapCacheDir(), poCT, scale_factor);
basemap = new Gda::Basemap(basemap_item, screen, current_map,
orig_map, GenUtils::GetBasemapCacheDir(),
poCT, scale_factor);
}
}
return true;
@@ -2615,6 +2654,7 @@ void MapCanvas::DisplayMapLayers()
{
wxLogMessage("MapCanvas::DisplayMapLayers()");
full_map_redraw_needed = true;
ExtentMap();
PopulateCanvas();
}

6 changes: 5 additions & 1 deletion Explore/MapNewView.h
Original file line number Diff line number Diff line change
@@ -86,7 +86,8 @@ class SliderDialog: public wxDialog
};


class MapCanvas : public TemplateCanvas, public CatClassifStateObserver, public MapLayerStateObserver, public AssociateLayerInt
class MapCanvas : public TemplateCanvas, public CatClassifStateObserver,
public MapLayerStateObserver, public AssociateLayerInt
{
DECLARE_CLASS(MapCanvas)
public:
@@ -149,6 +150,7 @@ class MapCanvas : public TemplateCanvas, public CatClassifStateObserver, public
virtual void ResetShapes();
virtual void ZoomShapes(bool is_zoomin = true);
virtual void PanShapes();
virtual void ExtentMap();
virtual void ResizeSelectableShps(int virtual_scrn_w = 0,
int virtual_scrn_h = 0);
virtual void PopulateCanvas();
@@ -211,6 +213,8 @@ class MapCanvas : public TemplateCanvas, public CatClassifStateObserver, public
virtual bool IsAssociatedWith(AssociateLayerInt* layer);
virtual GdaShape* GetShape(int idx);
virtual int GetHighlightRecords();
virtual void GetExtent(double &minx, double &miny, double &maxx,
double &maxy);
void UpdateMapTree();

Shapefile::Main& GetGeometryData();
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@ namespace Gda {
const int version_major = 1;
const int version_minor = 12;
const int version_build = 1;
const int version_subbuild = 197;
const int version_subbuild = 199;
const int version_year = 2019;
const int version_month = 2;
const int version_day = 12;
const int version_day = 19;
const int version_night = 0;
const int version_type = 2; // 0: alpha, 1: beta, 2: release
}