<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.Shkpostityyli20
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 2.0cm 70.85pt 2.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FI" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">I made some tests and noticed that the OGR tileindex does not need to be a shapefile but GeoPackage worked as well. Actully what did not work was to make a vector layer from tileindex
 that was saved into GeoPackage and to use that layer in TILEINDEX. And then I noticed that this behavior is documented in
<a href="https://www.mapserver.org/input/vector/ogr.html#tileindex-with-ogr">https://www.mapserver.org/input/vector/ogr.html#tileindex-with-ogr</a>:<br>
<br>
“</span><span lang="EN-US">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.”<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">So this is what I used in LAYER and it worked both for WMS and WFS:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><br>
</span><span lang="EN-US" style="mso-fareast-language:EN-US">CONNECTIONTYPE OGR<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">TILEINDEX "c:\data\000\mapservertest\tindex.gpkg"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">I do not know when and if this behavior has changed. I thought as well that the layer-as-a-tileindex would be the way to follow if tileindex is not in shapefile format.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">-Jukka Rahkonen-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">Lähettäjä:</span></b><span lang="EN-US"> MapServer-users <mapserver-users-bounces@lists.osgeo.org>
<b>Puolesta </b>Peter Schmitt<br>
<b>Lähetetty:</b> keskiviikko 7. joulukuuta 2022 19.08<br>
<b>Vastaanottaja:</b> Schylberg Lars <lars.schylberg@saabgroup.com><br>
<b>Kopio:</b> Mapserver-Users (mapserver-users@lists.osgeo.org) <mapserver-users@lists.osgeo.org><br>
<b>Aihe:</b> Re: [MapServer-users] [EXTERNAL] Vector tileindex with connectiontype OGR<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal">On Wed, Dec 7, 2022 at 1:16 AM Schylberg Lars <<a href="mailto:lars.schylberg@saabgroup.com">lars.schylberg@saabgroup.com</a>> wrote:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> The important thing is to have a one layer for the actual tile index, that has status off and one layer that is using the tile index layer.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks for the message, Lars!  This gave me another idea to debug.  <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">When I set DEBUG 5 and request <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">     mapserv -nh QUERY_STRING='service=WFS&VERSION=1.0.0&REQUEST=getfeature&map=/app/mapfiles/test2.map&typename=vector_via_ogr&OUTPUTFORMAT=geojson'<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">then the log contains<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">    OGROPen(tindex_ogr)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">    msOGRFileOpen(): OGR error. Open failed for OGR connection in layer `vector_via_ogr'.  File not found or unsupported format. Check server logs.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">    Open failed for OGR connection in layer `vector_via_ogr'.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">with the layers<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">    LAYER<br>
        DEBUG 5<br>
        NAME "tindex_ogr"<br>
        TYPE POLYGON<br>
        CONNECTIONTYPE OGR<br>
        CONNECTION "/app/mapfiles/tindex.geojson"<br>
        STATUS OFF<br>
    END<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">    LAYER<br>
        DEBUG 5<br>
        NAME "vector_via_ogr"<br>
        TYPE POLYGON<br>
        TILEINDEX tindex_ogr<br>
        CONNECTIONTYPE OGR<br>
        STATUS OFF<br>
    END<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">This log line<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">        OGROPen(tindex_ogr)<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">makes me suspect the following lines of code are setting the OGR dataset name to "tindex_ogr", whereas I expect it to do something like use the value from CONNECTION in the layer with name "tindex_ogr". <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMapServer%2FMapServer%2Fblob%2F71ecf4028b0769027df3a970a36d56feb1d46ab6%2Fmapogr.cpp%23L1205-L1238&data=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7C6cce5ce3dc674b610d1608dad875a01d%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C0%7C638060296970211320%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3bCVBIt9JxfoIArjTPKTM4AREHBzvW5iq%2Fev8XsfZJw%3D&reserved=0">https://github.com/MapServer/MapServer/blob/71ecf4028b0769027df3a970a36d56feb1d46ab6/mapogr.cpp#L1205-L1238</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">In other words, I expect the log line to read<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">        OGROPen(/app/mapfiles/tindex.geojson)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">and not<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">        OGROPen(tindex_ogr)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">This seems to be unique for a vector tile index of vectors.  This otherwise works fine when using a vector tileindex of rasters.  So if I make a bogus raster layer like<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">    LAYER<br>
        DEBUG 5<br>
        NAME "bogus_raster"<br>
        TYPE RASTER<br>
        TILEINDEX tindex_ogr<br>
        STATUS OFF<br>
        PROJECTION<br>
            "init=epsg:3857"<br>
        END<br>
    END<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">and then issue a bogus request like<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">    curl '<a href="http://localhost:8000/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&map=/app/mapfiles/test2.map&layers=bogus_raster&WIDTH=256&HEIGHT=256&CRS=EPSG:3857&STYLES=&BBOX=4163066.308523841,5943743.319455305,4167958.2783340923,5948635.289265556">http://localhost:8000/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&map=/app/mapfiles/test2.map&layers=bogus_raster&WIDTH=256&HEIGHT=256&CRS=EPSG:3857&STYLES=&BBOX=4163066.308523841,5943743.319455305,4167958.2783340923,5948635.289265556</a>'<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Then the log line includes<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">     msOGRFileOpen(/app/mapfiles/tindex.geojson)...<br>
     OGROPen(/app/mapfiles/tindex.geojson)<br>
     msConnPoolRegister(tindex_ogr,/app/mapfiles/tindex.geojson,0x556aba222630)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">and _not_ <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">     msOGRFileOpen(tindex_ogr)...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">like I see for a vector tile index of vectors.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks, Pete<o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>