Skip to content

Commit 1e74e8d

Browse files
authored
Merge pull request #3 from blevesearch/polygon_hole_fix
Include the polygon vertices for WithIn query
2 parents 4ff549e + fa50322 commit 1e74e8d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

geojson/geojson_s2_util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func s2PolygonFromCoordinates(coordinates [][][]float64) *s2.Polygon {
185185
loops = append(loops, s2loop)
186186
}
187187

188-
rv := s2.PolygonFromLoops(loops)
188+
rv := s2.PolygonFromOrientedLoops(loops)
189189
return rv
190190
}
191191

geojson/geojson_shapes_impl.go

+10
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,16 @@ func checkMultiPolygonContainsShape(s2pgns []*s2.Polygon,
12701270
if s2pgn.ContainsPoint(*point) {
12711271
pointsWithIn[pointIndex] = struct{}{}
12721272
continue nextPoint
1273+
} else {
1274+
// double check for containment with the vertices.
1275+
for _, loop := range s2pgn.Loops() {
1276+
for i := 0; i < loop.NumVertices(); i++ {
1277+
if point.ApproxEqual(loop.Vertex(i)) {
1278+
pointsWithIn[pointIndex] = struct{}{}
1279+
continue nextPoint
1280+
}
1281+
}
1282+
}
12731283
}
12741284
}
12751285
}

0 commit comments

Comments
 (0)