0

I woudlike to store in my database :

example data :

ST_GeomFromGML('
        <gml:LineString srsName="EPSG:4269">
            <gml:coordinates>
                -71.16028,42.258729 -71.160837,42.259112 -71.161143,42.25932
            </gml:coordinates>
        </gml:LineString>');

I made an API with 2 parameters in entry (String id and Geometry shape) :

{
  "id": "string",
  "shape": {
    "envelope": {},
    "factory": {
      "coordinateSequenceFactory": {},
      "precisionModel": {
        "scale": 0
      }
    },
    "srid": 0,
    "userData": {}
  }
}

My model :

Entity
@Table(name = "test", schema = "aaa")
public class rectangle {

    @Id
    @Column(name = "id", length = 32)
    private String id;

    @Column(name = "shape")
    private Geometry shape;

    public rectangle() {
    }

    public rectangle(String id, Geometry shape) {
        this.id = id;
        this.shape = shape;
    }

How can I parse my example date to my database ?

Docs found about st_GeomFromGml :

https://postgis.net/docs/ST_GeomFromGML.html

sticky bit
  • 36,626
  • 12
  • 31
  • 42
crashoulol
  • 19
  • 1
  • 6
  • 1
    How is this related to the Game Maker Language? Read a tags description when you add it and make sure it is about what you actually mean... I removed the [tag:gml] tag and replaced it for [tag:gml-geographic-markup-lan] which you presumably meant. – sticky bit Jan 31 '21 at 18:34

1 Answers1

0

There's a hibernate dialect for this case called org.hibernate.spatial.dialect.postgis.PostgisDialect

This is capable of loading and storing geometries directly with JPA to the Postgres DB with PostGis.

At http://www.hibernatespatial.org/documentation/02-Tutorial/01-tutorial4/ you find a tutorial for working with it.