[mapguide-users] spatial search problem

ram282 ram282 at gmail.com
Mon Jun 14 08:18:24 EDT 2010


Hi, 
I am trying to perform a spatial query. I click a point on the map and
trying to find the features from a layer called 'LandMarks'. I have the
google map as the background layer. All the layers(from SQL server spatial)
have the 4326 as SRID. I changed the CoOrdinate system in the map definition
to support google maps as background.
        
I am forming a polygon by creating a buffer around the point using 
  MgGeometry mgGeometry = mgPoint.Buffer(50, measure); 

The measure values is obtained from the function getMeasureValue() specified
below 

But how could we specify the units? In the above line does the 50 means 50
metres ? 
Can any one describe clearly about how to provide the correct measure value
while creating a buffer.

I have used the MgFeatureSpatialOperations.Intersects , Inside. But in the
selectionXML there are no records obtained.  

Instead of performing the spatial search, if I perform the non-spatial
search like  
 options.SetFilter("CityName='XYZ'"); 
I am getting the records in selectionXML.

below are the functions I have used. I also referred some postings.
 

 private void searchObjects(MgCoordinate coOrdinate)
    {
       MgGeometryFactory GF = new MgGeometryFactory();
         MgPoint mgPoint = GF.CreatePoint(coOrdinate);
        MgCoordinateSystemMeasure measure = getMeasureValue();

     
        MgGeometry mgGeometry = mgPoint.Buffer(50, measure); 
       
        MgFeatureQueryOptions options = new MgFeatureQueryOptions();
        options.SetSpatialFilter("LandMarkPoint", mgGeometry,
MgFeatureSpatialOperations.Intersects);


        MgLayer landmarkLayer =
(MgLayer)map.GetLayers().GetItem("LandMarks");

        MgFeatureReader reader = crossingsLayer.SelectFeatures(options);
  
        .... create siteconnection obj here ...       
        MgResourceService resService =
(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
       

        MgSelection selection = new MgSelection(map);
        selection.AddFeatures(landmarkLayer , reader, 0);

        string selectionXML = selection.ToXml();
        selection.Save(resService, mapName);
        map.Save();
        reader.Close();
}

 private MgCoordinateSystemMeasure getMeasureValue()
    {
        MgCoordinateSystemFactory coordSysFac = new
MgCoordinateSystemFactory();
        MgCoordinateSystem cs = coordSysFac.Create(map.GetMapSRS());

//map.GetMapSRS() returns PROJCS["Popular Visualisation CRS /
Mercator",GEOGCS["Popular Visualisation
CRS",DATUM["Popular_Visualisation_Datum",SPHEROID["Popular Visualisation
Sphere",6378137,0,AUTHORITY["EPSG","7059"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6055"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4055"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],AUTHORITY["EPSG","3785"],AXIS["X",EAST],AXIS["Y",NORTH]]


        return cs.GetMeasure();
    }
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/spatial-search-problem-tp5177173p5177173.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20100614/09d017a0/attachment.html


More information about the mapguide-users mailing list