linestring nearby search correction, fixes #43
This commit is contained in:
parent
70556ec375
commit
9ab35d91f8
@ -109,11 +109,11 @@ func (g LineString) Within(o Object) bool {
|
|||||||
func (g LineString) Intersects(o Object) bool {
|
func (g LineString) Intersects(o Object) bool {
|
||||||
return intersectsObjectShared(g, o,
|
return intersectsObjectShared(g, o,
|
||||||
func(v Polygon) bool {
|
func(v Polygon) bool {
|
||||||
return polyPositions(g.Coordinates).Intersects(polyExteriorHoles(v.Coordinates))
|
return polyPositions(g.Coordinates).LineStringIntersects(polyExteriorHoles(v.Coordinates))
|
||||||
},
|
},
|
||||||
func(v MultiPolygon) bool {
|
func(v MultiPolygon) bool {
|
||||||
for _, c := range v.Coordinates {
|
for _, c := range v.Coordinates {
|
||||||
if polyPositions(g.Coordinates).Intersects(polyExteriorHoles(c)) {
|
if polyPositions(g.Coordinates).LineStringIntersects(polyExteriorHoles(c)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,12 @@ func (p Point) Intersects(exterior Polygon, holes []Polygon) bool {
|
|||||||
|
|
||||||
// Intersects detects if a polygon intersects another polygon
|
// Intersects detects if a polygon intersects another polygon
|
||||||
func (shape Polygon) Intersects(exterior Polygon, holes []Polygon) bool {
|
func (shape Polygon) Intersects(exterior Polygon, holes []Polygon) bool {
|
||||||
|
return shape.doesIntersects(false, exterior, holes)
|
||||||
|
}
|
||||||
|
func (shape Polygon) LineStringIntersects(exterior Polygon, holes []Polygon) bool {
|
||||||
|
return shape.doesIntersects(true, exterior, holes)
|
||||||
|
}
|
||||||
|
func (shape Polygon) doesIntersects(isLineString bool, exterior Polygon, holes []Polygon) bool {
|
||||||
switch len(shape) {
|
switch len(shape) {
|
||||||
case 0:
|
case 0:
|
||||||
return false
|
return false
|
||||||
@ -30,7 +36,6 @@ func (shape Polygon) Intersects(exterior Polygon, holes []Polygon) bool {
|
|||||||
if !shape.Rect().IntersectsRect(exterior.Rect()) {
|
if !shape.Rect().IntersectsRect(exterior.Rect()) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(shape); i++ {
|
for i := 0; i < len(shape); i++ {
|
||||||
for j := 0; j < len(exterior); j++ {
|
for j := 0; j < len(exterior); j++ {
|
||||||
if lineintersects(
|
if lineintersects(
|
||||||
@ -49,10 +54,11 @@ func (shape Polygon) Intersects(exterior Polygon, holes []Polygon) bool {
|
|||||||
if shape.Inside(exterior, nil) {
|
if shape.Inside(exterior, nil) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if exterior.Inside(shape, nil) {
|
if !isLineString {
|
||||||
return true
|
if exterior.Inside(shape, nil) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user