[QGIS-Developer] Can't open postgrest geojson service
SIGéal
sigeal at sigeal.com
Tue Feb 15 05:56:54 PST 2022
Further testing, I discovered that I can open my postgrest geojson
service using Python :
|myLayer= QgsVectorLayer('http://mydomain:3000/rpc/wod_geojson,
'myLayer', 'ogr') QgsProject.instance().addMapLayers([myLayer]) |
Also, testing with ogrinfo on command line, it fails with 404 error ,
but adding |Accept: application/json| header makes it work.
(using --config GDAL_HTTP_HEADER_FILE)
--
Christophe Damour
Le 11/02/2022 à 14:27, SIGéal a écrit :
> Hi,
>
> I have a PostgreSql stored procedure which returns a geojson feature
> collection created with json_build_object function.
> This web service opens fine in OpenLayers, however, when I try to open
> it in QGIS, with data source manager -> vector -> protocol -> geojson :
>
>
>
> I get the following error :
>> Invalid data source: [myurl]/rpc/wod_geojson is not a valid or
>> recognized data source.
> This is the query wrapped in a plpgsql function called my_geojson :
>> |SELECT json_build_object(
>> 'type', 'FeatureCollection', 'features',
>> json_agg(
>> json_build_object(
>> 'type', 'Feature', 'id', id, 'geometry',
>> ST_AsGeoJSON(ST_Transform(geometry, 4326))::json,
>> 'properties', json_build_object(
>> 'lib', lib
>> )
>> )
>> )
>> )::json my_geojson FROM (SELECT ROW_NUMBER() OVER() id, * FROM
>> mytable) tmp|
> This is the url I use to call the service:
>> |http://mydomain:3000/rpc/my_geojson|
> I tested a similar geojson REST service served with pg_featureserv,
> and it works fine...
>
> Environment :
>>
>> Server Environment :
>> PostgreSQL version: 10.19
>> PostgREST version: 9.0.0
>> Operating system: Ubuntu 16.04
>>
>> Client Environment :
>> QGIS version: 3.16.16
>> Operating system: Windows 10
>>
>
> Thanks for any int
>
> --
> Christophe Damour
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220215/c8b73e81/attachment.html>
More information about the QGIS-Developer
mailing list