[mapguide-users] Re: coordinates of layer extent mapguide

Jackie Ng jumpinjackie at gmail.com
Fri Jan 7 02:35:58 EST 2011


A rough example would be:



MgFeatureService featSvc = ...;
MgResourceIdentifer featureSourceId = ...;
string className = ...;
string geom = "Geometry";

//This is how you use the SpatialExtents() function
MgFeatureAggregateOptions query = new MgFeatureAggregateOptions();
query.AddComputedProperty("LayerExtents", "SpatialExtents(" + geom + ")");

MgDataReader reader = featSvc.SelectAggregates(featureSourceId, className,
query);

//There should only be one result here, a geometry value containing the
result of SpatialExtents()
if (reader.ReadNext())
{
    MgAgfReaderWriter agfRW = new MgAgfReaderWriter();
    MgByteReader agf = reader.GetGeometry("LayerExtents");
    MgGeometry myExtents = agfRW.Read(agf);

    //All MgGeometry objects have a centroid property
    MgPoint center = myExtents.GetCentroid();

    reader.Close();
}




The key thing to know is what is the feature source id, class name and
geometry property. All of this information you can get from your runtime
MgLayer in your MgMap.

- Jackie
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/coordinates-of-layer-extent-mapguide-tp5888314p5898365.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list