[geotk] Add Postgis data

Arnaud Vandecasteele arnaud.sig at gmail.com
Fri Oct 28 05:01:51 EDT 2011


Back again with some new results.
I recreate my geometry column and thos works better now :
ModifiableSimpleFeaturetype releve identified extends Feature
╔══════════╤══════╤══════╤═══════════╤═══════════╤═══════════╤═══════════════════╗
║ name     │  min │  max │  nillable │  type     │  CRS      │
UserData         ║
╟──────────┼──────┼──────┼───────────┼───────────┼───────────┼───────────────────╢
║ imo      │ 1    │ 1    │ true      │ Double    │           │
          ║
║ lon      │ 1    │ 1    │ true      │ Double    │           │
          ║
║ lat      │ 1    │ 1    │ true      │ Double    │           │
          ║
║ reltime  │ 1    │ 1    │ true      │ Timestamp │           │
          ║
║ speed    │ 1    │ 1    │ true      │ Double    │           │
          ║
║ the_geom │ 1    │ 1    │ true      │ Point     │ EPSG:4326 │
nativeSRID=4326   ║
╚══════════╧══════╧══════╧═══════════╧═══════════╧═══════════╧═══════════════════╝
crs=EPSG:WGS 84

But I'm not still able to see my data on my application :(

A.

On Fri, Oct 28, 2011 at 10:51 AM, Arnaud Vandecasteele
<arnaud.sig at gmail.com> wrote:
> Hi all,
>
> Cedric, thanks for the NameSpace tips.
>
> I checked my postgis parms and I did what Johann said.
> The  System.out.println(postgisStore.getFeatureType(typeName)); give me :
>
> ModifiableSimpleFeaturetype releve identified extends Feature
> ╔═════════╤══════╤══════╤═══════════╤═══════════╤══════╤═══════════╗
> ║ name    │  min │  max │  nillable │  type     │  CRS │  UserData ║
> ╟─────────┼──────┼──────┼───────────┼───────────┼──────┼──── ───────╢
> ║ imo     │ 1    │ 1    │ true      │ Double    │      │           ║
> ║ lon     │ 1    │ 1    │ true      │ Double    │      │           ║
> ║ lat     │ 1    │ 1    │ true      │ Double    │      │           ║
> ║ point   │ 1    │ 1    │ true      │ Geometry  │      │           ║
> ║ reltime │ 1    │ 1    │ true      │ Timestamp │      │           ║
> ║ speed   │ 1    │ 1    │ true      │ Double    │      │           ║
> ╚═════════╧══════╧══════╧═══════════╧═══════════╧══════╧═══════════╝
> crs null
>
> The problem could be the CRS but when I do :
> select srid(point) from releve;
>
> The result is :
>
>  srid
> ------
>  4326
>  4326
> ...
>
> Do you see what could be wrong ?
>
> Regards
>
> Arnaud
>
> On Fri, Oct 28, 2011 at 9:31 AM, Cédric Briançon
> <cedric.briancon at geomatys.fr> wrote:
>> Hi Arnaud,
>>
>> here you have a namespace by default for your data (http://geotoolkit.org)
>> which is displayed by your println.
>> If you want to test "postgisStoreTable.toString().contains("traj")", you
>> should remove the default namespace by adding the following property to the
>> datastore :
>>
>> Parameters.getOrCreate(PostgisNGDataStoreFactory.NAMESPACE,
>> parameters).setValue("no namespace");
>>
>> This way, your tables will be traj, speed and releve, not
>> {http://geotoolkit.org}traj.
>>
>> Regards,
>> Cédric Briançon
>>
>>
>> Le 27/10/2011 19:31, Arnaud Vandecasteele a écrit :
>>>
>>> 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
>>>
>>
>> _______________________________________________
>> Geotoolkit mailing list
>> Geotoolkit at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/geotoolkit
>>
>
>
>
> --
> --------------------------------------------------------------------
> Van De Casteele Arnaud
> Mines Paris Tech - CRC
> Sophia-Antipolis
> 0698 24 25 29
> SIG - WebMapping - SOLAP - BI - GeoCollaboration
>
> Web Site
> http://geotribu.net/
> http://www.i2c.eu/
>



-- 
--------------------------------------------------------------------
Van De Casteele Arnaud
Mines Paris Tech - CRC
Sophia-Antipolis
0698 24 25 29
SIG - WebMapping - SOLAP - BI - GeoCollaboration

Web Site
http://geotribu.net/
http://www.i2c.eu/


More information about the Geotoolkit mailing list