Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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) + "]";
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to make a quiz in javascript 
Javascript :: js array modify element 
Javascript :: node js file extension 
Javascript :: react autocomplete 
Javascript :: angular emit 
Javascript :: display none after hover 
Javascript :: html form action javascript method 
Javascript :: javascript function destructuring 
Javascript :: js access array value if exist 
Javascript :: working with multiple db in single query mongodb 
Javascript :: how to wait for function to finish in JS 
Javascript :: asyncio.sleep in javascript 
Javascript :: react admin 
Javascript :: ex:js 
Javascript :: sweetalret 
Javascript :: pure component in react 
Javascript :: open source 
Javascript :: express middleware status code always 200 
Javascript :: Everything Be True 
Javascript :: tooltip in javasrript UI 
Javascript :: javascript nested objects 
Javascript :: MERN stack implementing Sign in with Google. 
Javascript :: relative path vs absolute path javascript 
Javascript :: google-maps-react give undefined lat long 
Javascript :: js.l26 
Javascript :: samuel 
Javascript :: org.json.JSONException: Value null of type org.json.JSONObject$1 cannot be converted to JSONObject 
Javascript :: how er create json data file to train our rasa model 
Javascript :: laravel pass collection to javascript 
Javascript :: detecter un click sur un bouton en jquery 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =