[Mapguide-users] CGI QueryMapFeatures
Chris Claydon
chris.claydon at autodesk.com
Fri Jan 12 17:18:35 EST 2007
And here's a php script that uses the Feature Service's SelectFeatures
API method. It is independent of the selectability and visibility of the
corresponding layer in the map. One thing to make sure of is that the
geometry you use for the query is in the coordinate system used by the
feature source (which may differ from the map).
<!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);
$featureSrvc =
$siteConn->CreateService(MgServiceType::FeatureService);
$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((-180 -90, -180 90, 180 90, 180 -90,
-180 -90))";
$wktReader = new MgWktReaderWriter();
$geometry = $wktReader->Read($geomWkt);
$layers = $map->GetLayers();
$selLayer = $layers->GetItem("Hydrography");
$featureResourceId = new
MgResourceIdentifier($selLayer->GetFeatureSourceId());
$featureClassName = $selLayer->GetFeatureClassName();
$geometryName = $selLayer->GetFeatureGeometryName();
$queryOptions = new MgFeatureQueryOptions();
$queryOptions->SetSpatialFilter($geometryName,
$geometry, MgFeatureSpatialOperations::Intersects);
$layers = new MgStringCollection();
$layers->Add("Hydrography");
$featureReader =
$featureSrvc->SelectFeatures($featureResourceId, $featureClassName,
$queryOptions);
while($featureReader->ReadNext())
{
$id = $featureReader->GetString("ID");
print($id);
print("<br>");
}
}
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 Trevor
Wekel
Sent: January 12, 2007 2:28 PM
To: Scott Hameister; mapguide-users at lists.osgeo.org
Subject: RE: [Mapguide-users] CGI QueryMapFeatures
Hi Scott,
I did a quick check on the QueryMapFeatures OPERATION. It is intended
to work with visible layers only. Any layers not visible at the current
scale range will be excluded.
You may want to look at SELECTFEATURES instead. It requires more in
depth knowledge of the layers and their data sources but does not depend
on view state because it goes directly against the feature source.
Thanks,
Trevor
-----Original Message-----
From: Scott Hameister [mailto:ScottH at mPower-tech.com]
Sent: Thursday, January 11, 2007 9:45 AM
To: Mapguide_users at lists.osgeo.org
Subject: RE: [Mapguide_users] CGI QueryMapFeatures
Is there any documentation on the FCGI OPERATIONS and params Yet?
Since the WebAPI is so wrapped around it it would be nice to no what
parameters are available...
When I goto http://localhost/mapguide/mapagent/index.html
"OPERATION=QueryMapFeatures" isn't even an option...and I'm assuming
even this site doesn't give all the options of FCGI params either.
-----Original Message-----
From: mapguide_users-bounces at lists.osgeo.org
[mailto:mapguide_users-bounces at lists.osgeo.org] On Behalf Of Scott
Hameister
Sent: Wednesday, January 10, 2007 6:47 PM
To: Mapguide_users at lists.osgeo.org
Subject: [Mapguide_users] CGI QueryMapFeatures
I can't find documentation on the FCGI operation QueryMapFeatures When I
change the ViewerAPi Code where it filters by the selectable and visible
layers " LAYERNAMES=" + encodeURIComponent(GetVisSelLayers())"
To a list of Non-visible layers it doesn't work....
....I want users to be able to select features using the geometry on
layers that are not visible as well for parsing purposes? Can I use this
Operation for that
_______________________________________________
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