[mapguide-users] Feature Vertices

Tom Lazo / Stygy tom.lazo at hotmail.com
Thu Jul 9 11:46:06 EDT 2009


Hi,

I got it... here's the code

                                $featureReader->ReadNext();
				$byteReader = $featureReader->GetGeometry("Geometry"); 
				$geometryReaderWriter = new MgAgfReaderWriter(); 
				$geometry = $geometryReaderWriter->Read($byteReader); 							
				$polygon = $geometry->Boundary();
				$area = $polygon->GetArea();
				$coordIter = $polygon->GetCoordinates();
				
                                while ($coordIter->MoveNext()){
				  $coord = $coordIter->GetCurrent();
				  $coordX = $coord->GetX(); 
				  $coordY = $coord->GetY();
				  echo "$coordX $coordY \n ";
                               }

Actually, i did not need a type casting because i realized, or maybe i'm
wrong,  that the Boundary function gives me a MgPolygon object. Thanks.

Tom


Jackie Ng wrote:
> 
> If GetGeometryType() return MgGeometryType.Polygon, then yes you can
> safely cast it to a MgPolygon.
> 
> - Jackie
> 
> 
> Tom Lazo wrote:
>> 
>> Hi Jackie, 
>> 
>> Just one question, is the geometry cast just and (MgPolygon) geometry?,
>> srry about my ignorance. n.n' . I think i should use the geometry's
>> Boundary function. But i dunno how, i've looked everywhere without luck.
>> Plz help.
>> 
>> Thanks
>> 
>> Tom / Stygy 
>> 
>> 
>> 
>> Jackie Ng wrote:
>>> 
>>> Given a MgFeatureReader that contains your feature(s):
>>> 
>>> - Call its GetGeometry() method to get a byte reader
>>> - Convert this byte reader to a MgGeometry object by using a
>>> MgAgfReaderWriter object.
>>> - Call GetGeometryType() on the MgGeometry to determine what type of
>>> geometry it actually is.
>>> - Depending on the type, cast the MgGeometry to that given type (if not
>>> using PHP) and consult the relevant APIs for that derived geometry type.
>>> Basically you want to take note of any class methods that return
>>> MgPoint, MgCoordinate or MgCoordinateIterator objects.
>>> 
>>> Hope that helps.
>>> 
>>> - Jackie
>>> 
>>> 
>>> Tom Lazo wrote:
>>>> 
>>>> Hi all!,
>>>> 
>>>> Anyone knows how could i get the coordinates of the vertices of a
>>>> feature, Is there any function that do that?. Thanks.
>>>> 
>>>> Stygy / Tom
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 


-----
http://n2.nabble.com/file/u222842/warning.png   Stygy is not a living being!
-- 
View this message in context: http://n2.nabble.com/Feature-Vertices-tp3205810p3232266.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list