Reloading a reprojected OGR layer from source causes layer to disappear

Description

The OgrLayer.ReloadFromSource call does not work properly on reprojected layers. Following the reload of the layer, the layer must again be reprojected. Otherwise its coordinates are no longer in the proper range, and it is no longer visible on the map.

Activity

Show:
Jerry Faust
March 6, 2019, 12:29 AM

Within MapWinGIS, layers can be loaded into memory without being added to the Map. Both Shapefiles and OGR layers can be loaded, retaining their internal projection. It is only after they are added to the Map that they are then reprojected as necessary to match the Maps projection (given all of the proper settings).

Because of this, I did not think it was appropriate to modify the ReloadFromSource method. That method should simply reload the layer, as it always has, retaining its native projection. The problem arises if the layer has already been added to, and reprojected by, the Map.

Although code could be added by the developer to account for this, and reapply the Map projection, the steps would always be the same. So I thought that it made sense to provide a single method to reload the layer from the Map's perspective (rather than the Layer's perspective). As such, I've added a new method at the top level (AxMap) called ReloadOgrLayerFromSource.

This method first calls OgrLayer.ReloadFromSource, and then goes through the same steps that already exist for layers that are added to the map - specifically to compare projections and to reproject as necessary. In this way, all of the same rules and error checking are applied, and the FireProjectionMismatch event is once again raised (in case that matters to the developer).

Note that this method only applies to OGR layers that have already been added to the Map. You must already have a valid layer handle that references an OGR layer.

Done

Assignee

Jerry Faust

Reporter

Jerry Faust

Labels

None

Epic Link

None

Affects versions

None

Fix versions

Priority

Medium