[mapguide-internals] question about inserting features

Paul Spencer pspencer at dmsolutions.ca
Tue Jul 17 08:19:20 EDT 2007


Hi Trevor ... nice thought ...  GetPropertyType() returns 12,  
MgPropertyType::Feature ... This makes sense because the identity  
property of a feature source may be composed of several attributes so  
there wouldn't necessarily be a single value.

I hadn't checked the property type before, but I did print_r($res- 
 >GetItem(0)->GetValue()) and it told me it was an  
mg_feature_reader_obj (or something like that) and ReadNext() also  
did not fail - it is only the calls to get at the properties that  
fail with a null reference.

Cheers

Paul

On 16-Jul-07, at 5:54 PM, Trevor Wekel wrote:

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







More information about the mapguide-internals mailing list