Re: [JPP-Devel] PSQLException trying to load empty geotables

2009-10-02 Thread Nils Kuhn

Hi Uwe,

Uwe Dalluege schrieb:

Hi Nils,

you can save dataset as shape-file
when you use my PostGISPlugIn.

1. RightMouseClick on a category then Load Dataset(s)... (green cross).
Choose PostGIS Table (ComboBox behind Format:).
Then you can load a PostGIS-Table.

2. RightMouseClick at the PostGIS-Layer then Save Dataset As
Choose ESRI Shapefile (ComboBox behind Format:) and you can save 
the layer as shapefile.
Sorry, you are right, in general this function works with layers loaded 
with your PlugIn.
But I have geotables with postgres-BIGINT-fields in my project and for 
these I get a Class Cast Exception (java.lang.Long cannot be cast to 
java.lang.Integer) trying to save them as shapefile.


But you are right: you can not refresh the PostGISLayer with this PlugIn.
I have written a workaround for refreshing layers loaded by your PlugIn. 
If sombody else is interested in that, see the attachment.
And: Yes, I know that it's a bad habbit to put some structured 
programming in static methods of a final Class ;-)


Regards
Nils


Regards

Uwe Dalluege




--
Dipl.-Biol. Nils Kuhn
Hohe Weide 25
20253 Hamburg

public static Layer refreshPostgisLayer(Layer lyr,WorkbenchContext context) {
System.out.println(lyr.getName(): +lyr.getName());
System.out.println(lyr.getDataSourceQuery().getQuery(): 
+lyr.getDataSourceQuery().getQuery());
Category cat = 
context.getLayerNamePanel().getLayerManager().getCategory(lyr);
String strCategoryName = cat.getName();
int intPositionOfTheLayerToRefresh = cat.indexOf(lyr); 
try {

String strLayerName=lyr.getName();
DataSourceQuery targetQuery = lyr.getDataSourceQuery();

//remove the layer
//**

lyr.getLayerManager().dispose(context.getWorkbench().getFrame(), lyr);

//adding the layer again
//**
com.vividsolutions.jump.io.datasource.Connection 
connection = targetQuery.getDataSource().getConnection();
try {

ArrayList exceptions = new ArrayList();
FeatureCollection dataset = 
targetQuery.getDataSource().installCoordinateSystem(
   
connection.executeQuery(targetQuery.getQuery(),
   exceptions, 
   null), 
   
CoordinateSystemRegistry.instance(context.getBlackboard()));
if (dataset != null) {
//creating the refreshed layer, adding it to 
the LayerManager, removing it and adding it again at the right position of the 
category
//(it would be nice to have a method for adding 
a layer to the LayerManager directly at a certain category-position)
System.out.println(strCategoryName: 
+strCategoryName);

lyr=context.getLayerManager().addLayer(strCategoryName,strLayerName,dataset);
lyr.setDataSourceQuery(targetQuery);
lyr.setFeatureCollectionModified(false);
context.getLayerManager().remove(lyr);

context.getLayerManager().getCategory(strCategoryName).add(intPositionOfTheLayerToRefresh,
 lyr);
}

} finally {
connection.close();
}
} catch (Exception e) {
JOptionPane
.showMessageDialog(null,
An error occurred 
refreshing the layer \+lyr.getName()+\ (
+ 
e.getMessage() + )!, Truncation,

JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
return lyr;
}--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf___
Jump-pilot-devel mailing list

Re: [JPP-Devel] PSQLException trying to load empty geotables

2009-10-01 Thread Uwe Dalluege
Hi Nils,

you can save dataset as shape-file
when you use my PostGISPlugIn.

1. RightMouseClick on a category then Load Dataset(s)... (green cross).
Choose PostGIS Table (ComboBox behind Format:).
Then you can load a PostGIS-Table.

2. RightMouseClick at the PostGIS-Layer then Save Dataset As
Choose ESRI Shapefile (ComboBox behind Format:) and you can save the 
layer as shapefile.

But you are right: you can not refresh the PostGISLayer with this PlugIn.

Regards

Uwe Dalluege

-- 
--
Dipl.-Ing. Uwe Dalluege
Labor fuer Geoinformatik und Geovisualisierung
HafenCity Universitaet Hamburg
Hebebrandstr. 1
22297 Hamburg
Tel.: +49 40 42827 - 5335
Fax:  +49 40 42827 - 5409
E-Mail: mailto:uwe.dallu...@hcu-hamburg.de
Url: http://www.hcu-hamburg.de/geomatik/
--


Nils Kuhn schrieb:
 Hi,
 I get an org.postgresql.util.PSQLException (syntax error at or near )) 
 if I try to load empty postgis-tables or -views. I am using the function 
 FileOpenDataStoreLayer in oj 1.3. I am changing the data source of 
 some layers programmatically and can't prevent that the view I link to 
 the layer is just empty in some cases.
 My workaround is to use the postgis-plugin by uwe dalluege which can 
 actually load empty tables, but unfortunately some of the standard 
 oj-functions doesn't work together with these layers (like refresh 
 layer from layer-context-menu or save dataset as shape-file).
 Can anybody help me?
 Can I get the stacktrace of the Exceptions that occur while oj is running?
 Nils
 
  
 
 --
 Come build with us! The BlackBerryreg; Developer Conference in SF, CA
 is the only developer event you need to attend this year. Jumpstart your
 developing skills, take BlackBerry mobile applications to market and stay 
 ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
 http://p.sf.net/sfu/devconf
 ___
 Jump-pilot-devel mailing list
 Jump-pilot-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


Re: [JPP-Devel] PSQLException trying to load empty geotables

2009-10-01 Thread Stefan Steiniger
Hei Nils,

I don't have really an idea since I have never worked with PostGIS, but 
what if you test first in pgAdmin and look for errors (see the OGRS 
tutorial[1], and Ravi Kumars tutorial on mineral prog[2] for using 
pgadmin).

Not sure but maybe the new book on PostGIS (PostGIS in Action) could 
help, see:
http://www.bostongis.com/?content_name=postgis_tut01

Btw. wouldn't you get some error messages in Eclipse?

stefan

[1] 
http://sourceforge.net/projects/jump-pilot/files/Documentation/OpenJUMP%201.3%20Docs%20%28English%29/ogrs2009_tutorial.pdf/download
[2] 
http://sourceforge.net/projects/jump-pilot/files/Documentation/OpenJUMP%201.3%20Docs%20%28English%29/mockex_mineral_targeting_v2.zip/download


Nils Kuhn wrote:
 Hi,
 I get an org.postgresql.util.PSQLException (syntax error at or near )) 
 if I try to load empty postgis-tables or -views. I am using the function 
 FileOpenDataStoreLayer in oj 1.3. I am changing the data source of 
 some layers programmatically and can't prevent that the view I link to 
 the layer is just empty in some cases.
 My workaround is to use the postgis-plugin by uwe dalluege which can 
 actually load empty tables, but unfortunately some of the standard 
 oj-functions doesn't work together with these layers (like refresh 
 layer from layer-context-menu or save dataset as shape-file).
 Can anybody help me?
 Can I get the stacktrace of the Exceptions that occur while oj is running?
 Nils
 
  
 
 --
 Come build with us! The BlackBerryreg; Developer Conference in SF, CA
 is the only developer event you need to attend this year. Jumpstart your
 developing skills, take BlackBerry mobile applications to market and stay 
 ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
 http://p.sf.net/sfu/devconf
 ___
 Jump-pilot-devel mailing list
 Jump-pilot-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
 
 

--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


[JPP-Devel] PSQLException trying to load empty geotables

2009-09-30 Thread Nils Kuhn
Hi,
I get an org.postgresql.util.PSQLException (syntax error at or near )) 
if I try to load empty postgis-tables or -views. I am using the function 
FileOpenDataStoreLayer in oj 1.3. I am changing the data source of 
some layers programmatically and can't prevent that the view I link to 
the layer is just empty in some cases.
My workaround is to use the postgis-plugin by uwe dalluege which can 
actually load empty tables, but unfortunately some of the standard 
oj-functions doesn't work together with these layers (like refresh 
layer from layer-context-menu or save dataset as shape-file).
Can anybody help me?
Can I get the stacktrace of the Exceptions that occur while oj is running?
Nils

 

--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel