[MapServer-users] [EXTERNAL] Vector tileindex with connectiontype OGR

Peter Schmitt pschmitt at gmail.com
Wed Dec 7 15:02:29 PST 2022


Hi Jukka,

On Wed, Dec 7, 2022 at 12:18 PM Rahkonen Jukka <
jukka.rahkonen at maanmittauslaitos.fi> wrote:

> “OGR layers can utilize tile indexes in a similar fashion to Shapefile
> based layers. The TILEINDEX keyword should contain the connection string
> for the tile index file. The tile index file may be any supported OGR
> format, including shapefiles.”
>
>
>
> So this is what I used in LAYER and it worked both for WMS and WFS:
>
>
> CONNECTIONTYPE OGR
>
TILEINDEX "c:\data\000\mapservertest\tindex.gpkg"
>


Thanks for your message, it is very helpful!  I am now struggling how to
use an SQL query of my choosing when the OGR TILEINDEX is in a Postgis
database.

I can get a TILEINDEX working using the OGR format.  Ultimately my
TILEINDEX lives in Postgis.  I can make a postgis table and populate it
with items like so:

    create table testtable (id int, location text, geom
geometry(Polygon,4326));
    insert into testtable (id, location, geom) values (1,
'/test_data/test.geojson,0', 'POLYGON((122.01377475333321
29.96355712017804,122.01424752183958 29.915620560607106,122.06927507957919
29.91602043815968,122.0688286928125 29.963957768165944,122.01377475333321
29.96355712017804))'::geometry);

and then reference my Postgis TILEINDEX of vectors in this fashion:

    LAYER
        DEBUG 5
        NAME "vector_via_postgis"
        TYPE POLYGON
        TILEINDEX "PG:\"host='localhost' user='postgres' dbname='mydatabase'
password='mypwd' tables=testtable(geom)\""
        CONNECTIONTYPE OGR
        STATUS OFF
    END

and now I can query my vector index of tiles:

    mapserv -nh
QUERY_STRING='service=WFS&VERSION=1.0.0&REQUEST=getfeature&map=/app/mapfiles/test2.map&typename=vector_via_postgis&OUTPUTFORMAT=geojson'

I can query the database with the OGR driver by passing the `-sql` option:

    ogrinfo -ro PG:"host='localhost' user='postgres' dbname='mydatabase'
password='mypwd'" -sql 'SELECT * FROM testtable'

but let's say my query was more complicated than `SELECT * FROM
testtable;`.  I could make a Postgres view, but I'm hoping there is some
way to override the default SQL query used.

How do I specify such a query using the OGR PG driver as a Mapserver layer
to be used as a TILEINDEX of OGR vector files?

Perhaps this is more of a GDAL question... or how does Mapserver's use of
OGR TILEINDEX of OGR vector files allow custom SQL?  Note that as a
TILEINDEX of Rasters the TILEINDEX can point to a Mapserver Layer, so I
/can/ add custom SQL queries in that case.  But I don't know how to do it
as a OGR TILEINDEX pointing to OGR vectors.

Thanks,
Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20221207/35c87c84/attachment-0001.htm>


More information about the MapServer-users mailing list