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

Maciej Skorczewski maciej.skorczewski at procad.pl
Tue Jan 22 09:57:03 EST 2008


Hi!

I wrote aplication who generate kml files.

all work fine but i have problem whit some polygons (and use API to get 
coords of this polygon)

some screenshot
http://img179.imageshack.us/img179/1966/41289677tu3.png

The problem is: when i try to get coords of polygon nr.1 (in this place 
  are two object-polygon in one source after use filter guery)

ex. i use
$featureReader->ReadNext() ...and MG show me 2 polygons

(1 polygon)
++++++
++++++

(second polygon)
======
======


can't get any coords of this.



the code is
______________

$featureService = 
$siteConnection->CreateService(MgServiceType::FeatureService);
$queryOptions = new MgFeatureQueryOptions();
$queryOptions->SetFilter("FID > 253");
$featureReader = $featureService->SelectFeatures(new
MgResourceIdentifier($x_adress),$x_layer, $queryOptions);
	
	$geometryReaderWriter = new MgAgfReaderWriter();

//
// this is loop on FID > 1(next are 2,3,4,...)
//
//
	while ($featureReader->ReadNext())
	{
		$muniName = $featureReader->$a7_1($a7_0);
		$byteReader = $featureReader->GetGeometry('Geometry');
		$geometry = $geometryReaderWriter->Read($byteReader);
		$point = $geometry->GetCentroid();
		$x = $point->GetCoordinate()->GetX();
		$y = $point->GetCoordinate()->GetY();
		echo '<Placemark>';	

//
// This can be a bug...
// question: how to know that there are 2 object-polygon
// and $linearRing get coords of first the second, polygon object.
//
//
		$linearRing = $geometry->GetExteriorRing();		
		$coordIter = $linearRing->GetCoordinates();
		echo'<MultiGeometry>';
		echo'<Polygon>';
		echo'<outerBoundaryIs>';
		echo'<LinearRing>';
		echo'<coordinates>';
//
// So when loop is in 1. iterate it show 2 object polygons.
// ...and MG don't show any coords
//

		while ($coordIter->MoveNext())
		{
			$coord = $coordIter->GetCurrent();
			if ($coord != null)
			{
			 $coord->GetX().",".$coord->GetY().",0 ";		
			}
		}
		echo'</coordinates>';
		echo'</LinearRing>';
		echo'</outerBoundaryIs>';
		echo'</Polygon>';
		echo'</MultiGeometry></Placemark>';
		
	}
	$featureReader->Close();
	echo '</Document></kml>';



thx for any help.
maciek


More information about the mapguide-users mailing list