CRS支持

Pygeapi支持完整的规范: OGC API - Features - Part 2: Coordinate Reference Systems by Reference corrigendum 。指定的CRS相关功能可用于所有要素数据提供程序。

配置

有关详细信息,请访问 配置 部分为功能提供程序。目前仅支持‘URI’CRS表示法格式。

  • crs -支持的CRSS列表

  • storage_crs -存储数据的CRS(必须位于 crs 列表)

  • storage_crs_coordinate_epoch -新纪元 storage_crs 对于动态坐标参考系

这些每个提供商的配置字段都是可选的。CRS-Values的默认值为 http://www.opengis.net/def/crs/OGC/1.3/CRS84 ,因此具有经轴/经轴排序的“WGS84”。如果空间特征集合的存储CRS是动态坐标参考系, storage_crs_coordinate_epoch 配置坐标的坐标纪元。

还有对CRSS的支持,支持高度,如 http://www.opengis.net/def/crs/OGC/1.3/CRS84h 。在这种情况下,BBox参数(见下文)可能包含6个坐标。

元数据

一致性类 http://www.opengis.net/spec/ogcapi-features-2/1.0/conf/crs 作为一种 conformsTo 根登录页响应中的字段。

配置的CRSS或其缺省值, crsstorageCRS 并且可选地 storageCrsCoordinateEpoch 将出现在“Describe Collection”响应中。

参数

这个 items 查询支持以下参数:

  • crs -应返回其中的要素坐标的CRS,也用于‘Get Single Item’请求

  • bbox-crs -的CRS bbox 参数(仅适用于支持 bbox 参数)

如果指定了这两个参数中的任何一个或两者,则它们的CRS-值应该来自集合元数据中通告的CRS-列表(见上文)。

名为的HTTP标头 Content-Crs 根据“OGC API-Feature-Part 2”标准,指定返回的特征坐标的CRS。例如:

Content-Crs: <http://www.opengis.net/def/crs/EPSG/0/3395>

请注意,这些参数的值可能需要进行URL编码。

实施

所有功能提供商都支持CRS和BBOX CRS。一些细节可能有助于理解(性能)影响。

BBOX CRS参数

这个 bbox-crs 参数在公共的pygeapi级别进行处理,因此对功能提供程序是透明的。显然,提供商应该支持 bbox 。这是一种转变 bbox 参数是根据 storage_crs 配置。然后是(转变的) bbox 与其他查询参数一起传递给提供程序实例。

CRS参数

当属性的值 crs 参数与提供程序数据存储CRS不同,需要将响应功能坐标转换为该CRS。由于一些要素提供程序(如PostgreSQL或OGR)可能支持原生坐标变换,因此pygeapi将变换委托给这些提供程序,将 crs 与其他查询参数一起使用。

例如,像CSV这样还不支持坐标转换的功能提供程序提供了一个‘标志’,该‘标志’触发了pygeapi在提供程序响应数据上执行转换。详细信息:这是通过一个Python修饰器实现的 @crs_transform 关于提供者函数 query()get() 。通过删除该标志,提供商稍后可以将转换转移到其内部实现。

实例

假设一个集合的集合元数据中包含以下CRS支持的地址:

curl 'http://localhost:5000/collections/dutch_addresses_4326?f=json'

 .
 .

"crs": [
 "http://www.opengis.net/def/crs/EPSG/0/4326",
 "http://www.opengis.net/def/crs/EPSG/0/3857",
 "http://www.opengis.net/def/crs/EPSG/0/28992",
 "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
],
"storageCRS": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"

这允许一个 bbox-crs 使用荷兰语“RD”坐标与CRS进行查询 http://www.opengis.net/def/crs/EPSG/0/28992 以检索例如单个地址。请注意,URI是URL编码的,这在 curl 命令,但在浏览器中输入时,可以使用纯文本。尽管 curl 当在完整的URL两边使用单引号时,也可以理解非编码的URL。

curl 'http://localhost:5000/collections/dutch_addresses_4326/items?f=json&bbox-crs=http%3A%2F%2Fwww.opengis.net%2Fdef%2Fcrs%2FEPSG%2F0%2F28992&bbox=177430,459268,177440,459278'
# or plain URL
curl 'http://localhost:5000/collections/dutch_addresses_4326/items?f=json&bbox-crs=http://www.opengis.net/def/crs/EPSG/0/28992&bbox=177430,459268,177440,459278'

# response fragment
{
  "type": "FeatureCollection",
  "features": [
      {
          "type": "Feature",
          "geometry": {
              "type": "Point",
              "coordinates": [
                  5.714846709450305,
                  52.12122746454743
              ]
          },
          "properties": {
              "straatnaam": "Willinkhuizersteeg",
              "huisnummer": "2",
              "huisletter": "C",
              "woonplaats": "Wekerom",
              "postcode": "6733EB",
              "toevoeging": null
          },
          "id": "inspireadressen.1742212"
      }
  ],
  "links": [
  .
  .

您还可以使用与CRS中一样具有经轴/经轴顺序的WGS84等效项 http://www.opengis.net/def/crs/EPSG/0/4326

curl 'http://localhost:5000/collections/dutch_addresses_4326/items?f=json&bbox-crs=http%3A%2F%2Fwww.opengis.net%2Fdef%2Fcrs%2FEPSG%2F0%2F4326&bbox=52.12122,5.71484,52.12123,5.71486'

# response fragment
{
  "type": "FeatureCollection",
  "features": [
      {
          "type": "Feature",
          "geometry": {
              "type": "Point",
              "coordinates": [
                  5.714846709450305,
                  52.12122746454743
              ]
          },
          "properties": {
              "straatnaam": "Willinkhuizersteeg",
              "huisnummer": "2",
              "huisletter": "C",
              "woonplaats": "Wekerom",
              "postcode": "6733EB",
              "toevoeging": null
          },
          "id": "inspireadressen.1742212"
      }
  ],
  "links": [
  .
  .

使用 crs 参数,您可以在不同的CRS中检索BBox中的数据,如 http://www.opengis.net/def/crs/EPSG/0/28992 。这个 bbox 假定在存储CRS中指定 http://www.opengis.net/def/crs/OGC/1.3/CRS84

curl 'http://localhost:5000/collections/dutch_addresses_4326/items?f=json&crs=http%3A%2F%2Fwww.opengis.net%2Fdef%2Fcrs%2FEPSG%2F0%2F28992&bbox=5.71484,52.12122,5.71486,52.12123'
# or plain URL
curl 'http://localhost:5000/collections/dutch_addresses_4326/items?f=json&crs=http://www.opengis.net/def/crs/EPSG/0/28992&bbox=5.71484,52.12122,5.71486,52.12123'

# response fragment
{
  "type": "FeatureCollection",
  "features": [
      {
          "type": "Feature",
          "geometry": {
              "type": "Point",
              "coordinates": [
                  177439.0002001376,
                  459273.9995615507
              ]
          },
          "properties": {
              "straatnaam": "Willinkhuizersteeg",
              "huisnummer": "2",
              "huisletter": "C",
              "woonplaats": "Wekerom",
              "postcode": "6733EB",
              "toevoeging": null
          },
          "id": "inspireadressen.1742212"
      }
  ],
  "links": [
  .
  .

或者,您也可以同时指定两者 crsbbox-crs 因此, bbox 在CRS中 http://www.opengis.net/def/crs/EPSG/0/28992

curl 'http://localhost:5000/collections/dutch_addresses_4326/items?f=json&crs=http%3A%2F%2Fwww.opengis.net%2Fdef%2Fcrs%2FEPSG%2F0%2F28992&bbox-crs=http%3A%2F%2Fwww.opengis.net%2Fdef%2Fcrs%2FEPSG%2F0%2F28992&bbox=177430,459268,177440,459278'
# or plain URL
curl 'http://localhost:5000/collections/dutch_addresses_4326/items?f=json&crs=http://www.opengis.net/def/crs/EPSG/0/28992&bbox-crs=http://www.opengis.net/def/crs/EPSG/0/28992&bbox=177430,459268,177440,459278'

# response fragment
{
  "type": "FeatureCollection",
  "features": [
      {
          "type": "Feature",
          "geometry": {
              "type": "Point",
              "coordinates": [
                  177439.0002001376,
                  459273.9995615507
              ]
          },
          "properties": {
              "straatnaam": "Willinkhuizersteeg",
              "huisnummer": "2",
              "huisletter": "C",
              "woonplaats": "Wekerom",
              "postcode": "6733EB",
              "toevoeging": null
          },
          "id": "inspireadressen.1742212"
      }
  ],
  "links": [
  .
  .