[mapguide-users] coordinates of layer extent mapguide
yashika
sareen.yashika at gmail.com
Tue Jan 4 06:29:21 EST 2011
Hi every1,
I am new to mapguide.I tried to write a code to get the coordinates of the
layer so that i can zoom on it.
i m using c#
public String getcoords()
{
MgByteReader byteReader;
String layerSelect = GetParameter(this.args, "LAYERNAME");
if(layerSelect.Equals("Santa"))
{
layerSelect="Parcels";
}
MgResourceService resourceService =
(MgResourceService)this.site.CreateService(MgServiceType.ResourceService);
MgMap map = new MgMap();
map.Open(resourceService, GetParameter(this.args, "MAPNAME"));
String str2 = "";
MgLayer layer = (MgLayer)
map.GetLayers().GetItem(layerSelect);
String featureClass = layer.GetName();
MgResourceIdentifier ad = new
MgResourceIdentifier(layer.GetFeatureSourceId());
MgFeatureService featureService =
(MgFeatureService)this.site.CreateService(MgServiceType.FeatureService);
MgSpatialContextReader spatialReader =
featureService.GetSpatialContexts(ad, true);
byteReader = spatialReader.GetExtent();
if (byteReader.GetLength() == 0)
{
str2="nothing found";
}
else
{
MgAgfReaderWriter agfReaderWriter= new
MgAgfReaderWriter();
MgWktReaderWriter wktReaderWriter=new
MgWktReaderWriter();
MgGeometry geometry = agfReaderWriter.Read(byteReader);
str2 = wktReaderWriter.Write(geometry);
spatialReader.Close();
}
return(str2);
}
The problem with the code is that it returns the output as
POLYGON ((-180 -90, 180 -90, 180 90, -180 90, -180 -90))
My layer is of polygon type but the extent is not correct.
can any1 tell me what is the problem in my code.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/coordinates-of-layer-extent-mapguide-tp5888314p5888314.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list