Geometery parsing GeoJSON
import org.apache.commons.lang3.ArrayUtils;
import com.google.gson.Gson;
public class Scratch {
public static void main(String[] args) throws Exception {
String json = "{" +
" \"geometry\": {" +
" \"type\": \"Polygon\"," +
" \"coordinates\": [" +
" [" +
" [-69.899139," +
" 12.452005" +
" ]," +
" [-69.895676," +
" 12.423015" +
" ]" +
" ]" +
" ]" +
" }" +
"}";
Geometry g = new Gson().fromJson(json, Geometry.class);
System.out.println(g);
// Geometry [geometry=GeometryData [type=Polygon, coordinates={{{-69.899139,12.452005},{-69.895676,12.423015}}}]]
}
}
class Geometry {
GeometryData geometry;
@Override
public String toString() {
return "Geometry [geometry=" + geometry + "]";
}
}
class GeometryData {
String type;
double[][][] coordinates;
@Override
public String toString() {
return "GeometryData [type=" + type + ", coordinates=" + ArrayUtils.toString(coordinates) + "]";
}
}
Also in JavaScript:
- chartjs random color line
- libuv nodejs
- discord js clear message from id
- how to run a js file in node
- how to get textedit on mac without download
- electron quit app from renderer
- js-cookie
- access to model from js
- react disable eslint errors
- using index of on array of objects
- Discord.js ban command
- array fill
- js combine two arrays
- javascript key pressed enter
- react html symbol code
- nativescript vue get native from ref
- instanceof javascript
- alternative for componentdidmount
- async await javascript
- how to compare elements in an array
- reactjs start project
- substring javascript
- jquery cheat sheet
- how to get value inside span using javascript