[mapguide-users] RE: [Mapguide_users] MGRenderingServiceQueryFeatures

Chris Claydon chris.claydon at autodesk.com
Fri Jan 12 14:20:56 EST 2007

Hi Scott,

Your method for creating the polygon seems to be valid. I wrote the
following php script to test it out. It uses QueryFeatures to retrieve a
feature set containing the IDs of all of the features in the Hydrography
layer within the specified polygon.

Important: Internally, the server performs a selection of all features
within the polygon, and then returns their IDs. Thus, it only works on
layers that are selectable. I had to modify the Sheboygan map definition
to make the Hydrography features selectable, otherwise I received an
empty feature set.


(To test this code, save it to a php file in the mapviewerphp folder of
the web tier.)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

	    <title>PHP Test Page</title>
		    include 'constants.php';
		    	$thisFile = __FILE__;
				$pos = strrpos($thisFile, '\\');
				if ($pos == false)
					$pos = strrpos($thisFile, '/');
				$configFilePath = substr($thisFile, 0,
$pos+1) . "../webconfig.ini";
		        MgInitializeWebTier ($configFilePath);

				$userInfo = new
		        $siteConn = new MgSiteConnection();
                $site = new MgSite();
                $sessionId = $site->CreateSession();

				$renderingSrvc =
                $resourceSrvc =

				$mapId = new

                $map = new MgMap();
                $map->Create($resourceSrvc, $mapId, "My Test Map");
                //$geomWkt = "POLYGON((13383.143956941916
5108123.520005487, 41288.72069078572 5108123.520005487,
41288.72069078572 5091167.27038247, 13383.143956941916 5091167.27038247,
13383.143956941916 5108123.520005487))";
                $geomWkt = "POLYGON((-180 -90, -180 90, 180 90, 180 -90,
-180 -90))";
                $wktReader = new MgWktReaderWriter();
                $geometry = $wktReader->Read($geomWkt);
                $layers = new MgStringCollection();
                $featureInfo = $renderingSrvc->QueryFeatures($map,
$layers, $geometry, MgFeatureSpatialOperations::Intersects, -1);
		    catch (MgException $e)
		        echo $e->GetMessage();




-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Scott
Sent: January 12, 2007 9:59 AM
To: Mapguide_users at lists.osgeo.org
Subject: [mapguide-users] RE: [Mapguide_users]

I'm going to reword this hoping it sparks some interest....

I have a Geometry Variable (geom) equal to:

POLYGON((13383.143956941916 5108123.520005487, 41288.72069078572
5108123.520005487, 41288.72069078572 5091167.27038247,
5091167.27038247, 13383.143956941916 5108123.520005487))

I need to get it into the proper format (MgGeometry) for this call:

RenderingService.QueryFeatures( MgMap map, MgStringCollection
>>MgGeometry<< geometry, int selectionVariant, int maxfeatures)

I'm using:
"MgWktReaderWriter" to send the variable into the RenderingService

GeometryFromWkt = MgWktReaderWriter.Read(geom)

It creates an MgPolygon Object...But the QueryFeatures function won't
run....Is this the wrong Geometry type or the wrong geometry level?

I checked with GeometryFromWkt.IsValid() and it responds Yes?

mapguide-users mailing list
mapguide-users at lists.osgeo.org

More information about the mapguide-users mailing list