mirror of https://github.com/tidwall/tile38.git
Fixes a false negative for intersecting rings
https://github.com/tidwall/geojson/commit/ac08098
This commit is contained in:
parent
644f65c7d9
commit
6f3716a0cf
2
go.mod
2
go.mod
|
@ -28,7 +28,7 @@ require (
|
||||||
github.com/tidwall/buntdb v1.1.0
|
github.com/tidwall/buntdb v1.1.0
|
||||||
github.com/tidwall/cities v0.0.0-20190730194520-dbe1ae0b862c // indirect
|
github.com/tidwall/cities v0.0.0-20190730194520-dbe1ae0b862c // indirect
|
||||||
github.com/tidwall/geoindex v1.1.0
|
github.com/tidwall/geoindex v1.1.0
|
||||||
github.com/tidwall/geojson v1.1.7
|
github.com/tidwall/geojson v1.1.8
|
||||||
github.com/tidwall/gjson v1.3.2
|
github.com/tidwall/gjson v1.3.2
|
||||||
github.com/tidwall/grect v0.0.0-20161006141115-ba9a043346eb // indirect
|
github.com/tidwall/grect v0.0.0-20161006141115-ba9a043346eb // indirect
|
||||||
github.com/tidwall/lotsa v0.0.0-20180225195211-a03631ac7f1c // indirect
|
github.com/tidwall/lotsa v0.0.0-20180225195211-a03631ac7f1c // indirect
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -59,8 +59,8 @@ github.com/tidwall/cities v0.0.0-20190730194520-dbe1ae0b862c h1:K/6v4woP8qym96ZK
|
||||||
github.com/tidwall/cities v0.0.0-20190730194520-dbe1ae0b862c/go.mod h1:lV/HDp2gCcRcHJWqgt6Di54GiDrTZwh1aG2ZUPNbqa4=
|
github.com/tidwall/cities v0.0.0-20190730194520-dbe1ae0b862c/go.mod h1:lV/HDp2gCcRcHJWqgt6Di54GiDrTZwh1aG2ZUPNbqa4=
|
||||||
github.com/tidwall/geoindex v1.1.0 h1:d/pGCgKUonfQINd1235kKqx9gWBU4N7GjDS9WvbPvLY=
|
github.com/tidwall/geoindex v1.1.0 h1:d/pGCgKUonfQINd1235kKqx9gWBU4N7GjDS9WvbPvLY=
|
||||||
github.com/tidwall/geoindex v1.1.0/go.mod h1:3gTa91BW+eiVIipuR6aU1Y9Sa0q75b1teE/NP2vfsTc=
|
github.com/tidwall/geoindex v1.1.0/go.mod h1:3gTa91BW+eiVIipuR6aU1Y9Sa0q75b1teE/NP2vfsTc=
|
||||||
github.com/tidwall/geojson v1.1.7 h1:uNeIRbzYzGpFw88CLajyrN3d0To5GcMW5YJSmPqkhH0=
|
github.com/tidwall/geojson v1.1.8 h1:n/WT/PG0OEHrxUJQoeqkupWDt3pwbHMynl6OF9xKIM0=
|
||||||
github.com/tidwall/geojson v1.1.7/go.mod h1:tBjfxeALRFLc25LLpjtWzy2nIrNmW1ze1EAhLtd8+QQ=
|
github.com/tidwall/geojson v1.1.8/go.mod h1:tBjfxeALRFLc25LLpjtWzy2nIrNmW1ze1EAhLtd8+QQ=
|
||||||
github.com/tidwall/gjson v1.3.2 h1:+7p3qQFaH3fOMXAJSrdZwGKcOO/lYdGS0HqGhPqDdTI=
|
github.com/tidwall/gjson v1.3.2 h1:+7p3qQFaH3fOMXAJSrdZwGKcOO/lYdGS0HqGhPqDdTI=
|
||||||
github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
|
github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
|
||||||
github.com/tidwall/grect v0.0.0-20161006141115-ba9a043346eb h1:5NSYaAdrnblKByzd7XByQEJVT8+9v0W/tIY0Oo4OwrE=
|
github.com/tidwall/grect v0.0.0-20161006141115-ba9a043346eb h1:5NSYaAdrnblKByzd7XByQEJVT8+9v0W/tIY0Oo4OwrE=
|
||||||
|
|
|
@ -30,8 +30,11 @@ core/gen.sh
|
||||||
# Set final Go environment options
|
# Set final Go environment options
|
||||||
LDFLAGS="$LDFLAGS -extldflags '-static'"
|
LDFLAGS="$LDFLAGS -extldflags '-static'"
|
||||||
export CGO_ENABLED=0
|
export CGO_ENABLED=0
|
||||||
export GO111MODULE=on
|
|
||||||
export GOFLAGS=-mod=vendor
|
if [ "$NOMODULES" != "1" ]; then
|
||||||
|
export GO111MODULE=on
|
||||||
|
export GOFLAGS=-mod=vendor
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and store objects into original directory.
|
# Build and store objects into original directory.
|
||||||
go build -ldflags "$LDFLAGS" -o $1 cmd/$1/*.go
|
go build -ldflags "$LDFLAGS" -o $1 cmd/$1/*.go
|
||||||
|
|
|
@ -4,8 +4,11 @@ set -e
|
||||||
cd $(dirname "${BASH_SOURCE[0]}")/..
|
cd $(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
export CGO_ENABLED=0
|
export CGO_ENABLED=0
|
||||||
export GO111MODULE=on
|
|
||||||
export GOFLAGS=-mod=vendor
|
if [ "$NOMODULES" != "1" ]; then
|
||||||
|
export GO111MODULE=on
|
||||||
|
export GOFLAGS=-mod=vendor
|
||||||
|
fi
|
||||||
|
|
||||||
cd tests && go test && cd ..
|
cd tests && go test && cd ..
|
||||||
go test $(go list ./... | grep -v /vendor/ | grep -v /tests)
|
go test $(go list ./... | grep -v /vendor/ | grep -v /tests)
|
||||||
|
|
|
@ -216,6 +216,11 @@ func (g *Circle) Spatial() Spatial {
|
||||||
return g.getObject().Spatial()
|
return g.getObject().Spatial()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Primative returns a primative GeoJSON object. Either a Polygon or Point.
|
||||||
|
func (g *Circle) Primative() Object {
|
||||||
|
return g.getObject()
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Circle) getObject() Object {
|
func (g *Circle) getObject() Object {
|
||||||
if g.object != nil {
|
if g.object != nil {
|
||||||
return g.object
|
return g.object
|
||||||
|
|
|
@ -31,11 +31,7 @@ func Haversine(latA, lonA, latB, lonB float64) float64 {
|
||||||
|
|
||||||
// NormalizeDistance ...
|
// NormalizeDistance ...
|
||||||
func NormalizeDistance(meters float64) float64 {
|
func NormalizeDistance(meters float64) float64 {
|
||||||
m1 := math.Mod(meters, twoPiR)
|
return math.Mod(meters, twoPiR)
|
||||||
if m1 <= piR {
|
|
||||||
return m1
|
|
||||||
}
|
|
||||||
return twoPiR - m1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DistanceToHaversine ...
|
// DistanceToHaversine ...
|
||||||
|
|
|
@ -301,23 +301,11 @@ func ringIntersectsRing(ring, other Ring, allowOnEdge bool) bool {
|
||||||
// swap the rings so that the inner ring is smaller than the outer ring
|
// swap the rings so that the inner ring is smaller than the outer ring
|
||||||
ring, other = other, ring
|
ring, other = other, ring
|
||||||
}
|
}
|
||||||
if ring.Convex() && allowOnEdge {
|
|
||||||
// outer ring is convex so test that any inner points are inside of
|
otherNumSegments := other.NumSegments()
|
||||||
// the outer ring
|
for i := 0; i < otherNumSegments; i++ {
|
||||||
otherNumPoints := other.NumPoints()
|
if ringIntersectsSegment(ring, other.SegmentAt(i), allowOnEdge) {
|
||||||
for i := 0; i < otherNumPoints; i++ {
|
return true
|
||||||
if ringContainsPoint(ring, other.PointAt(i), allowOnEdge).hit {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// outer ring is concave so let's make sure that all inner segments are
|
|
||||||
// fully contained inside of the outer ring.
|
|
||||||
otherNumSegments := other.NumSegments()
|
|
||||||
for i := 0; i < otherNumSegments; i++ {
|
|
||||||
if ringIntersectsSegment(ring, other.SegmentAt(i), allowOnEdge) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -81,7 +81,7 @@ github.com/tidwall/buntdb
|
||||||
# github.com/tidwall/geoindex v1.1.0
|
# github.com/tidwall/geoindex v1.1.0
|
||||||
github.com/tidwall/geoindex
|
github.com/tidwall/geoindex
|
||||||
github.com/tidwall/geoindex/child
|
github.com/tidwall/geoindex/child
|
||||||
# github.com/tidwall/geojson v1.1.7
|
# github.com/tidwall/geojson v1.1.8
|
||||||
github.com/tidwall/geojson
|
github.com/tidwall/geojson
|
||||||
github.com/tidwall/geojson/geo
|
github.com/tidwall/geojson/geo
|
||||||
github.com/tidwall/geojson/geometry
|
github.com/tidwall/geojson/geometry
|
||||||
|
|
Loading…
Reference in New Issue