[geotk] Add Postgis data

sorel johann johann.sorel at geomatys.fr
Fri Oct 28 03:24:08 EDT 2011


Hello,

It might come from several things :

- first check you database, is the geometry column of your table 
properly set ? including geometry type and srid.

- second, print the FeatureType to see if anything is missing. ( 
System.out.println(store.getFeatureType(name));

- third, check the style ( System.out.println(style)); see if the 
Symbolizer is the proper one for your data type. If your geometry column 
is just 'Geometry' and the style is PolygonSymbolizer you won't see 
anything.

-fourth, did you zoom on the map you are trying to display ? If you use 
JMap2DFrame, then configure the VisibleArea on the MapContext. this will 
open the map directly on the extent you will have set.

johann


On 27/10/2011 19:31, Arnaud Vandecasteele wrote:
> Hi all,
>
> I'm trying to add some data from postgis in my geotoolkit application.
> All seems to work fine. But the data doesn't appear on the map.
> It must be something I've forgot but I dont see what.
> Below is the code I use (better view in pastbin http://pastebin.com/WR1mymtf ):
>
> ********************************************************
> final ParameterValueGroup parameters =
> PostgisNGDataStoreFactory.PARAMETERS_DESCRIPTOR.createValue();
> Name typeName = null;
> 			
> Parameters.getOrCreate(PostgisNGDataStoreFactory.HOST,
> parameters).setValue("*******");
> Parameters.getOrCreate(PostgisNGDataStoreFactory.PORT,
> parameters).setValue(5432);
> Parameters.getOrCreate(PostgisNGDataStoreFactory.DATABASE,
> parameters).setValue("vessel");
> Parameters.getOrCreate(PostgisNGDataStoreFactory.USER,
> parameters).setValue("*******");
> Parameters.getOrCreate(PostgisNGDataStoreFactory.PASSWD,
> parameters).setValue("******");
> 	
> final DataStore postgisStore = DataStoreFinder.getDataStore(parameters);
> if (postgisStore == null) {
>    JOptionPane.showMessageDialog(null, "Could not connect - check parameters");
> }else{
>    System.out.println("----------------------------------------");
>    System.out.println(postgisStore.getNames());
>    for(Iterator<Name>  postgisStoreTables =
> postgisStore.getNames().iterator(); postgisStoreTables.hasNext();){
>           Name postgisStoreTable = postgisStoreTables.next();
>           if (postgisStoreTable.toString().contains("traj")){ typeName
> = postgisStoreTable;}
> }
>
>     Session postGisSession = postgisStore.createSession(true);
>     FeatureCollection collection =
> postGisSession.getFeatureCollection(QueryBuilder.all(typeName));
>     final MutableStyle style =
> RandomStyleFactory.createRandomVectorStyle(collection);
>     final FeatureMapLayer featMapLayer =
> MapBuilder.createFeatureLayer(collection, style);
>     this.MAPCONTEXT.layers().add(featMapLayer);
> ********************************************************
>
> the System.out.println(postgisStore.getNames()) show me the name of my
> tables as : [{http://geotoolkit.org}traj,
> {http://geotoolkit.org}speed, {http://geotoolkit.org}releve]
>
> Do you see what I'm doing wrong ?
>
> Thanks for your help.
>
> Regards
>
> Arnaud
>



More information about the Geotoolkit mailing list