diff --git a/go.sum b/go.sum index 15d0fdba..8fa5c3e8 100644 --- a/go.sum +++ b/go.sum @@ -61,6 +61,7 @@ github.com/tidwall/geoindex v1.1.0 h1:d/pGCgKUonfQINd1235kKqx9gWBU4N7GjDS9WvbPvL github.com/tidwall/geoindex v1.1.0/go.mod h1:3gTa91BW+eiVIipuR6aU1Y9Sa0q75b1teE/NP2vfsTc= github.com/tidwall/geojson v1.1.8 h1:n/WT/PG0OEHrxUJQoeqkupWDt3pwbHMynl6OF9xKIM0= github.com/tidwall/geojson v1.1.8/go.mod h1:tBjfxeALRFLc25LLpjtWzy2nIrNmW1ze1EAhLtd8+QQ= +github.com/tidwall/geojson v1.1.10 h1:ALzsrTn62pq65DudSQpYDjjCUaq6dP1XQm51GVYgJyo= github.com/tidwall/geojson v1.1.10/go.mod h1:tBjfxeALRFLc25LLpjtWzy2nIrNmW1ze1EAhLtd8+QQ= github.com/tidwall/gjson v1.3.2 h1:+7p3qQFaH3fOMXAJSrdZwGKcOO/lYdGS0HqGhPqDdTI= github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= diff --git a/scripts/build.sh b/scripts/build.sh index 97203e1e..902bea2b 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -34,6 +34,7 @@ export CGO_ENABLED=0 if [ "$NOMODULES" != "1" ]; then export GO111MODULE=on export GOFLAGS=-mod=vendor + go mod vendor fi # Build and store objects into original directory. diff --git a/vendor/github.com/tidwall/geojson/circle.go b/vendor/github.com/tidwall/geojson/circle.go index 5dd3a724..f001f223 100644 --- a/vendor/github.com/tidwall/geojson/circle.go +++ b/vendor/github.com/tidwall/geojson/circle.go @@ -103,13 +103,6 @@ func (g *Circle) Contains(obj Object) bool { return g.containsPoint(other.Center()) case *Circle: return other.Distance(g) < (other.meters + g.meters) - case *LineString: - for i := 0; i < other.base.NumPoints(); i++ { - if !g.containsPoint(other.base.PointAt(i)) { - return false - } - } - return true case Collection: for _, p := range other.Children() { if !g.Contains(p) { @@ -123,36 +116,6 @@ func (g *Circle) Contains(obj Object) bool { } } -// intersectsSegment returns true if the circle intersects a given segment -func (g *Circle) intersectsSegment(seg geometry.Segment) bool { - start, end := seg.A, seg.B - - // These are faster checks. - // If they succeed there's no need do complicate things. - if g.containsPoint(start) || g.containsPoint(end) { - return true - } - - // Distance between start and end - l := geo.DistanceTo(start.Y, start.X, end.Y, end.X) - - // Unit direction vector - dx := (end.X - start.X) / l - dy := (end.Y - start.Y) / l - - // Point of the line closest to the center - t := dx*(g.center.X-start.X) + dy*(g.center.Y-start.Y) - px := t*dx + start.X - py := t*dy + start.Y - if px < start.X || px > end.X || py < start.Y || py > end.Y { - // closest point is outside the segment - return false - } - - // Distance from the closest point to the center - return g.containsPoint(geometry.Point{X: px, Y: py}) -} - // Intersects returns true the circle intersects other object func (g *Circle) Intersects(obj Object) bool { switch other := obj.(type) { @@ -160,13 +123,6 @@ func (g *Circle) Intersects(obj Object) bool { return g.containsPoint(other.Center()) case *Circle: return other.Distance(g) <= (other.meters + g.meters) - case *LineString: - for i := 0; i < other.base.NumSegments(); i++ { - if g.intersectsSegment(other.base.SegmentAt(i)) { - return true - } - } - return false case Collection: for _, p := range other.Children() { if g.Intersects(p) { @@ -174,6 +130,8 @@ func (g *Circle) Intersects(obj Object) bool { } } return false + case *Feature: + return g.Intersects(other.base) default: // No simple cases, so using polygon approximation. return g.getObject().Intersects(obj) diff --git a/vendor/github.com/tidwall/geojson/feature.go b/vendor/github.com/tidwall/geojson/feature.go index da5e405f..518127bc 100644 --- a/vendor/github.com/tidwall/geojson/feature.go +++ b/vendor/github.com/tidwall/geojson/feature.go @@ -110,7 +110,7 @@ func (g *Feature) Within(obj Object) bool { // Contains ... func (g *Feature) Contains(obj Object) bool { - return obj.Within(g.base) + return g.base.Within(obj) } // WithinRect ... @@ -135,7 +135,7 @@ func (g *Feature) WithinPoly(poly *geometry.Poly) bool { // Intersects ... func (g *Feature) Intersects(obj Object) bool { - return obj.Intersects(g.base) + return g.base.Intersects(obj) } // IntersectsPoint ... diff --git a/vendor/github.com/tidwall/geojson/point.go b/vendor/github.com/tidwall/geojson/point.go index 55c4a375..1776141c 100644 --- a/vendor/github.com/tidwall/geojson/point.go +++ b/vendor/github.com/tidwall/geojson/point.go @@ -165,7 +165,7 @@ func parseJSONPoint(keys *parseKeys, opts *ParseOptions) (Object, error) { } if extra == nil && opts.AllowSimplePoints { var g SimplePoint - g.base = base + g.Point = base o = &g } else { var g Point diff --git a/vendor/github.com/tidwall/geojson/simplepoint.go b/vendor/github.com/tidwall/geojson/simplepoint.go index 8cbb0dc8..c66b4b9e 100644 --- a/vendor/github.com/tidwall/geojson/simplepoint.go +++ b/vendor/github.com/tidwall/geojson/simplepoint.go @@ -4,12 +4,12 @@ import "github.com/tidwall/geojson/geometry" // SimplePoint ... type SimplePoint struct { - base geometry.Point + geometry.Point } -// NewSimplePoint ... +// NewSimplePoint returns a new SimplePoint object. func NewSimplePoint(point geometry.Point) *SimplePoint { - return &SimplePoint{base: point} + return &SimplePoint{Point: point} } // ForEach ... @@ -19,17 +19,17 @@ func (g *SimplePoint) ForEach(iter func(geom Object) bool) bool { // Empty ... func (g *SimplePoint) Empty() bool { - return g.base.Empty() + return g.Point.Empty() } // Valid ... func (g *SimplePoint) Valid() bool { - return g.base.Valid() + return g.Point.Valid() } // Rect ... func (g *SimplePoint) Rect() geometry.Rect { - return g.base.Rect() + return g.Point.Rect() } // Spatial ... @@ -39,18 +39,18 @@ func (g *SimplePoint) Spatial() Spatial { // Center ... func (g *SimplePoint) Center() geometry.Point { - return g.base + return g.Point } // Base ... func (g *SimplePoint) Base() geometry.Point { - return g.base + return g.Point } // AppendJSON ... func (g *SimplePoint) AppendJSON(dst []byte) []byte { dst = append(dst, `{"type":"Point","coordinates":`...) - dst = appendJSONPoint(dst, g.base, nil, 0) + dst = appendJSONPoint(dst, g.Point, nil, 0) dst = append(dst, '}') return dst } @@ -77,7 +77,7 @@ func (g *SimplePoint) Within(obj Object) bool { // Contains ... func (g *SimplePoint) Contains(obj Object) bool { - return obj.Spatial().WithinPoint(g.base) + return obj.Spatial().WithinPoint(g.Point) } // Intersects ... @@ -85,47 +85,47 @@ func (g *SimplePoint) Intersects(obj Object) bool { if obj, ok := obj.(*Circle); ok { return obj.Contains(g) } - return obj.Spatial().IntersectsPoint(g.base) + return obj.Spatial().IntersectsPoint(g.Point) } // WithinRect ... func (g *SimplePoint) WithinRect(rect geometry.Rect) bool { - return rect.ContainsPoint(g.base) + return rect.ContainsPoint(g.Point) } // WithinPoint ... func (g *SimplePoint) WithinPoint(point geometry.Point) bool { - return point.ContainsPoint(g.base) + return point.ContainsPoint(g.Point) } // WithinLine ... func (g *SimplePoint) WithinLine(line *geometry.Line) bool { - return line.ContainsPoint(g.base) + return line.ContainsPoint(g.Point) } // WithinPoly ... func (g *SimplePoint) WithinPoly(poly *geometry.Poly) bool { - return poly.ContainsPoint(g.base) + return poly.ContainsPoint(g.Point) } // IntersectsPoint ... func (g *SimplePoint) IntersectsPoint(point geometry.Point) bool { - return g.base.IntersectsPoint(point) + return g.Point.IntersectsPoint(point) } // IntersectsRect ... func (g *SimplePoint) IntersectsRect(rect geometry.Rect) bool { - return g.base.IntersectsRect(rect) + return g.Point.IntersectsRect(rect) } // IntersectsLine ... func (g *SimplePoint) IntersectsLine(line *geometry.Line) bool { - return g.base.IntersectsLine(line) + return g.Point.IntersectsLine(line) } // IntersectsPoly ... func (g *SimplePoint) IntersectsPoly(poly *geometry.Poly) bool { - return g.base.IntersectsPoly(poly) + return g.Point.IntersectsPoly(poly) } // NumPoints ... @@ -135,7 +135,7 @@ func (g *SimplePoint) NumPoints() int { // Distance ... func (g *SimplePoint) Distance(obj Object) float64 { - return obj.Spatial().DistancePoint(g.base) + return obj.Spatial().DistancePoint(g.Point) } // DistancePoint ... diff --git a/vendor/modules.txt b/vendor/modules.txt index 562e844a..198e6c86 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -81,7 +81,7 @@ github.com/tidwall/buntdb # github.com/tidwall/geoindex v1.1.0 github.com/tidwall/geoindex github.com/tidwall/geoindex/child -# github.com/tidwall/geojson v1.1.8 +# github.com/tidwall/geojson v1.1.10 github.com/tidwall/geojson github.com/tidwall/geojson/geo github.com/tidwall/geojson/geometry