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

-- 
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

-------------------------------------------------------------------------
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

Reply via email to