google / google/s2-geometry-library-java

Request for Guidance - Point in Polygon and S2

Đang mở
#5 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
587
Fork
231
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Would it be possible for the good folks here to please help me with a problem that I am trying to solve with the S2 geometry library? I am a complete novice, so please bear with me if I do not make sense.

**Problem**
I am trying to determine the best way to write an offline point-in-polygon check for the Android platform. Essentially, convert (lat,lng) to a country. In future, I plan to increase the granularity to regions, states, provinces, counties and cities/towns.

**Research**
My initial research landed me up on https://github.com/AReallyGoodName/OfflineReverseGeocode with http://download.geonames.org/export/dump/cities1000.zip. From what I understand, this is (lat,lng) to nearest neighbor. Now, I do get the country from this, but it relies on finding the nearest neighbor city with population, which may not be accurate.

Further research led me to S2. It is here that I am struggling, and request your guidance.

**Current Approach**
A) Computation at app startup:
1) Get geojson co-ordinates from http://download.geonames.org/export/dump/shapes_simplified_low.zip.
2) For each country,
i) Convert geojson co-ordinates into S2 LatLng and then S2 Loops.
ii) Build S2 Polygon using S2 Loops.
iii) If MultiPolygon, use S2PolygonBuilder.addPolygon() to add additional polygons.

B) LatLng input during app functioning:
1) Convert Lat Lng Input to S2Point.
2) Iterate over country polygons, checking for S2Polygon.contains(S2Point).
3) Return country.

**Questions**
1) Some geojson countries are "multipolygon", whereas there is no multipolygon in S2. Are S2 polygons equivalent to multipolygons from geojson?
2) Can the geojson to S2Polygon initial computation result be persisted, to avoid re-computation at app startup?
3) Geonames geojson input does not seem to conform to counter clockwise (CCW) convention. Would S2PolygonBuilder be able to tackle this correctly?
4) Is there a better way to search for point-in-polygon rather than iterating over each countries S2Polygons.contains function call? Does this mechanism also help avoid polygon re-computation?
5) Is there a better way to achieve the offline point-in-polygon check?
6) Is there a better (small, accurate) source for country boundaries for use with S2?

Thank you for your time.

@eengle @hagbard @kluever @cpovirk

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Không có tệp, bài kiểm thử hoặc điểm vào nào của repository được nêu tên. Hãy bắt đầu bằng việc xem xét các API S2Polygon, S2PolygonBuilder, S2Loop và S2Point được tham chiếu, sau đó làm rõ câu hỏi nào trong sáu câu hỏi về Android và point-in-polygon ngoại tuyến nên trở thành một thay đổi cụ thể trong repository; công việc được xem là hoàn tất khi phạm vi và các tiêu chí nghiệm thu đã được thống nhất.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
android, java
Lĩnh vực
computer-graphics, mobile-dev
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
15/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.