[postgis-users] Re: Problem with PostGIS MapServer layer

Doug B ummmmm22 at gmail.com
Wed Feb 28 13:03:03 PST 2007


When I replaced the code in question with:

    @$layer->whichshapes($bounds->createRectObj());
    while ($shape = $layer->nextShape())
    {
        ...
    }
    $layer->close();

All results were returned as expected.  This approach obviously only
works as a replacement for queryByRect(), not for other queryBy
methods.  Based on both our experience here, and on at least his one
other post I found:

http://lists.umn.edu/cgi-bin/wa?A2=ind0509&L=mapserver-users&T=0&F=&S=&P=54917

it appears that something is incorrect about the shapeindex values
that are being returned by getResult(), and that this problem doesn't
exist for queries on the non-PostGIS (shapefile) layers.

Any ideas on what is wrong or what can be done to rectify or at least
work around the problem?

Doug

On 2/27/07, Doug B <ummmmm22 at gmail.com> wrote:
> I've posted this on the MapServer list as well, but so far don't have
> any resolution.  Thought I'd try here as well in case it's a PostGIS
> thing.
>
> RHEL 4
> MapServer 4.8.4
> PHP 4.4.5
> Postgres 7.4.16
> PostGIS 1.2.1
>
> $layer->queryByRect(...);
> $numResults = $layer->getNumResults(); // returns 88 results, which is correct
> $layer->open();
> for ($i = 0; $i < $numResults; $i++)
> {
>    $result = $layer->getResult($i);
>    // echo $result->shapeindex shows all different values that look reasonable
>    $shape = $layer->getShape(-1, $result->shapeindex);
>    ...
> }
>
> The getShape() call returns nothing.  If I try to echo the shape
> object itself, it's blank, and not surprisingly all of the attributes
> are as well, including index.
>
> On an older system (MapServer 4.2, Postgres 7.4.3, PostGIS 0.9) this
> code works correctly, and I can't see what we could be doing wrong
> between asking the layer for a shapeindex and asking the layer for the
> shape at that shapeindex.  The database appears to contain valid data,
> and the query sees enough of it to find the correct number of results.
>
> I do have both GIST and oid indices on the database tables, and my
> MapServer DATA layer is the simple form:
>
> DATA "geom from sows_offenders"
>
> Thanks for any advice.
> Doug
>



More information about the postgis-users mailing list