[mapguide-internals] question about inserting features
Paul Spencer
pspencer at dmsolutions.ca
Mon Jul 16 17:26:41 EDT 2007
Hi all,
when inserting new features into a feature source, the (php) code
looks like this:
$className = $layer->GetFeatureClassName();
$cmd = new MgInsertFeatures($className, $drawProps);
$commands = new MgFeatureCommandCollection();
$commands->Add($cmd);
$res = $featureService->UpdateFeatures($dataSourceId, $commands, false);
this works great. What I would like to do is access the newly
created feature. According to the documentation, the result of
UpdateFeatures is an MgPropertyCollection which should have one
property, of type MgFeatureProperty whose value is an MgFeatureReader
that contains the set of properties inserted into the datastore by
the insert command.
When I try to get access to the properties, I receive an error
- MgFeatureReader.GetPropertyCount line 29 file .\Services
\FeatureReader.cpp
This happens with the following code:
$featureReader = $res->GetItem(0)->GetValue();
while ($featureReader->ReadNext()) {
$nProps = $featureReader->GetPropertyCount();
// would do something more here if it didn't crap out
}
Is this the right way to access a newly inserted feature? If not,
then how should I do it? If yes, is the code wrong or is there a bug
somewhere?
Cheers
Paul
+-----------------------------------------------------------------+
|Paul Spencer pspencer at dmsolutions.ca |
+-----------------------------------------------------------------+
|Chief Technology Officer |
|DM Solutions Group Inc http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+
More information about the mapguide-internals
mailing list