[mapguide-internals] question about inserting features

Trevor Wekel trevor.wekel at autodesk.com
Mon Jul 16 17:54:36 EDT 2007


Hi Paul,

I wonder if UpdateFeatures returns the identity property for the
inserted property and not an MgFeatureReader.  Try calling
res->GetItem(0)->GetPropertyType() and see what the type is.

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: Monday, July 16, 2007 3:27 PM
To: MapGuide Internals Mail List
Subject: [mapguide-internals] question about inserting features

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/ |
+-----------------------------------------------------------------+





_______________________________________________
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