Skip to content

Commit 828977f

Browse files
committed
Merge pull request #38 from buckhx/dev
Csv shapes
2 parents 97aa16a + 50210b0 commit 828977f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2024
-368
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/resources/*.go
44
!/resources/stub.go
55
*.sh
6+
*.dig
67

78
# Compiled Object files, Static and Dynamic libs (Shared Objects)
89
*.o
@@ -29,3 +30,9 @@ _testmain.go
2930
*.test
3031
*.prof
3132
*.swp
33+
*.pid
34+
*.out
35+
*.log
36+
*.csv
37+
*.txt
38+
*.gz

README.md

Lines changed: 84 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,48 @@
44

55
A simple tool for solving common geospatial workflows.
66

7-
* wms: Web Mapping Server (tile server)
8-
* mbt: Tile builder for vector tiles into the mbtiles spec
7+
* [wms](#wms): Web Mapping Server (tile server)
8+
* [mbt](#mbt): Tile builder for vector tiles into the mbtiles spec
9+
* fence: A geofence utility
10+
* dig: A geocoder based on OSM data
11+
12+
This project is under heavy development and APIs/CLIs are subject to change until further notice.
13+
14+
## Installation
15+
16+
Install diglet into /usr/local/bin (assuming you have permissions to) like so
17+
18+
curl -sSL https://raw.githubusercontent.com/buckhx/diglet/master/scripts/install.py | sudo python - /usr/local/bin
19+
20+
If you don't have permission at /usr/local/bin, try something like this where you extend your PATH
21+
22+
BINDIR=~/diglet
23+
mkdir -p $BINDIR
24+
export PATH=$PATH:$BINDIR
25+
curl -sSL https://raw.githubusercontent.com/buckhx/denv/master/scripts/install.py | python - $BINDIR
26+
27+
If you just want the binary, the final arg to the install py is a directory to download into
28+
29+
Or do it manually by going to the releases page and download the diglet artifact https://github.com/buckhx/diglet/releases/latest
30+
31+
Currently only building 64 bit linux for simplicity, but will build for more archs as things stabilize.
32+
Instructions for [building](#building)
933

1034
# wms
1135

1236
A real-time tile server in a single binary
1337

1438
Here are some neat things that diglet wms does
1539

16-
* Backend changes are pushed to the front end in real time
17-
* Currently changes are registered from the kernel (inotify/kqueue/ReadDirectoryChangesW)
18-
* Sniffs the tile format
19-
* (pbf, json, gz, jpg, png, etc...)
20-
* Source specific hooks in the works
21-
* (on PostGIS insert -> build mbtiles)
40+
* Read-through mmap LRU cache
41+
* Easy peasy-lemon squeezy HTTPS
42+
* Sniffs the tile format and set Content-Type: (pbf, json, gz, jpg, png, etc...)
2243
* HTTP/JSON-RPC/WS endpoints
23-
* All packaged up in an itty-bitty binary
44+
45+
Some things in the works
46+
47+
* Backend changes are pushed to the front end in real time (via websockeys)
48+
* Source specific hooks (on PostGIS insert -> build mbtiles)
2449

2550
## Usage
2651

@@ -70,9 +95,25 @@ Get information about the specific tileset. This information is populated from t
7095
Get the tile at the given coordinates and return the contents as the response body.
7196
Passing json=true as a will return the tile as a json object with it's coordinates
7297

98+
###Gallery
99+
100+
GET /tileset/gallery/{tileset-slug}
101+
102+
A simple gallery to view your tiles with. Only supports vector tiles for now. ?lat={}&lon={}&zoom{} will zoom to desired location.
103+
73104
#mbt
74105

75-
More info to come, but here's the current help message
106+
Will build tiles from either geojson or a csv.
107+
108+
If a csv is used, either --csv-lat/--csv-lon or --csv shape must be set to read the coordinates correctly.
109+
The csv-shape is a list of list of [[],[],[]] and will only render a single, exterior ring polygon per line.
110+
Csv also requires a named header.
111+
112+
Geojson is fair-game, no support for GeometryCollection or Topojson
113+
114+
--filter if included will only include these columns in this properties. Includes all if not added
115+
116+
Valid extentsions for mbtiles are .mbtiles or .mbt
76117

77118
```
78119
NAME:
@@ -92,15 +133,20 @@ OPTIONS:
92133
--layer-name "features" Name of the layer for the features to be added to
93134
--desc, --description "Generated from Diglet" Value inserted into the description entry of the mbtiles
94135
--extent "4096" Extent of tiles to be built. Default is 4096
95-
--max, --max-zoom "10" Maximum zoom level to build tiles for. Not Implemented.
96-
--min, --min-zoom "5" Minimum zoom level to build tiles from. Not Implemented.
97-
--filter Only include fields keys in this comma delimited list. EXAMPLE --filter name,date,case_number,id NOTE all fields are lowercased and non-word chars replaced with '_'
98-
--csv-lat "latitude"
99-
--csv-lon "longitude"
100-
--csv-geometry "geometry" Column containing geometry in geojson-like 'coordinates' form
136+
--max, --max-zoom "10" Maximum zoom level to build tiles for
137+
--min, --min-zoom "5" Minimum zoom level to build tiles from
138+
--filter Only include fields keys in this comma delimited list
139+
--csv-lat Column containing latitude
140+
--csv-lon Column containint longitude
141+
--csv-shape Column containing geometry in geojson-like 'coordinates' form
101142
--csv-delimiter ","
102143
```
103144

145+
#fence & dig
146+
147+
I did a geofencing experiment and may or may not include that in the standard build.
148+
Also did some geocoding work from OSM. Hit's ~500 r/s, but unstable so won't be included for now.
149+
104150
## Releases
105151

106152
Diglet uses a go library for reading mbtiles that depends on some C code, this makes
@@ -114,6 +160,25 @@ We'll include a script and or directions for building on your own.
114160

115161
#### Major releases will have platform specific binaries
116162

163+
## Building
164+
165+
Here are the basics, but you can inspect the .travis.yml for specifics
166+
167+
Prereqs
168+
169+
* [go installed](https://golang.org/doc/install#install), preferably 1.4+
170+
* gcc access
171+
* go get github.com/buckhx/diglet
172+
* cd into diglet
173+
174+
```
175+
CGO_ENABLED=1
176+
go test -v ./...
177+
go get ./...
178+
go generate
179+
go build -ldflags '-extldflags "-static"'
180+
```
181+
117182
## Some food for thought
118183

119184
##### A tile is a girls best friend
@@ -139,6 +204,9 @@ Here are dependencies and their licenese
139204
* buckhx/diglet: MIT
140205
* buckhx/mbtiles: MIT
141206
* codegangsta/cli: MIT
207+
* qedus/osmpbf: MIT
142208
* gorilla: BSD 3-Clause
143209
* mattn/go-sqlite3: MIT
144210
* go-std-lib: BSD 3-Clause
211+
212+
I got lazy and haven't maintained the licenses...

burrow/routes.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,18 @@ type RequestContext struct {
179179
Params MethodParams
180180
}
181181

182+
func (ctx *RequestContext) Render(template string) (string, error) {
183+
params := ctx.HTTPReader.URL.Query()
184+
vars := make(map[string]string, len(ctx.Params)+len(params))
185+
for k, v := range ctx.Params {
186+
vars[k] = v.GetString()
187+
}
188+
for k, v := range params {
189+
vars[k] = v[0] //only take first
190+
}
191+
return RenderTemplate(template, vars)
192+
}
193+
182194
func (r *RouteHandler) MountRoutes(methods []Method) {
183195
dict := make(map[string]Method)
184196
for _, method := range methods {

burrow/util.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ package burrow
33
import (
44
"encoding/binary"
55
"fmt"
6+
"github.com/cbroglie/mustache"
67
"log"
78
"strconv"
89
"strings"
910
)
1011

12+
func RenderTemplate(template string, vars ...interface{}) (string, error) {
13+
return mustache.Render(template, vars...)
14+
}
15+
1116
func info(format string, vals ...interface{}) {
1217
log.Printf("Burrow info: "+format, vals...)
1318

0 commit comments

Comments
 (0)