Search code examples
javageometrypostgis

Best data type to store long/lat JSON in postGis using Spring-boot 2


I'm new to PostGIS and I'm trying to store the below JSON into postGIS DB. Let me know the best data Type to use in Spring Boot and what are the dependencies that I need to use. The lat/long array is of varying length and is of different shape every time.

{
    Shape : POLYGON
    LatLong : [[lat1,long1], 
              [lat2,long2], 
              [lat3,long3], 
              [lat4,long4], 
              [lat5,long5]]
    Radius : NULL
}

Solution

  • You may employ ST_GeomFromGeoJSON(). But it will, probably, require you to play around with JSON attributes names. https://postgis.net/docs/ST_GeomFromGeoJSON.html