Skip to content

Commit fa50322

Browse files
author
Sreekanth Sivasankaran
committed
Include the polygon vertices for WithIn query
-Consider the polygon vertices for checking the containment for the points during a within filtering. -Move to PolygonFromOrientedLoops s2 api.
1 parent 4ff549e commit fa50322

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

geojson/geojson_s2_util.go

Lines changed: 1 addition & 1 deletion
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

Lines changed: 10 additions & 0 deletions
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)