[mapguide-internals] MapGuide RFC 33 - Convenience Methods
forSelection
Trevor Wekel
trevor.wekel at autodesk.com
Thu Sep 13 18:38:13 EDT 2007
Hello Paul and list,
I have updated RFC 33 to include method signatures which should address
Paul's concerns. Please let me know if this is satisfactory.
http://trac.osgeo.org/mapguide/wiki/MapGuideRfc33
Thanks,
Trevor
-----Original Message-----
From: mapguide-internals-bounces at lists.osgeo.org
[mailto:mapguide-internals-bounces at lists.osgeo.org] On Behalf Of Paul
Spencer (External)
Sent: Thursday, September 06, 2007 5:34 AM
To: MapGuide Internals Mail List
Subject: Re: [mapguide-internals] MapGuide RFC 33 - Convenience Methods
forSelection
Hi Trevor,
to figure out what this saves in realistic terms (in PHP anyway) I
wrote a sample of the difference in the code:
Before:
MgInitializeWebTier($extensionDir. "webconfig.ini");
$user = new MgUserInformation('Anonymous', '');
$siteConnection = new MgSiteConnection();
$siteConnection->Open($user);
$resourceService = $siteConnection->CreateService
(MgServiceType::ResourceService);
$featureService = $siteConnection->CreateService
(MgServiceType::FeatureService);
$map = new MgMap();
$map->Open($resourceService, $mapname);
$selection = new MgSelection($map);
$selection->Open($resourceService, $mapname);
$layers = $selection->GetLayers();
for ($i=0; $i<$layers->GetCount(); $i++) {
$layer = $layers->GetItem($i);
$featureId = $layer->GetFeatureSourceId();
$featureResource = new MgResourceIdentifier($featureId);
$className = $layer->GetFeatureClassName();
$selectionString = $selection->GenerateFilter($layer, $className);
$queryOptions = new MgFeatureQueryOptions();
$queryOptions->SetFilter($selectionString);
$featureReader = $featureService->SelectFeatures($featureSource,
$className, $queryOptions);
// do something with the feature reader
}
After:
MgInitializeWebTier($extensionDir. "webconfig.ini");
$user = new MgUserInformation('Anonymous', '');
$siteConnection = new MgSiteConnection();
$siteConnection->Open($user);
$resourceService = $siteConnection->CreateService
(MgServiceType::ResourceService);
$featureService = $siteConnection->CreateService
(MgServiceType::FeatureService);
$map = new MgMap();
$map->Open($resourceService, $mapname);
$selection = new MgSelection($map);
$selection->Open($resourceService, $mapname);
$layers = $selection->GetLayers();
for ($i=0; $i<$layers->GetCount(); $i++) {
$layer = $layers->GetItem($i);
//$featureId = $layer->GetFeatureSourceId();
//$featureResource = new MgResourceIdentifier($featureId);
$className = $layer->GetFeatureClassName();
//$selectionString = $selection->GenerateFilter($layer,
$className);
//$queryOptions = new MgFeatureQueryOptions();
//$queryOptions->SetFilter($selectionString);
//$featureReader = $featureService->SelectFeatures
($featureSource, $className, $queryOptions);
$featureReader = $selection->GetSelectedFeatures($layer,
$className);
// do something with the feature reader
}
It looks like this will save about 5 lines of code, is that right?
Also, the code I took the example from also modified the
$queryOptions to call AddFeaturePropertyName for each of the property
mappings in the associated layer so that I only get back the
properties that the layer is configured for. If I use the new API, I
would have to actually do that for every feature as it comes out of
the feature reader, and FDO would have to pass back all the
properties, regardless of the property mappings.
So I guess, for me, I won't really be able to use these new
convenience APIs :( I'm not against adding them, and it would
probably be nice to save those 5 lines of code for some people (or
not have to go through the learning curve of figuring out how to get
features from a selection is more likely), but I'm not sure in
practice how much of a convenience it would be. Depending on FDO
performance handling properties, it may actually encourage writing
code that performs more poorly (since you can't limit feature
properties).
Cheers
Paul
On 5-Sep-07, at 3:49 PM, Trevor Wekel wrote:
> Hello list,
>
> MapGuide RFC 33 is ready for review and posted on the Wiki at
> http://trac.osgeo.org/mapguide/wiki/MapGuideRfc33.
>
> Feel free to post any comments to the internals list and I will be
> happy
> to respond.
>
> Thanks,
> Trevor Wekel
>
> _______________________________________________
> mapguide-internals mailing list
> mapguide-internals at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-internals
+-----------------------------------------------------------------+
|Paul Spencer pspencer at dmsolutions.ca |
+-----------------------------------------------------------------+
|Chief Technology Officer |
|DM Solutions Group Inc http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+
_______________________________________________
mapguide-internals mailing list
mapguide-internals at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
More information about the mapguide-internals
mailing list