MapWinGIS.Point.Key property - lost then point is added to the shape


If I create new object of MapWinGis.Point class and assign some value to the shape point “Key” property - the last one is stored. But if I add this point to the shape points collection then I don’t see that this property is remembered. Long time ago it was working fine and the property allowed to keep some references to the external data structures.
Also if I use following code below to obtain the point data and assign the “Key” property value – then it doesn’t work either:
shape.get_Point(i).Key = “ttt”.
I have checked the latest activeX control code and found that this point property is ignored then the point is added to the data collection. (shape file feature points)
Could you advise if this property is not in using anymore or perhaps I don’t use it correctly?
If do the same things to the MapWinGIS.Shape class, create an object assign "Key" value and add it to the shape collection into the shape file - then it is working fine.
Closed Dec 10, 2014 at 4:35 PM by sleschinski
Point.Key isn't stored in fast mode. So it functions as designed.


danames wrote Jan 18, 2011 at 1:50 AM


This is likely a bug that was introduced but wasn't meant to be. Does the
work around of adding the Key value after adding the point to the array
work for you? Are you C++ skilled enough to look at the code and suggest a



IgorKl wrote Jan 19, 2011 at 12:09 PM


I tried to assign the key value after adding the point to the array, but it still didn’t work.

I am not really good with C++, but after I revised the code I found following:

MapwinGis.Shapeclass is not using MapwinGis.Point structure to keep the point data in the collection. Instead of this I see that Point data is stored int separate collections which are:
std::vector _parts;
std::vector _pointsZ;            
std::vector _pointsM;
When you add a point to the shape the following procedure adds the data to these collections: “InsertPointXYZM”. And this procedure copies all Point attributes but not a “Key” property.

Also I don’t see that ShapeClass can keep “Keys” as I don’t see any appropriate collection to keep these values in. I suppose one more collection should be added to the ShapeFileClass, something like: std::vector _pointsKey;


sleschinski wrote Jan 19, 2011 at 10:32 PM

you are right. The ShapeWrapper class doesn't store the key property. Actually it's not difficult to fix it. But the problem is somewhat wider.

The idea of introducing this ShapeWrapper class was to speed up edit mode. And it indeed works as Shapefile.StartEditShapes works about 5 times faster when we must not generate COM objects. The redraw is notecably faster then in regular mode.

But there is a serious problem here: while using Shape.get_Point() property one receive instance of COM class which isn't bound to the data. So
Shape.get_Point(Index).X = newValue;
won't change the the X position and this actually break the existing code.

I was thinking over the problem, but the only way I see is return to the old code. Luckily it's still there, as I used conditional compilation for shape class.

Mostly likely the optimization made in ShapeWrapper class will be available as separate mode, through property like:
bool Shapefile.UseFastEditMode();

I'm going make the changes in the next 1-2 weeks.

Thanks for reporting this,

IgorKl wrote Jan 19, 2011 at 11:54 PM


I have noticed the difference. My personal feeling is that you are doing right. If I would make a choice between a performance and usability of dll interface I would choose performance! I strongly believe that most of developers would go for the first option as well. I think the performance is most important feature of GIS canvas. And it should allow developers to make a really performed application. Year by year Users are using larger and larger data sets as it was years ago. So if you are going to simplify developer’s life and implement better usability of programming interface then, I am afraid, final Users will not need ordinary software as they can find a lot of nice implementations like QGIS and others.

For now if I need to update point coords I do the following:
Shape.DeletePoint( pointed ); Shape.InsertPoint ( pointIndex, Point);

What I would expect to see is the following:
Shape.UpdatePoint (pointIndex, Point)

That would be good enough. And I would extend missing functionality in this manner. This also would allow you to trace the changes within the “MapWinGis.Shape” class. As an example: in case if user applies some changes to the point - it would be easy to trace changes and update (redraw) the ma. Or if user locked the map – update the last one only if it is unlocked (in case if User needs to make lots of changes before redraw the map)

One more useful thing would be procedure description (XML comment/Tag) so if Developer types Shape.get_Point( pointID) then Visual studio could popup this comment and Developer could see the following: (returned object properties are not editable. to edit property value use:.... etc...)