# [mapguide-users] Problem whit generate kml from mapguide.

Traian Stanev traian.stanev at autodesk.com
Tue Jan 22 14:31:57 EST 2008

```Here is an excerpt from some C++ code from MapGuide that seems to do something to that effect. You will need to replicate
The for loop that iterates over the inner rings:

INT32 outerNumRings = 0;
Ptr<MgLinearRing> outerRing = polygon->GetExteriorRing();

// OuterRing
int currentIndex = 0;
Ptr<MgCoordinateIterator> iter = outerRing->GetCoordinates();
int nCoords = CoordinateIteratorToFloatArray(bufferParams, iter, vertices, currentIndex);
if (nCoords > 0)
{
nPolyVerts[0] = nCoords; // outerRing coordinates
}

INT32 innerNumRings = polygon->GetInteriorRingCount();

// Inner rings
for (int i = 0; i < innerNumRings; i++)
{
Ptr<MgLinearRing> innerRing = polygon->GetInteriorRing(i); // Get Ring
Ptr<MgCoordinateIterator> iter1 = innerRing->GetCoordinates();
nCoords = CoordinateIteratorToFloatArray(bufferParams, iter1, vertices, currentIndex); // Covert to OpsFloatPoint
if (nCoords > 0)
{
nPolyVerts[i+1] = nCoords;
}
}

Note that you don't have to call the function CoordinateIteratorToFloatArray -- this is particular to what thise code is trying to do. In your case you want to write the iterator to XML.

Traian

> -----Original Message-----
> From: mapguide-users-bounces at lists.osgeo.org [mailto:mapguide-users-
> bounces at lists.osgeo.org] On Behalf Of Maciej Skorczewski
> Sent: Tuesday, January 22, 2008 2:22 PM
> To: MapGuide Users Mail List
> Subject: Re: [mapguide-users] Problem whit generate kml from mapguide.
>
>
> > I don't think the filter fallback you mention (used only when
> redering)
> > is causing the problem of being unable to tell how many rings make up
> a
> > multi-polygon when using the feature service API, which is what
> Maciej
> > seems to be asking.
>
> yes i think that is the problem.
>
> > Maciej, did you also try iterating over the interior rings, using
> > GetInteriorRingCount() and GetInteriorRing(). Even though the polygon
> is
> > made up of two outer rings, it is possible that in the data source it
> is
> > described as a Polygon, in which case the second ring would have to
> > necessarily be put in the InteriorRings collection.
> > Traian
>
> Traian can you write pseudo code of this solution...it seems that i
> don't try GetInteriorRingCount() and GetInteriorRing() (how should i
> use
> this)
>
> question is how should i call API to generate coords of second
> (third,fourth,etc) polygon in this iteration?
>
> thx
> maciej
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
```