[postgis-users] Problem with Z coordinate using postgis-jts
Fernando González
fergonco at gmail.com
Wed Mar 5 03:51:37 PST 2008
Thank you for the answer. When I execute this code:
public static void main(String[] args) throws Throwable {
Class.forName("org.postgresql.Driver").newInstance();
String sql = "CREATE TABLE test (pk_0 int4 NOT NULL);";
sql += "select
AddGeometryColumn('test','the_geom','-1','GEOMETRY','2');";
sql += "insert into test "
+ "values(3, "
+ "GeomFromText('LINESTRING(191232 243118,191108
243242)',-1));";
Connection c = DriverManager
.getConnection("jdbc:postgresql://127.0.0.1/gdms/test",
"postgres", "postgres");
((PGConnection) c)
.addDataType("geometry", org.postgis.PGgeometry.class);
((PGConnection) c).addDataType("box3d", org.postgis.PGbox3d.class);
Statement st = c.createStatement();
try {
st.execute("drop table test");
} catch (SQLException e) {
}
st.execute(sql);
ResultSet rs = st.executeQuery("select * from test");
rs.next();
String geom = rs.getString(2);
JtsBinaryParser parser = new JtsBinaryParser();
Geometry g = parser.parse(geom);
Coordinate[] coords = g.getCoordinates();
for (Coordinate coordinate : coords) {
System.out.println(coordinate);
}
}
I obtain this output:
(191232.0, 243118.0, 0.0)
(191108.0, 243242.0, 0.0)
I think I should obtain
(191232.0, 243118.0, NaN)
(191108.0, 243242.0, NaN)
am I wrong?
Fernando.
On Wed, Mar 5, 2008 at 12:14 PM, Mark Cave-Ayland <
mark.cave-ayland at siriusit.co.uk> wrote:
> On Wednesday 05 March 2008 10:13:26 Fernando González wrote:
> > Hi,
> >
> > I'm storing and reading some geometries from a postgis table. The table
> is
> > 2D. I'm using a jar I have compiled with the "make postgis_jts" command.
> It
> > works very well except for one thing. I write 2D JTS geometries, this is
> > with the z component equal to NaN, into a postgis table but when I read
> > them the Z coordinate is no longer equal to NaN but equal to 0. is this
> a
> > feature? a bug?
> >
> > I'm using this code to read the geometry. To store them I use
> GeomFromText
> > function and I specify only X-Y components for each coordinate (I'm not
> > specifying the Z coordinate):
> >
> > JtsBinaryParser parser = new JtsBinaryParser();
> > String bytes = rs.getString(fieldId);
> > Geometry geom = parser.parse(bytes);
> >
> > is it clear? I can write some code to reproduce the problem if anyone is
> > interested.
> >
> > Thanks in advance,
> > Fernando
>
>
> Hi Fernando,
>
> Yes please. I may not be the person that eventually looks at this, however
> a
> reproducible test case is enormously helpful in cases like these.
>
>
> ATB,
>
> Mark.
>
> --
> Mark Cave-Ayland
> Sirius Corporation - The Open Source Experts
> http://www.siriusit.co.uk
> T: +44 870 608 0063
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080305/d91d5451/attachment.html>
More information about the postgis-users
mailing list