[postgis-users] Postgis Driver returning JtsGeometries

Kevin Neufeld kneufeld at refractions.net
Tue Mar 6 08:57:22 PST 2007


Yes. Available from PostGIS download page. 
(http://postgis.refractions.net/download/). (Although Markus Schaber, 
the author, warns to use at your own risk).

You could simply use JTS directly.
ie:

    WKBReader wkbReader = new WKBReader();
    Class.forName("org.postgresql.Driver");
    Connection c = DriverManager.getConnection("jdbc:postgresql://" +
    host + ":" + port, user, password);

    // This works
    ResultSet rs = c.createStatement().executeQuery("SELECT the_geom
    FROM my_spatial_table LIMIT 1");
    if (rs.next()) {
        Geometry g = wkbReader.read(WKBReader.hexToBytes(rs.getString(1)));
        System.out.println(g.toString());
    }

    // or alternatively
    rs = c.createStatement().executeQuery("SELECT asEWKB(the_geom) FROM
    cwb_edges LIMIT 1");
    if (rs.next()) {
        Geometry g = wkbReader.read(rs.getBytes(1));
        System.out.println(g.toString());
    }

Note: This is using JTS 1.8 and PostGIS 1.x

Cheers,
-- Kevin

Paul Austin wrote:
> Is there a JDBC driver for postgis that returns JTS Geometry objects 
> rather than PGgeometry objects?
>
> Cheers,
> Paul
> ------------------------------------------------------------------------
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>   



More information about the postgis-users mailing list