Overview

The Pure PostGIS Query APIs make PostGIS functions available in as close a form as possible to the original. The function names (except for the 'st_' prefix) are used, as are all the requirements.

Each endpoint redirects the submitted query to a Giraffe Geo PostGIS database and returns the response.

geomfromtext

Description: implements the PostGIS function ST_GeomFromText and returns a PostGIS ST_Geometry from a well-known text argument.

postgis.org documentation: http://www.postgis.org/docs/ST_GeomFromText.html/

Endpoint: https://api.giraffegeo.com/geomfromtext

parameter description
text well-known text, e.g. POLYGON((-122.3474 47.6185,-122.3330 47.6185,-122.3391 47.6138,-122.3474 47.6185))
srid target SRID, not required

Example python implementation

headers = {'x-api-key':'your_key'}

payload = {
        'srid':'4326',
        'text':POLYGON((-122.3474 47.6185,-122.3330 47.6185,-122.3391 47.6138,-122.3474 47.6185))
          }
r = requests.get('https://api.giraffegeo.com/geomfromtext', headers=headers, params=payload,)

issimple

Description: Implements the PostGIS function ST_IsSimple and returns {'st_issimple': True} from a well-known text argument if the geometry has no anomalous points and otherwise {'st_issimple': False}.

postgis.org documentation: https://postgis.net/docs/ST_IsSimple.html

Endpoint: https://api.giraffegeo.com/issimple

parameter description
text well-known text, e.g. POLYGON((-122.3474 47.6185,-122.3330 47.6185,-122.3391 47.6138,-122.3474 47.6185))

Example python implementation

headers = {'x-api-key':'your_key'}

payload = { 
        'text':POLYGON((-122.3474 47.6185,-122.3330 47.6185,-122.3391 47.6138,-122.3474 47.6185))
          }
r = requests.get('https://api.giraffegeo.com/issimple', headers=headers, params=payload)

isvalid

Description: Implements the PostGIS function ST_IsVALID and returns {'st_isvalid': True} from a well-known text argument if the geometry is well fordmed and otherwise {'st_isvalid': False}.

postgis.org documentation: https://postgis.net/docs/ST_IsValid.html

Endpoint: https://api.giraffegeo.com/isvalid

parameter description
text well-known text, e.g. POLYGON((-122.3474 47.6185,-122.3330 47.6185,-122.3391 47.6138,-122.3474 47.6185))
flags an optional flag integer. Accepted values are described here: https://postgis.net/docs/ST_IsValidDetail.html

Example python implementation

headers = {'x-api-key':'your_key'}

payload = { 
        'text':POLYGON((-122.3474 47.6185,-122.3330 47.6185,-122.3391 47.6138,-122.3474 47.6185))
          }
r = requests.get('https://api.giraffegeo.com/isvalid', headers=headers, params=payload)

wktasgeojson

Description: Implements the PostGIS function ST_AsGeoJSON(ST_GeomFromText()) to return the geometry in GeoJSON format from a well-known text argument. The response uses the key "geojson".

Endpoint: https://api.giraffegeo.com/wktasgeojson

parameter description
text well-known text, e.g. POLYGON((-122.3474 47.6185,-122.3330 47.6185,-122.3391 47.6138,-122.3474 47.6185))

Example python implementation

headers = {'x-api-key':'your_key'}

payload = { 
        'text':POLYGON((-122.3474 47.6185,-122.3330 47.6185,-122.3391 47.6138,-122.3474 47.6185))
          }
r = requests.get('https://api.giraffegeo.com/isvalid', headers=headers, params=payload)

Response

{u'geojson': u'{"type":"LineString","coordinates":[[-71.160281,42.258729],[-71.160837,42.259113],[-71.161144,42.25932]]}'}