Export to GeoJson
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
L’esempio si trova in InitService, in particolare h3.polyfill(..., 3), h3ToGeoBoundary e getGeoJson; inizia controllando l’ordine delle coordinate e il poligono passato a polyfill rispetto alla convenzione delle coordinate di GeoJSON. Riproduci la FeatureCollection stampata e confronta i confini dei suoi esagoni con la recinzione fornita; il lavoro è completato quando i poligoni esportati corrispondono all’area prevista.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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();
}
}


- Lingua principale
- Java
- Stelle
- 333
- Fork
- 68
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di uber/h3-java
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
Tutte le issue di uber/h3-java
Issue simili
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Apertaarea/plugin
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
kestra-io/plugin-kestra#190 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
apache/rocketmq-dashboard#5064 ·