<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Re: [mapguide-users] multiple extent attributes on a layer</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>Hey Jason,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>I don't think there is a direct API call to do this. If I'm
wrong hopefully someone will pipe up.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>Programmatically there are a couple of ways you can do
this.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>A quick and dirty way would be to get the WKT string of the
Polygon using the MgWktReaderWriter which would yield something
like:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>POLYGON ((1 1, 1 -1, -1 -1, -1 1, 1 1))</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>You could parse the resulting string to remove the POLYGON
( and trailing ) leaving (1 1, 1 -1, -1 -1, -1 1, 1
1).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>Then concatenate LINESTRING to it and you can use the
ReaderWriter to create the geometry object for you from the
string.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>Regards,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=673443120-15032006><FONT face=Arial
color=#0000ff size=2>Dave</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Jason Birch
[mailto:Jason.Birch@nanaimo.ca] <BR><B>Sent:</B> Wednesday, March 15, 2006 1:21
PM<BR><B>To:</B> users@mapguide.osgeo.org<BR><B>Subject:</B> API call for
transforming polygon to line?<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV id=idOWAReplyText50625 dir=ltr>
<DIV dir=ltr><FONT size=2>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.</FONT></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>Thanks,<BR>Jason</FONT></DIV></DIV></BODY></HTML>