Export to GeoJson
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Ví dụ nằm trong InitService, đặc biệt là h3.polyfill(..., 3), h3ToGeoBoundary và getGeoJson; trước tiên hãy kiểm tra thứ tự tọa độ và polygon được truyền vào polyfill theo quy ước tọa độ GeoJSON. Tái hiện FeatureCollection được in ra và so sánh các ranh giới lục giác của nó với hàng rào được cung cấp; hoàn tất khi các polygon được export khớp với khu vực dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
You will need
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
I still getting some strange results like the image in the end where I show the resulting hexagons covers a much bigger area than my fence.
package br.com.cmabreu.hexagon.services;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Service;
import com.uber.h3core.H3Core;
import com.uber.h3core.util.GeoCoord;
@Service
public class InitService {
private H3Core h3;
@PostConstruct
public void onInit() {
try {
List<GeoCoord> fence = new ArrayList<GeoCoord>();
fence.add( new GeoCoord(-19.487, -46.747) );
fence.add( new GeoCoord(-19.487, -35.585) );
fence.add( new GeoCoord(-25.275, -35.585) );
fence.add( new GeoCoord(-25.275, -46.747) );
h3 = H3Core.newInstance();
List<Long> hexagons = h3.polyfill(fence, null, 3);
System.out.println( getGeoJson( hexagons ) );
} catch (IOException e) {
e.printStackTrace();
}
}
private JSONObject getGeometry( List<GeoCoord> coordinates ) {
JSONObject geometry = new JSONObject();
JSONArray wrapper = new JSONArray();
JSONArray coords = new JSONArray();
for( int x=0; x < coordinates.size(); x++ ) {
JSONArray coord = new JSONArray();
coord.put(0, coordinates.get(x).lng );
coord.put(1, coordinates.get(x).lat );
wrapper.put( x, coord );
}
// Close the polygon last = first
JSONArray coord = new JSONArray();
coord.put(0, coordinates.get(0).lng );
coord.put(1, coordinates.get(0).lat );
wrapper.put( coordinates.size(), coord );
coords.put( wrapper );
geometry.put("type", "Polygon");
geometry.put("coordinates", coords);
return geometry;
}
private JSONObject getFeature( List<GeoCoord> coordinates ) {
JSONObject feature = new JSONObject();
feature.put("type", "Feature");
feature.put("properties", getProperties() );
feature.put("geometry", getGeometry( coordinates ) );
return feature;
}
private JSONObject getProperties() {
JSONObject properties = new JSONObject();
properties.put("prop01", "value01");
return properties;
}
private String getGeoJson( List<Long> hexagons ) {
JSONObject featureCollection = new JSONObject();
featureCollection.put("type", "FeatureCollection");
JSONArray features = new JSONArray();
for( Long cell : hexagons ) {
features.put( getFeature( h3.h3ToGeoBoundary(cell) ) );
}
featureCollection.put("features", features);
return featureCollection.toString();
}
}


- Ngôn ngữ chính
- Java
- Star
- 333
- Fork
- 68
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của uber/h3-java
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
elastic/gradle-plugins#157 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
cryptomator/hub#497 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
johanhaleby/occurrent#1120 ·