Andrea Aime a écrit : > johann sorel ha scritto: >> Here is a test case : >> >> CREATE TABLE places >> ( >> ref_id character(8) NOT NULL, >> emplacement geometry, >> CONSTRAINT "mainKey" PRIMARY KEY (ref_id) >> ) >> WITH (OIDS=FALSE); >> ALTER TABLE places OWNER TO admin; >> >> //dont forget to add the column in the geometry_columns >> >> insert into places values('SCR08123', GeometryFromText('POINT(1 >> 3)',4326)); >> >> CREATE OR REPLACE VIEW myview AS >> SELECT places.ref_id, places.emplacement >> FROM places; >> >> ALTER TABLE myview OWNER TO admin; >> >> >> final Map params = new HashMap<String, Object>(); >> params.put("dbtype", "postgis"); >> params.put(PostgisDataStoreFactory.HOST.key, "..."); >> params.put(PostgisDataStoreFactory.PORT.key, 5432); >> params.put(PostgisDataStoreFactory.SCHEMA.key, "public"); >> params.put(PostgisDataStoreFactory.DATABASE.key, "..."); >> params.put(PostgisDataStoreFactory.USER.key, "..."); >> params.put(PostgisDataStoreFactory.PASSWD.key, "..."); >> DataStore store = DataStoreFinder.getDataStore(params); >> FeatureSource fs = >> store.getFeatureSource("myview"); >> fs.getBounds(); //RAISE ERROR >> >> First try to connect to the Table, it works >> Next try to connect to the view and you will have a : >> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException >> at com.vividsolutions.jts.geom.Envelope.init(Envelope.java:254) >> at com.vividsolutions.jts.geom.Envelope.<init>(Envelope.java:186) >> at >> org.geotools.geometry.jts.ReferencedEnvelope.<init>(ReferencedEnvelope.java:203) >> > > > > First thing I notice from the commands is that you did not register the > view in geometry_columns. How can the datastore know about the SRS > and geometry columns of the view if you don't? > Yet, a NPE is a very bad reaction, the situation must dealt with it > more gracefully. I'll have a look into it. > > Oh... where did the OID issue end up? > > Cheers > Andrea > Try to fix the view like this :
CREATE OR REPLACE VIEW myview AS SELECT places.ref_id as oid , places.emplacement FROM places; ALTER TABLE myview OWNER TO admin; (see the "as oid" in the query) with the named oid field, the view will work. Strange isn't it ? -- Johann Sorel Company - Geomatys GIS Developer Mail - [EMAIL PROTECTED] ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Geotools-devel mailing list Geotools-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel