Return all polylines within a Region

Skip to first unread message

Rikesh agarwal

Aug 1, 2020, 5:15:30 PM8/1/20
to s2geometry-io
Problem Statement:- I have defined an S2Region, and I want to return all the polylines within that Region upon querying. 

I am aware of the RegionCoveror algorithm that returns a set of S2Cell IDs within a Region.

rect := s2.RectFromLatLng(s2.LatLngFromDegrees(48.99, 1.852))

rect = rect.AddPoint(s2.LatLngFromDegrees(48.68, 2.75))

rc := &s2.RegionCoverer{MaxLevel: 20, MaxCells: 8}

r := s2.Region(rect.CapBound())

covering := rc.Covering(r)

for _, c := range covering {



In the above logic, it's calling pointsInCellID(c)which returns all the points within that Cell. How can I extend this logic to return the Polylines within the Cell? In other words, I wish to define a  polyLinesInCellID(c)instead of 
pointsInCellID(c).I am assuming I will need to create a polyline Index in-memory. 

Also, is this the best way to approach my problem Statement? Or should I avoid using the RegionCoveror algorithm and look for other solutions within S2 library? 
Which Indexing is best for my use case: A polyline Index or S2RegionTermIndexer or S2ShapeIndex or something else? 
Reply all
Reply to author
0 new messages