Coder Social home page Coder Social logo

geohosting-server's Introduction

Geohosting Server Application

This NodeJS+MongoDB application demonstrates how to create simple RESTful JSON-based API that operates with GeoSpatial data.

It shows implementation approaches to basic CRUD operations and demonstrates methods of getting and grouping (clusterization)

of large amount of GeoSpatial data on server side. Data is provided in GeoJSON format.

As a frontend part it uses highly efficient RemoteObjectManager module from Yandex.Maps API.

Getting Started

  1. Fork your own copy of this git repository and clone it.

  2. Install NodeJS, npm and MongoDB

  3. Install all dependencies

    npm install
  1. Write your config overrides in config/local.json

  2. Run server.js

    node server.js
  1. Run tests
    mocha test

Upload data to MongoDB

Use Feature model to upload geospatial data to MongoDB on server side.

Test helper saveFeatures method shows an example how to do it.

var helper = require('./test/helper');

// Upload 1 million Features to MongoDB
helper.saveFeatures(1000000)
  .then(function (res) {
    console.log(res);
  }, function (err) {
    console.log(err);
  }, function (stat) {
    console.log(stat);
  });

API Examples

API operates with GeoSpatial data using GeoJSON format

Create Feature

Use POST type of request and send GeoJSON Feature object Currently only "Point" type of geometry supported and long-lat coordinates order Provide special "properties" data fields as "balloonContent", "hintContent", "iconContent". You are able to use own Feature identificator "id" or it will be assigned by Server.

POST /api/v1/features

{
  "id": "1",
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [ 37.5, 55.7 ]
  },
  "properties": {
    "balloonContent": "The quick brown fox jumps over the lazy dog",
    "hintContent": "The quick brown fox jumps over the lazy dog"
  }
}

Server will reply with 201 status and return stored Feature data.

Update Feature

Use PUT type of request to update existed Feature data using featureId on the end of request URL Send the fields you want to update.

PUT /api/v1/features/1

{
  "properties": {
    "balloonContent": "New content of Placemark Balloon"
  }
}

Server will reply with 204 status.

Remove Feature

Use DELETE type of request to remove existed Feature using featureId on the end of request URL

DELETE /api/v1/features/1

Server will reply with 204 status.

Get Feature

Use GET type of request to get existed Feature data using featureId on the end of request URL

GET /api/v1/features/1

Server will reply with 204 status and return Feature data.

Search Features

Use GET type of request to search Features using URL path according to type of search. Provide additional arguments from GeoJSON Feature schema to filter only necessary Features.

For getting Features within certain tile numbers provide bbox argument describes requested tiles area, zoom, and necessity in clusterization. GET /api/v1/features/within/tiles?bbox=0,0,2,2?clusterize=1&zoom=5

Server will reply with 200 status and return found Features as FeatureColection

geohosting-server's People

Contributors

dimik avatar

Watchers

Arkady Spiridonov 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.