qgis / qwc2-demo-app

QWC2 demo application
Other
240 stars 149 forks source link

qgis provider in searchBox don't work #508

Closed naub1n closed 7 months ago

naub1n commented 7 months ago

Hi,

qwc-map-viewer-demo:v2023.11.22 (idem with latest pulled today) qwc-feature-info-service:latest (pulled today)

When I try to search layer whith qgis provider, there is no data in searchBox.

My themesConfig:

"searchProviders": [
    "nominatim",
    {
        "provider": "qgis",
        "params": {
          "title": "test",
          "resultTitle": "Test",
          "expression": {
            "Sous-bassins": "\"COMI_TER\" ILIKE '%$TEXT$%'"
          }
        }
    }
]

I can see the request to FeatureInfo service and this is the result:

<GetFeatureInfoResponse>
<Layer name="Sous-bassins" layername="Sous-bassins" layerinfo="Sous-bassins" displayfield="COMI_TER">
<Feature id="1">
<HtmlContent inline="1">
<table class="attribute-list"> <tbody> <tr> <td class="identify-attr-title wrap"> <i>id</i> </td> <td class="identify-attr-value wrap"> 1 </td> </tr> <tr> <td class="identify-attr-title wrap"> <i>OBJECTID</i> </td> <td class="identify-attr-value wrap"> 1 </td> </tr> <tr> <td class="identify-attr-title wrap"> <i>FID_COMITE</i> </td> <td class="identify-attr-value wrap"> 0 </td> </tr> <tr> <td class="identify-attr-title wrap"> <i>COMI_TER</i> </td> <td class="identify-attr-value wrap"> Rivières d&#x27;Ile-de-France </td> </tr> <tr> <td class="identify-attr-title wrap"> <i>SHAPE.AREA</i> </td> <td class="identify-attr-value wrap"> 13050836083.1511 </td> </tr> <tr> <td class="identify-attr-title wrap"> <i>SHAPE.LEN</i> </td> <td class="identify-attr-value wrap"> 809246.680936491 </td> </tr> </tbody> </table>
</HtmlContent>
<Attribute name="id" value="1" attrname="id"/>
<Attribute name="OBJECTID" value="1" attrname="OBJECTID"/>
<Attribute name="FID_COMITE" value="0" attrname="FID_COMITE"/>
<Attribute name="COMI_TER" value="Rivières d'Ile-de-France" attrname="COMI_TER"/>
<Attribute name="SHAPE.AREA" value="13050836083.1511" attrname="SHAPE.AREA"/>
<Attribute name="SHAPE.LEN" value="809246.680936491" attrname="SHAPE.LEN"/>
</Feature>
<Feature id="4">
<HtmlContent inline="1">
<table class="attribute-list"> <tbody> <tr> <td class="identify-attr-title wrap"> <i>id</i> </td> <td class="identify-attr-value wrap"> 4 </td> </tr> <tr> <td class="identify-attr-title wrap"> <i>OBJECTID</i> </td> <td class="identify-attr-value wrap"> 4 </td> </tr> <tr> <td class="identify-attr-title wrap"> <i>FID_COMITE</i> </td> <td class="identify-attr-value wrap"> 3 </td> </tr> <tr> <td class="identify-attr-title wrap"> <i>COMI_TER</i> </td> <td class="identify-attr-value wrap"> Rivières de Basse-Normandie </td> </tr> <tr> <td class="identify-attr-title wrap"> <i>SHAPE.AREA</i> </td> <td class="identify-attr-value wrap"> 14205301070.1776 </td> </tr> <tr> <td class="identify-attr-title wrap"> <i>SHAPE.LEN</i> </td> <td class="identify-attr-value wrap"> 955203.622223173 </td> </tr> </tbody> </table>
</HtmlContent>
<Attribute name="id" value="4" attrname="id"/>
<Attribute name="OBJECTID" value="4" attrname="OBJECTID"/>
<Attribute name="FID_COMITE" value="3" attrname="FID_COMITE"/>
<Attribute name="COMI_TER" value="Rivières de Basse-Normandie" attrname="COMI_TER"/>
<Attribute name="SHAPE.AREA" value="14205301070.1776" attrname="SHAPE.AREA"/>
<Attribute name="SHAPE.LEN" value="955203.622223173" attrname="SHAPE.LEN"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>

When I try to debug code in SearchProvider.js, axios.get(...) always use callback function in catch(). Where is the error ??

manisandro commented 7 months ago

Not sure that is the issue, but one thing I see is that your response does not contain any geometry. Make sure you have configured your QGIS project to return geometries in FeatureInfo responses.

naub1n commented 7 months ago

Ah Ok !!

I activate this parameter in my project:

image

And it work !!

It's possible to add this requirement in Search documentation?

Thx !!

manisandro commented 7 months ago

Sure, I've added a note to https://qwc-services.github.io/topics/Search/#configuring-the-qgis-feature-search