0

我有一个 PostgreSql 存储过程,它返回一个使用 json_build_object 函数创建的 geojson 特征集合。此 Web 服务在 OpenLayers 中打开良好,但是,当我尝试在 QGIS 中使用数据源管理器 -> 矢量 -> 协议 -> geojson 打开它时,出现以下错误:

无效的数据源:[myurl]/rpc/wod_geojson 不是有效或可识别的数据源。

返回的 geojson 如下所示:

{
"type": "FeatureCollection",
"features": [{
        "type": "Feature",
        "id": 1,
        "geometry": {
            "type": "Point",
            "coordinates": [0.0, 0.0]
        },
        "properties": {
            "num": 1,
            "lib": "bla"
        }
    }, {
        "type": "Feature",
        "id": 2,
        "geometry": {
            "type": "Point",
            "coordinates": [1.0, 1.0]
        },
        "properties": {
            "num": 2,
            "lib": "blabla"
        }
    }, {
        "type": "Feature",
        "id": 3,
        "geometry": {
            "type": "Point",
            "coordinates": [2.0, 2.0]
        },
        "properties": {
            "num": 3,
            "lib": "blablabla"
        }
    }
]

}

我错过了什么?

PostGrest 响应标头:

Content-Range   0-0/*
Content-Type    application/geo+json
Date    Wed, 09 Feb 2022 11:02:26 GMT
Server  postgrest/9.0.0
Transfer-Encoding   chunked
Vary    Accept-Encoding

已编辑:奇怪的是,我可以使用 Python 在 QGIS 中打开 Web 服务:

myLayer= QgsVectorLayer('[myurl]/rpc/wod_geojson', 'myLayer', 'ogr')
QgsProject.instance().addMapLayers([myLayer])
4

0 回答 0