Skip to content

Arkitektum/pygeoapi.provider.postgresql_ext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL Extended Provider

Extended PostgreSQL provider for pygeoapi with support for:

  • nonlinear geometry types via GDAL
  • field/value mappings from lookup tables or GML codelists
  • cached lookups for previous/next items within a collection
  • templated related links surfaced through the feature links array

Related links between collections

Use the optional links block in your provider definition to expose links that point to related collections. Each entry is rendered with str.format, so you can reference the feature identifier ({id}) or any property returned for the feature.

providers:
  - type: feature
    name: postgresql_ext.PostgreSQLExtendedProvider
    data:
      id_field: your_id
      table: parent_collection_table
      links_base: "https://example.com/vorpah/"
      links:
        - rel: related
          href: "collections/child-collection/items?foreignKey={foreign_key_prop}"
          title: "child"
        - rel: related
          href: "collections/parent-collection/items/{id}"
          title: "Parent for {id}"

When features are returned (both for query and get requests) every link template renders an entry in the feature links array. The rendered template is resolved to an absolute href, with defaults rel: "related" and type: "application/json" unless you override them. You can also supply custom titles or other metadata; nested dictionaries and lists are rendered recursively.

{
  "type": "Feature",
  "id": "123",
  "geometry": { "...": "..." },
  "properties": { "...": "..." },
  "links": [
    {
      "rel": "related",
      "href": "collections/child-collection/items?foreignKey=42",
      "title": "child",
      "type": "application/json"
    },
    {
      "rel": "related",
      "href": "collections/parent-collection/items/123",
      "title": "parent",
      "type": "application/json"
    }
  ]
}

If a template references an unknown property, the entry is skipped and a warning is logged. This allows you to define different related links per collection without breaking responses when some attributes are missing. Use any rel values that make sense for your API; related is the default when none is provided. To force a specific base URL (for example when running behind a reverse proxy) supply links_base in the provider configuration; otherwise the current request URL is used.

About

Extended PostgreSQL provider for pygeoapi

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages