Home > Mobile >  GeoTools to read featureSource from a different postgresql schema than public
GeoTools to read featureSource from a different postgresql schema than public

Time:03-02

Working my way through GeoTools. Just trying to read features from a view in postgresql that is not in public schema. I have a bunch of views in a schema called cache

store = DataStoreFinder.getDataStore(map);
// print a bunch of tables and views including the one I want
for(String s:store.getTypeNames()) 
   System.out.println(s);

I can see my view name in the list eg: vw_well without the prefix cache

but

featureSource = store.getFeatureSource("vw_well");

will generate

WARNING: Error occured determing srid for vw_well.geom
org.postgresql.util.PSQLException: ERROR: relation "public.vw_well" does not exist

and

featureSource = store.getFeatureSource("cache.vw_well");

generates

Schema 'cache.vw_well' does not exist.

Any way to tell GeoTools to read in a different schema than `public. I googled around I could not find an answer.

Thank you.

CodePudding user response:

You don't show the code setting your map of parameters, but I suspect you didn't include a schema key so the database connection defaults to public. You need a line like:

map.put(PostgisNGDataStoreFactory.SCHEMA.key, "cache");
  • Related