Skip to content

Commit

Permalink
Merge branch 'end-to-end' into issue-21
Browse files Browse the repository at this point in the history
  • Loading branch information
ARolek committed Jul 12, 2016
2 parents 3fb1bf4 + df95e88 commit d6805d7
Show file tree
Hide file tree
Showing 45 changed files with 7,569 additions and 224 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Tegola aims to be a high performance vector tile server delivering [Mapbox Vector Tiles](https://github.com/mapbox/vector-tile-spec). The project aims to be written in pure Go.

## Near term goals
- [x] Support for transcoding WKB to MVT.
- [X] Support for transcoding WKB to MVT.
- [ ] Support for `/z/x/y` web mapping URL scheme.
- [ ] Support for PostGIS data provider.

Expand All @@ -12,4 +12,4 @@ Tegola aims to be a high performance vector tile server delivering [Mapbox Vecto
- [Mapbox Vector Tile (MVT) 2.1](https://github.com/mapbox/vector-tile-spec/tree/master/2.1)

## License
See [license](LICENSE.md) file in repo.
See (license)[LICENSE.md] file in repo.
4 changes: 4 additions & 0 deletions basic/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ func (c *Collection) Geometeries() (geometeries []tegola.Geometry) {
}
return geometeries
}

func (Collection) String() string {
return "Collectioin"
}
64 changes: 64 additions & 0 deletions basic/geometry_math.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package basic

import (
"fmt"

"github.com/terranodo/tegola"
)

// RehomeGeometry will make sure to normalize all points to the ulx and uly coordinates.
func RehomeGeometry(geometery tegola.Geometry, ulx, uly float64) (tegola.Geometry, error) {
switch geo := geometery.(type) {
default:
return nil, fmt.Errorf("Unknown Geometry: %+v", geometery)
case tegola.Point:
return &Point{geo.X() - ulx, geo.Y() - uly}, nil
case tegola.Point3:
return &Point3{geo.X() - ulx, geo.Y() - uly, geo.Z()}, nil
case tegola.MultiPoint:
var pts MultiPoint
for _, pt := range geo.Points() {
pts = append(pts, Point{pt.X() - ulx, pt.Y() - uly})
}
return pts, nil
case tegola.LineString:
var line Line
for _, ptGeo := range geo.Subpoints() {
line = append(line, Point{ptGeo.X() - ulx, ptGeo.Y() - uly})
}
return &line, nil
case tegola.MultiLine:
var line MultiLine
for i, lineGeo := range geo.Lines() {
geoLine, err := RehomeGeometry(lineGeo, ulx, uly)
if err != nil {
return nil, fmt.Errorf("Got error converting line(%v) of multiline: %v", i, err)
}
ln, _ := geoLine.(Line)
line = append(line, ln)
}
return line, nil
case tegola.Polygon:
var poly Polygon
for i, line := range geo.Sublines() {
geoLine, err := RehomeGeometry(line, ulx, uly)
if err != nil {
return nil, fmt.Errorf("Got error converting line(%v) of polygon: %v", i, err)
}
ln, _ := geoLine.(Line)
poly = append(poly, ln)
}
return &poly, nil
case tegola.MultiPolygon:
var mpoly MultiPolygon
for i, poly := range geo.Polygons() {
geoPoly, err := RehomeGeometry(poly, ulx, uly)
if err != nil {
return nil, fmt.Errorf("Got error converting poly(%v) of multipolygon: %v", i, err)
}
p, _ := geoPoly.(Polygon)
mpoly = append(mpoly, p)
}
return &mpoly, nil
}
}
5 changes: 4 additions & 1 deletion basic/line.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import "github.com/terranodo/tegola"
type Line []Point

// Just to make basic collection only usable with basic types.
func (Line) basicType() {}
func (Line) basicType() {}
func (Line) String() string { return "Line" }

// Subpoints return the points in a line.
func (l *Line) Subpoints() (points []tegola.Point) {
Expand All @@ -22,6 +23,8 @@ func (l *Line) Subpoints() (points []tegola.Point) {
// MultiLine is a set of lines.
type MultiLine []Line

func (MultiLine) String() string { return "Line" }

// Just to make basic collection only usable with basic types.
func (MultiLine) basicType() {}

Expand Down
28 changes: 21 additions & 7 deletions basic/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,57 @@ package basic
import "github.com/terranodo/tegola"

// Point describes a simple 2d point
type Point [2]int
type Point [2]float64

// Just to make basic collection only usable with basic types.
func (Point) basicType() {}

// X is the x coordinate
func (bp *Point) X() float64 {
return float64(bp[0])
return bp[0]
}

// Y is the y coordinate
func (bp *Point) Y() float64 {
return float64(bp[1])
return bp[1]
}

func (*Point) String() string {
return "Point"
}

// Point3 describes a simple 3d point
type Point3 [3]int
type Point3 [3]float64

// Just to make basic collection only usable with basic types.
func (Point3) basicType() {}

// X is the x coordinate
func (bp *Point3) X() float64 {
return float64(bp[0])
return bp[0]
}
func (*Point3) String() string {
return "Point3"
}

// Y is the y coordinate
func (bp *Point3) Y() float64 {
return float64(bp[1])
return bp[1]
}

// Z is the z coordinate
func (bp *Point3) Z() float64 {
return float64(bp[2])
return bp[2]
}

// MultiPoint describes a simple set of 2d points
type MultiPoint []Point

// Just to make basic collection only usable with basic types.
func (MultiPoint) basicType() {}
func (*MultiPoint) String() string {
return "MultiPoint"
}

// Points are the points that make up the set
func (v *MultiPoint) Points() (points []tegola.Point) {
Expand All @@ -66,3 +76,7 @@ func (v *MultiPoint3) Points() (points []tegola.Point) {
}
return points
}

func (*MultiPoint3) String() string {
return "MultiPoint3"
}
6 changes: 6 additions & 0 deletions basic/polygon.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func (p *Polygon) Sublines() (slines []tegola.LineString) {
}
return slines
}
func (Polygon) String() string {
return "Polygon"
}

// MultiPolygon describes a set of polygons.
type MultiPolygon []Polygon
Expand All @@ -31,3 +34,6 @@ func (mp *MultiPolygon) Polygons() (polygons []tegola.Polygon) {
}
return polygons
}
func (MultiPolygon) String() string {
return "Polygon"
}
Loading

0 comments on commit d6805d7

Please sign in to comment.