Revision 1219
org.gvsig.raster.postgis/tags/buildNumber_8/org.gvsig.raster.postgis/prepare-workspace.xml | ||
---|---|---|
1 |
<project name="org.gvsig.initial.build" default="prepare-workspace"> |
|
2 |
|
|
3 |
<dirname property="org.gvsig.initial.build.basedir" file="${ant.file.org.gvsig.initial.build}" /> |
|
4 |
|
|
5 |
<property name="workspace.basedir" value="${org.gvsig.initial.build.basedir}/.." /> |
|
6 |
<property name="build.basedir" value="${workspace.basedir}/org.gvsig.maven.base.build" description="Eclipse workspace location" /> |
|
7 |
<property name="build.jar.version" value="1.0.8-SNAPSHOT" /> |
|
8 |
<property name="build.jar.file" value="org.gvsig.maven.base.build-${build.jar.version}.jar" /> |
|
9 |
|
|
10 |
<property name="ant.libs.dir" location="${build.basedir}" description="Additional ant tasks libs folder" /> |
|
11 |
|
|
12 |
<target name="check-maven-base-build-available"> |
|
13 |
<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" property="maven-base-build-available" /> |
|
14 |
</target> |
|
15 |
|
|
16 |
<target name="get-maven-base-build-local" depends="check-maven-base-build-available" if="maven-base-build-available"> |
|
17 |
<!-- Unzip de build jar file from the maven repository into the workspace root folder --> |
|
18 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
19 |
<zipfileset src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}"> |
|
20 |
<patternset> |
|
21 |
<exclude name="META-INF/**" /> |
|
22 |
</patternset> |
|
23 |
</zipfileset> |
|
24 |
</copy> |
|
25 |
</target> |
|
26 |
|
|
27 |
<target name="get-maven-base-build-remote" depends="check-maven-base-build-available" unless="maven-base-build-available"> |
|
28 |
<mkdir dir="target" /> |
|
29 |
|
|
30 |
<!-- Download the build jar file --> |
|
31 |
<get src="http://devel.gvsig.org/m2repo/j2se/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" dest="target/${build.jar.file}" verbose="true" /> |
|
32 |
|
|
33 |
<!-- Unzip de build jar file into the workspace root folder --> |
|
34 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
35 |
<zipfileset src="target/${build.jar.file}"> |
|
36 |
<patternset> |
|
37 |
<exclude name="META-INF/**" /> |
|
38 |
</patternset> |
|
39 |
</zipfileset> |
|
40 |
</copy> |
|
41 |
|
|
42 |
</target> |
|
43 |
|
|
44 |
<target name="find.depends.natives.file"> |
|
45 |
<condition property="depends.natives.file.exists"> |
|
46 |
<available file="${org.gvsig.initial.build.basedir}/DEPENDS_ON_NATIVE_LIBRARIES"/> |
|
47 |
</condition> |
|
48 |
</target> |
|
49 |
|
|
50 |
<target name="find.gvsig.platform.properties.file" |
|
51 |
depends="find.depends.natives.file" |
|
52 |
if="depends.natives.file.exists"> |
|
53 |
<condition property="gvsig.platform.exists"> |
|
54 |
<available file="${user.home}/.gvsig.platform.properties"/> |
|
55 |
</condition> |
|
56 |
</target> |
|
57 |
|
|
58 |
<target name="check.gvsig.platform.properties" |
|
59 |
depends="find.gvsig.platform.properties.file"> |
|
60 |
<fail if="depends.natives.file.exists" unless="gvsig.platform.exists"> |
|
61 |
ERROR!! |
|
62 |
|
|
63 |
You have to define your gvSIG platform properties, |
|
64 |
by creating the file: ${user.home}/.gvsig.platform.properties |
|
65 |
with the following content: |
|
66 |
|
|
67 |
native_platform=linux |
|
68 |
native_distribution=all |
|
69 |
native_compiler=gcc4 |
|
70 |
native_arch=i386 |
|
71 |
native_libraryType=dynamic |
|
72 |
export native_classifier=${native_platform}-${native_distribution}-${native_compiler}-${native_arch}-${native_libraryType} |
|
73 |
|
|
74 |
Replace the fifth initial variables values with the ones appropiate |
|
75 |
to your platform. |
|
76 |
|
|
77 |
If you use maven in the command line, you can use the previous file also |
|
78 |
to define the MAVEN_OPTS environment variable, by adding to your |
|
79 |
.bash_rc file something like this: |
|
80 |
|
|
81 |
if [ -f "${HOME}/.gvsig.platform.properties" ] |
|
82 |
then |
|
83 |
. ${HOME}/.gvsig.platform.properties |
|
84 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m -Dnative-classifier=${native_classifier}" |
|
85 |
else |
|
86 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m" |
|
87 |
fi |
|
88 |
|
|
89 |
It will work if you use the bash shell. In any other case or platform, you'll |
|
90 |
have to define your MAVEN_OPTS environment variable and set the |
|
91 |
"native-classifier" parameter directly. |
|
92 |
</fail> |
|
93 |
|
|
94 |
</target> |
|
95 |
|
|
96 |
<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote,check.gvsig.platform.properties"> |
|
97 |
|
|
98 |
<mkdir dir="target" /> |
|
99 |
|
|
100 |
<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug" /> |
|
101 |
|
|
102 |
<!-- Copy the maven launchers to the workspace metadata folder --> |
|
103 |
<copy todir="${workspace.basedir}/.metadata"> |
|
104 |
<fileset dir="${build.basedir}/eclipse-launchers"> |
|
105 |
<exclude name="**/org.eclipse.jdt.core.prefs" /> |
|
106 |
<exclude name="**/org.eclipse.core.variables.prefs" /> |
|
107 |
</fileset> |
|
108 |
</copy> |
|
109 |
|
|
110 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" append="true"> |
|
111 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.jdt.core.prefs" /> |
|
112 |
</concat> |
|
113 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" append="true"> |
|
114 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.core.variables.prefs" /> |
|
115 |
</concat> |
|
116 |
|
|
117 |
<!-- Configure the eclipse workspace --> |
|
118 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace" /> |
|
119 |
|
|
120 |
<!-- Configure the gvSIG profile --> |
|
121 |
<ant antfile="${build.basedir}/check-gvsig-profile.xml" /> |
|
122 |
|
|
123 |
<property name="user-settings-file-location" value="${user.home}/.m2/settings.xml" /> |
|
124 |
|
|
125 |
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"> |
|
126 |
<classpath> |
|
127 |
<pathelement location="${ant.libs.dir}/com.oopsconsultancy.xmltask-1.16.1.jar" /> |
|
128 |
</classpath> |
|
129 |
</taskdef> |
|
130 |
|
|
131 |
<xmltask source="${user-settings-file-location}" dest="${user-settings-file-location}"> |
|
132 |
<copy path="//:settings/:profiles/:profile[:id/text() = 'gvsig-install']/:properties/:gvsig.install.dir/text()" property="current-gvsig-location" /> |
|
133 |
</xmltask> |
|
134 |
|
|
135 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
136 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
137 |
|
|
138 |
<!-- Compile, install and generate eclipse projects --> |
|
139 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse" /> |
|
140 |
|
|
141 |
<echo>INFORMATION!!!</echo> |
|
142 |
<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo> |
|
143 |
|
|
144 |
<!-- TODO: copiar al proyecto de configuración general --> |
|
145 |
</target> |
|
146 |
|
|
147 |
<target name="clean"> |
|
148 |
<delete dir="target" /> |
|
149 |
</target> |
|
150 |
|
|
151 |
</project> |
|
0 | 152 |
org.gvsig.raster.postgis/tags/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
</assembly> |
|
0 | 3 |
org.gvsig.raster.postgis/tags/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>distribution</id> |
|
3 |
<formats> |
|
4 |
<format>dir</format> |
|
5 |
</formats> |
|
6 |
<fileSets> |
|
7 |
<!-- Estructure for the extension --> |
|
8 |
<fileSet> |
|
9 |
<directory>src/main/resources</directory> |
|
10 |
<outputDirectory>${extension.install.dir.name} |
|
11 |
</outputDirectory> |
|
12 |
</fileSet> |
|
13 |
</fileSets> |
|
14 |
<files> |
|
15 |
<file> |
|
16 |
<source>package.info</source> |
|
17 |
<outputDirectory>${extension.install.dir.name}</outputDirectory> |
|
18 |
</file> |
|
19 |
</files> |
|
20 |
<dependencySets> |
|
21 |
<dependencySet> |
|
22 |
<outputDirectory>${extension.install.dir.name}/${library-dir} |
|
23 |
</outputDirectory> |
|
24 |
<includes> |
|
25 |
<include>org.gvsig:org.gvsig.raster.postgis.app.postgisrasterclient:jar</include> |
|
26 |
<include>org.gvsig:org.gvsig.raster.postgis.io:jar</include> |
|
27 |
<include>org.gvsig:org.gvsig.raster.postgis.swing.api:jar</include> |
|
28 |
<include>org.gvsig:org.gvsig.raster.postgis.swing.impl:jar</include> |
|
29 |
</includes> |
|
30 |
</dependencySet> |
|
31 |
</dependencySets> |
|
32 |
</assembly> |
|
0 | 33 |
org.gvsig.raster.postgis/tags/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Wed Aug 08 10:27:07 CEST 2012 |
|
3 |
buildNumber=8 |
|
0 | 4 |
org.gvsig.raster.postgis/tags/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/package.info | ||
---|---|---|
1 |
# |
|
2 |
#Tue Aug 07 14:55:48 CEST 2012 |
|
3 |
owner=gvSIG Association |
|
4 |
code=org.gvsig.raster.postgis.app.postgisrasterclient |
|
5 |
java-version=j1_5 |
|
6 |
official=true |
|
7 |
type=plugin |
|
8 |
version=2.0.0-SNAPSHOT-8 |
|
9 |
state=devel |
|
10 |
operating-system=all |
|
11 |
dependencies=required\: org.gvsig.raster.tilecache -ge 2.0.0-0 |
|
12 |
sources-url=https\://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app.postgisrasterclient |
|
13 |
web-url=http\://www.gvsig.com |
|
14 |
architecture=all |
|
15 |
model-version=1.0.1 |
|
16 |
categories=Database, Raster, Formats |
|
17 |
description=PostGIS raster adapter for gvSIG |
|
18 |
buildNumber=8 |
|
19 |
gvSIG-version=2.0.0 |
|
20 |
name=Format\: PostGIS raster format support |
org.gvsig.raster.postgis/tags/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/resources/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 > |
org.gvsig.raster.postgis/tags/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/resources/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/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/resources/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/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/resources/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/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/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/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/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.RasterDataParameters; |
|
34 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
35 |
import org.gvsig.fmap.dal.exception.DataException; |
|
36 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
37 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
38 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
39 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
40 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
|
41 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
42 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
43 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
44 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
45 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
46 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
47 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
48 |
import org.gvsig.raster.postgis.io.PostGISRasterCoreException; |
|
49 |
import org.gvsig.raster.postgis.io.PostGISRasterServerExplorer; |
|
50 |
import org.gvsig.raster.postgis.io.PostGISRasterServerExplorerParameters; |
|
51 |
import org.gvsig.raster.postgis.swing.AddLayerUI; |
|
52 |
import org.gvsig.raster.util.RasterNotLoadException; |
|
53 |
import org.slf4j.Logger; |
|
54 |
import org.slf4j.LoggerFactory; |
|
55 |
|
|
56 |
/** |
|
57 |
* Manager to load layers in TOC. There are some strategies, load a entire layer |
|
58 |
* or load subdatasets depending on the user selection or the layer structure. |
|
59 |
* |
|
60 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
61 |
*/ |
|
62 |
public class LayerLoaderManager { |
|
63 |
private static int ALL_SUBDATASETS = -2; |
|
64 |
private static int ENTIRE = -1; |
|
65 |
|
|
66 |
private static Logger logger = LoggerFactory.getLogger(AddPostGISRasterLayerWizard.class.getName()); |
|
67 |
private AddLayerUI apiUI = null; |
|
68 |
private DBServerExplorerParameters dbExplorerParameters = null; |
|
69 |
private MapContext mapContext = null; |
|
70 |
|
|
71 |
public LayerLoaderManager(AddLayerUI ui) { |
|
72 |
this.apiUI = ui; |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* Assigns a {@link DBServerExplorerParameters} |
|
77 |
* @param params |
|
78 |
*/ |
|
79 |
public void setDBServerExplorerParameters(DBServerExplorerParameters params) { |
|
80 |
this.dbExplorerParameters = params; |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* Gets the {@link DBServerExplorerParameters} |
|
85 |
* @return {@link DBServerExplorerParameters} |
|
86 |
*/ |
|
87 |
public DBServerExplorerParameters getDBServerExplorerParameters() { |
|
88 |
return this.dbExplorerParameters; |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* Return FLayers if user performs multi selection. |
|
93 |
*/ |
|
94 |
public void loadLayers() { |
|
95 |
if(dbExplorerParameters == null) |
|
96 |
return; |
|
97 |
|
|
98 |
List<Object> tables = apiUI.getSelectedTables(); |
|
99 |
|
|
100 |
//Para una tabla seleccionada |
|
101 |
if(tables.size() == 1) { |
|
102 |
TableListItem item = (TableListItem)tables.get(0); |
|
103 |
String schema = item.getSchema(); |
|
104 |
String table = item.getTableName(); |
|
105 |
|
|
106 |
//Sin subdatasets |
|
107 |
if(getNumberOfColumns(schema, table) == 1) { |
|
108 |
loadOneLayer(item, ENTIRE); |
|
109 |
} |
|
110 |
//Con subdatasets |
|
111 |
else { |
|
112 |
int[] subdatasets = apiUI.getSelectedSubdatasets(); |
|
113 |
if(subdatasets == null || subdatasets.length <= 0) { |
|
114 |
loadOneLayer(item, ALL_SUBDATASETS); |
|
115 |
} else { |
|
116 |
long cols = getNumberOfColumns(schema, table); |
|
117 |
for (int i = 0; i < cols; i++) { |
|
118 |
loadOneLayer(item, i + 1); |
|
119 |
} |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
//Para m?s de una tabla seleccionada (se usan todos los subdatasets) |
|
125 |
if(tables.size() > 1) { |
|
126 |
for (int i = 0; i < tables.size(); i++) { |
|
127 |
TableListItem item = (TableListItem)tables.get(i); |
|
128 |
String schema = item.getSchema(); |
|
129 |
String table = item.getTableName(); |
|
130 |
long subdatasets = getNumberOfColumns(schema, table); |
|
131 |
if(subdatasets == 1) { |
|
132 |
loadOneLayer(item, ENTIRE); |
|
133 |
} |
|
134 |
if(subdatasets > 1) { |
|
135 |
loadOneLayer(item, ALL_SUBDATASETS); |
|
136 |
} |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
} |
|
141 |
|
|
142 |
/** |
|
143 |
* Loads only one layer |
|
144 |
* @param item |
|
145 |
* @param subdataset |
|
146 |
*/ |
|
147 |
private void loadOneLayer(TableListItem item, int subdataset) { |
|
148 |
String host = dbExplorerParameters.getHost(); |
|
149 |
if(host.compareTo("localhost") == 0) |
|
150 |
host = "127.0.0.1"; |
|
151 |
Integer port = dbExplorerParameters.getPort(); |
|
152 |
String dbname = dbExplorerParameters.getDBName(); |
|
153 |
String user = dbExplorerParameters.getUser(); |
|
154 |
String password = dbExplorerParameters.getPassword(); |
|
155 |
String schema = item.getSchema(); |
|
156 |
String table = item.getTableName(); |
|
157 |
String connString = null; |
|
158 |
if(schema == null) |
|
159 |
connString = "PG:host='" + host + "' port='" + port + "' dbname='" + dbname + "' user='" + user + "' password='" + password + "' table='" + table + "'"; |
|
160 |
else |
|
161 |
connString = "PG:host='" + host + "' port='" + port + "' dbname='" + dbname + "' user='" + user + "' password='" + password + "' schema='" + schema + "' table='" + table + "'"; |
|
162 |
|
|
163 |
if(subdataset == ALL_SUBDATASETS) |
|
164 |
connString += " mode='2'"; |
|
165 |
|
|
166 |
if(subdataset >= 0) |
|
167 |
connString += " column='rast' where='rid = "+ subdataset + "'"; |
|
168 |
|
|
169 |
try { |
|
170 |
FLayer layer = createLayer(getFormatedRasterFileName(connString), connString, item, getNumberOfColumns(schema, table)); |
|
171 |
|
|
172 |
//Adds the layer to the view |
|
173 |
getMapContext().beginAtomicEvent(); |
|
174 |
layer.setVisible(true); |
|
175 |
getMapContext().getLayers().addLayer(layer); |
|
176 |
getMapContext().callLegendChanged(); |
|
177 |
getMapContext().endAtomicEvent(); |
|
178 |
getMapContext().invalidate(); |
|
179 |
} catch (LoadLayerException e) { |
|
180 |
logger.info("Error creating layer: " + e.getMessage(), e); |
|
181 |
//showConnectionErrorMessage(PluginServices.getText(this, "error_creating_layer") + ""); |
|
182 |
} |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* Gets the MapContext |
|
187 |
* @return |
|
188 |
*/ |
|
189 |
private MapContext getMapContext() { |
|
190 |
if(mapContext == null) { |
|
191 |
IWindow[] w = PluginServices.getMDIManager().getAllWindows(); |
|
192 |
for (int i = 0; i < w.length; i++) { |
|
193 |
if (w[i] instanceof org.gvsig.app.project.documents.view.gui.AbstractViewPanel) { |
|
194 |
mapContext = ((org.gvsig.app.project.documents.view.gui.AbstractViewPanel)w[i]).getMapControl().getMapContext(); |
|
195 |
} |
|
196 |
} |
|
197 |
} |
|
198 |
return mapContext; |
|
199 |
} |
|
200 |
|
|
201 |
/** |
|
202 |
* Builds a new raster layer |
|
203 |
* @param fileName |
|
204 |
* @return |
|
205 |
* @throws RasterNotLoadException |
|
206 |
* @throws LoadLayerException |
|
207 |
*/ |
|
208 |
@SuppressWarnings("deprecation") |
|
209 |
public FLyrRaster createLayer(String layerName, String conn, TableListItem item, long nColumns) throws LoadLayerException { |
|
210 |
DataManager dataManager = DALLocator.getDataManager(); |
|
211 |
DefaultFLyrRaster lyr = null; |
|
212 |
try { |
|
213 |
PostGISRasterServerExplorerParameters explorerParams = (PostGISRasterServerExplorerParameters) dataManager.createServerExplorerParameters(PostGISRasterServerExplorer.NAME); |
|
214 |
explorerParams.setHost(conn); |
|
215 |
PostGISRasterServerExplorer explorer = (PostGISRasterServerExplorer) dataManager.createServerExplorer(explorerParams); |
|
216 |
RasterDataParameters storeParameters = (RasterDataParameters)explorer.getStoreParameters(); |
|
217 |
storeParameters.setURI(conn); |
|
218 |
storeParameters.setDynValue("BLOCKS", nColumns); |
|
219 |
storeParameters.setDynValue("DBPARAMS", item.getDBStoreParameters()); |
|
220 |
storeParameters.setDynValue("DBEXPLORER", item.getExplorer()); |
|
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 |
} catch (PostGISRasterCoreException e) { |
|
248 |
throw new LoadLayerException("", e); |
|
249 |
} |
|
250 |
|
|
251 |
return lyr; |
|
252 |
} |
|
253 |
|
|
254 |
/** |
|
255 |
* Gets the number of column of the selected table |
|
256 |
* @param schema |
|
257 |
* @param table |
|
258 |
* @return |
|
259 |
*/ |
|
260 |
@SuppressWarnings("deprecation") |
|
261 |
public long getNumberOfColumns(String schema, String table) { |
|
262 |
DataManager manager = DALLocator.getDataManager(); |
|
263 |
try { |
|
264 |
DataStoreParameters params = manager.createStoreParameters("PostgreSQL"); |
|
265 |
|
|
266 |
params.setDynValue("host", dbExplorerParameters.getHost()); |
|
267 |
params.setDynValue("port", dbExplorerParameters.getPort()); |
|
268 |
params.setDynValue("dbuser", dbExplorerParameters.getUser()); |
|
269 |
params.setDynValue("password", dbExplorerParameters.getPassword()); |
|
270 |
params.setDynValue("schema", schema); |
|
271 |
params.setDynValue("dbname", dbExplorerParameters.getDBName()); |
|
272 |
params.setDynValue("table", table); |
|
273 |
|
|
274 |
FeatureStore store = (FeatureStore)manager.createStore(params); |
|
275 |
long size = store.getFeatureCount(); |
|
276 |
store.dispose(); |
|
277 |
return size; |
|
278 |
} catch (DataException e) { |
|
279 |
return 0; |
|
280 |
} catch (ValidateDataParametersException e) { |
|
281 |
return 0; |
|
282 |
} |
|
283 |
} |
|
284 |
|
|
285 |
/** |
|
286 |
* Gets the name of a raster file |
|
287 |
*/ |
|
288 |
private String getFormatedRasterFileName(String name) { |
|
289 |
String newName = ""; |
|
290 |
String schema = null; |
|
291 |
String table = null; |
|
292 |
int index = name.indexOf(" schema='") + 8; |
|
293 |
if(index != -1) { |
|
294 |
try { |
|
295 |
schema = name.substring(index + 1, name.indexOf("'", index + 1)); |
|
296 |
newName += schema + "."; |
|
297 |
} catch (StringIndexOutOfBoundsException e) { |
|
298 |
} |
|
299 |
} |
|
300 |
index = name.indexOf(" table='") + 7; |
|
301 |
if(index != -1) { |
|
302 |
try { |
|
303 |
table = name.substring(index + 1, name.indexOf("'", index + 1)); |
|
304 |
newName += table; |
|
305 |
} catch (StringIndexOutOfBoundsException e) { |
|
306 |
} |
|
307 |
} |
|
308 |
return newName; |
|
309 |
} |
|
310 |
|
|
311 |
/** |
|
312 |
* Shows an error |
|
313 |
* @param _msg |
|
314 |
*/ |
|
315 |
public void showConnectionErrorMessage(String _msg) { |
|
316 |
String msg = (_msg.length() > 300) ? "" : (": " + _msg); |
|
317 |
String title = PluginServices.getText(this, "connection_error"); |
|
318 |
JOptionPane.showMessageDialog(apiUI.getComponent(), title + msg, title, |
|
319 |
JOptionPane.ERROR_MESSAGE); |
|
320 |
} |
|
321 |
|
|
322 |
/** |
|
323 |
* Shows a information window |
|
324 |
* @param _msg |
|
325 |
*/ |
|
326 |
public void showConnectionInfoMessage(String _msg) { |
|
327 |
String msg = (_msg.length() > 300) ? "" : (": " + _msg); |
|
328 |
String title = PluginServices.getText(this, "warning"); |
|
329 |
JOptionPane.showMessageDialog(apiUI.getComponent(), title + msg, title, |
|
330 |
JOptionPane.WARNING_MESSAGE); |
|
331 |
} |
|
332 |
} |
|
0 | 333 |
org.gvsig.raster.postgis/tags/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/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.Iterator; |
|
27 |
import java.util.List; |
|
28 |
import java.util.Map; |
|
29 |
import java.util.Map.Entry; |
|
30 |
|
|
31 |
import javax.swing.JComboBox; |
|
32 |
import javax.swing.JPanel; |
|
33 |
import javax.swing.event.ListSelectionEvent; |
|
34 |
import javax.swing.event.ListSelectionListener; |
|
35 |
|
|
36 |
import org.apache.commons.collections.map.HashedMap; |
|
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.DataStoreParameters; |
|
49 |
import org.gvsig.fmap.dal.exception.DataException; |
|
50 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
51 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
52 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
53 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
54 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
55 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
56 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
57 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer; |
|
58 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
|
59 |
import org.gvsig.fmap.dal.store.db.DBStoreParameters; |
|
60 |
import org.gvsig.geodb.ExtDB_Spatial; |
|
61 |
import org.gvsig.geodb.vectorialdb.wizard.MyExplorer; |
|
62 |
import org.gvsig.geodb.vectorialdb.wizard.VectorialDBConnectionParamsDialog; |
|
63 |
import org.gvsig.raster.postgis.io.PostGISRasterCoreException; |
|
64 |
import org.gvsig.raster.postgis.swing.AddLayerUI; |
|
65 |
import org.gvsig.raster.postgis.swing.PostGISRasterSwingLocator; |
|
66 |
import org.gvsig.raster.util.CancelTaskImpl; |
|
67 |
import org.gvsig.tools.dynobject.DynObject; |
|
68 |
import org.slf4j.Logger; |
|
69 |
import org.slf4j.LoggerFactory; |
|
70 |
|
|
71 |
/** |
|
72 |
* Wizard panel to add a new PostGIS raster layer |
|
73 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
74 |
*/ |
|
75 |
public class AddPostGISRasterLayerWizard extends WizardPanel implements ActionListener, ListSelectionListener { |
|
76 |
private static final long serialVersionUID = 1L; |
|
77 |
private static final String TAB_NAME = "PostGIS Raster"; |
|
78 |
private static Logger logger = LoggerFactory.getLogger(AddPostGISRasterLayerWizard.class.getName()); |
|
79 |
private AbstractViewPanel view = null; |
|
80 |
private AddLayerUI apiUI = null; |
|
81 |
private ICancellable cancel = null; |
|
82 |
private LayerLoaderManager layerLoaderManager = null; |
|
83 |
private WizardListenerSupport listenerSupport = null; |
|
84 |
|
|
85 |
/** |
|
86 |
* Thread to connect to a PostGIS raster server |
|
87 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
88 |
*/ |
|
89 |
public class ConnectThread extends Thread { |
|
90 |
private ICancellable cancel = null; |
|
91 |
|
|
92 |
public ConnectThread(ICancellable cancel) { |
|
93 |
this.cancel = cancel; |
|
94 |
} |
|
95 |
|
|
96 |
public void run() { |
|
97 |
try { |
|
98 |
layerLoaderManager.loadLayers(); |
|
99 |
} finally { |
|
100 |
((CancelTaskImpl)cancel).setCanceled(false); |
|
101 |
} |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
public AddPostGISRasterLayerWizard() { |
|
106 |
super(); |
|
107 |
initialize(); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* This method initializes this |
|
112 |
* |
|
113 |
* @return void |
|
114 |
*/ |
|
115 |
private void initialize() { |
|
116 |
setTabName(PluginServices.getText(this, TAB_NAME)); |
|
117 |
setLayout(null); |
|
118 |
|
|
119 |
IWindow iw = PluginServices.getMDIManager().getActiveWindow(); |
|
120 |
|
|
121 |
if (iw == null) { |
|
122 |
return; |
|
123 |
} |
|
124 |
|
|
125 |
if (!(iw instanceof AbstractViewPanel)) { |
|
126 |
return; |
|
127 |
} |
|
128 |
|
|
129 |
apiUI = PostGISRasterSwingLocator.getSwingManager().createAddLayerUI(); |
|
130 |
apiUI.addListenerToBDSelectionCombo(this); |
|
131 |
apiUI.addListenerToNewDBButton(this); |
|
132 |
apiUI.addListenerToTableSelector(this); |
|
133 |
|
|
134 |
view = (AbstractViewPanel) iw; |
|
135 |
setMapCtrl(view.getMapControl()); |
|
136 |
|
|
137 |
JPanel mainPanel = (JPanel)apiUI.getComponent(); |
|
138 |
mainPanel.setBounds(new java.awt.Rectangle(0, 0, 501, 350)); |
|
139 |
add(mainPanel, null); |
|
140 |
|
|
141 |
layerLoaderManager = new LayerLoaderManager(apiUI); |
|
142 |
|
|
143 |
loadVectorialDBDatasourcesCombo(null); |
|
144 |
} |
|
145 |
|
|
146 |
private WizardListenerSupport getWizardListenerSupport() { |
|
147 |
if(listenerSupport == null) |
|
148 |
listenerSupport = new WizardListenerSupport(); |
|
149 |
return listenerSupport; |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* This method checks for the options selected within the configuration |
|
154 |
* dialog are correct. |
|
155 |
* |
|
156 |
* @return true if you're done, false if not. |
|
157 |
*/ |
|
158 |
public boolean areSettingsValid() { |
|
159 |
return (apiUI.getSelectedTables() != null && apiUI.getSelectedTables().size() > 0); |
|
160 |
} |
|
161 |
|
|
162 |
/* |
|
163 |
* (non-Javadoc) |
|
164 |
* @see org.gvsig.app.gui.WizardPanel#addWizardListener(org.gvsig.app.gui.wizards.WizardListener) |
|
165 |
*/ |
|
166 |
public void addWizardListener(WizardListener listener) { |
|
167 |
getWizardListenerSupport().addWizardListener(listener); |
|
168 |
getWizardListenerSupport().callStateChanged(false); |
|
169 |
} |
|
170 |
|
|
171 |
/* |
|
172 |
* (non-Javadoc) |
|
173 |
* @see org.gvsig.app.gui.WizardPanel#removeWizardListener(org.gvsig.app.gui.wizards.WizardListener) |
|
174 |
*/ |
|
175 |
public void removeWizardListener(WizardListener listener) { |
|
176 |
getWizardListenerSupport().removeWizardListener(listener); |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* Loads the ComboBox for listing connections |
|
181 |
* @param sel |
|
182 |
*/ |
|
183 |
@SuppressWarnings("unchecked") |
|
184 |
private void loadVectorialDBDatasourcesCombo(MyExplorer sel) { |
|
185 |
JComboBox combo = apiUI.getDBCombo(); |
|
186 |
PluginsManager manager = PluginsLocator.getManager(); |
|
187 |
DynObject values = manager.getPlugin(ExtDB_Spatial.class).getPluginProperties(); |
|
188 |
Map connections = (Map) values.getDynValue("db_connections"); |
|
189 |
if (connections != null){ |
|
190 |
Iterator it = connections.entrySet().iterator(); |
|
191 |
combo.removeAllItems(); |
|
192 |
combo.addItem(""); |
|
193 |
while (it.hasNext()){ |
|
194 |
Map.Entry entry = (Entry) it.next(); |
|
195 |
MyExplorer myExplorer = new MyExplorer(); |
|
196 |
myExplorer.setDbExplorerParameters((DBServerExplorerParameters) entry.getValue()); |
|
197 |
myExplorer.setName((String) entry.getKey()); |
|
198 |
combo.addItem(myExplorer); |
|
199 |
if(sel!=null && sel.getName().equalsIgnoreCase(myExplorer.getName())){ |
|
200 |
combo.setSelectedItem(myExplorer); |
|
201 |
} |
|
202 |
} |
|
203 |
} else { |
|
204 |
connections = new HashedMap(); |
|
205 |
values.setDynValue("db_connections", connections); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
@Override |
|
210 |
public void close() { |
|
211 |
|
|
212 |
} |
|
213 |
|
|
214 |
@Override |
|
215 |
public void execute() { |
|
216 |
layerLoaderManager.showConnectionInfoMessage(PluginServices.getText(this, "loading_postgis_raster_layer")); |
|
217 |
cancel = new CancelTaskImpl(); |
|
218 |
new ConnectThread(cancel).start(); |
|
219 |
} |
|
220 |
|
|
221 |
@Override |
|
222 |
public DataStoreParameters[] getParameters() { |
|
223 |
return null; |
|
224 |
} |
|
225 |
|
|
226 |
@Override |
|
227 |
public void initWizard() { |
|
228 |
|
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* Updates the JList component with the list of tables of |
|
233 |
* the selected database. |
|
234 |
* |
|
235 |
* @param dbSeverExplorerParameters2 |
|
236 |
*/ |
|
237 |
@SuppressWarnings("unchecked") |
|
238 |
private void updateTableList( |
|
239 |
DBServerExplorerParameters dbSeverExplorerParameters2) { |
|
240 |
if (dbSeverExplorerParameters2 == null) { |
|
241 |
return; |
|
242 |
} |
|
243 |
DataManager dm = DALLocator.getDataManager(); |
|
244 |
DBServerExplorer dbExplorer = null; |
|
245 |
try { |
|
246 |
dbExplorer = (DBServerExplorer) dm.openServerExplorer(dbSeverExplorerParameters2.getExplorerName(), dbSeverExplorerParameters2); |
|
247 |
|
|
248 |
if(dbExplorer == null) { |
|
249 |
throw new Exception(); |
|
250 |
} |
|
251 |
|
|
252 |
List parameters = dbExplorer.list(); |
|
253 |
|
|
254 |
Iterator iter = parameters.iterator(); |
|
255 |
DBStoreParameters param = null; |
|
256 |
apiUI.clearList(); |
|
257 |
while (iter.hasNext()) { |
|
258 |
param = (DBStoreParameters) iter.next(); |
|
259 |
|
|
260 |
//Criterios para a?adir la tabla a la lista |
|
261 |
try { |
|
262 |
if(/*!param.getTable().startsWith("o_") &&*/ isRasterTable(param)) { |
|
263 |
apiUI.addElementToTable(new TableListItem(dbExplorer, param)); |
|
264 |
} |
|
265 |
} catch (PostGISRasterCoreException e) { |
|
266 |
logger.info("While getting table names: " + e.getMessage(), e); |
|
267 |
} |
|
268 |
} |
|
269 |
|
|
270 |
} catch (ReadException e) { |
|
271 |
logger.info("While getting table names: " + e.getMessage(), e); |
|
272 |
layerLoaderManager.showConnectionErrorMessage(PluginServices.getText(this, "error_getting_tables")); |
|
273 |
return; |
|
274 |
} catch (Exception e) { |
|
275 |
logger.info("While getting table names: " + e.getMessage(), e); |
|
276 |
layerLoaderManager.showConnectionErrorMessage(PluginServices.getText(this, "error_getting_tables")); |
|
277 |
return; |
|
278 |
} |
|
279 |
} |
|
280 |
|
|
281 |
/** |
|
282 |
* Checks is the table has the structure to contain a raster |
|
283 |
* @param param |
|
284 |
* @return |
|
285 |
* @throws PostGISRasterCoreException |
|
286 |
*/ |
|
287 |
@SuppressWarnings({ "deprecation" }) |
|
288 |
private boolean isRasterTable(DBStoreParameters param) throws PostGISRasterCoreException { |
|
289 |
DataManager dm = DALLocator.getDataManager(); |
|
290 |
FeatureStore store; |
|
291 |
try { |
|
292 |
store = (FeatureStore)dm.createStore(param); |
|
293 |
|
|
294 |
FeatureType featureType = store.getDefaultFeatureType(); |
|
295 |
if(featureType.size() == 2) { |
|
296 |
if(existsAttr(featureType, "rid") && existsAttr(featureType, "rast")) |
|
297 |
return true; |
|
298 |
} |
|
299 |
store.dispose(); |
|
300 |
} catch (ValidateDataParametersException e) { |
|
301 |
throw new PostGISRasterCoreException(e); |
|
302 |
} catch (InitializeException e) { |
|
303 |
throw new PostGISRasterCoreException(e); |
|
304 |
} catch (ProviderNotRegisteredException e) { |
|
305 |
throw new PostGISRasterCoreException(e); |
|
306 |
} catch (DataException e) { |
|
307 |
throw new PostGISRasterCoreException(e); |
|
308 |
} |
|
309 |
return false; |
|
310 |
} |
|
311 |
|
|
312 |
@SuppressWarnings("unchecked") |
|
313 |
private boolean existsAttr(FeatureType featureType, String attr) { |
|
314 |
Iterator it = featureType.iterator(); |
|
315 |
while( it.hasNext() ) { |
|
316 |
FeatureAttributeDescriptor attribute = (FeatureAttributeDescriptor)it.next(); |
|
317 |
if(attribute.getName().compareTo(attr) == 0) { |
|
318 |
return true; |
|
319 |
} |
|
320 |
} |
|
321 |
return false; |
|
322 |
} |
|
323 |
|
|
324 |
/* |
|
325 |
* (non-Javadoc) |
|
326 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
327 |
*/ |
|
328 |
public void actionPerformed(ActionEvent e) { |
|
329 |
if (apiUI.isAddDBEventObject(e.getSource())) { |
|
330 |
MyExplorer sel = addNewConnection(); |
|
331 |
|
|
332 |
if (sel != null) { |
|
333 |
DBServerExplorerParameters dbExplorerParameters = sel.getDbSeverExplorerParameters(); |
|
334 |
layerLoaderManager.setDBServerExplorerParameters(dbExplorerParameters); |
|
335 |
loadVectorialDBDatasourcesCombo(sel); |
|
336 |
apiUI.getDBCombo().setSelectedItem(sel); |
|
337 |
} |
|
338 |
} |
|
339 |
|
|
340 |
if(e.getSource() == apiUI.getDBCombo()) { |
|
341 |
JComboBox dbCombo = apiUI.getDBCombo(); |
|
342 |
if(dbCombo.getItemCount() == 0) { |
|
343 |
apiUI.clearList(); |
|
344 |
} else { |
|
345 |
Object selected = dbCombo.getSelectedItem(); |
|
346 |
if(selected == null) |
|
347 |
return; |
|
348 |
if (selected instanceof MyExplorer) { |
|
349 |
MyExplorer sel_obj = (MyExplorer) selected; |
|
350 |
dbCombo.repaint(); |
|
351 |
DBServerExplorerParameters dbExplorerParameters = sel_obj.getDbSeverExplorerParameters(); |
|
352 |
layerLoaderManager.setDBServerExplorerParameters(dbExplorerParameters); |
|
353 |
updateTableList(dbExplorerParameters); |
|
354 |
} |
|
355 |
} |
|
356 |
} |
|
357 |
} |
|
358 |
|
|
359 |
/** |
|
360 |
* Adds a new connection using the generic dialog. This function |
|
361 |
* is used when the button add new connection is pressed by the user |
|
362 |
* @return |
|
363 |
*/ |
|
364 |
@SuppressWarnings("unchecked") |
|
365 |
private MyExplorer addNewConnection() { |
|
366 |
MyExplorer myExplorer = new MyExplorer(); |
|
367 |
DBServerExplorerParameters resp = null; |
|
368 |
|
|
369 |
VectorialDBConnectionParamsDialog newco = new VectorialDBConnectionParamsDialog(); |
|
370 |
newco.showDialog(); |
|
371 |
|
|
372 |
if (newco.isOkPressed()) { |
|
373 |
try { |
|
374 |
resp = newco.getParameters(); |
|
375 |
} catch (Exception e) { |
|
376 |
layerLoaderManager.showConnectionErrorMessage(e.getMessage()); |
|
377 |
return null; |
|
378 |
} |
|
379 |
PluginsManager manager = PluginsLocator.getManager(); |
|
380 |
DynObject values = manager.getPlugin(ExtDB_Spatial.class).getPluginProperties(); |
|
381 |
Map connections = (Map) values.getDynValue("db_connections"); |
|
382 |
if(connections == null){ |
|
383 |
connections = new HashedMap(); |
|
384 |
values.setDynValue("db_connections", connections); |
|
385 |
} |
|
386 |
connections.put(newco.getConnectionName(), resp); |
|
387 |
|
|
388 |
myExplorer.setDbExplorerParameters(resp); |
|
389 |
myExplorer.setName(newco.getConnectionName()); |
|
390 |
return myExplorer; |
|
391 |
} else { |
|
392 |
return null; |
|
393 |
} |
|
394 |
} |
|
395 |
|
|
396 |
/* |
|
397 |
* (non-Javadoc) |
|
398 |
* @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) |
|
399 |
*/ |
|
400 |
public void valueChanged(ListSelectionEvent e) { |
|
401 |
if (apiUI.isAddTableEvent(e.getSource())) { |
|
402 |
List<Object> tables = apiUI.getSelectedTables(); |
|
403 |
apiUI.clearSubdatasetList(); |
|
404 |
|
|
405 |
if(tables.size() == 1) { |
|
406 |
TableListItem item = (TableListItem)tables.get(0); |
|
407 |
String schema = item.getSchema(); |
|
408 |
String table = item.getTableName(); |
|
409 |
long columns = layerLoaderManager.getNumberOfColumns(schema, table); |
|
410 |
for (int i = 0; i < columns; i++) { |
|
411 |
apiUI.addSubdatasetToTable(schema + "." + table + " rid = " + i); |
|
412 |
} |
|
413 |
} |
|
414 |
getWizardListenerSupport().callStateChanged(areSettingsValid()); |
|
415 |
} |
|
416 |
} |
|
417 |
|
|
418 |
} |
|
0 | 419 |
org.gvsig.raster.postgis/tags/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/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/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/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 java.io.IOException; |
|
22 |
|
|
23 |
import org.gvsig.about.AboutManager; |
|
24 |
import org.gvsig.about.AboutParticipant; |
|
25 |
import org.gvsig.andami.plugins.Extension; |
|
26 |
import org.gvsig.app.ApplicationLocator; |
|
27 |
import org.gvsig.app.ApplicationManager; |
|
28 |
import org.gvsig.app.extension.AddLayer; |
|
29 |
import org.gvsig.jgdal.Gdal; |
|
30 |
import org.gvsig.jgdal.GdalBuffer; |
|
31 |
import org.gvsig.jgdal.GdalException; |
|
32 |
import org.gvsig.jgdal.GdalRasterBand; |
|
33 |
import org.gvsig.raster.postgis.app.postgisrasterclient.gui.AddPostGISRasterLayerWizard; |
|
34 |
|
|
35 |
/** |
|
36 |
* Entry point for PostGISRaster extension |
|
37 |
* |
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.org) |
|
39 |
*/ |
|
40 |
public class PostGISRasterExtension extends Extension { |
|
41 |
/** |
|
42 |
* Initializes the wizard panel |
|
43 |
* |
|
44 |
*/ |
|
45 |
public void initialize() { |
|
46 |
initializeIcons(); |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* @see com.iver.andami.plugins.IExtension#postInitialize() |
|
51 |
*/ |
|
52 |
@Override |
|
53 |
public void postInitialize() { |
|
54 |
super.postInitialize(); |
|
55 |
addAboutInfo(); |
|
56 |
|
|
57 |
AddLayer.addWizard(AddPostGISRasterLayerWizard.class); |
|
58 |
} |
|
59 |
|
|
60 |
private void addAboutInfo() { |
|
61 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
62 |
|
|
63 |
AboutManager about = application.getAbout(); |
|
64 |
about.addDeveloper("PRODEVELOP", getClass().getClassLoader() |
|
65 |
.getResource("about/postgisraster-about.html"), 2); |
|
66 |
|
|
67 |
AboutParticipant participant = about.getDeveloper("PRODEVELOP"); |
|
68 |
participant.addContribution( |
|
69 |
"PostGIS Raster", |
|
70 |
"Soporte para BBDD r?ster usando PostGIS", |
|
71 |
2011,12,1, |
|
72 |
2011,12,31 |
|
73 |
); |
|
74 |
} |
|
75 |
|
|
76 |
public void execute(String actionCommand) { |
|
77 |
try { |
|
78 |
test(); |
|
79 |
} catch (GdalException e) { |
|
80 |
e.printStackTrace(); |
|
81 |
} catch (IOException e) { |
|
82 |
e.printStackTrace(); |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
private void test() throws GdalException, IOException{ |
|
87 |
Gdal gdal = new Gdal(); |
|
88 |
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); |
|
89 |
int w = gdal.getRasterXSize(); |
|
90 |
int h = gdal.getRasterYSize(); |
|
91 |
System.out.println(w + " " + h); |
|
92 |
GdalRasterBand[] b = new GdalRasterBand[3]; |
|
93 |
b[0] = gdal.getRasterBand(1); |
|
94 |
b[1] = gdal.getRasterBand(2); |
|
95 |
b[2] = gdal.getRasterBand(3); |
|
96 |
|
|
97 |
int dt = b[0].getRasterDataType(); |
|
98 |
GdalBuffer buf = b[0].readRaster(0, 0, w, h, w, h, dt); |
|
99 |
byte[] bb = buf.buffByte; |
|
100 |
for(int i = 0; i < 10; i++) { |
|
101 |
System.out.print(bb[i] + " "); |
|
102 |
} |
|
103 |
gdal.close(); |
|
104 |
} |
|
105 |
|
|
106 |
|
|
107 |
public boolean isEnabled() { |
|
108 |
return true; |
|
109 |
} |
|
110 |
|
|
111 |
public boolean isVisible() { |
|
112 |
return true; |
|
113 |
} |
|
114 |
|
|
115 |
void initializeIcons(){ |
|
116 |
|
|
117 |
} |
|
118 |
} |
|
0 | 119 |
org.gvsig.raster.postgis/tags/buildNumber_8/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
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 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.raster.postgis.app</artifactId> |
|
11 |
<version>2.0.0-SNAPSHOT</version> |
|
12 |
</parent> |
|
13 |
<description>PostGIS raster adapter for gvSIG</description> |
|
14 |
<dependencies> |
|
15 |
<dependency> |
Also available in: Unified diff