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?
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?
Do you mean a jts Point?
If yes so use WkbReader, because your geometry is in well-know-binary format:
import com.vividsolutions.jts.io.WKBReader;
WKBReader wkbReader = new WKBReader();
byte[] geom = wkbReader.hexToBytes('0101000020E6100000C006335CD3043840504BBDB89EC14140');
System.out.println(wkbReader.read(geom));
// prints POINT (24.01885010000001 35.5126563)
The result is of type com.vividsolutions.jts.geom.Point
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();
}