[mapguide-users] RE: API call for transforming polygon to line?

Andy Morsell amorsell at spatialgis.com
Wed Mar 15 18:54:30 EST 2006


Hi Jason,
How about using FME to convert your polygon data to line data prior to
loading through Studio?  As you know, I am generally not a proponent of
pre-processing of data if it can be avoided.  But, I am finding that I have
to generalize almost all of my data anyway for use with Google Earth /
MapGuide Open to avoid the GE timeout problems you mention.  I do this with
FME so adding a couple more transformers to the process to convert to lines
wouldn't add too much overhead.  Doing this would also speed things up on
the MapGuide processing side of things.

Andy Morsell, P.E. 
Spatial Integrators, Inc. 
http://www.SpatialGIS.com 

  _____  

From: Jason Birch [mailto:Jason.Birch at nanaimo.ca] 
Sent: Wednesday, March 15, 2006 3:37 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] RE: API call for transforming polygon to line?


Thanks Dave.  
 
I think I'll go with the less rigorous approach, as it would lend itself
well to a simple regular expression substitution, and because it would take
considerably less processing time.  Google Earth seems to be picky about
getting data back in a timely manner, and I'd rather support a larger number
of features returned than better code.  Sometimes the best approach isn't
the best solution :)
 
Jason

  _____  

From: Dave Wilson [mailto:dave.wilson at autodesk.com]
Sent: Wed 2006-03-15 2:06 PM
To: users at mapguide.osgeo.org
Subject: [mapguide-users] RE: API call for transforming polygon to line?


Hey Jason,
 
I don't think there is a direct API call to do this. If I'm wrong hopefully
someone will pipe up.
 
Programmatically there are a couple of ways you can do this.
 
A quick and dirty way would be to get the WKT string of the Polygon using
the MgWktReaderWriter which would yield something like:
 
POLYGON ((1 1, 1 -1, -1 -1, -1 1, 1 1))
 
You could parse the resulting string to remove the POLYGON (  and trailing )
leaving (1 1, 1 -1, -1 -1, -1 1, 1 1).
 
Then concatenate LINESTRING to it and you can use the ReaderWriter to create
the geometry object for you from the string.
 
Of course if your polygon has inner rings you will have to check the count
of the inner rings using GetInteriorRingCount as these won't convert to
simple linestrings. You may be able to convert them to MULTILINESTRING
instead by just changing the leading concatenation.
 
If your polygon contains curvestrings in it I'm not sure if you can again
just change the leading concatenation to CURVESTRING as I haven't worked
with these. The quick and dirty is nice because it requires minimal
processing and if all your polygons don't have inner rings or curves it's a
piece of cake.
 
An alternative and more rigorous approach would be to determine the types of
polygon involved and walk the geometry, getting each of the coordinate
values and using an MgGeometryFactory create the MgLinestring or
MgMultLinestring or other type as needed but this will be more complex code
I think because you need to use collection objects and looping to walk the
objects.
 
Regards,
Dave

  _____  

From: Jason Birch [mailto:Jason.Birch at nanaimo.ca] 
Sent: Wednesday, March 15, 2006 1:21 PM
To: users at mapguide.osgeo.org
Subject: API call for transforming polygon to line?


Is there a method that would allow me to type case a polygon to a line?  I
can do the same going to a point with the GetCentroid command (I think) but
can't figure out poly->line.
 
Thanks,
Jason
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 7462 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/mapguide-users/attachments/20060315/824da5a0/winmail.bin


More information about the Mapguide-users mailing list