Coder Social home page Coder Social logo

geopython / pygeoapi Goto Github PK

View Code? Open in Web Editor NEW
458.0 37.0 248.0 44.6 MB

pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.

Home Page: https://pygeoapi.io

License: MIT License

Python 94.13% CSS 0.06% HTML 5.24% Shell 0.23% Dockerfile 0.33%
geospatial data api ogc ogc-api osgeo pygeoapi

pygeoapi's Introduction

geopython

Vanity package for geopython projects

pip install geopython
>>> import geopython

pygeoapi's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pygeoapi's Issues

Elasticsearch: fix 500 error on index not found 404

[Thu May 24 18:35:11.004322 2018] [:error] [pid 22573:tid 140706876249856] NotFoundError: TransportError(404, u'index_not_found_exception', u'no such index')[Thu May 24 18:35:11.004322 2018] [:error] [pid 22573:tid 140706876249856] NotFoundError: TransportError(404, u'index_not_found_exception', u'no such index')

link to metadata

Would be good to add and/or link to metadata in/from collections.

Considering opengeospatial/ogcapi-features#160 (comment) core currently does not provide a detailed mechanism to link to metadata. They only mention that a link to additional metadata could be provided. Oapi-cov is a bit more explicit in req 2.9.

Where to store metadata:

  • as part of config (like title/desc currently)
  • some providers (such as geopackage/geotiff) may have embedded metadata
  • config could have a link to external metadata (file/database/online)

Ingest elements from embedded/external metadata?

  • In order to include some metadata on the collection response, it would be nice to ingest some external/embedded metadata, but we'll run into the issue of supporting multiple or requiring specific metadata schema's: DC, DCAT, Iso19115(-3), QGIS, schema.org, ...

implement file paths

Base provider class uses self.url to indicate where the provider is locate, this is problematic when we have for example spatialite that is a file.

Current we used file:// with asbolute paths. Need to create a specific file attriubte in the base class and support relative paths
e.g
self.file = "./data/"

roll back code to python 3.5

parts of code uses PEP-0498 as string interpolator, this is very specific to python3.6 and reducing compatilibity

Should this be supported (min python version 3.6) or rolled out and mim python version 3.5

activate sorting from html represention

#73 added sorting functionality
sorting should be activated by clicking a column header in the html representation
consider that for example pagination links should consider a sorting option applied

fix SQLite provider feature responses

Following on from OSGeo/gdal#626 (comment), fix sqlite provider to add 'type': 'Feature'. The below seems to work but assigning to @jorgejesus as the lead on this provider.

index b344b37..d922eb6 100644
--- a/pygeoapi/provider/sqlite.py
+++ b/pygeoapi/provider/sqlite.py
@@ -73,7 +73,9 @@ class SQLiteProvider(BaseProvider):
         feature_list = list()
         for row_data in self.dataDB:
             row_data = dict(row_data)  # sqlite3.Row is doesnt support pop
-            feature = {}
+            feature = {
+                'type': 'Feature'
+            }
             feature["geometry"] = json.loads(
                 row_data.pop('AsGeoJSON(geometry)')
                 )

Feature representation is expected to have ID (capitalized) field

This concerns in particular the templates for HTML rendering of items like here.

Problem

Some of the code in PyGeoAPIrelies on the fact that a Feature has an id-field named 'ID'. IMHO the GeoJSON standard specifies 'id' (lowercase) as Id-field:

  If a Feature has a commonly used identifier, that identifier
  SHOULD be included as a member of the Feature object with the name
  "id", and the value of this member is either a JSON string or number

Proposed Changes

Ok, we are dealing with an internal representation, but since some formatting is automated I propose to use the name id all over or at least some indirection i.s.o. of hard-coding ID..

Docker image doesnt build

Docker image is broken with package problem:

OK: 13151 distinct packages available
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  libcrypto1.1-1.1.1-r3:
    masked in: @edge-testing
    satisfies:
               openssl-dev-1.1.1-r3[libcrypto1.1=1.1.1-r3]
               libssl1.1-1.1.1-r3[so:libcrypto.so.1.1]
  libssl1.1-1.1.1-r3:
    masked in: @edge-testing
    satisfies:
               openssl-dev-1.1.1-r3[libssl1.1=1.1.1-r3]
  openssl-dev-1.1.1-r3:
    masked in: @edge-testing
    satisfies: world[openssl-dev]
The command '/bin/sh -c apk update && apk add --no-cache    git    python3-dev    libffi    libffi-dev    musl-dev    gcc   

Upgrading to alpine 3.8 fixes the problem

Several Providers return FeatureCollection on get single Feature

This applies to the Providers GeoPackage, PostgreSQL and SQLite.

The WFS3 operation to request a single Feature, like e.g. http://localhost:5000/collections/obs/items/371?f=json
should return a single Feature GeoJSON construct like:

{"type": "Feature", 
 "ID": "371", 
 "geometry": {"type": "Point", "coordinates": [-75.0, 45.0]}, 
 "properties": {
     "stn_id": "35", 
     "datetime": "2001-10-30T14:24:55Z", "value": "89.9"
        .
   }, 
  "links": [...
 }

Instead these Providers return a GeoJSON FeatureCollection with a single Feature.
Other providers like CSV, ES and GeoJSON return a single Feature as expected.

Applies to Provider implementations: geopackage.py, postgresql.py and sqlite.py and their tests.

implement query sorting

Add support for clients specifying sorting of query results as per sortby=p1[:A|D][,p2[:A|D].

py conventions for trailing slash management

I noticed sometimes users arrive in collections/obs/items and sometimes at collections/obs/items/. Both url's provide a valid answer however browsers treat both url's different when linking relatively. From these locations a '..' link will guide users to /collections in case 1 and to /collections/obs in case 2

Some 'solutions'

  • do not use relative links, always link to a full url
  • check all links for consistency on adding the trailing slash (or not)
  • auto-remove/add a trailing slash if detected it is not added (rewrite rule)

support for transactions

Ability to delete, insert, update or patch features from the api
OGC-API-Features currently does not offer a specification for transactions yet
However Openapi typically uses DELETE, POST and PUT verbs to update content in an API, so I don't expect much deviation to this in the upcoming ogc api's. It could actually support the discussion there to have an initial implementation available.

Transactions should be disabled by default, and only activated if proper authorisation is in place

Create feature

POST /items/{id} [obj]

Update feature

PUT /items/{id} [obj]

Delete feature

DELETE /items/{id}

Patch feature (partial update)

PATCH /items/{id} [partial obj]

support text/html encoding request in headers

Currently the default output of pygeoapi is a json format encoding with html only being supported when using f=html on the requests

Sofwares that are not geospatial aware e.g browser should automatically display the html formating. This could be achieved by by reading text/hml encoding on the HTTP header request

https://github.com/opengeospatial/WFS_FES/blob/75d7c7839aca8c27ad9f8590727b37e110cfa0e7/placeholder-additional-conformance-class/parameters/f.yaml

discussion:
opengeospatial/ogcapi-features#179

possibilities:

  • a visitor opening a feature in a browser (browser will send html header)
  • a search engine crawling the service (crawler will send html header)
  • leaflet/openlayers requesting a set of features (it will send the json header)
  • a desktop gis following a link from a feature to another feature (does it expect a webpage or a feature?)

'Invalid format' error

Running plain pygeoapi in virtualenv Python 3.7.1 Ubuntu 18.04 and requesting any URL via the browser all requests return:

                InvalidParameterValue
                Invalid format

We expect collections etc.

Inspecting the code it appears to come out of the function pygeoapi.py: check_format(), in particular this line will return a list of accept formats so the check on this line will always fail.

Have tested and will make a PR, replacing the check_format() function with something like:

def check_format(args, headers):
    """
    check format requested from arguments or headers

    :param args: dict of request keyword value pairs
    :param headers: dict of request headers

    :returns: format value
    """

    # Optional f=html or f=json query param
    # overrides accept
    format_ = args.get('f')
    if format_:
        return format_

    # Format not specified: get from accept headers
    format_ = 'text/html'

    if 'accept' in headers.keys():
        format_ = headers['accept']
    elif 'Accept' in headers.keys():
        format_ = headers['Accept']

    format_ = format_.split(',')

    if 'text/html' in format_:
        format_ = 'html'
    elif 'application/json' in format_:
        format_ = 'json'

    return format_

This works for us, both with query parm, and even default (neither f= nor accept headers).

enhance HTML representations

The f=html responses need a better layout. The goal here should be to enhance layout (especially the maps) without introducing too many external dependencies.

implement ordered properties

Implement server side property order in configuration so, by default, users get result properties in a specified order.

Note that this differs from #51 which will allow the user to explicitly specify properties.

HTML UI issues from #92 (mini.css)

Several issues found, some were there already before #92:

  1. Stale links when navigating with Next|Prev through Collections

NB this was already seen before #92

  1. Ditto for single Item
  1. JSON OpenAPI doc link

Not sure what the standard requires, or if http://localhost:5000/api?f=json should be explicitly rendered?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.