Node.js REST API for PostGres Spatial Entities. AKA: SpatialServer

Related tags

Maps PGRestAPI
Overview

PGRestAPI (a.k.a. Chubbs Spatial Server)

Join the chat at https://gitter.im/spatialdev/PGRestAPI

alt text

Overview

Node.js REST API for PostgreSQL Spatial Tables.

An introduction to PGRestAPI can be found here

A few key uses for PGRestAPI:

  • Create Mapbox Vector Tiles on the fly from PostGIS or shapefiles. more...
  • Serve pre-created Vector Tiles .mbtiles files
  • Serve pre-created PNG .mbtiles files (like TileStream)
  • REST API for querying Postgres tables - Supports spatial intersection, tabular queries and aggregation queries
  • REST API returns GeoJSON, CSV, Shapefile or esriJSON
  • Templates for creating custom web service endpoints - (Execute custom SQL functions, for example)
  • Rasters in PostGIS offer basic intersect operations and zonal stats. Find sum of raster values that intersect a polygon, for example.

Utilities:

  • WKT Previewer
  • Server side proxy - support requests to servers that don't support CORS

Under development:

  • Better caching for different endpoints

  • Raster map services (Drop a .tif into data/rasters)

  • Authentication with passport/MongoDB/Mongoose (Disabled for now)

More To-Dos:

  • Update Express and other libraries to current versions
  • More tests
  • Major refactoring of endpoints folder
  • Break up endpoint functionality into modules
  • Persistent caching
  • Administrative Panel
  • Editing

Soon will drop:

  • PNG image creation from PostGIS Tables
  • CartoCSS to Mapnik XML parser (Carto module) (this actually works, but is not used by our team)

##Installation

Dependencies

  • PostgreSQL 9.1 + w/ PostGIS 2.0 +
  • Mapnik

##Screenshots

###Table/View List: alt text

###Table Details: alt text

###Query Endpoint: alt text

###Query Endpoint Results: alt text

###Dynamic Map Tile Service Endpoint: alt text

###Dynamic Vector Tile Endpoint: alt text

###Geoprocessing Operations: alt text

###Geoprocessing Operation: alt text

###Utililties - WKT Preview endpoint: alt text

###Raster Operations List: alt text

###Raster Operations - Zonal Statistics: alt text

###Tile Rendering Stats (/admin): alt text

Comments
  • Unable to open the vector tile end points

    Unable to open the vector tile end points

    I am trying to parse the vector tile end points but the results I get

    http://localhost:3001/services/postgis/pois/geom/vector-tiles/{z}/{x}/{y}.json
    

    are not readable. I can't open or read the endpoints in any format. How can I parse/read the vector tile endpoints?

    opened by hasan9206 6
  • Running tests

    Running tests

    Can someone help me with running the test folder content? I have made some modifications to the codebase and would like to run the existing tests. I could not find any documentation for this.

    opened by rtodea 4
  • Detecting Tables Outside `public` Schema

    Detecting Tables Outside `public` Schema

    I had a quick question. Is it possible to set a list of schemas to search in addition to public in settings.js?

    I've got a DB which has geometries stored in tables outside of the public schema, as seen by this output:

    pg_geocoding=# select *
    FROM geometry_columns;
     f_table_catalog | f_table_schema | f_table_name | f_geometry_column | coord_dimension | srid |     type     
    -----------------+----------------+--------------+-------------------+-----------------+------+--------------
     pg_geocoding    | geocoding      | points       | the_geom          |               2 | 4326 | POINT
     pg_geocoding    | geocoding      | polygons     | the_geom          |               2 | 4326 | MULTIPOLYGON
    (2 rows)
    

    However, the admin viewer will show no spatial tables when pointing to this db. FWIW I'm connecting via a user who has the geocoding schema on their search path.

    If, however, I modify this sql statement in the tables endpoint, to include both the public and geocoding schemas, I can successfully view the tables and get rolling.

    Am I missing something basic here?

    Thanks!

    opened by mattmakesmaps 4
  • Issue with mapnik installation

    Issue with mapnik installation

    Hi, when I start the server I get the following error:

    Mapnik not properly installed. Skipping. Reason: TypeError: Object [ null ] has no method 'createWindow'

    This appears to be a problem with the jsdom module. Unfortunately I have no experience with node so am finding it difficult to debug this.

    I'm on OSX 10.9.3 with node 0.10.31 and mapnik 2.2.0_2

    opened by aratcliffe 3
  • Can not access feature properties in Openlayer3

    Can not access feature properties in Openlayer3

    I am serving a vector tile from Chubbs and rendering it with Openlayers3.14.3. I am not able to access the feature properties of the vector tile.

    My layer:

    var observationLayer = new ol.layer.VectorTile({
       source: new ol.source.VectorTile({
        format: new ol.format.MVT(),
        tileGrid: ol.tilegrid.createXYZ({maxZoom: 22}),
        tilePixelRatio: 16,
        url: '/services/postgis/test_observations/geometry/vector-tiles/{z}/{x}/{y}.pbf'
      }),
      style: observationStyle
    }); 
    

    Trying to access feature properties:

       map.on(ol.MapBrowserEvent.EventType.SINGLECLICK, function (e) {
        console.log('e:');
        console.log(e);
        map.forEachFeatureAtPixel(e.pixel, function (feature, layer) {
          console.log('feature.getProperties():');
          console.log(feature.getProperties());
          // This only returns: id: "test_observations_geometry"
          // instead of all of the layers attributes. If I change the layer to a GeoJSON source,
          // then it works correctly. 
        });
      });
    
    opened by bwyss 2
  • Dynamic vector tiles not working?

    Dynamic vector tiles not working?

    Hi, I'm not sure if I'm doing something wrong, but all of my vector sources are returning 404s. I installed PGRestAPI and pointed it to my PostGIS instance, and also dropped a shapefile into the data/shapefiles directory.

    PGRestAPI finds these data sources ok and creates endpoints for them (LGAvic is my shapefile):

    Created vector tile service: /services/shapefile/Ken_CountyWithWater/vector-tiles/:z/:x/:y.*
    Created vector tile service: /services/shapefile/LGAvic/vector-tiles/:z/:x/:y.*
    Created vector tile service: /services/shapefile/kenya_coverage/vector-tiles/:z/:x/:y.*
    SpatialServer listening on port 3001
    Executing query: select * from geometry_columns where f_table_catalog = $1, gis
    Created PBF .mbtiles service: /services/vector-tiles/KenyaCounties/:z/:x/:y.pbf
    Executing query: select * from geometry_columns where f_table_catalog = $1, gis
    Created vector tile service: /services/postgis/j/wkb_geometry/vector-tiles/:z/:x/:y.*
    Created vector tile service: /services/postgis/planet_osm_point/way/vector-tiles/:z/:x/:y.*
    Created vector tile service: /services/postgis/planet_osm_roads/way/vector-tiles/:z/:x/:y.*
    Created vector tile service: /services/postgis/planet_osm_polygon/way/vector-tiles/:z/:x/:y.*
    Created vector tile service: /services/postgis/planet_osm_line/way/vector-tiles/:z/:x/:y.*
    Created vector tile service: /services/postgis/j2/wkb_geometry/vector-tiles/:z/:x/:y.*
    Created vector tile service: /services/postgis/footprints/wkb_geometry/vector-tiles/:z/:x/:y.*
    Created vector tile service: /services/postgis/lga06gen0_05/wkb_geometry/vector-tiles/:z/:x/:y.*
    Created vector tile service: /services/postgis/buildingfootprints/wkb_geometry/vector-tiles/:z/:x/:y.*
    Created single tile service (postgis): /services/postgis/j/wkb_geometry/dynamicSingleMap/*
    Created single tile service (postgis): /services/postgis/planet_osm_point/way/dynamicSingleMap/*
    Created single tile service (postgis): /services/postgis/planet_osm_roads/way/dynamicSingleMap/*
    Created single tile service (postgis): /services/postgis/planet_osm_polygon/way/dynamicSingleMap/*
    Created single tile service (postgis): /services/postgis/planet_osm_line/way/dynamicSingleMap/*
    Created single tile service (postgis): /services/postgis/j2/wkb_geometry/dynamicSingleMap/*
    Created single tile service (postgis): /services/postgis/footprints/wkb_geometry/dynamicSingleMap/*
    Created single tile service (postgis): /services/postgis/lga06gen0_05/wkb_geometry/dynamicSingleMap/*
    Created single tile service (postgis): /services/postgis/buildingfootprints/wkb_geometry/dynamicSingleMap/*
    Created multi tile service (postgis): /services/postgis/j/wkb_geometry/dynamicMap/:z/:x/:y.*
    Created multi tile service (postgis): /services/postgis/planet_osm_roads/way/dynamicMap/:z/:x/:y.*
    Created multi tile service (postgis): /services/postgis/planet_osm_point/way/dynamicMap/:z/:x/:y.*
    Created multi tile service (postgis): /services/postgis/planet_osm_polygon/way/dynamicMap/:z/:x/:y.*
    Created multi tile service (postgis): /services/postgis/planet_osm_line/way/dynamicMap/:z/:x/:y.*
    Created multi tile service (postgis): /services/postgis/j2/wkb_geometry/dynamicMap/:z/:x/:y.*
    Created multi tile service (postgis): /services/postgis/footprints/wkb_geometry/dynamicMap/:z/:x/:y.*
    Created multi tile service (postgis): /services/postgis/lga06gen0_05/wkb_geometry/dynamicMap/:z/:x/:y.*
    Created multi tile service (postgis): /services/postgis/buildingfootprints/wkb_geometry/dynamicMap/:z/:x/:y.*
    <?xml version="1.0" encoding="utf-8"?>
    

    They are listed in the "Table Listing" page, and the preview under "Dynamic Map Service" (raster tiles) works correctly. screenshot 2015-03-13 14 27 35

    However, vector tiles don't seem to get generated. The endpoint provided seems sensible: .../services/postgis/j2/wkb_geometry/vector-tiles/{z}/{x}/{y}.pbf; but all the vector tiles return 404. For example, .../services/postgis/j2/wkb_geometry/vector-tiles/12/3696/2514.pbf.

    On the server side, there's not much output:

    <?xml version="1.0" encoding="utf-8"?>
    <Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" buffer-size="10">
        <Layer name="j2_wkb_geometry" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
            <StyleName>j2</StyleName>
            <StyleName>default</StyleName>
            <Datasource>
                <Parameter name="dbname">gis</Parameter>
                <Parameter name="estimate_extent">false</Parameter>
                <Parameter name="geometry_field">wkb_geometry</Parameter>
                <Parameter name="geometry_type">MULTIPOLYGON</Parameter>
                <Parameter name="host">127.0.0.1</Parameter>
                <Parameter name="layerName">default</Parameter>
                <Parameter name="password">ubuntu</Parameter>
                <Parameter name="port">5432</Parameter>
                <Parameter name="srid">3857</Parameter>
                <Parameter name="table">(SELECT wkb_geometry from &quot;j2&quot;) as &quot;j2&quot;</Parameter>
                <Parameter name="type">postgis</Parameter>
                <Parameter name="user">ubuntu</Parameter>
            </Datasource>
        </Layer>
    </Map>
    
    No cached response for: /services/postgis/j2/wkb_geometry/vector-tiles/12/3696/2514.pbf.  Generating.
    GET /services/postgis/j2/wkb_geometry/vector-tiles/12/3696/2514.pbf 404 221ms
    

    Meanwhile, the shapefiles don't seem to appear anywhere in the web interface. Perhaps that part isn't implemented, judging from the readme. For instance, I can't see the included "kenya_coverage" or "Ken_CountyWithWater" shapefiles either.

    The shapefile endpoints seem to return 404 (/services/shapefile/kenya_coverage/vector-tiles/7/76/64.pbf ), but perhaps I'm just requesting the wrong thing.

    opened by stevage 2
  • Test there are column names for table (i.e. table exists) before attempting to use them

    Test there are column names for table (i.e. table exists) before attempting to use them

    I've simply added guard conditions around the code that uses the column names to prevent the process from crashing when a request is made for a table that does not exist. Should also return an appropriate error response - 404 maybe?

    opened by aratcliffe 2
  • Node-mapnik Install Fail on Mac OS X 10.9.1

    Node-mapnik Install Fail on Mac OS X 10.9.1

    After some deliberation, I have gotten node-mapnik to install. However, now when I try to run the app, I get this:

    Nicholass-MacBook-Pro:PGRestAPI nick$ node app.js
    dyld: lazy symbol binding failed: Symbol not found: __ZN6mapnik16datasource_cache20register_datasourcesERKSs
      Referenced from: /Users/nick/PGRestAPI/node_modules/mapnik/lib/_mapnik.node
      Expected in: dynamic lookup
    
    dyld: Symbol not found: __ZN6mapnik16datasource_cache20register_datasourcesERKSs
      Referenced from: /Users/nick/PGRestAPI/node_modules/mapnik/lib/_mapnik.node
      Expected in: dynamic lookup
    
    Trace/BPT trap: 5
    
    opened by hallahan 2
  • Cannot GET /services/vector-tiles

    Cannot GET /services/vector-tiles

    i have installed mapnik and node-mapink as well is installed in node_modules folders, all other functions run fine ( query - geoprosessing ) only dynamic vector-tiles appear when i click on a table and then it redirect to error cannot get / url

    opened by mapsgeek 1
  • Table name/srid caching from table/:table_name endpoint

    Table name/srid caching from table/:table_name endpoint

    If the app starts up, and the first endpoint you hit is services/tables/:table_name, the details and srid of the table will not yet have been cached. Fix it.

    opened by apollolm 1
  • Map behavior malfunction for query results preview

    Map behavior malfunction for query results preview

    Desc: when double-click zooming or box zooming, map re-centers well north of target

    e.g.

    • Go to http://chubbs.spatialdev.com/services/tables/bangladesh_cicos/query
    • Submit query
    • Try to draw box zoom around points
    opened by abenrob 1
  • vector tile server compatible with arcmap?

    vector tile server compatible with arcmap?

    Hi, If we server our pbf files using this server is it compatible with arcmap? and can we show the pbf data servered by this server on arcmap or qgis too?

    opened by am2222 4
  • Problem with contextify@1.0.0 during 'npm install'

    Problem with [email protected] during 'npm install'

    During the installing node modules with 'npm install' in project PGRestAPI, I am gettting error

    npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'

    There is problem with the contextify package. I have already checked the package and it is in unmaintained state.

    I am using Ubuntu 16.04.

    opened by ghost 1
  • Question: Mapnik vs Mapbox vector tiles?

    Question: Mapnik vs Mapbox vector tiles?

    In the Windows installation instructions, it specifies that Mapnik is required for vector tiles. However, on the main README.md, PGRestAPI specifies that Mapbox vector tiles are used, which are different from Mapnik tiles.

    So, is Mapnik required for PGRestAPI to create Mapbox vector tiles from a PostGIS database on the fly?

    opened by FilmCoder 1
  • Can't load dynamic tile endopints error

    Can't load dynamic tile endopints error

    Hi. I have a next error:

    Error in reading spatial tables from DB. Can't load dynamic tile endopints. Message is: undefined Error in reading spatial tables from DB. Can't load dynamic tile endopints. Message is: undefined { [error: relation "geometry_columns" does not exist] name: 'error', length: 115, severity: 'ERROR', code: '42P01', detail: undefined, hint: undefined, position: '15', internalPosition: undefined, internalQuery: undefined, where: undefined, file: 'parse_relation.c', line: '1160', routine: 'parserOpenTable' }

    But PostGIS extension is sucessfully installed ond works.

    postgres=# CREATE EXTENSION postgis; ERROR: extension "postgis" already exists

    postgres=# select * from geometry_columns DBNAME; f_table_catalog | f_table_schema | f_table_name | f_geometry_column | coord_dimension | srid | type
    -----------------+----------------+--------------+-------------------+-----------------+------+----------------- postgres | tiger | county | the_geom | 2 | 4269 | MULTIPOLYGON postgres | tiger | state | the_geom | 2 | 4269 | MULTIPOLYGON postgres | tiger | place | the_geom | 2 | 4269 | MULTIPOLYGON postgres | tiger | cousub | the_geom | 2 | 4269 | MULTIPOLYGON postgres | tiger | edges | the_geom | 2 | 4269 | MULTILINESTRING postgres | tiger | addrfeat | the_geom | 2 | 4269 | LINESTRING postgres | tiger | faces | the_geom | 2 | 4269 | MULTIPOLYGON postgres | tiger | zcta5 | the_geom | 2 | 4269 | MULTIPOLYGON postgres | tiger | tract | the_geom | 2 | 4269 | MULTIPOLYGON postgres | tiger | tabblock | the_geom | 2 | 4269 | MULTIPOLYGON postgres | tiger | bg | the_geom | 2 | 4269 | MULTIPOLYGON (11 rows)

    What it can be?

    opened by nibygro 2
  • "isSolid" function missing

    Hi Everyone,

    I met the "isSolid" function missing issue when running the vector tiling service:

    C:\PGRestAPI\endpoints\tiles\index.js:1547 image.isSolid(function (err, solid, key) { ^ TypeError: Object # has no method 'isSolid' at C:\PGRestAPI\endpoints\tiles\index.js:1547:17

    Do you have solution for this? Thank you!

    opened by piedmontlong 0
Owner
SpatialDev
The Emerging Markets Team at Critigen
SpatialDev
A very fast geospatial point clustering library for browsers and Node.

supercluster A very fast JavaScript library for geospatial point clustering for browsers and Node. <script src="https://unpkg.com/[email protected]/d

Mapbox 1.6k Jan 7, 2023
Asynchronous, non-blocking SQLite3 bindings for Node.js

Asynchronous, non-blocking SQLite3 bindings for Node.js. Supported platforms The sqlite3 module works with: Node.js v11.x, v12.x, v13.x and v14.x. Ele

Mapbox 5.6k Jan 4, 2023
A Node.js map tile library for PostGIS and torque.js, with CartoCSS styling

Windshaft A Node.js map tile library for PostGIS and torque.js, with CartoCSS styling. Can render arbitrary SQL queries Generates image and UTFGrid in

CARTO 306 Dec 22, 2022
Lightweight Node.js isochrone map server

Galton Lightweight Node.js isochrone server. Build isochrones using OSRM, Turf and concaveman. Francis Galton is the author of the first known isochro

Urbica 266 Dec 17, 2022
A pluggable Node.js map tile server.

TileStrata TileStrata is a pluggable "slippy map" tile server that emphasizes code-as-configuration. The primary goal is painless extendability. It's

Natural Atlas 409 Dec 30, 2022
WMS server using node-mapnik

landspeed.js A simple WMS server written in node.js Only supports WMS 1.1 GetMap requests (bbox, width, height, and srs). Requirements Node.js 0.10.x

Dane Springmeyer 52 Jul 21, 2022
Mapbox JavaScript API, a Leaflet Plugin

mapbox.js A Mapbox plugin for Leaflet, a lightweight JavaScript library for traditional raster maps. For the state-of-the-art Mapbox vector maps libra

Mapbox 1.9k Dec 23, 2022
React friendly API wrapper around MapboxGL JS

react-map-gl | Docs react-map-gl is a suite of React components designed to provide a React API for Mapbox GL JS-compatible libraries. More informatio

Vis.gl 6.9k Jan 2, 2023
A web based data mining tool for OpenStreetMap using the Overpass API.

overpass turbo https://overpass-turbo.eu/ – stable version https://tyrasd.github.io/overpass-turbo/ – latest version This is a GUI for testing and dev

Martin Raifer 607 Dec 29, 2022
Implements the tilelive API for generating vector tiles from PostGIS

tilelive-postgis Implements the tilelive API for generating mapnik vector tiles from PostGIS. Installation npm install @mapbox/tilelive tilelive-postg

Stepan Kuzmin 50 Dec 12, 2022
This map is tracking the position of ISS(international space setallite) at every 1 second. I use Nasa's "where the iss" API and "Leaflet.js" for the map.

ISS-tracking-map About This map is tracking the position of ISS(international space setallite) at every 1 second. I use Nasa's "where the iss" API and

Waz.sheeran 2 Oct 25, 2021
MERN stack travel app using mapbox API, Travel and drop pin , share reviews and rate the location

MERN-Travel-Map Travel Map Pin A single page application built with MERN Stack from scratch (MongoDB + Mongoose, Express, React & NodeJs) Table of Con

Bùi Quốc Trọng 11 Dec 29, 2022
This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js. But in most cases, I would recommend you to use something like Express in a production project for productivity purposes.

Eduardo Dantas 7 Jul 19, 2022
Node js package makes creating node jd dependincies files like Controllers,Entities and Repositories easier by executing a few instructions

Nodejs Studio Node js package makes creating node js project dependincies files like Controllers,Entities and Repositories easier by executing a few i

Syrian Open Source 9 Oct 12, 2022
Modern Spatial Reference System Class. Supports EPSG Codes, PROJ4 String, and Well-Known Text.

spatial-reference-system Modern Spatial Reference System Class. supports EPSG Codes PROJ4 Strings ESRI and OGC Well-Known Text PRJ File install npm in

Daniel J. Dufour 6 Jul 22, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
WCS : Project 2 (Spatial travel agency)

Concept This template is meant to serve as a foundation for every P2/P3 following the React-Express-MySQL stack, as learned in Wild Code School. It's

Jacques Poulin 3 May 19, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A card for Home Assistant Lovelace for exploring the history of your entities interactively and in real time.

History explorer card This is a custom history card for Home Assistant. This card offers a highly interactive and configurable way to view the history

null 165 Dec 31, 2022