Overview
This is a light weight api server aimed at making it easy to create, store and serve geospatial data to other webmapping applications. The core api server is written in GoLang and uses three Go packages: Gorilla Mux , Gorilla WebSocket , go.geojson and Bolt.
Features
Installation
Install GoLang
Follow the guide to install GoLang on your computer.
Get the Code
With GoLang installed, we will have to get the latest GoSpatial source code. We can do this simply cloning the repository:
Installing Dependencies
We will now need to aquire the three Go packages (Gorilla Mux , Gorilla WebSocket and Bolt). There is a simple shell script provided in the repositories main directory that will go get
these packages and setup the working directory:
Building from source
Finally we can compile from our source:
We are now ready to run the server!
Quickstart
Start the server
Start server with the by executing the binary file produced in the bin directory:
Options
Option | Default | Description |
---|---|---|
-db | bolt.db | Specifies what database file to use |
-p | 8080 | Specifies the server port |
-s | su | Specifies the superuser key for management routes |
-c | Gets port, database, and superuser key from config json file (produced by ./setup) | |
-v | Prints the app version |
Generate settings.json
To create a settings.json (server config) run the following command
This will create a file called settings.json
Troubleshooting
You are bound to run into problems. Please review the following hints for troubleshooting. Of course, you're welcome to contact us if you're unable to resolve.
Customer Routes
View layers
GET /api/v1/layers?apikey=<apikey>
Returns json containing customers datasources
- apikey - customer apikey
Create layer
POST /api/v1/layer?apikey=<apikey>
Creates a new datasource layer and returns datasource uuid
- apikey - customer apikey
View layer
GET /api/v1/layer/{ds}?apikey=<apikey>
Returns GeoJSON for requested datasource layer
- ds (in url) - datsource layer uuid
- apikey - customer apikey
Delete layer
DELETE /api/v1/layer{ds}?apikey=<apikey>
Deletes a datasource layer and removes it from customer
- ds (in url) - datsource layer uuid
- apikey - customer apikey
Create feature
POST /api/v1/layer/{ds}/feature?apikey=<apikey>
Adds GeoJSON feature to datasource layer
- ds (in url) - datsource layer uuid
- apikey
View feature
GET /api/v1/layer/{ds}/feature{k}?apikey=<apikey>
Adds GeoJSON feature to datasource layer
- ds (in url) - datsource layer uuid
- k (in url) - index of feature
- apikey - customer apikey
Superuser Routes
Add Customer
POST /management/customer?authkey=<superuserkey>
Creates a new customer and returns customer apikey
- authkey - superuser apikey
Share Layer
PUT /api/v1/layer/{ds}?apikey=<apikey>&authkey=<superuserkey>
Shares datasource layer with another customer
- ds (in url) - datsource layer uuid
- apikey - customer apikey
- authkey - superuser apikey
Server profile
GET /management/profile?authkey=<superuserkey>
Returns basic server info such as uptime
- authkey - superuser apikey
Views
Map Client
GET /map/{ds}?apikey=<superuserkey>
Mobile friendy map client using the Leaflet mapping library. Easy to use interface for viewing and submitting geospatial features. This view is touch screen supported.
- ds (in url) - datsource layer uuid
- apikey - customer apikey
Management
GET /management?apikey=<superuserkey>
Simple interface for creating and managing your datasources. Users are able to create and delete layers, and link basemap layers
- apikey - customer apikey
Command line tools
gospatial_cmd
Command line tool for backend operations
Options
Option | Default | Description |
---|---|---|
-db | bolt.db | Specifies what database file to use |
Methods
Method | Arg | Arg | Description |
---|---|---|---|
ls | Lists all datasources in database | ||
export | datasource id | Exports datasource to GeoJSON file | |
import | *.shp | Imports shapefile into database | |
import | *.geojson | Imports geojson file into database | |
create | datasource | Creates new datasource | |
create | customer | Creates new customer | |
assign | datasource id | customer key | Assigns datasource to customer |