Skip to content

Basic Usage

Kevin Macharia edited this page May 28, 2017 · 7 revisions

Welcome to the express-test wiki!

The api endpoints are as follows:-

GET :/api/fences

Returns 20 available cordinates

GET :/api/fences/id

Returns the selected id cordinates

POST :api/fences

For all location payload [longitude, latitude]

Expected payload: {name:"The cool Place",location:[34,25],radius:4500}

Returns all locations around location with defined radius.

POST :/api/fences/box

Expected payload: {name:"The cool Place",location:[34,25],length:4000,width:5000}

Returns all box locations with the point as the center of the rectangle.

POST :/api/fences/polygon

Expected payload {location:[34,56]}

Returns the polygon that that point is in.

DELETE :/api/fences/id

Deletes the specific id cordinated in DB.

PS: When posting to API ensure you include in headers {Content-Type:application/json} All other coordinates other than location are in metres

Created features/Rest but no endpoints yet:-

1:Create co-ordinates

https://github.com/kevokevoh/express-test/blob/master/geodata/model/fence.js#L90

2.Update Cordinates

https://github.com/kevokevoh/express-test/blob/master/geodata/model/fence.js#L95

Demo Data Used in project

Co-ordinates data:

https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/restaurants.json

Polygons data:

https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/neighborhoods.json

Be sure to index after you import the data into your db

db.collection.createIndex({<location field>: '2dsphere'})

Basic HTTP tests:

I will update this to be more comprehensive

Ensure you have the dependencies installed then

cd geodata/tests

mocha -R spec fences.js

Cheers

Clone this wiki locally