SimplifyLines sample

Mar 30, 2013 at 4:04 PM

Anybody can share piece of code that shows usage of SimplifyLines ? i keep getting null for all the my shapefiles. Please help! it is urgent.

thank a lot.
Mar 31, 2013 at 2:57 AM
anybody??? i am stuck just for this piece of code. please.
Mar 31, 2013 at 3:37 AM
Check the last error by calling get_ErrorMsg() on the original shapefile. Looking at the code for SimplifyLines, it is probably one of these:
  1. no shapes in the shapefile
  2. incompatible shapefile (point shapefiles are incompatible for obvious reasons)
  3. failed to clone the original (this occurs prior to simplifying the lines, but I kind of doubt this is the issue)
  4. no shapes in the new shapefile after all the lines were simplified
Along with checking the ErrorMsg, you could also specified a global callback method to see how far (percentage-wise) you are getting in the process.

Oh yea, here is a list of what I think are the valid shapefile types: POLYGON, POLYGONM, POLYGONZ, POLYLINE, POLYLINEM, POLYLINEZ

Hope some of this helps.
Mar 31, 2013 at 6:37 AM
This is my code:
MapWinGIS.Shapefile shapefile1 = new MapWinGIS.Shapefile();
shapefile1.Open(@"C:\Shapes\grid100.shp", null );
MapWinGIS.Shapefile beforeresult = shapefile1.
MapWinGIS.Shapefile result = beforeresult.SimplifyLines(1.00, false);
It says no error but result is NULL.

Any idea?
Mar 31, 2013 at 12:01 PM
First off, try this to get the error:
MapWinGIS.Shapefile shapefile1 = new MapWinGIS.Shapefile();
shapefile1.Open(@"c:\shapes\grid100.shp", null);
MapWinGIS.Shapefile result = shapefile1.SimplifyLines(1.00, false);
Secondly, you could try a bigger tolerance. Try using 10 (or even 100) to see if the result is different.

If that doesn't help, you could try to send me the shapefile and I'll play with it. Send me a message via codeplex with your email if you want to go that route. I'm guessing the file is probably small enough to fit on an email.
Mar 31, 2013 at 12:09 PM
First of all , your code gives me another error.

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Main reason i used the CLONE was to get rid of this error. I tried my own code changing it to LastErrorCode and still says no error.
Mar 31, 2013 at 2:35 PM
For guys after having same problem, this is a bug in current version ( 31-Mar-2013) . When you call simplifyline you need to set the call back otherwise you go into this. ... This is fixed by heste015. ( big thank you to him ) .

Thank you.