<div dir="ltr">Hi,<div><br></div><div><div>How do I get a tileindex of vector files working from data in a Postgis database and accessed via an SQL query of my choosing?</div></div><div><br></div><div>I would like to make a vector tile index as described at <a href="https://mapserver.org/optimization/vector.html#index-your-data">https://mapserver.org/optimization/vector.html#index-your-data</a> using  data stored in a Postgis database and a SQL query of my choosing.  Here is one approach that works:</div><div><br></div><div>1.  create a test table in postgres database:<br>     > create table testtable (id int, location text, geom geometry(Polygon,4326));<br></div><div><br></div><div>2.  insert data into the table:<br><br></div><div>     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);<br><br></div><div>3. Define a layer using the OGR connection:</div><div><br></div><div>LAYER<br>  NAME "vector"<br>  TYPE POLYGON<br>  CONNECTIONTYPE OGR<br>  CONNECTION "PG:\"host=localhost user=postgres dbname=mydatabase password=mypwd tables=testtable(geom)\""<br>  STATUS OFF<br>  CLASS<br>    STYLE<br>      WIDTH 1<br>      OUTLINECOLOR 255 105 180<br>    END<br>  END<br>END<br></div><div><div><br></div><div>4. Issue a request:</div><div><br></div><div>    mapserv QUERY_STRING='SERVICE=WMS&map=/tmpp/mapfile.map&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&layers=vector&width=256&height=256&crs=EPSG:3857&bbox=13580108.193257555,3487974.474709164,13585000.163067807,3492866.4445194146'<br><br>and I get an image of my vectors back.</div><div><br></div><div>How do I use a more complex query than `testtable(geom)`?  I tried specifying a query via a DATA block:</div><div><br></div><div>LAYER<br>    NAME "vector"<br>    TYPE POLYGON<br>    CONNECTIONTYPE OGR<br>    CONNECTION "PG:\"host=localhost user=postgres dbname=mydatabase password=mypwd\""<br>    DATA "geom FROM (SELECT<br>        id,<br>        geom,<br>        location <br>      FROM testtable<br>    ) AS subquery USING unique id USING SRID=4326"<br>    PROJECTION<br>      "init=epsg:4326"<br>    END<br>    STATUS OFF<br>    CLASS<br>      STYLE<br>        WIDTH 1<br>        OUTLINECOLOR 255 105 180<br>      END<br>    END<br>  END<br></div><div><br></div><div>However, the same query generates an error:</div><div><br></div><div>mapserv QUERY_STRING='SERVICE=WMS&map=/tmpp/mapfile.map&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&layers=vector&width=256&height=256&crs=EPSG:3857&bbox=13580108.193257555,3487974.474709164,13585000.163067807,3492866.4445194146'<br></div><div><br></div><div>"msOGRFileOpen(): OGR error. Open failed for OGR connection in layer `vector'.  File not found or unsupported format. Check server logs.<br></div><div>msDrawMap(): Image handling error. Failed to draw layer named 'vector'"<br></div><div><br></div><div>I tried using a postgis connectiontype, but could not get that working either <a href="https://mapserver.org/mapfile/layer.html#mapfile-layer-connectiontype">https://mapserver.org/mapfile/layer.html#mapfile-layer-connectiontype</a></div><div><br></div><div>How do I get a tileindex of vector files working from data in a Postgis database and accessed via an SQL query of my choosing?</div><div><br></div>Thanks!<br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Pete</div></div></div>