Revision 2970
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.raster.postgis</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
<version>2.2.2</version> |
|
7 |
<name>Plugin list for PostGIS raster in gvSIG</name> |
|
8 |
<description>Plugin list for PostGIS raster in gvSIG</description> |
|
9 |
<inceptionYear>2011</inceptionYear> |
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.raster</artifactId> |
|
13 |
<version>2.2.4</version> |
|
14 |
</parent> |
|
15 |
|
|
16 |
<repositories> |
|
17 |
<repository> |
|
18 |
<id>gvsig-public-http-repository</id> |
|
19 |
<name>gvSIG maven public HTTP repository</name> |
|
20 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
21 |
<releases> |
|
22 |
<enabled>true</enabled> |
|
23 |
<updatePolicy>daily</updatePolicy> |
|
24 |
<checksumPolicy>warn</checksumPolicy> |
|
25 |
</releases> |
|
26 |
<snapshots> |
|
27 |
<enabled>true</enabled> |
|
28 |
<updatePolicy>daily</updatePolicy> |
|
29 |
<checksumPolicy>warn</checksumPolicy> |
|
30 |
</snapshots> |
|
31 |
</repository> |
|
32 |
</repositories> |
|
33 |
|
|
34 |
<scm> |
|
35 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2</connection> |
|
36 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2</developerConnection> |
|
37 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2</url> |
|
38 |
</scm> |
|
39 |
<build> |
|
40 |
<plugins> |
|
41 |
<plugin> |
|
42 |
<groupId>org.apache.maven.plugins</groupId> |
|
43 |
<artifactId>maven-release-plugin</artifactId> |
|
44 |
<configuration> |
|
45 |
<tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.postgis/tags/</tagBase> |
|
46 |
<goals>deploy</goals> |
|
47 |
</configuration> |
|
48 |
</plugin> |
|
49 |
</plugins> |
|
50 |
</build> |
|
51 |
<developers> |
|
52 |
<developer> |
|
53 |
<id>nbrodin</id> |
|
54 |
<name>Nacho Brodin</name> |
|
55 |
<email>nachobrodin@gmail.com</email> |
|
56 |
<roles> |
|
57 |
<role>Architect</role> |
|
58 |
<role>Developer</role> |
|
59 |
</roles> |
|
60 |
</developer> |
|
61 |
</developers> |
|
62 |
|
|
63 |
<dependencyManagement> |
|
64 |
<dependencies> |
|
65 |
|
|
66 |
<dependency> |
|
67 |
<groupId>org.gvsig</groupId> |
|
68 |
<artifactId>org.gvsig.raster.gdal.io</artifactId> |
|
69 |
<version>2.2.3</version> |
|
70 |
</dependency> |
|
71 |
|
|
72 |
<!-- |
|
73 |
<dependency> |
|
74 |
<groupId>org.gvsig</groupId> |
|
75 |
<artifactId>org.gvsig.jgdal</artifactId> |
|
76 |
<version>${jgdal.version}</version> |
|
77 |
</dependency> |
|
78 |
<dependency> |
|
79 |
<groupId>org.gvsig</groupId> |
|
80 |
<artifactId>org.gvsig.jgdal</artifactId> |
|
81 |
<version>${jgdal.version}</version> |
|
82 |
<classifier>${native_classifier}</classifier> |
|
83 |
<type>tar.gz</type> |
|
84 |
</dependency> |
|
85 |
--> |
|
86 |
<dependency> |
|
87 |
<groupId>org.gvsig</groupId> |
|
88 |
<artifactId>org.gvsig.raster.postgis.swing.impl</artifactId> |
|
89 |
<version>2.2.2</version> |
|
90 |
</dependency> |
|
91 |
<dependency> |
|
92 |
<groupId>org.gvsig</groupId> |
|
93 |
<artifactId>org.gvsig.raster.postgis.io</artifactId> |
|
94 |
<version>2.2.2</version> |
|
95 |
</dependency> |
|
96 |
<dependency> |
|
97 |
<groupId>org.gvsig</groupId> |
|
98 |
<artifactId>org.gvsig.raster.postgis.swing.api</artifactId> |
|
99 |
<version>2.2.2</version> |
|
100 |
</dependency> |
|
101 |
|
|
102 |
</dependencies> |
|
103 |
</dependencyManagement> |
|
104 |
|
|
105 |
<modules> |
|
106 |
<module>org.gvsig.raster.postgis.io</module> |
|
107 |
<module>org.gvsig.raster.postgis.swing</module> |
|
108 |
<module>org.gvsig.raster.postgis.app.postgisrasterclient</module> |
|
109 |
</modules> |
|
110 |
|
|
111 |
</project> |
|
112 |
|
|
0 | 113 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/buildNumber.properties | ||
---|---|---|
1 |
#Thu Oct 02 10:52:52 EDT 2014 |
|
2 |
buildNumber=54 |
|
0 | 3 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
|
|
26 |
<dependencySets> |
|
27 |
<dependencySet> |
|
28 |
<useProjectArtifact>false</useProjectArtifact> |
|
29 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
30 |
<outputDirectory>lib</outputDirectory> |
|
31 |
<includes> |
|
32 |
<include>org.gvsig:org.gvsig.raster.postgis.app.postgisrasterclient:jar</include> |
|
33 |
<include>org.gvsig:org.gvsig.raster.postgis.io:jar</include> |
|
34 |
<include>org.gvsig:org.gvsig.raster.postgis.swing.api:jar</include> |
|
35 |
<include>org.gvsig:org.gvsig.raster.postgis.swing.impl:jar</include> |
|
36 |
</includes> |
|
37 |
</dependencySet> |
|
38 |
</dependencySets> |
|
39 |
</assembly> |
|
0 | 40 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/java/org/gvsig/raster/postgis/app/postgisrasterclient/PostGISRasterExtension.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.postgis.app.postgisrasterclient; |
|
20 |
|
|
21 |
import org.gvsig.about.AboutManager; |
|
22 |
import org.gvsig.about.AboutParticipant; |
|
23 |
import org.gvsig.andami.plugins.Extension; |
|
24 |
import org.gvsig.app.ApplicationLocator; |
|
25 |
import org.gvsig.app.ApplicationManager; |
|
26 |
import org.gvsig.app.extension.AddLayer; |
|
27 |
import org.gvsig.raster.postgis.app.postgisrasterclient.gui.AddPostGISRasterLayerWizard; |
|
28 |
|
|
29 |
/** |
|
30 |
* Entry point for PostGISRaster extension |
|
31 |
* |
|
32 |
* @author Nacho Brodin (nachobrodin@gmail.org) |
|
33 |
*/ |
|
34 |
public class PostGISRasterExtension extends Extension { |
|
35 |
/** |
|
36 |
* Initializes the wizard panel |
|
37 |
* |
|
38 |
*/ |
|
39 |
public void initialize() { |
|
40 |
initializeIcons(); |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* @see com.iver.andami.plugins.IExtension#postInitialize() |
|
45 |
*/ |
|
46 |
@Override |
|
47 |
public void postInitialize() { |
|
48 |
super.postInitialize(); |
|
49 |
addAboutInfo(); |
|
50 |
|
|
51 |
AddLayer.addWizard(AddPostGISRasterLayerWizard.class); |
|
52 |
} |
|
53 |
|
|
54 |
private void addAboutInfo() { |
|
55 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
56 |
|
|
57 |
AboutManager about = application.getAbout(); |
|
58 |
about.addDeveloper("PRODEVELOP", getClass().getClassLoader() |
|
59 |
.getResource("about/postgisraster-about.html"), 2); |
|
60 |
|
|
61 |
AboutParticipant participant = about.getDeveloper("PRODEVELOP"); |
|
62 |
participant.addContribution( |
|
63 |
"PostGIS Raster", |
|
64 |
"Soporte para BBDD r?ster usando PostGIS", |
|
65 |
2011,12,1, |
|
66 |
2011,12,31 |
|
67 |
); |
|
68 |
} |
|
69 |
|
|
70 |
public void execute(String actionCommand) { |
|
71 |
//Removes Gdal dependency |
|
72 |
/*try { |
|
73 |
test(); |
|
74 |
} catch (GdalException e) { |
|
75 |
e.printStackTrace(); |
|
76 |
} catch (IOException e) { |
|
77 |
e.printStackTrace(); |
|
78 |
}*/ |
|
79 |
} |
|
80 |
|
|
81 |
//Removes Gdal dependency |
|
82 |
/*private void test() throws GdalException, IOException{ |
|
83 |
Gdal gdal = new Gdal(); |
|
84 |
gdal.open("PG:host='130.0.2.122' port='5432' dbname='testgis' user='postgres' password='postgres' schema='public' table='small_world_1tile'", Gdal.GA_ReadOnly); |
|
85 |
int w = gdal.getRasterXSize(); |
|
86 |
int h = gdal.getRasterYSize(); |
|
87 |
System.out.println(w + " " + h); |
|
88 |
GdalRasterBand[] b = new GdalRasterBand[3]; |
|
89 |
b[0] = gdal.getRasterBand(1); |
|
90 |
b[1] = gdal.getRasterBand(2); |
|
91 |
b[2] = gdal.getRasterBand(3); |
|
92 |
|
|
93 |
int dt = b[0].getRasterDataType(); |
|
94 |
GdalBuffer buf = b[0].readRaster(0, 0, w, h, w, h, dt); |
|
95 |
byte[] bb = buf.buffByte; |
|
96 |
for(int i = 0; i < 10; i++) { |
|
97 |
System.out.print(bb[i] + " "); |
|
98 |
} |
|
99 |
gdal.close(); |
|
100 |
}*/ |
|
101 |
|
|
102 |
|
|
103 |
public boolean isEnabled() { |
|
104 |
return true; |
|
105 |
} |
|
106 |
|
|
107 |
public boolean isVisible() { |
|
108 |
return true; |
|
109 |
} |
|
110 |
|
|
111 |
void initializeIcons(){ |
|
112 |
|
|
113 |
} |
|
114 |
} |
|
0 | 115 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/java/org/gvsig/raster/postgis/app/postgisrasterclient/gui/LayerLoaderManager.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.postgis.app.postgisrasterclient.gui; |
|
23 |
|
|
24 |
import java.util.List; |
|
25 |
|
|
26 |
import javax.swing.JOptionPane; |
|
27 |
|
|
28 |
import org.gvsig.andami.PluginServices; |
|
29 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
30 |
import org.gvsig.fmap.dal.DALLocator; |
|
31 |
import org.gvsig.fmap.dal.DataManager; |
|
32 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
33 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
34 |
import org.gvsig.fmap.dal.exception.DataException; |
|
35 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
36 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
37 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
39 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
|
40 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
41 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
42 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
43 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
44 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
45 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
46 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
47 |
import org.gvsig.raster.postgis.io.PostGISRasterDataParameters; |
|
48 |
import org.gvsig.raster.postgis.io.PostGISRasterServerExplorer; |
|
49 |
import org.gvsig.raster.postgis.io.PostGISRasterServerExplorerParameters; |
|
50 |
import org.gvsig.raster.postgis.swing.AddLayerUI; |
|
51 |
import org.gvsig.raster.util.RasterNotLoadException; |
|
52 |
import org.slf4j.Logger; |
|
53 |
import org.slf4j.LoggerFactory; |
|
54 |
|
|
55 |
/** |
|
56 |
* Manager to load layers in TOC. There are some strategies, load a entire layer |
|
57 |
* or load subdatasets depending on the user selection or the layer structure. |
|
58 |
* |
|
59 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
60 |
*/ |
|
61 |
public class LayerLoaderManager { |
|
62 |
private static int ALL_SUBDATASETS = -2; |
|
63 |
private static int ENTIRE = -1; |
|
64 |
|
|
65 |
private static Logger logger = LoggerFactory.getLogger(AddPostGISRasterLayerWizard.class.getName()); |
|
66 |
private AddLayerUI apiUI = null; |
|
67 |
private DBServerExplorerParameters dbExplorerParameters = null; |
|
68 |
private MapContext mapContext = null; |
|
69 |
|
|
70 |
public LayerLoaderManager(AddLayerUI ui) { |
|
71 |
this.apiUI = ui; |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Assigns a {@link DBServerExplorerParameters} |
|
76 |
* @param params |
|
77 |
*/ |
|
78 |
public void setDBServerExplorerParameters(DBServerExplorerParameters params) { |
|
79 |
this.dbExplorerParameters = params; |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* Gets the {@link DBServerExplorerParameters} |
|
84 |
* @return {@link DBServerExplorerParameters} |
|
85 |
*/ |
|
86 |
public DBServerExplorerParameters getDBServerExplorerParameters() { |
|
87 |
return this.dbExplorerParameters; |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Return FLayers if user performs multi selection. |
|
92 |
*/ |
|
93 |
public void loadLayers() { |
|
94 |
if(dbExplorerParameters == null) |
|
95 |
return; |
|
96 |
|
|
97 |
List<Object> tables = apiUI.getSelectedTables(); |
|
98 |
|
|
99 |
//Para una tabla seleccionada |
|
100 |
if(tables.size() == 1) { |
|
101 |
TableListItem item = (TableListItem)tables.get(0); |
|
102 |
String schema = item.getSchema(); |
|
103 |
String table = item.getTableName(); |
|
104 |
|
|
105 |
//Sin subdatasets |
|
106 |
if(getNumberOfColumns(schema, table) == 1) { |
|
107 |
loadOneLayer(item, ENTIRE); |
|
108 |
} |
|
109 |
//Con subdatasets |
|
110 |
else { |
|
111 |
int[] subdatasets = apiUI.getSelectedSubdatasets(); |
|
112 |
if(subdatasets == null || subdatasets.length <= 0) { |
|
113 |
loadOneLayer(item, ALL_SUBDATASETS); |
|
114 |
} else { |
|
115 |
long cols = getNumberOfColumns(schema, table); |
|
116 |
for (int i = 0; i < cols; i++) { |
|
117 |
loadOneLayer(item, i + 1); |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
//Para m?s de una tabla seleccionada (se usan todos los subdatasets) |
|
124 |
if(tables.size() > 1) { |
|
125 |
for (int i = 0; i < tables.size(); i++) { |
|
126 |
TableListItem item = (TableListItem)tables.get(i); |
|
127 |
String schema = item.getSchema(); |
|
128 |
String table = item.getTableName(); |
|
129 |
long subdatasets = getNumberOfColumns(schema, table); |
|
130 |
if(subdatasets == 1) { |
|
131 |
loadOneLayer(item, ENTIRE); |
|
132 |
} |
|
133 |
if(subdatasets > 1) { |
|
134 |
loadOneLayer(item, ALL_SUBDATASETS); |
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* Loads only one layer |
|
143 |
* @param item |
|
144 |
* @param subdataset |
|
145 |
*/ |
|
146 |
private void loadOneLayer(TableListItem item, int subdataset) { |
|
147 |
String host = dbExplorerParameters.getHost(); |
|
148 |
if(host.compareTo("localhost") == 0) |
|
149 |
host = "127.0.0.1"; |
|
150 |
Integer port = dbExplorerParameters.getPort(); |
|
151 |
String dbname = dbExplorerParameters.getDBName(); |
|
152 |
String user = dbExplorerParameters.getUser(); |
|
153 |
String password = dbExplorerParameters.getPassword(); |
|
154 |
String schema = item.getSchema(); |
|
155 |
String table = item.getTableName(); |
|
156 |
String connString = null; |
|
157 |
if(schema == null) |
|
158 |
connString = "PG:host='" + host + "' port='" + port + "' dbname='" + dbname + "' user='" + user + "' password='" + password + "' table='" + table + "'"; |
|
159 |
else |
|
160 |
connString = "PG:host='" + host + "' port='" + port + "' dbname='" + dbname + "' user='" + user + "' password='" + password + "' schema='" + schema + "' table='" + table + "'"; |
|
161 |
|
|
162 |
if(subdataset == ALL_SUBDATASETS) |
|
163 |
connString += " mode='2'"; |
|
164 |
|
|
165 |
if(subdataset >= 0) |
|
166 |
connString += " column='rast' where='rid = "+ subdataset + "'"; |
|
167 |
|
|
168 |
try { |
|
169 |
FLayer layer = createLayer(getFormatedRasterFileName(connString), connString, item, getNumberOfColumns(schema, table)); |
|
170 |
|
|
171 |
//Adds the layer to the view |
|
172 |
getMapContext().beginAtomicEvent(); |
|
173 |
layer.setVisible(true); |
|
174 |
getMapContext().getLayers().addLayer(layer); |
|
175 |
getMapContext().callLegendChanged(); |
|
176 |
getMapContext().endAtomicEvent(); |
|
177 |
getMapContext().invalidate(); |
|
178 |
} catch (LoadLayerException e) { |
|
179 |
logger.info("Error creating layer: " + e.getMessage(), e); |
|
180 |
//showConnectionErrorMessage(PluginServices.getText(this, "error_creating_layer") + ""); |
|
181 |
} |
|
182 |
} |
|
183 |
|
|
184 |
/** |
|
185 |
* Gets the MapContext |
|
186 |
* @return |
|
187 |
*/ |
|
188 |
private MapContext getMapContext() { |
|
189 |
if(mapContext == null) { |
|
190 |
IWindow[] w = PluginServices.getMDIManager().getAllWindows(); |
|
191 |
for (int i = 0; i < w.length; i++) { |
|
192 |
if (w[i] instanceof org.gvsig.app.project.documents.view.gui.AbstractViewPanel) { |
|
193 |
mapContext = ((org.gvsig.app.project.documents.view.gui.AbstractViewPanel)w[i]).getMapControl().getMapContext(); |
|
194 |
} |
|
195 |
} |
|
196 |
} |
|
197 |
return mapContext; |
|
198 |
} |
|
199 |
|
|
200 |
/** |
|
201 |
* Builds a new raster layer |
|
202 |
* @param fileName |
|
203 |
* @return |
|
204 |
* @throws RasterNotLoadException |
|
205 |
* @throws LoadLayerException |
|
206 |
*/ |
|
207 |
@SuppressWarnings("deprecation") |
|
208 |
public FLyrRaster createLayer(String layerName, String conn, TableListItem item, long nColumns) throws LoadLayerException { |
|
209 |
DataManager dataManager = DALLocator.getDataManager(); |
|
210 |
DefaultFLyrRaster lyr = null; |
|
211 |
try { |
|
212 |
PostGISRasterServerExplorerParameters explorerParams = (PostGISRasterServerExplorerParameters) dataManager.createServerExplorerParameters(PostGISRasterServerExplorer.NAME); |
|
213 |
explorerParams.setHost(conn); |
|
214 |
PostGISRasterServerExplorer explorer = (PostGISRasterServerExplorer) dataManager.createServerExplorer(explorerParams); |
|
215 |
PostGISRasterDataParameters storeParameters = (PostGISRasterDataParameters)explorer.getStoredParameters(); |
|
216 |
storeParameters.setURI(conn); |
|
217 |
storeParameters.setDBExplorer(item.getExplorer()); |
|
218 |
storeParameters.setNumberOfBlocks(nColumns); |
|
219 |
storeParameters.setDBStoreParameters(item.getDBStoreParameters()); |
|
220 |
storeParameters.setDBExplorerParameters(dbExplorerParameters); |
|
221 |
|
|
222 |
MapContextManager mcm = MapContextLocator.getMapContextManager(); |
|
223 |
|
|
224 |
if(apiUI.isLayerTiled()) { |
|
225 |
DataManager manager = DALLocator.getDataManager(); |
|
226 |
TileDataParameters tileParams = null; |
|
227 |
try { |
|
228 |
tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store"); |
|
229 |
} catch (InitializeException e) { |
|
230 |
throw new LoadLayerException("", e); |
|
231 |
} catch (ProviderNotRegisteredException e) { |
|
232 |
throw new LoadLayerException("", e); |
|
233 |
} |
|
234 |
tileParams.setDataParameters(storeParameters); |
|
235 |
lyr = (DefaultFLyrRaster) mcm.createLayer(layerName, tileParams); |
|
236 |
//dataStore = dataManager.createStore(tileParams); |
|
237 |
} else { |
|
238 |
lyr = (DefaultFLyrRaster) mcm.createLayer(layerName, storeParameters); |
|
239 |
//dataStore = dataManager.createStore(storeParameters); |
|
240 |
} |
|
241 |
} catch (ValidateDataParametersException e) { |
|
242 |
throw new LoadLayerException("Error validating parameters", e); |
|
243 |
} catch (InitializeException e) { |
|
244 |
throw new LoadLayerException("Error initializating layer.", e); |
|
245 |
} catch (ProviderNotRegisteredException e) { |
|
246 |
throw new LoadLayerException("Provider not registered.", e); |
|
247 |
} |
|
248 |
|
|
249 |
return lyr; |
|
250 |
} |
|
251 |
|
|
252 |
/** |
|
253 |
* Gets the number of column of the selected table |
|
254 |
* @param schema |
|
255 |
* @param table |
|
256 |
* @return |
|
257 |
*/ |
|
258 |
@SuppressWarnings("deprecation") |
|
259 |
public long getNumberOfColumns(String schema, String table) { |
|
260 |
DataManager manager = DALLocator.getDataManager(); |
|
261 |
try { |
|
262 |
DataStoreParameters params = manager.createStoreParameters("PostgreSQL"); |
|
263 |
|
|
264 |
params.setDynValue("host", dbExplorerParameters.getHost()); |
|
265 |
params.setDynValue("port", dbExplorerParameters.getPort()); |
|
266 |
params.setDynValue("dbuser", dbExplorerParameters.getUser()); |
|
267 |
params.setDynValue("password", dbExplorerParameters.getPassword()); |
|
268 |
params.setDynValue("schema", schema); |
|
269 |
params.setDynValue("dbname", dbExplorerParameters.getDBName()); |
|
270 |
params.setDynValue("table", table); |
|
271 |
|
|
272 |
FeatureStore store = (FeatureStore)manager.createStore(params); |
|
273 |
long size = store.getFeatureCount(); |
|
274 |
store.dispose(); |
|
275 |
return size; |
|
276 |
} catch (DataException e) { |
|
277 |
return 0; |
|
278 |
} catch (ValidateDataParametersException e) { |
|
279 |
return 0; |
|
280 |
} |
|
281 |
} |
|
282 |
|
|
283 |
/** |
|
284 |
* Gets the name of a raster file |
|
285 |
*/ |
|
286 |
private String getFormatedRasterFileName(String name) { |
|
287 |
String newName = ""; |
|
288 |
String schema = null; |
|
289 |
String table = null; |
|
290 |
int index = name.indexOf(" schema='") + 8; |
|
291 |
if(index != -1) { |
|
292 |
try { |
|
293 |
schema = name.substring(index + 1, name.indexOf("'", index + 1)); |
|
294 |
newName += schema + "."; |
|
295 |
} catch (StringIndexOutOfBoundsException e) { |
|
296 |
} |
|
297 |
} |
|
298 |
index = name.indexOf(" table='") + 7; |
|
299 |
if(index != -1) { |
|
300 |
try { |
|
301 |
table = name.substring(index + 1, name.indexOf("'", index + 1)); |
|
302 |
newName += table; |
|
303 |
} catch (StringIndexOutOfBoundsException e) { |
|
304 |
} |
|
305 |
} |
|
306 |
return newName; |
|
307 |
} |
|
308 |
|
|
309 |
/** |
|
310 |
* Shows an error |
|
311 |
* @param _msg |
|
312 |
*/ |
|
313 |
public void showConnectionErrorMessage(String _msg) { |
|
314 |
String msg = (_msg.length() > 300) ? "" : (": " + _msg); |
|
315 |
String title = PluginServices.getText(this, "connection_error"); |
|
316 |
JOptionPane.showMessageDialog(apiUI.getComponent(), title + msg, title, |
|
317 |
JOptionPane.ERROR_MESSAGE); |
|
318 |
} |
|
319 |
|
|
320 |
/** |
|
321 |
* Shows a information window |
|
322 |
* @param _msg |
|
323 |
*/ |
|
324 |
public void showConnectionInfoMessage(String _msg) { |
|
325 |
String msg = (_msg.length() > 300) ? "" : (": " + _msg); |
|
326 |
String title = PluginServices.getText(this, "warning"); |
|
327 |
JOptionPane.showMessageDialog(apiUI.getComponent(), title + msg, title, |
|
328 |
JOptionPane.WARNING_MESSAGE); |
|
329 |
} |
|
330 |
} |
|
0 | 331 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/java/org/gvsig/raster/postgis/app/postgisrasterclient/gui/AddPostGISRasterLayerWizard.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.postgis.app.postgisrasterclient.gui; |
|
23 |
|
|
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
import java.util.HashMap; |
|
27 |
import java.util.Iterator; |
|
28 |
import java.util.List; |
|
29 |
import java.util.Map; |
|
30 |
import java.util.Map.Entry; |
|
31 |
|
|
32 |
import javax.swing.JComboBox; |
|
33 |
import javax.swing.JPanel; |
|
34 |
import javax.swing.event.ListSelectionEvent; |
|
35 |
import javax.swing.event.ListSelectionListener; |
|
36 |
|
|
37 |
import org.gvsig.andami.PluginServices; |
|
38 |
import org.gvsig.andami.PluginsLocator; |
|
39 |
import org.gvsig.andami.PluginsManager; |
|
40 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
41 |
import org.gvsig.app.gui.WizardPanel; |
|
42 |
import org.gvsig.app.gui.wizards.WizardListener; |
|
43 |
import org.gvsig.app.gui.wizards.WizardListenerSupport; |
|
44 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
45 |
import org.gvsig.compat.net.ICancellable; |
|
46 |
import org.gvsig.fmap.dal.DALLocator; |
|
47 |
import org.gvsig.fmap.dal.DataManager; |
|
48 |
import org.gvsig.fmap.dal.DataServerExplorerPool; |
|
49 |
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry; |
|
50 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
51 |
import org.gvsig.fmap.dal.exception.DataException; |
|
52 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
53 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
54 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
55 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
56 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
57 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
58 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
59 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer; |
|
60 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
|
61 |
import org.gvsig.fmap.dal.store.db.DBStoreParameters; |
|
62 |
import org.gvsig.geodb.vectorialdb.wizard.MyExplorer; |
|
63 |
import org.gvsig.geodb.vectorialdb.wizard.VectorialDBConnectionParamsDialog; |
|
64 |
import org.gvsig.raster.postgis.io.PostGISRasterCoreException; |
|
65 |
import org.gvsig.raster.postgis.swing.AddLayerUI; |
|
66 |
import org.gvsig.raster.postgis.swing.PostGISRasterSwingLocator; |
|
67 |
import org.gvsig.raster.util.CancelTaskImpl; |
|
68 |
import org.gvsig.tools.dynobject.DynObject; |
|
69 |
import org.slf4j.Logger; |
|
70 |
import org.slf4j.LoggerFactory; |
|
71 |
|
|
72 |
/** |
|
73 |
* Wizard panel to add a new PostGIS raster layer |
|
74 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
75 |
*/ |
|
76 |
public class AddPostGISRasterLayerWizard extends WizardPanel implements ActionListener, ListSelectionListener { |
|
77 |
private static final long serialVersionUID = 1L; |
|
78 |
private static final String TAB_NAME = "PostGIS Raster"; |
|
79 |
private static Logger logger = LoggerFactory.getLogger(AddPostGISRasterLayerWizard.class.getName()); |
|
80 |
private AbstractViewPanel view = null; |
|
81 |
private AddLayerUI apiUI = null; |
|
82 |
private ICancellable cancel = null; |
|
83 |
private LayerLoaderManager layerLoaderManager = null; |
|
84 |
private WizardListenerSupport listenerSupport = null; |
|
85 |
|
|
86 |
/** |
|
87 |
* Thread to connect to a PostGIS raster server |
|
88 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
89 |
*/ |
|
90 |
public class ConnectThread extends Thread { |
|
91 |
private ICancellable cancel = null; |
|
92 |
|
|
93 |
public ConnectThread(ICancellable cancel) { |
|
94 |
this.cancel = cancel; |
|
95 |
} |
|
96 |
|
|
97 |
public void run() { |
|
98 |
try { |
|
99 |
layerLoaderManager.loadLayers(); |
|
100 |
} finally { |
|
101 |
((CancelTaskImpl)cancel).setCanceled(false); |
|
102 |
} |
|
103 |
} |
|
104 |
} |
|
105 |
|
|
106 |
public AddPostGISRasterLayerWizard() { |
|
107 |
super(); |
|
108 |
initialize(); |
|
109 |
} |
|
110 |
|
|
111 |
private void initialize() { |
|
112 |
setTabName(PluginServices.getText(this, TAB_NAME)); |
|
113 |
setLayout(null); |
|
114 |
|
|
115 |
IWindow iw = PluginServices.getMDIManager().getActiveWindow(); |
|
116 |
|
|
117 |
if (iw == null) { |
|
118 |
return; |
|
119 |
} |
|
120 |
|
|
121 |
if (!(iw instanceof AbstractViewPanel)) { |
|
122 |
return; |
|
123 |
} |
|
124 |
|
|
125 |
apiUI = PostGISRasterSwingLocator.getSwingManager().createAddLayerUI(); |
|
126 |
apiUI.addListenerToBDSelectionCombo(this); |
|
127 |
apiUI.addListenerToNewDBButton(this); |
|
128 |
apiUI.addListenerToTableSelector(this); |
|
129 |
|
|
130 |
view = (AbstractViewPanel) iw; |
|
131 |
setMapCtrl(view.getMapControl()); |
|
132 |
|
|
133 |
JPanel mainPanel = (JPanel)apiUI.getComponent(); |
|
134 |
mainPanel.setBounds(new java.awt.Rectangle(0, 0, 501, 350)); |
|
135 |
add(mainPanel, null); |
|
136 |
|
|
137 |
layerLoaderManager = new LayerLoaderManager(apiUI); |
|
138 |
|
|
139 |
loadVectorialDBDatasourcesCombo(null); |
|
140 |
} |
|
141 |
|
|
142 |
private WizardListenerSupport getWizardListenerSupport() { |
|
143 |
if(listenerSupport == null) |
|
144 |
listenerSupport = new WizardListenerSupport(); |
|
145 |
return listenerSupport; |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* This method checks for the options selected within the configuration |
|
150 |
* dialog are correct. |
|
151 |
* |
|
152 |
* @return true if you're done, false if not. |
|
153 |
*/ |
|
154 |
public boolean areSettingsValid() { |
|
155 |
return (apiUI.getSelectedTables() != null && apiUI.getSelectedTables().size() > 0); |
|
156 |
} |
|
157 |
|
|
158 |
public void addWizardListener(WizardListener listener) { |
|
159 |
getWizardListenerSupport().addWizardListener(listener); |
|
160 |
getWizardListenerSupport().callStateChanged(false); |
|
161 |
} |
|
162 |
|
|
163 |
public void removeWizardListener(WizardListener listener) { |
|
164 |
getWizardListenerSupport().removeWizardListener(listener); |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* Loads the ComboBox for listing connections |
|
169 |
* @param sel |
|
170 |
*/ |
|
171 |
private void loadVectorialDBDatasourcesCombo(MyExplorer sel) { |
|
172 |
JComboBox combo = apiUI.getDBCombo(); |
|
173 |
DataManager dataManager = DALLocator.getDataManager(); |
|
174 |
DataServerExplorerPool explorersPool = dataManager.getDataServerExplorerPool(); |
|
175 |
Iterator it = explorersPool.iterator(); |
|
176 |
combo.removeAllItems(); |
|
177 |
combo.addItem(""); |
|
178 |
while ( it.hasNext() ) { |
|
179 |
DataServerExplorerPoolEntry entry = (DataServerExplorerPoolEntry) it.next(); |
|
180 |
MyExplorer myExplorer = new MyExplorer(); |
|
181 |
myExplorer.setDbExplorerParameters((DBServerExplorerParameters) entry.getExplorerParameters()); |
|
182 |
myExplorer.setName(entry.getName()); |
|
183 |
combo.addItem(myExplorer); |
|
184 |
if ( sel != null && sel.getName().equalsIgnoreCase(myExplorer.getName()) ) { |
|
185 |
combo.setSelectedItem(myExplorer); |
|
186 |
} |
|
187 |
} |
|
188 |
} |
|
189 |
|
|
190 |
@Override |
|
191 |
public void close() { |
|
192 |
|
|
193 |
} |
|
194 |
|
|
195 |
@Override |
|
196 |
public void execute() { |
|
197 |
layerLoaderManager.showConnectionInfoMessage(PluginServices.getText(this, "loading_postgis_raster_layer")); |
|
198 |
cancel = new CancelTaskImpl(); |
|
199 |
new ConnectThread(cancel).start(); |
|
200 |
} |
|
201 |
|
|
202 |
@Override |
|
203 |
public DataStoreParameters[] getParameters() { |
|
204 |
return null; |
|
205 |
} |
|
206 |
|
|
207 |
@Override |
|
208 |
public void initWizard() { |
|
209 |
|
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* Updates the JList component with the list of tables of |
|
214 |
* the selected database. |
|
215 |
* |
|
216 |
* @param dbSeverExplorerParameters2 |
|
217 |
*/ |
|
218 |
private void updateTableList( |
|
219 |
DBServerExplorerParameters dbSeverExplorerParameters2) { |
|
220 |
if (dbSeverExplorerParameters2 == null) { |
|
221 |
return; |
|
222 |
} |
|
223 |
DataManager dm = DALLocator.getDataManager(); |
|
224 |
DBServerExplorer dbExplorer = null; |
|
225 |
try { |
|
226 |
dbExplorer = (DBServerExplorer) dm.openServerExplorer(dbSeverExplorerParameters2.getExplorerName(), dbSeverExplorerParameters2); |
|
227 |
|
|
228 |
if(dbExplorer == null) { |
|
229 |
throw new Exception(); |
|
230 |
} |
|
231 |
|
|
232 |
List<?> parameters = dbExplorer.list(); |
|
233 |
|
|
234 |
Iterator<?> iter = parameters.iterator(); |
|
235 |
DBStoreParameters param = null; |
|
236 |
apiUI.clearList(); |
|
237 |
while (iter.hasNext()) { |
|
238 |
param = (DBStoreParameters) iter.next(); |
|
239 |
|
|
240 |
//Criterios para a๏ฟฝadir la tabla a la lista |
|
241 |
try { |
|
242 |
if(isTableNamePreffixValid(param) && isRasterTable(param)) { |
|
243 |
apiUI.addElementToTable(new TableListItem(dbExplorer, param)); |
|
244 |
} |
|
245 |
} catch (PostGISRasterCoreException e) { |
|
246 |
logger.info("While getting table names: " + e.getMessage(), e); |
|
247 |
} |
|
248 |
} |
|
249 |
|
|
250 |
} catch (ReadException e) { |
|
251 |
logger.info("While getting table names: " + e.getMessage(), e); |
|
252 |
layerLoaderManager.showConnectionErrorMessage(PluginServices.getText(this, "error_getting_tables")); |
|
253 |
return; |
|
254 |
} catch (Exception e) { |
|
255 |
logger.info("While getting table names: " + e.getMessage(), e); |
|
256 |
layerLoaderManager.showConnectionErrorMessage(PluginServices.getText(this, "error_getting_tables")); |
|
257 |
return; |
|
258 |
} |
|
259 |
} |
|
260 |
|
|
261 |
private boolean isTableNamePreffixValid(DBStoreParameters param) { |
|
262 |
return !param.getTable().startsWith("o_"); |
|
263 |
} |
|
264 |
|
|
265 |
/** |
|
266 |
* Checks is the table has the structure to contain a raster |
|
267 |
* @param param |
|
268 |
* @return |
|
269 |
* @throws PostGISRasterCoreException |
|
270 |
*/ |
|
271 |
private boolean isRasterTable(DBStoreParameters param) throws PostGISRasterCoreException { |
|
272 |
DataManager dm = DALLocator.getDataManager(); |
|
273 |
FeatureStore store; |
|
274 |
try { |
|
275 |
store = (FeatureStore)dm.openStore(param.getDataStoreName(), param); |
|
276 |
|
|
277 |
FeatureType featureType = store.getDefaultFeatureType(); |
|
278 |
if(featureType.size() == 2) { |
|
279 |
if(existsAttr(featureType, "rid") && existsAttr(featureType, "rast")) |
|
280 |
return true; |
|
281 |
} |
|
282 |
store.dispose(); |
|
283 |
} catch (ValidateDataParametersException e) { |
|
284 |
throw new PostGISRasterCoreException(e); |
|
285 |
} catch (InitializeException e) { |
|
286 |
throw new PostGISRasterCoreException(e); |
|
287 |
} catch (ProviderNotRegisteredException e) { |
|
288 |
throw new PostGISRasterCoreException(e); |
|
289 |
} catch (DataException e) { |
|
290 |
throw new PostGISRasterCoreException(e); |
|
291 |
} |
|
292 |
return false; |
|
293 |
} |
|
294 |
|
|
295 |
private boolean existsAttr(FeatureType featureType, String attr) { |
|
296 |
Iterator<?> it = featureType.iterator(); |
|
297 |
while( it.hasNext() ) { |
|
298 |
FeatureAttributeDescriptor attribute = (FeatureAttributeDescriptor)it.next(); |
|
299 |
if(attribute.getName().compareTo(attr) == 0) { |
|
300 |
return true; |
|
301 |
} |
|
302 |
} |
|
303 |
return false; |
|
304 |
} |
|
305 |
|
|
306 |
public void actionPerformed(ActionEvent e) { |
|
307 |
if (apiUI.isAddDBEventObject(e.getSource())) { |
|
308 |
MyExplorer sel = addNewConnection(); |
|
309 |
|
|
310 |
if (sel != null) { |
|
311 |
DBServerExplorerParameters dbExplorerParameters = sel.getDbSeverExplorerParameters(); |
|
312 |
layerLoaderManager.setDBServerExplorerParameters(dbExplorerParameters); |
|
313 |
loadVectorialDBDatasourcesCombo(sel); |
|
314 |
apiUI.getDBCombo().setSelectedItem(sel); |
|
315 |
} |
|
316 |
} |
|
317 |
|
|
318 |
if(e.getSource() == apiUI.getDBCombo()) { |
|
319 |
JComboBox dbCombo = apiUI.getDBCombo(); |
|
320 |
if(dbCombo.getItemCount() == 0) { |
|
321 |
apiUI.clearList(); |
|
322 |
} else { |
|
323 |
Object selected = dbCombo.getSelectedItem(); |
|
324 |
if(selected == null) |
|
325 |
return; |
|
326 |
if (selected instanceof MyExplorer) { |
|
327 |
MyExplorer sel_obj = (MyExplorer) selected; |
|
328 |
dbCombo.repaint(); |
|
329 |
DBServerExplorerParameters dbExplorerParameters = sel_obj.getDbSeverExplorerParameters(); |
|
330 |
layerLoaderManager.setDBServerExplorerParameters(dbExplorerParameters); |
|
331 |
updateTableList(dbExplorerParameters); |
|
332 |
} |
|
333 |
} |
|
334 |
} |
|
335 |
} |
|
336 |
|
|
337 |
/** |
|
338 |
* Adds a new connection using the generic dialog. This function |
|
339 |
* is used when the button add new connection is pressed by the user |
|
340 |
* @return |
|
341 |
*/ |
|
342 |
@SuppressWarnings("unchecked") |
|
343 |
private MyExplorer addNewConnection() { |
|
344 |
MyExplorer myExplorer = new MyExplorer(); |
|
345 |
DBServerExplorerParameters resp = null; |
|
346 |
|
|
347 |
VectorialDBConnectionParamsDialog newco = new VectorialDBConnectionParamsDialog(); |
|
348 |
newco.showDialog(); |
|
349 |
|
|
350 |
if ( !newco.isCanceled()) { |
|
351 |
myExplorer.setDbExplorerParameters(newco.getServerExplorerParameters()); |
|
352 |
myExplorer.setName(newco.getConnectionName()); |
|
353 |
loadVectorialDBDatasourcesCombo(myExplorer); |
|
354 |
return myExplorer; |
|
355 |
} |
|
356 |
return null; |
|
357 |
} |
|
358 |
|
|
359 |
public void valueChanged(ListSelectionEvent e) { |
|
360 |
if (apiUI.isAddTableEvent(e.getSource())) { |
|
361 |
List<Object> tables = apiUI.getSelectedTables(); |
|
362 |
apiUI.clearSubdatasetList(); |
|
363 |
|
|
364 |
if(tables.size() == 1) { |
|
365 |
TableListItem item = (TableListItem)tables.get(0); |
|
366 |
String schema = item.getSchema(); |
|
367 |
String table = item.getTableName(); |
|
368 |
long columns = layerLoaderManager.getNumberOfColumns(schema, table); |
|
369 |
for (int i = 0; i < columns; i++) { |
|
370 |
apiUI.addSubdatasetToTable(schema + "." + table + " rid = " + i); |
|
371 |
} |
|
372 |
} |
|
373 |
getWizardListenerSupport().callStateChanged(areSettingsValid()); |
|
374 |
} |
|
375 |
} |
|
376 |
|
|
377 |
} |
|
0 | 378 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/java/org/gvsig/raster/postgis/app/postgisrasterclient/gui/TableListItem.java | ||
---|---|---|
1 |
package org.gvsig.raster.postgis.app.postgisrasterclient.gui; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer; |
|
4 |
import org.gvsig.fmap.dal.store.db.DBStoreParameters; |
|
5 |
|
|
6 |
/** |
|
7 |
* Represents an element in the list of tables. |
|
8 |
* |
|
9 |
* @author Nacho Brodin (nachobrodin@gmail.org) |
|
10 |
*/ |
|
11 |
public class TableListItem { |
|
12 |
private DBStoreParameters parameters = null; |
|
13 |
private DBServerExplorer explorer = null; |
|
14 |
private String tableName = ""; |
|
15 |
|
|
16 |
public TableListItem(DBServerExplorer explorer, |
|
17 |
DBStoreParameters param) { |
|
18 |
tableName = param.getTable(); |
|
19 |
this.parameters = param; |
|
20 |
this.explorer = explorer; |
|
21 |
} |
|
22 |
|
|
23 |
public String toString() { |
|
24 |
return tableName; |
|
25 |
} |
|
26 |
|
|
27 |
public String getTableName() { |
|
28 |
return tableName; |
|
29 |
} |
|
30 |
|
|
31 |
public String getSchema() { |
|
32 |
return (String)parameters.getDynValue("Schema"); |
|
33 |
} |
|
34 |
|
|
35 |
public DBStoreParameters getDBStoreParameters() { |
|
36 |
return parameters; |
|
37 |
} |
|
38 |
|
|
39 |
public DBServerExplorer getExplorer() { |
|
40 |
return explorer; |
|
41 |
} |
|
42 |
} |
|
0 | 43 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/java/TestReadBandData.java | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import org.gvsig.jgdal.Gdal; |
|
6 |
import org.gvsig.jgdal.GdalRasterBand; |
|
7 |
import org.gvsig.jgdal.GdalException; |
|
8 |
import org.gvsig.jgdal.GdalBuffer; |
|
9 |
|
|
10 |
public class TestReadBandData { |
|
11 |
private Gdal gdal = null; |
|
12 |
private GdalRasterBand band = null; |
|
13 |
private String file1 = "PG:host='130.0.2.122' port='5432' dbname='testgis' user='postgres' password='postgres' schema='public' table='small_world_1tile'"; |
|
14 |
private String file = "/home/nacho/prueba.png"; |
|
15 |
|
|
16 |
public TestReadBandData() throws GdalException, IOException{ |
|
17 |
gdal = new Gdal(); |
|
18 |
gdal.open(file1, 0); |
|
19 |
testStack(); |
|
20 |
} |
|
21 |
|
|
22 |
public void testStack() throws GdalException, IOException{ |
|
23 |
String[] metadata = gdal.getMetadata(); |
|
24 |
for (int i = 0 ; i<metadata.length ; i++){ |
|
25 |
System.out.println("Metadato: " + metadata[i]); |
|
26 |
} |
|
27 |
|
|
28 |
metadata = gdal.getMetadata("Image Structure Metadata"); |
|
29 |
for (int i = 0 ; i<metadata.length ; i++){ |
|
30 |
System.out.println("Metadato: " + metadata[i]); |
|
31 |
} |
|
32 |
|
|
33 |
int w = gdal.getRasterXSize(); |
|
34 |
int h = gdal.getRasterYSize(); |
|
35 |
System.out.println(w + " " + h); |
|
36 |
GdalRasterBand[] b = new GdalRasterBand[3]; |
|
37 |
b[0] = gdal.getRasterBand(1); |
|
38 |
b[1] = gdal.getRasterBand(2); |
|
39 |
b[2] = gdal.getRasterBand(3); |
|
40 |
|
|
41 |
int dt = b[0].getRasterDataType(); |
|
42 |
System.out.println("-- " + dt); |
|
43 |
//GdalBuffer buf = b[0].readRaster(50, 50, 100, 100, 100, 100, dt); |
|
44 |
GdalBuffer buf = b[0].readRaster(0, 0, w, h, w, h, dt); |
|
45 |
byte[] bb = buf.buffByte; |
|
46 |
for(int i = 0; i < /*bb.length*/500; i++) { |
|
47 |
System.out.print(bb[i] + " "); |
|
48 |
} |
|
49 |
//while(true); |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
public static void main(String[] s) { |
|
54 |
try { |
|
55 |
TestReadBandData t = new TestReadBandData(); |
|
56 |
} catch (Exception e) { |
|
57 |
} |
|
58 |
} |
|
59 |
} |
|
0 | 60 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/resources-plugin/about/postgisraster-about.html | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<style type="text/css"> |
|
4 |
BODY { background-image: url(logo.png); background-repeat: no-repeat; background-position: 100% 0% } |
|
5 |
</style> |
|
6 |
</head> |
|
7 |
<body> |
|
8 |
<h2>Soporte PostGIS Raster para gvSIG</h2> |
|
9 |
<p><b>Prodevelop S.L.</b> ha incorporado el soporte al formato raster en |
|
10 |
base de datos <b>PostGres</b></p> |
|
11 |
|
|
12 |
<p><b>Desarrollo:</b></p> |
|
13 |
|
|
14 |
<p>Director del proyecto:</p> |
|
15 |
<ul> |
|
16 |
<li>Miguel Montesinos Lajara</li> |
|
17 |
</ul> |
|
18 |
<p>Equipo de desarrollo:</p> |
|
19 |
<ul> |
|
20 |
<li>Nacho Brodin</li> |
|
21 |
</ul> |
|
22 |
|
|
23 |
<p><b>Colaboradores:</b></p> |
|
24 |
|
|
25 |
<p>Deimos:</p> |
|
26 |
<ul> |
|
27 |
<li>Jorge Arevalo</li> |
|
28 |
</ul> |
|
29 |
|
|
30 |
<p>Build Number de la extensión: 1</p> |
|
31 |
<center> |
|
32 |
<p><b><a href="http://www.prodevelop.es" title="Prodevelop">http://www.prodevelop.es</a></b></p> |
|
33 |
</center> |
|
34 |
|
|
35 |
</body> |
|
36 |
</html> |
|
0 | 37 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/resources-plugin/text.properties | ||
---|---|---|
1 |
error_getting_tables=Error conectando a la BBDD u obteniendo las tablas |
|
2 |
error_creating_layer=Error creando la capa PostGIS |
|
3 |
loading_postgis_raster_layer=La capa se est? cargando.\n. Esta operaci?n puede tardar un poco.\n Por favor, espere a que aparezca en la vista. |
|
4 |
warning=Aviso |
|
0 | 5 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/resources-plugin/text_en.properties | ||
---|---|---|
1 |
error_getting_tables=Error connecting to database or getting the tables |
|
2 |
error_creating_layer=Error creating PostGIS layer |
|
3 |
loading_postgis_raster_layer=The layer is loading.\n. This operation could last a little.\n Please, wait. |
|
4 |
warning=Warning |
|
0 | 5 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<depends plugin-name="org.gvsig.raster.gdal.app" /> |
|
4 |
<depends plugin-name="org.gvsig.geodb"/> |
|
5 |
<libraries library-dir="./lib"/> |
|
6 |
<resourceBundle name="text"/> |
|
7 |
<extensions> |
|
8 |
<extension class-name="org.gvsig.raster.postgis.app.postgisrasterclient.PostGISRasterExtension" |
|
9 |
description="M?dulo de PostGIS Raster." |
|
10 |
active="true" |
|
11 |
priority="1"> |
|
12 |
<!--test<tool-bar name="Test" position="40000"> |
|
13 |
<action-tool icon="none" action-command="" tooltip="" position="1"/> |
|
14 |
</tool-bar>--> |
|
15 |
</extension> |
|
16 |
</extensions> |
|
17 |
</plugin-config> |
|
0 | 18 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/resources-plugin/plugin.dtd | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO_8859-1"?> |
|
2 |
<!ELEMENT class EMPTY > |
|
3 |
<!ATTLIST class name NMTOKEN #REQUIRED > |
|
4 |
|
|
5 |
<!ELEMENT extension ( class | menu | toolBar | toolBoxItem | popupMenu)* > |
|
6 |
<!ATTLIST extension enabled NMTOKEN #IMPLIED > |
|
7 |
<!ATTLIST extension position NMTOKEN #IMPLIED > |
|
8 |
|
|
9 |
<!ELEMENT fileExtension ( class ) > |
|
10 |
<!ATTLIST fileExtension description CDATA #REQUIRED > |
|
11 |
<!ATTLIST fileExtension enabled NMTOKEN #IMPLIED > |
|
12 |
<!ATTLIST fileExtension endsWith CDATA #REQUIRED > |
|
13 |
<!ATTLIST fileExtension dialog CDATA #REQUIRED > |
|
14 |
|
|
15 |
<!ELEMENT import EMPTY > |
|
16 |
<!ATTLIST import plugin NMTOKEN #REQUIRED > |
|
17 |
|
|
18 |
<!ELEMENT libraries ( library+ ) > |
|
19 |
|
|
20 |
<!ELEMENT library EMPTY > |
|
21 |
<!ATTLIST library file NMTOKEN #REQUIRED > |
|
22 |
|
|
23 |
<!ELEMENT menu EMPTY > |
|
24 |
<!ATTLIST menu actionCommand NMTOKEN #IMPLIED > |
|
25 |
<!ATTLIST menu enableText CDATA #IMPLIED > |
|
26 |
<!ATTLIST menu key NMTOKEN #IMPLIED > |
|
27 |
<!ATTLIST menu mnemonic NMTOKEN #IMPLIED > |
|
28 |
<!ATTLIST menu icon CDATA #IMPLIED > |
|
29 |
<!ATTLIST menu text CDATA #REQUIRED > |
|
30 |
<!ATTLIST menu tooltip CDATA #IMPLIED > |
|
31 |
|
|
32 |
<!ELEMENT plugin ( import*, libraries, resourceBundle, labelSet*, extension*, fileExtension*, icon*) > |
|
33 |
|
|
34 |
<!ELEMENT icon EMPTY > |
|
35 |
<!ATTLIST icon src CDATA #REQUIRED > |
|
36 |
<!ATTLIST icon text CDATA #REQUIRED > |
|
37 |
|
|
38 |
<!ELEMENT resourceBundle EMPTY > |
|
39 |
<!ATTLIST resourceBundle name NMTOKEN #REQUIRED > |
|
40 |
|
|
41 |
<!ELEMENT tool EMPTY > |
|
42 |
<!ATTLIST tool actionCommand NMTOKEN #IMPLIED > |
|
43 |
<!ATTLIST tool enableText CDATA #IMPLIED > |
|
44 |
<!ATTLIST tool icon CDATA #IMPLIED > |
|
45 |
<!ATTLIST tool text NMTOKEN #IMPLIED > |
|
46 |
<!ATTLIST tool tooltip CDATA #IMPLIED > |
|
47 |
|
|
48 |
<!ELEMENT toolBar ( tool+ ) > |
|
49 |
<!ATTLIST toolBar name NMTOKEN #IMPLIED > |
|
50 |
|
|
51 |
<!ELEMENT entry EMPTY > |
|
52 |
<!ATTLIST entry text CDATA #IMPLIED > |
|
53 |
<!ATTLIST entry enableText CDATA #IMPLIED > |
|
54 |
<!ATTLIST entry tooltip CDATA #IMPLIED > |
|
55 |
<!ATTLIST entry actionCommand NMTOKEN #IMPLIED > |
|
56 |
|
|
57 |
<!ELEMENT popupMenu ( entry+ ) > |
|
58 |
<!ATTLIST popupMenu name NMTOKEN #IMPLIED > |
|
59 |
|
|
60 |
<!ELEMENT labelSet ( label+ ) > |
|
61 |
<!ATTLIST labelSet class NMTOKEN #REQUIRED > |
|
62 |
|
|
63 |
<!ELEMENT label EMPTY > |
|
64 |
<!ATTLIST label text NMTOKEN #REQUIRED > |
|
65 |
<!ATTLIST label size NMTOKEN #IMPLIED> |
|
66 |
|
|
67 |
<!ELEMENT toolBoxItem EMPTY > |
|
68 |
<!ATTLIST toolBoxItem default NMTOKEN #IMPLIED > |
|
69 |
<!ATTLIST toolBoxItem actionCommand NMTOKEN #IMPLIED > |
|
70 |
<!ATTLIST toolBoxItem icon CDATA #IMPLIED > |
|
71 |
<!ATTLIST toolBoxItem text CDATA #IMPLIED > |
|
72 |
<!ATTLIST toolBoxItem tooltip CDATA #IMPLIED > |
|
0 | 73 |
org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis.app.postgisrasterclient/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.raster.postgis.app.postgisrasterclient</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>Format: PostGIS raster format support</name> |
|
8 |
<description>PostGIS raster adapter for gvSIG</description> |
|
9 |
<parent> |
|
10 |
<groupId>org.gvsig</groupId> |
|
11 |
<artifactId>org.gvsig.raster.postgis</artifactId> |
|
12 |
<version>2.2.2</version> |
|
13 |
</parent> |
|
14 |
|
|
15 |
<scm> |
|
16 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis</connection> |
|
17 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis</developerConnection> |
|
18 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.postgis/tags/org.gvsig.raster.postgis-2.2.2/org.gvsig.raster.postgis</url> |
|
19 |
</scm> |
|
20 |
|
|
21 |
<dependencies> |
|
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>org.gvsig.about.api</artifactId> |
|
25 |
<scope>compile</scope> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>org.gvsig</groupId> |
|
29 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
30 |
<scope>compile</scope> |
|
31 |
</dependency> |
|
32 |
<dependency> |
|
33 |
<groupId>org.gvsig</groupId> |
|
34 |
<artifactId>org.gvsig.raster.postgis.swing.api</artifactId> |
|
35 |
<scope>compile</scope> |
|
36 |
</dependency> |
|
37 |
<dependency> |
|
38 |
<groupId>org.gvsig</groupId> |
|
39 |
<artifactId>org.gvsig.raster.postgis.swing.impl</artifactId> |
|
40 |
<scope>runtime</scope> |
|
41 |
</dependency> |
|
42 |
<dependency> |
|
43 |
<groupId>org.gvsig</groupId> |
|
44 |
<artifactId>org.gvsig.raster.postgis.io</artifactId> |
|
45 |
<scope>compile</scope> |
|
46 |
</dependency> |
|
47 |
<dependency> |
|
48 |
<groupId>org.gvsig</groupId> |
|
49 |
<artifactId>org.gvsig.ui</artifactId> |
|
50 |
<scope>compile</scope> |
|
51 |
</dependency> |
|
52 |
<dependency> |
|
53 |
<groupId>org.gvsig</groupId> |
|
54 |
<artifactId>org.gvsig.raster.fmap</artifactId> |
|
55 |
<scope>compile</scope> |
|
56 |
</dependency> |
|
57 |
<dependency> |
|
58 |
<groupId>org.gvsig</groupId> |
|
59 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
|
60 |
<scope>compile</scope> |
|
61 |
</dependency> |
|
62 |
|
|
63 |
<dependency> |
|
64 |
<groupId>org.gvsig</groupId> |
|
65 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
66 |
<scope>compile</scope> |
|
67 |
</dependency> |
|
68 |
<dependency> |
|
69 |
<groupId>org.gvsig</groupId> |
|
70 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
71 |
<scope>compile</scope> |
|
72 |
</dependency> |
|
73 |
<dependency> |
|
74 |
<groupId>org.gvsig</groupId> |
|
75 |
<artifactId>org.gvsig.i18n</artifactId> |
|
76 |
<scope>compile</scope> |
|
77 |
</dependency> |
|
78 |
<dependency> |
|
79 |
<groupId>org.gvsig</groupId> |
|
80 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
81 |
<scope>compile</scope> |
|
82 |
</dependency> |
|
83 |
<dependency> |
|
84 |
<groupId>org.slf4j</groupId> |
|
85 |
<artifactId>slf4j-api</artifactId> |
|
86 |
<scope>compile</scope> |
|
87 |
</dependency> |
|
88 |
<dependency> |
|
89 |
<groupId>org.slf4j</groupId> |
|
90 |
<artifactId>slf4j-log4j12</artifactId> |
|
91 |
<scope>runtime</scope> |
|
92 |
</dependency> |
|
93 |
<dependency> |
|
94 |
<groupId>org.gvsig</groupId> |
|
95 |
<artifactId>org.gvsig.andami</artifactId> |
|
96 |
<scope>compile</scope> |
|
97 |
</dependency> |
|
98 |
|
|
99 |
<dependency> |
|
100 |
<groupId>org.gvsig</groupId> |
|
101 |
<artifactId>org.gvsig.geodb.app.mainplugin</artifactId> |
|
102 |
<scope>compile</scope> |
|
103 |
</dependency> |
|
104 |
<dependency> |
|
105 |
<groupId>org.gvsig</groupId> |
|
106 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
107 |
<scope>compile</scope> |
|
108 |
</dependency> |
|
109 |
<dependency> |
|
110 |
<groupId>org.gvsig</groupId> |
|
111 |
<artifactId>org.gvsig.fmap.mapcontext.impl</artifactId> |
|
112 |
<scope>runtime</scope> |
|
113 |
</dependency> |
Also available in: Unified diff