Giter Site home page Giter Site logo

thinker-luo / es_tileserv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from watergis/es_tileserv

0.0 0.0 0.0 31.05 MB

This is a simple vector tile server which is served from Elasticsearch.

License: MIT License

Shell 2.48% JavaScript 64.03% HTML 29.10% Dockerfile 2.13% EJS 2.26%

es_tileserv's Introduction

es_tileserv

GitHub Docker Cloud Automated build Docker Image Size (latest by date)

This is a simple vector tile server which is served from Elasticsearch.

Install

npm install

Configuration

copy .env.example to .env

cp .env.example .env

Edit config.js for your Elasticsearch tile API.

elasticsearch: {
    url: process.env.ELASTICSEARCH_URL, //change it to your Elasticsearch URL
    extension: 'pbf' //If you want to use other file extenstion for vector tiles except 'pbf', please speficy here.
},
tilesets: path.join(__dirname,'../tilesets') //specify folder path which stores your mbtiles.

Usage

# for debug
npm run dev

or
# for production
npm start

Run on pm2

First, please install pm2 globally if you don't install it yet.

sudo npm install -g pm2
# start server
# for development
npm run pm2:dev

# for production
npm run pm2:prod

# stop server
npm run pm2:stop

Run on docker-compose together with Elasticsearch

# build docker image in local
npm run docker:build

# Or, you can pull the latest Docker image from Docker hub
docker pull gis4water/es_tileserv:latest

# start pm2 on docker
npm run docker:start

After running it on docker, please create index on Elasticsearch. The below is an example how to create index by ogr2ogr.

ogr2ogr -f "Elasticsearch" -lco NOT_ANALYZED_FIELDS={ALL} -lco INDEX_NAME=water_connection -lco OVERWRITE=YES http://localhost:9200 "PG:host='localhost' port=5432 user='postgres' dbname='rwss_assets' password='your password'" water_connection -skipfailures

Insert sample data for test

some building data from OSM in Narok town, Kenya will be inserted as following commands.

$ cd sample-data
$ ./insert_test_data.sh

$ ogrinfo ES:http://localhost:9200

INFO: Open of `ES:http://localhost:9200'
      using driver `Elasticsearch' successful.
1: africa_rwanda_poi (Point)
2: africa_rwanda_building (Point)

API documentation

After runing the server, please access http://localhost:8080/docs.

Example

for web browser

http://localhost:8080/api/tile/14/9824/8241.pbf?indices=[{"name":"africa_rwanda_poi","geometry":"geometry","query":{"term":{"building":"school"}}}]

for curl

curl -X GET "http://localhost:8080/api/tile/unvt/10/597/517.pbf?indices=%5B%7B%22name%22%3A%22africa_rwanda_poi%22%2C%22geometry%22%3A%22geometry%22%2C%22query%22%3A%7B%22term%22%3A%7B%22building%22%3A%22school%22%7D%7D%7D%5D" -H  "accept: application/gzip"

Test

npm test

Note. this test case can't work without installing sample test data of Rwanda.

License

This source code is under MIT license.


Copyright (c) 2020 Jin IGARASHI

es_tileserv's People

Contributors

jinigarashi avatar

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.