diff --git a/Gopkg.lock b/Gopkg.lock index 3d653b30..decb67eb 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -227,7 +227,7 @@ [[projects]] branch = "master" - digest = "1:157eb52179752d4d88f1049aa6c3e4954d6796af5f6bcd54b5ab40f8637805df" + digest = "1:62d3906c154a5fd594c51e434c8d38a3f5ae207f0396bf733fcfbe0ea4796430" name = "github.com/tidwall/geojson" packages = [ ".", @@ -235,7 +235,7 @@ "geometry", ] pruneopts = "" - revision = "8ff3ef500c61617c9f325603cf40863ca7086a1d" + revision = "996bb585989456cda9c8302e89c2fe6e82cc61bf" [[projects]] digest = "1:211773b67c5594aa92b1e8389c59558fa4927614507ea38237265e00c0ba6b81" diff --git a/vendor/github.com/tidwall/geojson/circle.go b/vendor/github.com/tidwall/geojson/circle.go index 5a1e5c82..a4df8572 100644 --- a/vendor/github.com/tidwall/geojson/circle.go +++ b/vendor/github.com/tidwall/geojson/circle.go @@ -57,7 +57,7 @@ func (g *Circle) AppendJSON(dst []byte) []byte { dst = strconv.AppendFloat(dst, g.center.Y, 'f', -1, 64) dst = append(dst, `]},"properties":{"type":"Circle","radius":`...) dst = strconv.AppendFloat(dst, g.meters, 'f', -1, 64) - dst = append(dst, `",radius_units":"m"}}`...) + dst = append(dst, `,"radius_units":"m"}}`...) return dst } diff --git a/vendor/github.com/tidwall/geojson/circle_test.go b/vendor/github.com/tidwall/geojson/circle_test.go index 859cd832..0407b26d 100644 --- a/vendor/github.com/tidwall/geojson/circle_test.go +++ b/vendor/github.com/tidwall/geojson/circle_test.go @@ -3,6 +3,10 @@ package geojson import "testing" func TestCircle(t *testing.T) { + expectJSON(t, + `{"type":"Feature","geometry":{"type":"Point","coordinates":[-112,33]},"properties":{"type":"Circle","radius":"5000"}}`, + `{"type":"Feature","geometry":{"type":"Point","coordinates":[-112,33]},"properties":{"type":"Circle","radius":5000,"radius_units":"m"}}`, + ) g, err := Parse(`{ "type":"Feature", "geometry":{"type":"Point","coordinates":[-112.2693,33.5123]}, @@ -14,5 +18,5 @@ func TestCircle(t *testing.T) { if err != nil { t.Fatal(err) } - println(g.Contains(PO(-112.26, 33.51))) + expect(t, g.Contains(PO(-112.26, 33.51))) } diff --git a/vendor/github.com/tidwall/geojson/collection_test.go b/vendor/github.com/tidwall/geojson/collection_test.go index 0dd99743..0bb379bf 100644 --- a/vendor/github.com/tidwall/geojson/collection_test.go +++ b/vendor/github.com/tidwall/geojson/collection_test.go @@ -97,7 +97,7 @@ func TestCollectionBostonSubset(t *testing.T) { func TestCollectionUSASubset(t *testing.T) { data, err := ioutil.ReadFile("test_files/usa.geojson") - if err == nil { + if err != nil { fmt.Printf("test_files/usa.geojson missing\n") return } diff --git a/vendor/github.com/tidwall/geojson/geometry/rect.go b/vendor/github.com/tidwall/geojson/geometry/rect.go index 8c280d4b..2072222d 100644 --- a/vendor/github.com/tidwall/geojson/geometry/rect.go +++ b/vendor/github.com/tidwall/geojson/geometry/rect.go @@ -17,6 +17,11 @@ func (rect Rect) Move(deltaX, deltaY float64) Rect { } } +// Index ... +func (rect Rect) Index() interface{} { + return nil +} + // Clockwise ... func (rect Rect) Clockwise() bool { return false diff --git a/vendor/github.com/tidwall/geojson/geometry/rect_test.go b/vendor/github.com/tidwall/geojson/geometry/rect_test.go index 1f451ced..7e674c01 100644 --- a/vendor/github.com/tidwall/geojson/geometry/rect_test.go +++ b/vendor/github.com/tidwall/geojson/geometry/rect_test.go @@ -21,6 +21,10 @@ func TestRectMove(t *testing.T) { expect(t, R(1, 2, 3, 4).Move(5, 6) == R(6, 8, 8, 10)) } +func TestRectIndex(t *testing.T) { + expect(t, (Rect{}).Index() == nil) +} + func TestRectNumPoints(t *testing.T) { expect(t, R(0, 0, 10, 10).NumPoints() == 5) } diff --git a/vendor/github.com/tidwall/geojson/geometry/series.go b/vendor/github.com/tidwall/geojson/geometry/series.go index 24e99ea5..413962e5 100644 --- a/vendor/github.com/tidwall/geojson/geometry/series.go +++ b/vendor/github.com/tidwall/geojson/geometry/series.go @@ -24,6 +24,7 @@ type Series interface { PointAt(index int) Point SegmentAt(index int) Segment Search(rect Rect, iter func(seg Segment, index int) bool) + Index() interface{} } func seriesCopyPoints(series Series) []Point { @@ -41,7 +42,7 @@ type baseSeries struct { convex bool // points create a convex shape rect Rect // minumum bounding rectangle points []Point // original points - tree *d2.BoxTree // segment tree + tree *d2.BoxTree // segment tree. } // makeSeries returns a processed baseSeries. @@ -62,6 +63,14 @@ func makeSeries(points []Point, copyPoints, closed bool, index int) baseSeries { return series } +// Index ... +func (series *baseSeries) Index() interface{} { + if series.tree == nil { + return nil + } + return series.tree +} + // Clockwise ... func (series *baseSeries) Clockwise() bool { return series.clockwise diff --git a/vendor/github.com/tidwall/geojson/geometry/series_test.go b/vendor/github.com/tidwall/geojson/geometry/series_test.go index fe9989d2..f4344770 100644 --- a/vendor/github.com/tidwall/geojson/geometry/series_test.go +++ b/vendor/github.com/tidwall/geojson/geometry/series_test.go @@ -34,6 +34,16 @@ func TestSeriesEmpty(t *testing.T) { expect(t, series2.Empty()) } +func TestSeriesIndex(t *testing.T) { + series := makeSeries(nil, false, false, 0) + expect(t, series.Index() == nil) + series = makeSeries([]Point{ + P(0, 0), P(10, 0), P(10, 10), P(0, 10), P(0, 0), + }, true, true, 1) + + expect(t, series.Index() != nil) +} + func TestSeriesClockwise(t *testing.T) { var series baseSeries series = makeSeries([]Point{