[mapguide-internals] question about inserting features
Traian Stanev
traian.stanev at autodesk.com
Wed Jul 18 09:52:33 EDT 2007
At least some of these should have worked. I am late to the thread, so I
may have missed this, but what data source are you inserting the feature
into (SDF, SHP, some DB?)
Traian
-----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: Tuesday, July 17, 2007 10:27 PM
To: Paul Spencer (External)
Cc: MapGuide Internals Mail List
Subject: Re: [mapguide-internals] question about inserting features
Another problem (potential problem) has cropped up. I thought that I
could provide a mechanism to do this by performing a select after
insert and using a spatial filter that had the geom that was inserted
and an operation of Equals. Doesn't work. I also tried CoveredBy
using a buffered version of the geometry. Doesn't work either.
Should any of these strategies work?
Paul
On 17-Jul-07, at 8:19 AM, Paul Spencer wrote:
> 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/ |
> +-----------------------------------------------------------------+
>
>
>
>
>
+-----------------------------------------------------------------+
|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