[mapguide-users] Having problem in getting the X-Y coordinate of any object

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Thu Sep 24 01:57:18 EDT 2009


You have to do the following:
1) Query the featuresource
2) Read the geometry from the response
3) Extract the coordinates

Item (1) is done with the MgFeatureService.SelectFeatures:
http://mapguide.osgeo.org/files/mapguide/docs/webapi/d5/d10/class_mg_feature_service_cc4faabfd68e8e891287f62e150e2d0d.htm#cc4faabfd68e8e891287f62e150e2d0d

As you can see, the result is a MgFeatureReader instance:
http://mapguide.osgeo.org/files/mapguide/docs/webapi/d6/ddc/class_mg_feature_reader.htm

The link has example code that shows how to read the data, and find find 
a column with the geometry, which is item (2).

The MgAgfReaderWrite can transform that geometry column into a 
MgGeometry object:
http://mapguide.osgeo.org/files/mapguide/docs/webapi/dd/db3/class_mg_agf_reader_writer.htm
http://mapguide.osgeo.org/files/mapguide/docs/webapi/d1/d85/class_mg_geometry.htm

Depending on your geometry type, you get a MgPoint, MgMultiPoint, 
MgLineString, etc. object (hint: GetGeometryType).
You need to decide how to get the x/y from such objects, but usually you 
can use GetCentroid():
http://mapguide.osgeo.org/files/mapguide/docs/webapi/dc/d21/class_mg_geometric_entity_3830444d005bbcff7bf4b4644a7a2dfc.htm#3830444d005bbcff7bf4b4644a7a2dfc

The centroid is the "center" of the object, and thus always a point, and 
you have item (3).

Regards, Kenneth Skovhede, GEOGRAF A/S



Amit Kumar Shukla skrev:
> Hi,
> Can anyone tell me how to  get the x-y coordinate of any object on map 
> trough query feature without using digitization method?
> Any suggestion or help will be appricated.
>
> -- 
> Thanks and regards-
> Amit
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090924/c5bfb07c/attachment.html


More information about the mapguide-users mailing list