I am using the SQL Server driver to load OGR layers into MapWinGIS. The layers required reprojection, and I encountered a number of issues during this process. I will list the issues here, and create Atlassian/JIRA tickets to document the fixes. My intent is to fix each of these issues. Thank you.
- When not reprojecting-in-place, shapes and attributes are copied from the source Shapefile to the destination Shapefile. This process allows for the bypassing of Shapes that could not be reprojected, in which case the source row index will get out-of-sync with the target row index. This was properly coded for the Shapes, but when copying the Shapefile attributes, the source row index was being used for the target row, resulting in an out-of-range exception for the target row.
ReprojectCore, while iterating the Shapes, a
VARIANT_BOOLis used to capture the result of individual library calls (for example,
EditCellValue). However, the value of the
VARIANT_BOOLis never observed during the iteration, so it may be toggling both
FALSE, and whatever value it has at the end of the iteration is (inappropriately) used to determine the success or failure of the function. This method will be slightly restructured to properly capture success or failure.
ReprojectCore, handing in a nullptr for the
Shapefile**parameter, and setting the
reprojectInPlaceflag = true. Every time the
Shapefile**is referenced, it should be conditional, based on the value of
reprojectInPlacebeing false. However, there is one call,
ClearShapefileModifiedFlag, which is not called conditionally, and the library throws a Null Reference exception in this case.
Shapefile.Reprojectis called from
MapView.ReprojectLayer. Following the call to
ReprojectLayer, a comparison is made to see if the number of Shapes reprojected is equal to the number of Shapes in the original layer. If the number differs, the Reprojection is failed, and the function returns
FALSE. So even though the
Reprojectmethod allows for failure of individual Shape conversions, the calling routine will reject the entire layer if there is even one bad record. I believe that we should allow a layer to be added to the map even if not all Shapes could be reprojected. Since this would be a change to the current map behavior, I would recommend a new Global Setting so that, at the programmers discretion, we allow layers to be added for which not all Shapes could be reprojected.
OgrLayer.ReloadFromSourcecall 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.