Quantcast
Channel: Question and Answer » json
Viewing all articles
Browse latest Browse all 148

geojson coordinate conversion to the format of the data coming from PostgreSQL?

$
0
0

I use hibernate spatial and geotools

this is save to vector code :

if (vectorType.equalsIgnoreCase("Point")) {
        LineString point =new GeometryJSON().readPoint(item.getData());
        lineString.setSRID(3857);
        theEvent.setGeom1(lineString);
        theEvent.setVectorType(vectorType);
    }

after I want to read data from the database format geojson but I need to do the shortcut

I did the following code :

if(entity.getVectorType().trim().equalsIgnoreCase("Point"))
    {
        JSONObject point = new JSONObject();
        point.put("type", "Point");
        JSONArray coord = new JSONArray("["+entity.getGeom().getX()+","+entity.getGeom().getY()+"]");
        point.put("coordinates", coord);
        geoJson.setData(point.toString());                
    }

but I must do shortcut . how can I do. I think do with geotools. we can use FeatureJson but how ?

like this : {"coordinates":[31.253906786442,26.859375536442],"type":"Point"}

Do you any ideaa ?


Viewing all articles
Browse latest Browse all 148

Trending Articles