[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [udig-devel] How do I programmatically add a layer from a PostGIS datastore?
|
Some comments, without having tried them though:
Create a postgis service. In PostgisServiceExtension2 there is a nice
cerate metoh you might be able to use.
Add the service to the catalog:
ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
catalog.add(service);
Add then I am going to guess heavily based on what I do with file
based things I use:
Create a PostgisGeoResource2 (pgeoResource) which will represent your
layer and add it to the layers list:
List< ? extends ILayer> addedLayers =
ApplicationGIS.addLayersToMap(map, pgeoResource, layerposition);
That should be more or less what you need.
Hope that helps.
ciao
Andrea
On Thu, Apr 22, 2010 at 11:48 PM, Mark Mathis <mmathis@xxxxxxxx> wrote:
> FWIW, the "geometry_columns" and "spatial_ref_sys" tables were owned by
> "postgres" not the user we were trying to connect to the database with.
> Once we fixed the permissions on those two tables, uDig was able to connect
> to the PostGIS datastore without any difficulty.
>
> I am still trying to figure out how to accomplish my original question, "How
> do I programmatically add a layer from a PostGIS datastore?". This can't be
> too hard. Can anyone point me in the right direction?
>
> Mark Mathis wrote:
>>
>> Any help on this? It seems like a pretty simple thing to do...
>>
>> Also, the PostGIS datastore (via the catalog) does not seem to work with
>> the enterprise db version of postgres. EnterpriseDB has a separate jdbc
>> connector, which seems to be required when connecting to the database from
>> elsewhere. In the case of uDig, I can connect to the database as is, but do
>> not see any layers. I could replace the postgres jdbc driver with the edb
>> jar if I could find it... The only reference I can find is in the pom for
>> gt2-postgis.jar. Any ideas?
>>
>> Mark Mathis wrote:
>>>
>>> All,
>>>
>>> I am currently trying to develop a uDig custom application. I have a set
>>> of existing plugins that create or modify data in a PostGIS database (behind
>>> the scenes using straight jdbc operations). I can see the results of my
>>> computations by manually refreshing the catalog (assuming I have already
>>> connected to the postgres datastore) and using other built in user interface
>>> functionality to add/remove layers and redraw the map.
>>> What I would like to do is, given the appropriate connection parameters
>>> (host, database, table, and optional filter), programmatically add a new
>>> layer to the map. I have done this (more or less) successfully by creating
>>> a (local) temporary layer and copying the features from the database to the
>>> new layer. Unfortunately, this does not meet my requirements since any
>>> changes to the database are not updated in the local layer (at least not
>>> without regenerating the local layer). I have also been able to
>>> programmtically add the database to the local catalog as an available data
>>> source.
>>>
>>> So, my question is this, "How do I programmatically 'reset' the database
>>> connection in the catalog view (to pick up any new tables) and call 'add to
>>> current map' for a specified table (layer)?".
>>>
>>> Thanks,
>>>
>>> MM
>>>
>>> I am currently working with uDig 1.1.1 SDK and eclipse PDE 3.5 (Galileo)
>>> _______________________________________________
>>> User-friendly Desktop Internet GIS (uDig)
>>> http://udig.refractions.net
>>> http://lists.refractions.net/mailman/listinfo/udig-devel
>>
>> _______________________________________________
>> User-friendly Desktop Internet GIS (uDig)
>> http://udig.refractions.net
>> http://lists.refractions.net/mailman/listinfo/udig-devel
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
>