Search code examples
javapostgresqlpostgissqlgeography

org.postgresql.util.PGobject to org.postgis.Point;


Do you know how can convert the type of PGobject to Point in Java? Actually PGobject is an object like this: PGobject geolocation:

type: geography
value: 0101000020E6100000C006335CD3043840504BBDB89EC14140

How can convert this number into Point?


Solution

  • My solution is below and it works fine, but I think that your solution is better

    String g = geolocation.getValue();
    try {
        Geometry fr = new PGgeometry().geomFromString(g);
        Point p = fr.getPoint(0);
        this.geolocation = p;
    } catch (SQLException e) {
        e.printStackTrace();
    }