[postgis-users] Hibernate Spatial Postgis 3D

Drew Sheedy drew at olvec.net
Wed May 7 16:54:53 PDT 2008


Hi Max,

What is your schema? Is hibernate creating it for you or are you creating it
for hibernate?

And if that is the WKTReader from VividSolutions, then you'll notice at:
http://www.vividsolutions.com/JTS/JTSHome.htm that the API only handles 2D.

HTH

Drew

On Thu, May 8, 2008 at 1:04 AM, Max <postgis at lists.meisel.cn> wrote:

> Hello,
>
> first i want to thank Karel for the great hibernate-spatial extension.
> Using this extension saves a lot of time.
>
> These days i got the new sources from the svn, because i saw that Karel
> was implementing the 3D stuff for the postgis-provider. So far so good.
>
> After compiling and using the new provider i found out, that it doesnt
> work for me, so maybe someone can help me to solve the problem. Writing
> a 3D point to the postgis-db still returns a 2D point, so i dont know
> whats wrong.
>
> My files are looking like this (parts - taken from hibernate spatial
> example)):
>
> ----------------------------
> ...hmb.xml
>
>        <property name="theGeom"
> type="org.hibernatespatial.GeometryUserType">
>            <column name="the_geom" />
>        </property>
>
> ----------------------------
> Class File
>
> import com.vividsolutions.jts.geom.Point;
> ...
>        public class Grd
>
>        private Point   theGeom;
>
>        public Point getTheGeom() {
>                return this.theGeom;
>        }
>
>        public void setTheGeom(Point theGeom) {
>                this.theGeom = theGeom;
>        }
> -------------------------------
>
> hibernateTest.java
>
>
>                hibernateTest hbTest = new hibernateTest();
>
>                hbTest.createAndStoreEvent("POINT(12 14 15)");
>
>                HibernateUtil.getSessionFactory().close();
>
>                .........
>
>        private void createAndStoreEvent(String wktPoint) {
>
>                // First interpret the WKT string to a point
>                WKTReader fromText = new WKTReader();
>                Geometry geom = null;
>                try {
>                        geom = fromText.read(wktPoint);
>                }
>                catch (ParseException e) {
>                        throw new RuntimeException("Not a WKT string:" +
> wktPoint);
>                }
>                if (!geom.getGeometryType().equals("Point")) {
>                        throw new RuntimeException("Geometry must be a
> point. Got a " + geom.getGeometryType());
>                }
>
>                Session session =
> HibernateUtil.getSessionFactory().getCurrentSession();
>
>                session.beginTransaction();
>
>                Grd theGrd = new Grd();
>                Point p = (Point) geom;
>
>        // at this point there is an Z-Coordinate ///
>                System.out.println(p.getCoordinate().z);
>
>                theGrd.setTheGeom(p);
>
>                session.save(theGrd);
>
>                session.getTransaction().commit();
>
>                HibernateUtil.getSessionFactory().close();
> --------------------------
>
> After reading the Point from the DB using:
>
>        private List<Grd> findAll() {
>                Session session =
>                HibernateUtil.getSessionFactory().getCurrentSession();
>                session.beginTransaction();
>                Criteria testCriteria =
> session.createCriteria(Dgm050Grd.class);
>                List<Dgm050Grd> results = testCriteria.list();
>                session.getTransaction().commit();
>                return results;
>
> // the Point has not Z-Coordinate, its just NaN
>
> So whats wrong? I know to appreciate your hekp
>
>
> best regards
>
> Steffen
>
> _______________________________________________
> 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/20080508/922d6185/attachment.html>


More information about the postgis-users mailing list