Skip to content
Geohosting Server Application
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config add geohosting server files Nov 11, 2014
lib leading zero fix for zoom = 0 Nov 16, 2014
routes/api
storage
test
.gitignore
README.md
app-cluster.js
app-worker.js
package.json
server.js file rename cluster-master.js -> app-cluster.js Nov 16, 2014

README.md

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

You can’t perform that action at this time.