Re: [postgis-users] Can save but not retrieve using Hibernate+PostGIS+JTS
Hi Have you checked in the postgres database logs? There might be a clue in there as to why it is not working El Thursday 26 August 2010, Paulo Angelo escribió: Hi Ppl, I'm getting a weird problem. I can save a Geometry type through Hibernate but I can't retrieve it. WKTReader fromText = new WKTReader(); Geometry geom = fromText.read(POLYGON((0 0,0 3,3 3,3 0,0 0))); Session session = dao.newSession(); Transaction tx = dao.beginTransaction(session); Query q = session.createQuery(select f from Geometries f); List list = q.list(); Poligono to = (Poligono) lista.get(0); dao.commitTransaction(session, tx); to.setPoli(geom); System.out.println(to.getPoli().toString()); // Apears POLYGON ((0 0, 0 3, 3 3, 3 0, 0 0)) dao.alterar(to, null, null); // I can see via SQL that it saves correctly And have you checked that it appears in the database after the commit? Maybe the commit is not really commited (can't see why, though). // Now, retrieve session = dao.newSession(); tx = dao.beginTransaction(session); q = session.createQuery(select f from Geometries f); list = q.list(); to = (Poligono) lista.get(0); dao.commitTransaction(session, tx); System.out.println(to.getPoli().toString()); // Get a *NullPointerException*, because to.getPoli() is null Have you tried debugging step by step checking that all variables are ok? Are you sure that to is not null instead of to.getPoli()? Have you tried using Criteria instead of hql? Maybe it is a conversion problem between geometry types. Could it be that closing/commiting the transaction is the problem? If hibernate didn't get all the data on one shot, closing the transaction makes hibernate unable to get more info from the database. Anyway, if you rollback a read-only transaction instead committing, hibernate goes faster. -- María Arias de Reyna Domínguez Área de Operaciones Emergya Consultoría Tfno: +34 954 51 75 77 / +34 607 43 74 27 Fax: +34 954 51 64 73 www.emergya.es ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users -- Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Pinan Software ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Difference polygon sets
Sory, the previous post was not to this list. 2010/8/27 Espen Isaksen espen.isak...@gmail.com Hi! I have a set of polygons where I have dissolved some of the polygons. So I get two sets of polygons where one set is my original data, and the other set is new polygons from the dissolve operations. Now I want to extract the remaining polygons from my original dataset which were not dissolved. I tried just a simple st_difference, but from what I understand this operation does now work on sets of polygons. Both datasets can be found here in shape format: http://dl.dropbox.com/u/8829/postgis.zip How can I extract only the remaining polygons from the original dataset. I had a look at this post(http://www.postgis.org/pipermail/postgis-users/2008-May/019511.html) in the mailing list, but I did not succeed in changing it to fit my purpose. Can anybody help me out? Kind regards, Espen Isaksen ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] pgsql2shp fails
Hello, Regina. There is information about my system: 1) RCSID: $Id: pgsql2shp-core.h 5646 2010-05-27 13:19:12Z pramsey $ RELEASE: 2.0 USE_GEOS=1 USE_PROJ=1 USE_STATS=1 2) pgsql2shp -f $dir_output/bounds/bnd-a-osm-buf.shp -U pgsql -d osm public.results 3) PostgreSQL 8.4 4) 2.0 r5830 5) FreeBSD 8.1 I get the following error: Error executing main scan query: ERROR: column gid does not exist LINE 1: ... -1), 'NDR') AS _geoX FROM public.results ORDER BY gid ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] pgsql2shp fails
Denis Rykov wrote: Hello, Regina. There is information about my system: 1) RCSID: $Id: pgsql2shp-core.h 5646 2010-05-27 13:19:12Z pramsey $ RELEASE: 2.0 USE_GEOS=1 USE_PROJ=1 USE_STATS=1 2) pgsql2shp -f $dir_output/bounds/bnd-a-osm-buf.shp -U pgsql -d osm public.results 3) PostgreSQL 8.4 4) 2.0 r5830 5) FreeBSD 8.1 I get the following error: Error executing main scan query: ERROR: column gid does not exist LINE 1: ... -1), 'NDR') AS _geoX FROM public.results ORDER BY gid That's probably my bug (although the other apparent bug is that I forgot to set the svn id property on pgsql2shp-core.h too). What does the output of \d public.results look like in psql? ATB, Mark. -- Mark Cave-Ayland - Senior Technical Architect PostgreSQL - PostGIS Sirius Corporation plc - control through freedom http://www.siriusit.co.uk t: +44 870 608 0063 Sirius Labs: http://www.siriusit.co.uk/labs ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
[postgis-users] [SOLVED] Can save but not retrieve using Hibernate+PostGIS+JTS
Hi Ppl.. Finally I found the problem. I put some breakpoints at AbstractDBGeometryType and realized that there were a postgresql-jdbc3.jar hidden in a JBoss lib folder, which is in classpath. I just removed the postgresql-jdbc3.jar and now is running... Thank you for help. Att, Paulo Angelo On Fri, Aug 27, 2010 at 3:46 AM, Maria Arias de Reyna mar...@emergya.es wrote: El Thursday 26 August 2010, Paulo Angelo escribió: Hi Ppl, I'm getting a weird problem. I can save a Geometry type through Hibernate but I can't retrieve it. WKTReader fromText = new WKTReader(); Geometry geom = fromText.read(POLYGON((0 0,0 3,3 3,3 0,0 0))); Session session = dao.newSession(); Transaction tx = dao.beginTransaction(session); Query q = session.createQuery(select f from Geometries f); List list = q.list(); Poligono to = (Poligono) lista.get(0); dao.commitTransaction(session, tx); to.setPoli(geom); System.out.println(to.getPoli().toString()); // Apears POLYGON ((0 0, 0 3, 3 3, 3 0, 0 0)) dao.alterar(to, null, null); // I can see via SQL that it saves correctly And have you checked that it appears in the database after the commit? Maybe the commit is not really commited (can't see why, though). // Now, retrieve session = dao.newSession(); tx = dao.beginTransaction(session); q = session.createQuery(select f from Geometries f); list = q.list(); to = (Poligono) lista.get(0); dao.commitTransaction(session, tx); System.out.println(to.getPoli().toString()); // Get a *NullPointerException*, because to.getPoli() is null Have you tried debugging step by step checking that all variables are ok? Are you sure that to is not null instead of to.getPoli()? Have you tried using Criteria instead of hql? Maybe it is a conversion problem between geometry types. Could it be that closing/commiting the transaction is the problem? If hibernate didn't get all the data on one shot, closing the transaction makes hibernate unable to get more info from the database. Anyway, if you rollback a read-only transaction instead committing, hibernate goes faster. -- María Arias de Reyna Domínguez Área de Operaciones Emergya Consultoría Tfno: +34 954 51 75 77 / +34 607 43 74 27 Fax: +34 954 51 64 73 www.emergya.es ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
[postgis-users] ST_Intersection problems
After I could not make ST_Difference with water bodies work, (as I documented in a previous thread http://postgis.refractions.net/pipermail/postgis-users/2010-August/027569.html ), I thought I would try ST_Intersection with a single multipolygon of the whole land area that I wanted to keep. So, what I have is a lot of multipolygons in one file that are adjacent to each other, but some of them extend out into water bodies (ca_ea_dbf), and another file with a single multipolygon with all the land I want to keep, i.e. it has a smaller outside footprint as well as holes within it for lakes (ca_dcf). When I did the following: INSERT INTO y1991.ca_ea_dbf_clp (eauid, pruid, the_geom_4269) (SELECT ea.eauid, ea.pruid, ST_MULTI(ST_INTERSECTION(ea.the_geom_4269, ca.the_geom_4269)) FROM y1991.ca_ea_dbf ea JOIN y1991.ca_dcf ca ON ST_INTERSECTS(ea.the_geom_4269, ca.the_geom_4269); I got the following error: ERROR: new row for relation ca_ea_dbf_clp violates check constraint enforce_geotype_the_geom_4269 So, then I ran the following to check the type of geometries: SELECT distinct(st_geometrytype(ST_MULTI(ST_INTERSECTION(ea.the_geom_4269, ca.the_geom_4269 FROM y1991.ca_ea_dbf ea JOIN y1991.ca_dcf ca ON ea.pruid = '35' AND ST_INTERSECTS(ea.the_geom_4269, ca.the_geom_4269); and found that there were both st_multipolygon and st_geometry types. The geometry field, the_geom_4269, was entered as being a multipolygon. So, then I used the following, thinking that maybe there were only a few rows that were not multipolygons: INSERT INTO y1991.ca_ea_dbf_clp (eauid, pruid, the_geom_4269) (SELECT ea.eauid, ea.pruid, ST_MULTI(ST_INTERSECTION(ea.the_geom_4269, ca.the_geom_4269)) FROM y1991.ca_ea_dbf ea JOIN y1991.ca_dcf ca ON ST_INTERSECTS(ea.the_geom_4269, ca.the_geom_4269) AND ST_GEOMETRYTYPE(ST_INTERSECTION(ea.the_geom_4269, ca.the_geom_4269)) = ST_GEOMETRYTYPE(ea.the_geom_4269)); It returned successfully, but there were only 282 of the original 45996 multipolygons in the ca_ea_dbf returned, even though all the missing ones would intersect with the one multipolygon in the clipping file. You can see pictures of the files at: http://web.ncf.ca/do841/GIS/index.html Thanks in advance for any tips you can give me on this ST_Intersection problem (or the previous ST_Difference one). I am at a loss for what to try next. Could it be that the files are too big and complex for postgis to handle-- i.e. too many multipolygons in each file? Or am I just doing something wrong? I am fairly new with postgis functions, but I have searched the archives to see if there have been similar problems before, and other than the ones I have tried above, I do not find any that I can manipulate to my particular needs. Regards, Loretta ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users