[mapguide-users] RE: [Mapguide_users]MGRenderingServiceQueryFeatures

Chris Claydon chris.claydon at autodesk.com
Fri Jan 12 14:40:06 EST 2007


Hi Scott,

Looking at your previous emails, it is apparent that you want this to
work even at scales where the layers are not visible.

Unfortunately, I don't think this will work, because of the following
filter in the ServerRenderingService.cpp code:

if (!layer->GetSelectable() ||
!layer->IsVisibleAtScale(map-GetViewScale()))
            continue;

Chris.

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Chris
Claydon
Sent: January 12, 2007 12:21 PM
To: Scott Hameister; Mapguide_users at lists.osgeo.org
Subject: RE: [mapguide-users] RE:
[Mapguide_users]MGRenderingServiceQueryFeatures

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.

Chris.

(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"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

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

				$userInfo = new
MgUserInformation("Administrator","admin");
		        $siteConn = new MgSiteConnection();
		        $siteConn->Open($userInfo);
                $site = new MgSite();
                $site->Open($userInfo);
                $sessionId = $site->CreateSession();
                $userInfo->SetMgSessionId($sessionId);

				$renderingSrvc =
$siteConn->CreateService(MgServiceType::RenderingService);
                $resourceSrvc =
$siteConn->CreateService(MgServiceType::ResourceService);

				$mapId = new
MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefi
nition");

                $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();
                $layers->Add("Hydrography");
                $featureInfo = $renderingSrvc->QueryFeatures($map,
$layers, $geometry, MgFeatureSpatialOperations::Intersects, -1);
                
	
print($featureInfo->ToXml()->ToString());
			}
		    catch (MgException $e)
		    {
		        echo $e->GetMessage();
		    }

		?>

	</body>

</html>

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

PLEEEEEEEASE....
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,
13383.143956941916
5091167.27038247, 13383.143956941916 5108123.520005487))

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

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

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

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
http://lists.osgeo.org/mailman/listinfo/mapguide-users

_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users



More information about the mapguide-users mailing list