Read Only Coordinate X and Y Properties?


As mentioned in

Was wondering why the X and Y properties of the Coordinate class were read only. I have a few use cases where I allow users to move coordinates. I had to obtain the InternalObject to do this. When I have time I will look at the Shape Editor Plugin to see how it handles this. There may be a good reason for this but it's not obvious to me right now.


Paul Meems
May 18, 2017, 12:10 PM

Response of :

it's difficult to recall the details exactly, but the intent was optimization. When so called 'fast mode' for shapefile is activated, it doesn't use COM points internally, so Point objects are created on the fly. Therefore it's useless to change their coordinates, the datasource won't know. Now, I see no reason why to allow setters for Z, M and not for X, Y. I think it was done just by mistake. As for moving point it should be done via Geometry.SetPoint(x, y). Currently there is no such method, but it should be added and it can call underlying method of Shape class. Also this whole situation can be resolved by not using fast mode in the first place. Then it's ok to change coordinates directly through Coordinate instance.

Paul Meems
June 3, 2017, 8:44 AM

and I have been discussing this over the last few weeks and this is the outcome:

Using InternalObject generally is not recommended, since it adds direct reference to MapWinGIS. I left this backdoor for example for situations where performance is needed or some members are missing in API. In MapWinGIS a point can be moved with Shape.put_XY(pointIndex, x, y). In MW5 (develop branch) I don't see a wrapper for this method. So I suggest to add Geometry.MovePoint(pointIndex, x, y).

To the geometry class I added

and disabled the Setters for M and Z in the Coordinate class.


Paul Meems


Paul Meems



Fix versions

Affects versions