Allow adding layers to map that could not be completely reprojected

Description

The core reprojection method (Shapefile.ReprojectCore) will iterate all shapes in a Shapefile, transforming as many as it can, bypassing shapes that cannot be transformed, and maintaining a count of how many were successfully transformed.

If the map has to reproject a layer while adding it to the map (via MapView.ReprojectLayer), a call is made into the reprojection method, and the number of reprojected shapes is returned. This number is compared with the total number of shapes in the file, and if they differ, the process fails and the layer will not be added to map.

There are times and circumstances in which you might want layers to be added to the map even if some of the shapes could not be transformed. To provide for this, a new Global Setting will be added, called AllowLayersWithIncompleteReprojection. The default value will be false, so that existing behavior is not changed, but when set to true, will allow layers to be added to the map even if not all shapes could be transformed.

Activity

Show:
Jerry Faust
October 19, 2019, 5:53 AM

Update posted on 10/18/2019: It was discovered that for OGR layers, the LayerReprojectedIncomplete event was being fired before the reprojected Shapefile was re-injected into the OGR layer, and thus might be acted upon while referencing the old data. Event is now deferred until after the re-injection.

Jerry Faust
March 7, 2019, 1:25 AM

A new global setting has been added to allow layers that could not be fully reprojected to still be added to the map. The setting is called AllowLayersWithIncompleteReprojection. The default value will be false, so that existing behavior is not changed.

Additionally, it seemed necessary to provide a mechanism to allow the caller to know if a layer has been added to map with incomplete data. Therefore, a new event has also been added. There was already a LayerReprojected event, passing as parameters the LayerHandle, and a Success value (true or false), indicating whether or not the layer was successfully reprojected. Those events will continue to be raised as before.

A new event has now been added, called LayerReprojectedIncomplete, passing as parameters the LayerHandle, and two integer values, NumReprojected and NumShapes, indicating the number of reprojected shapes out of the total number of shapes in the layer. This event will be raised in addition to LayerReprojected with Success = true.

And as before, following the reprojection, you can call either GdalLastErrorMessage or Shapefile.ErrorMsg to get an idea of what went wrong.

Done

Assignee

Jerry Faust

Reporter

Jerry Faust

Labels

None

Epic Link

None

Affects versions

None

Fix versions

Priority

Medium