Hello All.
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.
- Within
ReprojectCore
, while iterating the Shapes, aVARIANT_BOOL
is used to capture the result of individual library calls (for example,EditInsertShape
andEditCellValue
). However, the value of theVARIANT_BOOL
is never observed during the iteration, so it may be toggling bothTRUE
andFALSE
, 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. -
Shapefile.ReprojectInPlace
callsReprojectCore
, handing in a nullptr for theShapefile**
parameter, and setting thereprojectInPlace
flag = true. Every time theShapefile**
is referenced, it should be conditional, based on the value ofreprojectInPlace
being false. However, there is one call,ClearShapefileModifiedFlag
, which is not called conditionally, and the library throws a Null Reference exception in this case. -
Shapefile.Reproject
is called fromMapView.ReprojectLayer
. Following the call toReprojectLayer
, 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 returnsFALSE
. So even though theReproject
method 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. - 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.