[mapserver-users] Re: [mapserver-dev] MapScript resultsGetShape confusion

Christian Jauvin cjauvin at gmail.com
Tue Jun 1 12:11:09 EDT 2010


Hi Daniel,

Thanks for the answer!

In my context, I always need to retrieve a feature from the results of
a query, so I should always be using resultsGetShape if I understand
you correctly.

The problem I have is with Python-MapScript version 5.6.3, included
with MS4W beta 11.

For instance with a point query, this code used to work before:

if layer.queryByPoint(...) == MS_SUCCESS:
    res = layer.getResult(0)
    shp = shapeObj(MS_SHAPE_NULL)
    layer.resultsGetShape(shp, res.shapeindex)

whereas in version 5.6.3 (at least the one included with MS4W b11 like
I said) it completely hangs the server.

The solution I found is to replace the call to resultsGetShape by a
call to getFeature:

shp = layer.getFeature(res.shapeindex)

but then the fact that it works contradicts your explanation, so I am
even more confused I guess!

By the way, I guess it's important to note that these are
Python-specific problems: I have the exact same code in PHP, and it
works very fine.

Thanks,

Christian



On Mon, May 31, 2010 at 11:02 PM, Daniel Morissette
<dmorissette at mapgears.com> wrote:
> Hi Christian,
>
> resultsGetShape() should be used only with shape ids received as part of a
> query/resultset. The way queries work has changed in V5.6, and now shape ids
> returned by a resultset are relative to the resultset and not to the global
> dataset. That's why the new resultsGetShape() method was created.
>
> OTOH getFeature/getShape continue to work, but they work with absolute shape
> ids, so you should use them when you read shapes by id and not going through
> a query/resultset.
>
> In 5.6.2 or in 5.6.3, some of the drivers that were still not using the new
> query mechanism properly have been fixed and that could explain the
> different behavior that you get in v5.6.3.
>
> Daniel
>
>
> Christian Jauvin wrote:
>>
>> Hi,
>>
>> I've been using the new layerObj.resultsGetShape function with MS >=
>> 5.6.0, both with Python and PHP MapScript.
>>
>> (1) My first issue is that it seems that something changed with
>> version 5.6.3 of Python MS (I'm using MS4W beta 11) because calls to
>> that function that used to work now hangs the server. The PHP
>> equivalent code still works fine though.
>>
>> (2) My second issue is with the signature difference between the
>> Python and PHP versions of the same function: if I want to retrieve a
>> certain queried shape in Python, I do this:
>>
>> shp = shapeObj(MS_SHAPE_NULL)
>> layer.resultsGetShape(shp, target_shpindex)
>>
>> and then shp is what I want, whereas in PHP it takes only one
>> argument, and returns the desired shape. Why is that?
>>
>> (3) My third issue is that to make my first issue works, I noticed
>> that I can simply use layerObj.getFeature instead, which seems to be
>> doing the same job. What is the difference between those?
>>
>> Best regards,
>>
>> Christian
>> _______________________________________________
>> mapserver-dev mailing list
>> mapserver-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>
>
> --
> Daniel Morissette
> http://www.mapgears.com/
>


More information about the mapserver-users mailing list