Revision 1906
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/CMakeModules/FindGDAL.cmake | ||
---|---|---|
1 |
# Locate gdal |
|
2 |
# This module defines |
|
3 |
# GDAL_LIBRARY |
|
4 |
# GDAL_FOUND, if false, do not try to link to gdal |
|
5 |
# GDAL_INCLUDE_DIR, where to find the headers |
|
6 |
# |
|
7 |
# $GDALDIR is an environment variable that would |
|
8 |
# correspond to the ./configure --prefix=$GDAL_DIR |
|
9 |
# used in building gdal. |
|
10 |
# |
|
11 |
# Created by Eric Wing. I'm not a gdal user, but OpenSceneGraph uses it |
|
12 |
# for osgTerrain so I whipped this module together for completeness. |
|
13 |
# I actually don't know the conventions or where files are typically |
|
14 |
# placed in distros. |
|
15 |
# Any real gdal users are encouraged to correct this (but please don't |
|
16 |
# break the OS X framework stuff when doing so which is what usually seems |
|
17 |
# to happen). |
|
18 |
|
|
19 |
# This makes the presumption that you are include gdal.h like |
|
20 |
# #include "gdal.h" |
|
21 |
|
|
22 |
FIND_PATH(GDAL_INCLUDE_DIR gdal.h |
|
23 |
PATHS |
|
24 |
$ENV{GDAL_DIR} |
|
25 |
NO_DEFAULT_PATH |
|
26 |
PATH_SUFFIXES include |
|
27 |
) |
|
28 |
|
|
29 |
FIND_PATH(GDAL_INCLUDE_DIR gdal.h |
|
30 |
PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this. |
|
31 |
NO_DEFAULT_PATH |
|
32 |
PATH_SUFFIXES include |
|
33 |
) |
|
34 |
|
|
35 |
FIND_PATH(GDAL_INCLUDE_DIR gdal.h |
|
36 |
PATHS |
|
37 |
${DEPMAN_PATH}/include |
|
38 |
/home/nacho/Escritorio/gdal-1.6.3-linux-all-gcc4-i386-dynamic/include |
|
39 |
#/home/nacho/Escritorio/gdal-1.8.1/gcore |
|
40 |
~/Library/Frameworks/gdal.framework/Headers |
|
41 |
/Library/Frameworks/gdal.framework/Headers |
|
42 |
/usr/local/include/gdal |
|
43 |
/usr/local/include/GDAL |
|
44 |
/usr/local/include |
|
45 |
/usr/include/gdal |
|
46 |
/usr/include/GDAL |
|
47 |
/usr/include |
|
48 |
/sw/include/gdal |
|
49 |
/sw/include/GDAL |
|
50 |
/sw/include # Fink |
|
51 |
/opt/local/include/gdal |
|
52 |
/opt/local/include/GDAL |
|
53 |
/opt/local/include # DarwinPorts |
|
54 |
/opt/csw/include/gdal |
|
55 |
/opt/csw/include/GDAL |
|
56 |
/opt/csw/include # Blastwave |
|
57 |
/opt/include/gdal |
|
58 |
/opt/include/GDAL |
|
59 |
/opt/include |
|
60 |
) |
|
61 |
|
|
62 |
MARK_AS_ADVANCED(GDAL_INCLUDE_DIR) |
|
63 |
|
|
64 |
FIND_LIBRARY(GDAL_LIBRARY |
|
65 |
NAMES gdal gdal_i gdal1.7.0 gdal1.6.0 gdal1.5.0 gdal1.4.0 gdal1.3.2 GDAL |
|
66 |
PATHS |
|
67 |
/home/nacho/Escritorio/gdal-1.6.3-linux-all-gcc4-i386-dynamic/lib |
|
68 |
#/home/nacho/Escritorio/gdal-1.8.1/.libs |
|
69 |
$ENV{GDAL_DIR} |
|
70 |
NO_DEFAULT_PATH |
|
71 |
PATH_SUFFIXES lib64 lib |
|
72 |
) |
|
73 |
FIND_LIBRARY(GDAL_LIBRARY |
|
74 |
NAMES gdal gdal_i gdal1.7.0 gdal1.6.0 gdal1.5.0 gdal1.4.0 gdal1.3.2 GDAL |
|
75 |
PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this. |
|
76 |
NO_DEFAULT_PATH |
|
77 |
PATH_SUFFIXES lib64 lib |
|
78 |
) |
|
79 |
FIND_LIBRARY(GDAL_LIBRARY |
|
80 |
NAMES gdal gdal_i gdal1.7.0 gdal1.6.0 gdal1.5.0 gdal1.4.0 gdal1.3.2 GDAL |
|
81 |
PATHS |
|
82 |
${DEPMAN_PATH}/lib |
|
83 |
~/Library/Frameworks |
|
84 |
/Library/Frameworks |
|
85 |
/usr/local |
|
86 |
/usr |
|
87 |
/sw |
|
88 |
/opt/local |
|
89 |
/opt/csw |
|
90 |
/opt |
|
91 |
/usr/freeware |
|
92 |
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;GDAL_ROOT]/lib |
|
93 |
PATH_SUFFIXES lib64 lib |
|
94 |
) |
|
95 |
|
|
96 |
MARK_AS_ADVANCED(GDAL_LIBRARY) |
|
97 |
|
|
98 |
SET(GDAL_FOUND "NO") |
|
99 |
IF(GDAL_LIBRARY AND GDAL_INCLUDE_DIR) |
|
100 |
SET(GDAL_FOUND "YES") |
|
101 |
SET(GDAL_LIBRARY_DEBUG ${GDAL_LIBRARY}) |
|
102 |
ENDIF(GDAL_LIBRARY AND GDAL_INCLUDE_DIR) |
|
103 |
|
|
104 |
|
|
105 |
|
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/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://gvsig-desktop.forge.osor.eu/downloads/pub/projects/gvSIG-desktop/maven-repository/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> |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
2 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.jgdal</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<version>2.0.3-SNAPSHOT</version> |
|
8 |
<name>org.gvsig.jgdal</name> |
|
9 |
<parent> |
|
10 |
<groupId>org.gvsig</groupId> |
|
11 |
<artifactId>gvsig-base-library-jni-pom</artifactId> |
|
12 |
<version>2.0-SNAPSHOT</version> |
|
13 |
</parent> |
|
14 |
<properties> |
|
15 |
<build-dir>${basedir}/../../build</build-dir> |
|
16 |
<eclipse.project.name>org.gvsig.jgdal</eclipse.project.name> |
|
17 |
</properties> |
|
18 |
<build> |
|
19 |
<plugins> |
|
20 |
<!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION --> |
|
21 |
<plugin> |
|
22 |
<groupId>org.apache.maven.plugins</groupId> |
|
23 |
<artifactId>maven-surefire-plugin</artifactId> |
|
24 |
<configuration> |
|
25 |
<skipTests>true</skipTests> |
|
26 |
</configuration> |
|
27 |
</plugin> |
|
28 |
</plugins> |
|
29 |
</build> |
|
30 |
<profiles> |
|
31 |
<profile> |
|
32 |
<id>windows-profile</id> |
|
33 |
<activation> |
|
34 |
<property> |
|
35 |
<name>native-platform</name> |
|
36 |
<value>win</value> |
|
37 |
</property> |
|
38 |
</activation> |
|
39 |
<properties> |
|
40 |
<!-- This hack is necessary to allow correct search in windows --> |
|
41 |
<build-dir>${basedir}\..\..\build</build-dir> |
|
42 |
</properties> |
|
43 |
<dependencies> |
|
44 |
<dependency> |
|
45 |
<groupId>org.gdal</groupId> |
|
46 |
<artifactId>gdal</artifactId> |
|
47 |
<version>1.7.1</version> |
|
48 |
<classifier>${native-classifier}</classifier> |
|
49 |
<type>tar.gz</type> |
|
50 |
</dependency> |
|
51 |
<dependency> |
|
52 |
<groupId>com.microsoft</groupId> |
|
53 |
<artifactId>visualcppredist</artifactId> |
|
54 |
<version>2008</version> |
|
55 |
<classifier>${native-classifier}</classifier> |
|
56 |
<type>tar.gz</type> |
|
57 |
</dependency> |
|
58 |
</dependencies> |
|
59 |
</profile> |
|
60 |
<profile> |
|
61 |
<id>linux-profile</id> |
|
62 |
<activation> |
|
63 |
<property> |
|
64 |
<name>native-platform</name> |
|
65 |
<value>linux</value> |
|
66 |
</property> |
|
67 |
</activation> |
|
68 |
<dependencies> |
|
69 |
<dependency> |
|
70 |
<groupId>org.gdal</groupId> |
|
71 |
<artifactId>gdal</artifactId> |
|
72 |
<version>1.6.3</version> |
|
73 |
<classifier>${native-classifier}</classifier> |
|
74 |
<type>tar.gz</type> |
|
75 |
</dependency> |
|
76 |
<!-- <dependency> <groupId>eu.fbk</groupId> <artifactId>grass</artifactId> |
|
77 |
<version>6.0.2</version> <classifier>${native-classifier}</classifier> <type>tar.gz</type> |
|
78 |
<scope>runtime</scope> </dependency> --> |
|
79 |
</dependencies> |
|
80 |
</profile> |
|
81 |
<profile> |
|
82 |
<id>mac-profile</id> |
|
83 |
<activation> |
|
84 |
<property> |
|
85 |
<name>native-platform</name> |
|
86 |
<value>mac</value> |
|
87 |
</property> |
|
88 |
</activation> |
|
89 |
<dependencies> |
|
90 |
<dependency> |
|
91 |
<groupId>org.gdal</groupId> |
|
92 |
<artifactId>gdal</artifactId> |
|
93 |
<version>1.8.1</version> |
|
94 |
<classifier>${native-classifier}</classifier> |
|
95 |
<type>tar.gz</type> |
|
96 |
</dependency> |
|
97 |
</dependencies> |
|
98 |
</profile> |
|
99 |
</profiles> |
|
100 |
</project> |
|
101 |
|
|
0 | 102 |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/readme.txt | ||
---|---|---|
1 |
How to compile libjni-gdal |
|
2 |
-------------------------- |
|
3 |
|
|
4 |
General Requirements |
|
5 |
-------------------- |
|
6 |
|
|
7 |
Make sure you have a directory .m2 in your $HOME. In this directory there should be a file settings.xml. This step is only necessary if you have to deploy files. |
|
8 |
|
|
9 |
<?xml version="1.0" encoding="UTF-8"?> |
|
10 |
|
|
11 |
<settings xmlns="http://maven.apache.org/POM/4.0.0" |
|
12 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
13 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 |
|
14 |
http://maven.apache.org/xsd/settings-1.0.0.xsd"> |
|
15 |
<servers> |
|
16 |
<server> |
|
17 |
<id>gvsig-repository</id> |
|
18 |
<username>[USERNAME]</username> |
|
19 |
<password>[PASSWORD]</password> |
|
20 |
<filePermissions>666</filePermissions> |
|
21 |
<directoryPermissions>777</directoryPermissions> |
|
22 |
</server> |
|
23 |
</servers> |
|
24 |
</settings> |
|
25 |
|
|
26 |
Linux |
|
27 |
----- |
|
28 |
|
|
29 |
Installed programs |
|
30 |
|
|
31 |
cmake (apt-get install cmake) |
|
32 |
maven (minimum version 2.2.1. This version is available in build directory) |
|
33 |
ant (apt-get install ant) |
|
34 |
|
|
35 |
Open a system console and set variable JAVA_HOME with a right value. |
|
36 |
|
|
37 |
ej: export JAVA_HOME=[Path_to_JDK] |
|
38 |
|
|
39 |
Launch the command to compile: |
|
40 |
|
|
41 |
mvn install -Dnative-arch=[ARCHITECTURE] -Dnative-distribution=[DISTRIBUTION] -Pjni-devel -Dmaven.test.skip -Dnative-classifier=[CLASSIFIER] |
|
42 |
|
|
43 |
ARCHITECTURE = "X86_64", "i386", ... |
|
44 |
DISTRIBUTION = "nt", "Ubuntu-9.10", "10.5", ... |
|
45 |
CLASSIFIER = linux-Ubuntu-9.10-gcc4-X86_64-dynamic |
|
46 |
|
|
47 |
Example: |
|
48 |
mvn install -Dnative-arch="X86_64" -Dnative-distribution="Ubuntu-9.10" -Pjni-devel -Dmaven.test.skip -Dnative-classifier=linux-Ubuntu-9.10-gcc4-X86_64-dynamic |
|
49 |
|
|
50 |
Windows |
|
51 |
------- |
|
52 |
|
|
53 |
Installed programs |
|
54 |
|
|
55 |
Visual Studio 2005 (vs8) |
|
56 |
cmake |
|
57 |
maven (minimum version 2.2.1. This version is available in build directory) |
|
58 |
ant |
|
59 |
|
|
60 |
Make sure you have the right value in your JAVA_HOME variable |
|
61 |
|
|
62 |
libjni-gdal needs a GDAL SDK to be compiled. This SDK is in the maven repository. The pom.xml contains |
|
63 |
the version of GDAL. You should check the version. |
|
64 |
|
|
65 |
<dependency> |
|
66 |
<groupId>org.gdal</groupId> |
|
67 |
<artifactId>gdal</artifactId> |
|
68 |
<version>1.7.1</version> |
|
69 |
<classifier>${native-classifier}</classifier> |
|
70 |
<type>tar.gz</type> |
|
71 |
</dependency> |
|
72 |
|
|
73 |
The binaries of this version will be downloaded from maven repository. |
|
74 |
http://gvsig-desktop.forge.osor.eu/downloads/pub/projects/gvSIG-desktop/maven-repository/ |
|
75 |
|
|
76 |
Launch the command to compile: |
|
77 |
|
|
78 |
mvn install -Dnative-arch=[ARCHITECTURE] -Dnative-distribution=[DISTRIBUTION] -Pjni-devel -Dmaven.test.skip -Dnative-classifier=[CLASSIFIER] |
|
79 |
|
|
80 |
ARCHITECTURE = "X86_64", "i386", ... |
|
81 |
DISTRIBUTION = "nt", "Ubuntu-9.10", "10.5", ... |
|
82 |
CLASSIFIER = win-nt-gcc4-vs8-i386-dynamic |
|
83 |
|
|
84 |
Example: |
|
85 |
mvn install -Dnative-arch="i386" -Dnative-distribution="win-nt" -Pjni-devel -Dmaven.test.skip -Dnative-classifier=win-nt-gcc4-vs8-i386-dynamic |
|
86 |
|
|
0 | 87 |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/CMakeLists.txt | ||
---|---|---|
1 |
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE) |
|
2 |
|
|
3 |
IF(WIN32) |
|
4 |
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR) |
|
5 |
ELSE(WIN32) |
|
6 |
IF(APPLE) |
|
7 |
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) |
|
8 |
ELSE(APPLE) |
|
9 |
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4 FATAL_ERROR) |
|
10 |
ENDIF(APPLE) |
|
11 |
ENDIF(WIN32) |
|
12 |
|
|
13 |
if(COMMAND cmake_policy) |
|
14 |
# Works around warnings libraries linked against that don't |
|
15 |
# have absolute paths (e.g. -lpthreads) |
|
16 |
cmake_policy(SET CMP0003 NEW) |
|
17 |
|
|
18 |
# Works around warnings about escaped quotes in ADD_DEFINITIONS |
|
19 |
# statements. |
|
20 |
cmake_policy(SET CMP0005 NEW) |
|
21 |
|
|
22 |
# cmake-2.6.1 introduces policy cmp0008 decide how to treat full path libraries that do not appear to be valid library file names |
|
23 |
# quote from cvslog "Such libraries worked by accident in the VS IDE and Xcode generators in CMake 2.4 and below." |
|
24 |
if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4 AND ${CMAKE_PATCH_VERSION} GREATER 0) |
|
25 |
cmake_policy(SET CMP0008 OLD) |
|
26 |
endif() |
|
27 |
endif() |
|
28 |
|
|
29 |
PROJECT(org.gvsig.jgdal) |
|
30 |
|
|
31 |
SET(JGDAL_VERSION_MAJOR "2") |
|
32 |
SET(JGDAL_VERSION_MINOR "0") |
|
33 |
SET(JGDAL_VERSION_PATCH "3") |
|
34 |
|
|
35 |
SET(VERSION "${JGDAL_VERSION_MAJOR}.${JGDAL_VERSION_MINOR}.${JGDAL_VERSION_PATCH}") |
|
36 |
|
|
37 |
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../build/CMakeModules;${CMAKE_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}") |
|
38 |
|
|
39 |
FIND_PACKAGE(DepMan REQUIRED) |
|
40 |
INCLUDE(GeneralMacros) |
|
41 |
|
|
42 |
CONFIGURE_DEFAULTS() |
|
43 |
|
|
44 |
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
|
45 |
SET(CMAKE_INSTALL_PREFIX |
|
46 |
${DEPMAN_PATH} CACHE PATH "depman path install prefix" FORCE |
|
47 |
) |
|
48 |
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
|
49 |
|
|
50 |
FIND_PACKAGE(JNI REQUIRED) |
|
51 |
FIND_PACKAGE(GDAL REQUIRED) |
|
52 |
|
|
53 |
ADD_SUBDIRECTORY(src/main/native) |
|
54 |
|
|
55 |
CONFIGURE_END() |
|
56 |
|
|
57 |
|
|
0 | 58 |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/depman.xml | ||
---|---|---|
1 |
<depman> |
|
2 |
<package> |
|
3 |
<group>org.gvsig</group> |
|
4 |
<artifact>org.gvsig.jgdal</artifact> |
|
5 |
<version>2.0.3-SNAPSHOT</version> |
|
6 |
<libraryType>dynamic</libraryType> |
|
7 |
</package> |
|
8 |
<dependencies platform="win,mac"> |
|
9 |
<dependency> |
|
10 |
<group>org.gdal</group> |
|
11 |
<artifact>gdal</artifact> |
|
12 |
<version>1.7.1</version> |
|
13 |
<type>dynamic</type> |
|
14 |
</dependency> |
|
15 |
</dependencies> |
|
16 |
<dependencies platform="lin"> |
|
17 |
<dependency> |
|
18 |
<group>org.gdal</group> |
|
19 |
<artifact>gdal</artifact> |
|
20 |
<version>1.6.3</version> |
|
21 |
<type>dynamic</type> |
|
22 |
</dependency> |
|
23 |
</dependencies> |
|
24 |
</depman> |
|
25 |
|
|
0 | 26 |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.gvsig.jgdal</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
</buildSpec> |
|
9 |
<natures> |
|
10 |
</natures> |
|
11 |
</projectDescription> |
|
0 | 12 |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/src/test/java/org/gvsig/jgdal/TestReadData.java | ||
---|---|---|
1 |
package org.gvsig.jgdal; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
/** |
|
8 |
* Test de acceso a datos de la imagen. |
|
9 |
* @author Miguel ?ngel Qierol Carratal? <miguelangel.querol@iver.es> |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class TestReadData extends TestCase{ |
|
13 |
|
|
14 |
private Gdal gdal = null; |
|
15 |
private String baseDir = "./test-images/"; |
|
16 |
private String file1 = baseDir + "testGdal.tif"; |
|
17 |
private String[] metadata = null; |
|
18 |
|
|
19 |
public void start(){ |
|
20 |
try { |
|
21 |
setUp(); |
|
22 |
testStack(); |
|
23 |
} catch (GdalException e) { |
|
24 |
e.printStackTrace(); |
|
25 |
} catch (IOException e) { |
|
26 |
e.printStackTrace(); |
|
27 |
} |
|
28 |
|
|
29 |
} |
|
30 |
|
|
31 |
public void setUp() throws GdalException, IOException{ |
|
32 |
gdal = new Gdal(); |
|
33 |
gdal.open(file1, Gdal.GA_Update); |
|
34 |
} |
|
35 |
|
|
36 |
public void testStack() throws GdalException, IOException{ |
|
37 |
//Llamada sin dominio |
|
38 |
metadata = gdal.getMetadata(); |
|
39 |
assertNotNull("No se han devuelto metadatos", metadata); |
|
40 |
for (int i = 0 ; i<metadata.length ; i++){ |
|
41 |
System.out.println("Metadato: " + metadata[i]); |
|
42 |
} |
|
43 |
|
|
44 |
//Llamada con dominio "Image Structure Metadata" |
|
45 |
metadata = gdal.getMetadata("Image Structure Metadata"); |
|
46 |
assertNotNull("No se han devuelto metadatos", metadata); |
|
47 |
for (int i = 0 ; i<metadata.length ; i++){ |
|
48 |
System.out.println("Metadato: " + metadata[i]); |
|
49 |
} |
|
50 |
|
|
51 |
//Comprobaci?n del tama?o de la imagen |
|
52 |
assertEquals(842, gdal.getRasterXSize()); |
|
53 |
assertEquals(1023, gdal.getRasterYSize()); |
|
54 |
|
|
55 |
//Comprobaci?n del n?mero de bandas |
|
56 |
assertEquals(4, gdal.getRasterCount()); |
|
57 |
|
|
58 |
//Comprobaci?n del driver de la imagen |
|
59 |
assertEquals("GTiff", gdal.getDriverShortName()); |
|
60 |
|
|
61 |
//Comprobaci?n del acceso a las bandas |
|
62 |
for (int i = 0 ; i < gdal.getRasterCount() ; i++){ |
|
63 |
assertNotNull(gdal.getRasterBand(i+1)); |
|
64 |
} |
|
65 |
|
|
66 |
gdal.close(); |
|
67 |
gdal = null; |
|
68 |
System.gc(); |
|
69 |
} |
|
70 |
} |
|
0 | 71 |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/src/test/java/org/gvsig/jgdal/TestReadBandData.java | ||
---|---|---|
1 |
package org.gvsig.jgdal; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
/** |
|
8 |
* Test de acceso a datos de las bandas de una imagen. |
|
9 |
* @author Miguel ?ngel Querol Carratal? <miguelangel.querol@iver.es> |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class TestReadBandData extends TestCase{ |
|
13 |
private Gdal gdal = null; |
|
14 |
private GdalRasterBand band = null; |
|
15 |
private String baseDir = "./test-images/"; |
|
16 |
private String file1 = baseDir + "testGdal.tif"; |
|
17 |
|
|
18 |
public void start(){ |
|
19 |
try { |
|
20 |
setUp(); |
|
21 |
testStack(); |
|
22 |
} catch (GdalException e) { |
|
23 |
e.printStackTrace(); |
|
24 |
} catch (IOException e) { |
|
25 |
e.printStackTrace(); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
29 |
|
|
30 |
public void setUp() throws GdalException, IOException{ |
|
31 |
gdal = new Gdal(); |
|
32 |
gdal.open(file1, Gdal.GA_Update); |
|
33 |
} |
|
34 |
|
|
35 |
public void testStack() throws GdalException, IOException{ |
|
36 |
//Llamada sin dominio |
|
37 |
String[] metadata = gdal.getMetadata(); |
|
38 |
assertNotNull("No se han devuelto metadatos", metadata); |
|
39 |
for (int i = 0 ; i<metadata.length ; i++){ |
|
40 |
System.out.println("Metadato: " + metadata[i]); |
|
41 |
} |
|
42 |
|
|
43 |
//Llamada con dominio "Image Structure Metadata" |
|
44 |
metadata = gdal.getMetadata("Image Structure Metadata"); |
|
45 |
assertNotNull("No se han devuelto metadatos", metadata); |
|
46 |
for (int i = 0 ; i<metadata.length ; i++){ |
|
47 |
System.out.println("Metadato: " + metadata[i]); |
|
48 |
} |
|
49 |
|
|
50 |
//Comprobaci?n del tama?o de la imagen |
|
51 |
assertEquals(842, gdal.getRasterXSize()); |
|
52 |
assertEquals(1023, gdal.getRasterYSize()); |
|
53 |
|
|
54 |
//Comprobaci?n del n?mero de bandas |
|
55 |
assertEquals(4, gdal.getRasterCount()); |
|
56 |
|
|
57 |
//Comprobaci?n del driver de la imagen |
|
58 |
assertEquals("GTiff", gdal.getDriverShortName()); |
|
59 |
|
|
60 |
//Comprobaci?n del acceso a las bandas |
|
61 |
for (int i = 0 ; i < gdal.getRasterCount() ; i++){ |
|
62 |
assertNotNull(gdal.getRasterBand(i+1)); |
|
63 |
} |
|
64 |
} |
|
65 |
} |
|
0 | 66 |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/src/test/java/org/gvsig/jgdal/TestWarpDataset.java | ||
---|---|---|
1 |
package org.gvsig.jgdal; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
|
|
6 |
import junit.framework.TestCase; |
|
7 |
|
|
8 |
public class TestWarpDataset extends TestCase { |
|
9 |
private GdalWarp warp = null; |
|
10 |
private String baseDir = "./test-images/"; |
|
11 |
private String src = baseDir + "testGdalWarp.tif"; |
|
12 |
private String dst = baseDir + "warpedImage.tif"; |
|
13 |
private String frm = "GTiff"; |
|
14 |
private String t_srs = "EPSG:23030"; |
|
15 |
|
|
16 |
public void start() { |
|
17 |
setUp(); |
|
18 |
testStack(); |
|
19 |
} |
|
20 |
|
|
21 |
public void setUp() { |
|
22 |
warp = new GdalWarp(); |
|
23 |
File f = new File(src); |
|
24 |
Gdal dataset = new Gdal(); |
|
25 |
|
|
26 |
try { |
|
27 |
assertTrue("El fichero no existe", f.exists()); |
|
28 |
assertTrue("El fichero no se puede leer", f.canRead()); |
|
29 |
dataset.open(src, Gdal.GA_ReadOnly); |
|
30 |
GdalRasterBand band = dataset.getRasterBand(1); |
|
31 |
band.readRaster(0, 0, 10, 10, 10, 10, Gdal.GDT_Byte); |
|
32 |
} catch (GdalException e) { |
|
33 |
new AssertionError("Fallo en gdal al acceder al fichero fuente"); |
|
34 |
} catch (IOException e) { |
|
35 |
new AssertionError("Fallo en gdal al acceder al fichero fuente"); |
|
36 |
e.printStackTrace(); |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
public void testStack() { |
|
41 |
assertNotNull(t_srs); |
|
42 |
|
|
43 |
warp.warp(t_srs, src, dst, frm); |
|
44 |
System.err.println("Proceso completado al " + warp.getPercent() + " %"); |
|
45 |
|
|
46 |
File f = new File(dst); |
|
47 |
|
|
48 |
assertTrue("El fichero destino no existe", f.exists()); |
|
49 |
assertTrue("El fichero destino no se puede leer", f.canRead()); |
|
50 |
} |
|
51 |
} |
|
0 | 52 |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/src/test/java/org/gvsig/addo/TestBuildOverviews.java | ||
---|---|---|
1 |
package org.gvsig.addo; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
import org.gvsig.jgdal.Gdal; |
|
7 |
import org.gvsig.jgdal.GdalException; |
|
8 |
|
|
9 |
/** |
|
10 |
* Test para la generacion de overviews sobre una imagen raster. |
|
11 |
* Registra un listener para mostrar el incremento de la tarea. |
|
12 |
* |
|
13 |
* 18-nov-2007 |
|
14 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
15 |
*/ |
|
16 |
public class TestBuildOverviews extends TestCase implements IOverviewIncrement { |
|
17 |
private int value = 0; |
|
18 |
|
|
19 |
private Jaddo addo = null; |
|
20 |
private Gdal gdal = null; |
|
21 |
private String path = "./test-images/testGdalWarp.tif"; |
|
22 |
|
|
23 |
public void start(){ |
|
24 |
setUp(); |
|
25 |
testStack(); |
|
26 |
} |
|
27 |
|
|
28 |
|
|
29 |
public void setUp(){ |
|
30 |
addo = new Jaddo(); |
|
31 |
addo.setIncrementListener(this); |
|
32 |
gdal = new Gdal(); |
|
33 |
} |
|
34 |
|
|
35 |
|
|
36 |
public void testStack(){ |
|
37 |
try { |
|
38 |
addo.buildOverviews(Jaddo.AVERAGE, path, new int[]{2, 4, 8, 16}); |
|
39 |
gdal.open(path, Gdal.GA_ReadOnly); |
|
40 |
assertTrue("No hay overviews!!", gdal.getRasterBand(1).getOverviewCount()>0); |
|
41 |
} catch (BuildingOverviewsException e) { |
|
42 |
System.err.println(e); |
|
43 |
} catch (WritingException e) { |
|
44 |
System.err.println(e); |
|
45 |
} catch (GdalException e) { |
|
46 |
e.printStackTrace(); |
|
47 |
} catch (IOException e) { |
|
48 |
e.printStackTrace(); |
|
49 |
} |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
public int getPercent() { |
|
54 |
return value; |
|
55 |
} |
|
56 |
|
|
57 |
public void setPercent(int value) { |
|
58 |
this.value = value; |
|
59 |
System.out.println("Increment:" + value); |
|
60 |
} |
|
61 |
} |
|
0 | 62 |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/JNIBase.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 |
|
|
23 |
|
|
24 |
/** |
|
25 |
* @author Nacho Brodin <nachobrodin@gmail.com>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es |
|
26 |
* @version 0.0 |
|
27 |
* @link http://www.gvsig.gva.es |
|
28 |
*/ |
|
29 |
|
|
30 |
package org.gvsig.jgdal; |
|
31 |
|
|
32 |
public class JNIBase{ |
|
33 |
|
|
34 |
protected long cPtr; |
|
35 |
|
|
36 |
private native int getRasterBandXSizeNat(long cPtr); |
|
37 |
private native int getRasterBandYSizeNat(long cPtr); |
|
38 |
private native int getOverviewCountNat(long cPtr); |
|
39 |
private native int getBlockXSizeNat(long cPtr); |
|
40 |
private native int getBlockYSizeNat(long cPtr); |
|
41 |
private native int getRasterXSizeNat(long cPtr); |
|
42 |
private native int getRasterYSizeNat(long cPtr); |
|
43 |
private native int getRasterCountNat(long cPtr); |
|
44 |
private native int getGCPCountNat(long cPtr); |
|
45 |
private native int getRasterDataTypeNat(long cPtr); |
|
46 |
private native int getDriverCountNat(long cPtr); |
|
47 |
private native int getLayerCountNat(long cPtr); |
|
48 |
|
|
49 |
|
|
50 |
/** |
|
51 |
* Funci?n que sirve como base para funcionalidades de gdal que admiten como par?metro un entero y devuelven un entero. |
|
52 |
* |
|
53 |
* @throws GdalException. |
|
54 |
* @param msg1 Mensaje de error que se muestra cuando el puntero a objeto pasado es vacio. |
|
55 |
* @param msg2 Mensaje de error que se muestra cuando el resultado de la llamada a la funci�n de gdal es menor o igual que 0. |
|
56 |
*/ |
|
57 |
|
|
58 |
|
|
59 |
protected int baseSimpleFunctions(int n,String msg1,String msg2)throws GdalException{ |
|
60 |
|
|
61 |
int res = 0; |
|
62 |
|
|
63 |
switch(n){ |
|
64 |
case 0: res = getRasterBandXSizeNat(cPtr);break; |
|
65 |
case 1: res = getRasterBandYSizeNat(cPtr);break; |
|
66 |
case 2: res = getOverviewCountNat(cPtr);break; |
|
67 |
case 3: res = getBlockXSizeNat(cPtr);break; |
|
68 |
case 4: res = getBlockYSizeNat(cPtr);break; |
|
69 |
case 5: res = getRasterXSizeNat(cPtr);break; |
|
70 |
case 6: res = getRasterYSizeNat(cPtr);break; |
|
71 |
case 7: res = getRasterCountNat(cPtr);break; |
|
72 |
case 8: res = getGCPCountNat(cPtr);break; |
|
73 |
case 9: res = getRasterDataTypeNat(cPtr);break; |
|
74 |
} |
|
75 |
|
|
76 |
if (res < 0) |
|
77 |
throw new GdalException(msg2); |
|
78 |
else |
|
79 |
return res; |
|
80 |
} |
|
81 |
|
|
82 |
static { |
|
83 |
/*String os = System.getProperty("os.name"); |
|
84 |
if (os.toLowerCase().startsWith("windows")) |
|
85 |
System.loadLibrary("jgdal201"); |
|
86 |
else*/ |
|
87 |
System.loadLibrary("jgdal2.0.3"); |
|
88 |
} |
|
89 |
} |
|
0 | 90 |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/Options.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 |
|
|
23 |
package org.gvsig.jgdal; |
|
24 |
|
|
25 |
|
|
26 |
public class Options { |
|
27 |
String[] vars; |
|
28 |
String[] datos; |
|
29 |
int longitud; |
|
30 |
int nopc; |
|
31 |
|
|
32 |
public Options(int nopciones) { |
|
33 |
vars=new String[nopciones]; |
|
34 |
datos=new String[nopciones]; |
|
35 |
longitud=nopciones; |
|
36 |
nopc=0; |
|
37 |
} |
|
38 |
|
|
39 |
public void addOption(String var, String dato) { |
|
40 |
vars[nopc]=var; |
|
41 |
datos[nopc]=dato; |
|
42 |
nopc++; |
|
43 |
} |
|
44 |
|
|
45 |
public int getSize() { |
|
46 |
return longitud; |
|
47 |
} |
|
48 |
} |
|
0 | 49 |
org.gvsig.jgdal_deprecated/tags/jgdal2.0.3/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/GdalRasterBand.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 |
|
|
23 |
package org.gvsig.jgdal; |
|
24 |
|
|
25 |
/** |
|
26 |
* Representa a una banda simple de la im�gen o canal. |
|
27 |
* |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com).<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es |
|
29 |
* @version 0.0 |
|
30 |
* @link http://www.gvsig.gva.es |
|
31 |
*/ |
|
32 |
|
|
33 |
public class GdalRasterBand extends JNIBase{ |
|
34 |
|
|
35 |
|
|
36 |
private native long getOverviewNat(long cPtr,int i); |
|
37 |
private native long getRasterColorTableNat(long cPtr); |
|
38 |
private native GdalBuffer readRasterNat(long cPtr, |
|
39 |
int nXOff, int nYOff, int nXSize, int nYSize, |
|
40 |
int BufXSize, int BufYSize, |
|
41 |
int eBufType); |
|
42 |
private native GdalBuffer readRasterWithPaletteNat(long cPtr, |
|
43 |
int nXOff, int nYOff, int nXSize, int nYSize, |
|
44 |
int BufXSize, int BufYSize, |
|
45 |
int eBufType); |
|
46 |
private native void writeRasterNat( long cPtr, |
|
47 |
int nXOff, int nYOff, int nXSize, int nYSize, |
|
48 |
GdalBuffer buffer, |
|
49 |
int eBufType); |
|
50 |
private native double getRasterNoDataValueNat(long cPtr); |
|
51 |
private native int existsNoDataValueNat(long cPtr); |
|
52 |
private native String[] getMetadataNat(long cPtr,String pszDomain); |
|
53 |
private native int getRasterColorInterpretationNat(long cPtr); |
|
54 |
private native int setRasterColorInterpretationNat(long cPtr, int bandType); |
|
55 |
|
|
56 |
|
|
57 |
/** |
|
58 |
* Asigna el identificador de la banda |
|
59 |
*/ |
|
60 |
|
|
61 |
public GdalRasterBand(long cPtr) { |
|
62 |
this.cPtr=cPtr; |
|
63 |
} |
|
64 |
|
|
65 |
|
|
66 |
/** |
|
67 |
* Lee datos de la banda de la im�gen |
|
68 |
* |
|
69 |
* @return Devuelve un vector de bytes con el trozo de raster le�do. |
|
70 |
* @param nXOff El desplazamiento del pixel desde la esquina superior derecha |
|
71 |
* de la banda accedida. |
|
72 |
* @param nYOff El desplazamiento de l�nea desde la esquina superior derecha |
|
73 |
* de la banda accedida. |
|
74 |
* @param nXSize Ancho de la regi�n en pixels de la banda que ser� accedida |
|
75 |
* @param nYSize Altura de la regi�n en l�neas de la banda que ser� accedida |
|
76 |
* @param bufXSize Ancho del buffer donde la regi�n de la im�gen ser� guardada |
|
77 |
* @param bufYSize Altura del buffer donde la regi�n de la im�gen ser� guardada |
|
78 |
* En caso de que bufXSize o bufYSize sean menores que 1, pasan a tener el mismo valor que |
|
79 |
* nXSize y nYSize respectivamente para evitar buffers con tama?o 0. |
|
80 |
* @param eBufType |
|
81 |
*/ |
|
82 |
|
|
83 |
public GdalBuffer readRaster(int nXOff, int nYOff, int nXSize, int nYSize, |
|
84 |
int bufXSize, int bufYSize, |
|
85 |
int eBufType)throws GdalException { |
|
86 |
|
|
87 |
if (cPtr == 0) |
|
88 |
throw new GdalException("No se ha podido acceder al archivo."); |
|
89 |
|
|
90 |
if ((nXOff<0) || (nXOff > baseSimpleFunctions(5, "", "")) || (nYOff < 0) || (nYOff > baseSimpleFunctions(6, "", ""))) |
|
91 |
throw new GdalException("Desplazamiento de la ventana fuera de rango."); |
|
92 |
|
|
93 |
if ((nXSize < 1) || (nXSize > baseSimpleFunctions(5, "", "")) || (nYSize<1) || (nYSize > baseSimpleFunctions(6, "", ""))) |
|
94 |
throw new GdalException("Tama?o de ventana incorrecto."); |
|
95 |
|
|
96 |
if (((nXSize + nXOff) > (baseSimpleFunctions(5, "", ""))) || ((nYSize + nYOff) > (baseSimpleFunctions(6, "", "")))) |
|
97 |
throw new GdalException("Posicion de la ventana incorrecta."); |
|
98 |
|
|
99 |
if ((eBufType < 1) || (eBufType > 11)) |
|
100 |
throw new GdalException("Tipo de datos incorrecto."); |
|
101 |
|
|
102 |
if (bufXSize < 1) |
|
103 |
bufXSize = nXSize; |
|
104 |
|
|
105 |
if (bufYSize < 1) |
|
106 |
bufYSize = nYSize; |
|
107 |
|
|
108 |
GdalBuffer buffer = readRasterNat(cPtr, nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType); |
|
109 |
if(buffer!=null) |
|
110 |
return buffer; |
|
111 |
else |
|
112 |
return null; |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* Escribe datos en la banda de la im�gen |
|
117 |
* |
|
118 |
* @param nXOff El desplazamiento del pixel desde la esquina superior derecha |
|
119 |
* de la banda accedida. |
|
120 |
* @param nYOff El desplazamiento de l�nea desde la esquina superior derecha |
|
121 |
* de la banda accedida. |
|
122 |
* @param nXSize Ancho de la regi�n en pixels de la banda que ser� accedida |
|
123 |
* @param nYSize Altura de la regi�n en l�neas de la banda que ser� accedida |
|
124 |
* @param BufXSize Ancho del buffer donde la regi�n de la im�gen ser� guardada |
|
125 |
* @param BufYSize Altura del buffer donde la regi�n de la im�gen ser� guardada |
|
126 |
* @param eBufType |
|
127 |
*/ |
|
128 |
|
|
129 |
public void writeRaster(int nXOff, int nYOff, int nXSize, int nYSize, GdalBuffer buf, int eBufType)throws GdalException{ |
|
130 |
GdalBuffer buffer=new GdalBuffer(); |
|
131 |
|
|
132 |
if ((nXOff<0) || (nXOff > baseSimpleFunctions(5, "", "")) || (nYOff < 0) || (nYOff > baseSimpleFunctions(6, "", ""))) |
|
133 |
throw new GdalException("Desplazamiento de la ventana fuera de rango."); |
|
134 |
|
|
135 |
if ((nXSize < 1) || (nXSize > baseSimpleFunctions(5, "", "")) || (nYSize<1) || (nYSize > baseSimpleFunctions(6, "", ""))) |
|
136 |
throw new GdalException("Tama?o de ventana incorrecto."); |
|
137 |
|
|
138 |
if (((nXSize + nXOff) > (baseSimpleFunctions(5, "", ""))) || ((nYSize + nYOff) > (baseSimpleFunctions(6, "", "")))) |
|
139 |
throw new GdalException("Posicion de la ventana incorrecta."); |
|
140 |
|
|
141 |
if ((eBufType < 1) || (eBufType > 11)) |
|
142 |
throw new GdalException("Tipo de datos incorrecto."); |
|
143 |
|
|
144 |
if (buf == null) |
|
145 |
throw new GdalException("Buffer incorrecto"); |
|
146 |
|
|
147 |
switch(eBufType){ |
|
148 |
case 0: |
|
149 |
return; |
|
150 |
case 1: |
|
151 |
buffer.buffByte=buf.buffByte; |
|
152 |
break; |
|
153 |
case 2: |
|
154 |
case 3: |
|
155 |
case 8: |
|
156 |
buffer.buffShort=buf.buffShort; |
|
157 |
break; |
|
158 |
case 4: |
|
159 |
case 5: |
|
160 |
case 9: |
|
161 |
buffer.buffInt=buf.buffInt; |
|
162 |
break; |
|
163 |
case 6: |
|
164 |
case 10: |
|
165 |
buffer.buffFloat=buf.buffFloat; |
|
166 |
break; |
|
167 |
case 7: |
|
168 |
case 11: |
|
169 |
buffer.buffDouble=buf.buffDouble; |
|
170 |
break; |
|
171 |
case 12: |
|
172 |
return; |
|
173 |
} |
|
174 |
|
|
175 |
writeRasterNat(cPtr, nXOff, nYOff, nXSize, nYSize, buffer, eBufType); |
|
176 |
} |
|
177 |
|
|
178 |
/** |
|
179 |
*Obtiene el tama�o en pixeles de la im�gen en el eje de las X |
|
180 |
*@return Tama�o en pixeles del eje X |
|
181 |
*@throws GdalException |
|
182 |
*/ |
|
183 |
|
|
184 |
public int getRasterBandXSize()throws GdalException { |
|
185 |
String msg1="Error en getRasterBandXSize(). La llamada getRasterBand no tuvo exito"; |
|
186 |
String msg2="Tama�o de banda erroneo devuelto por GetRasterBandXSize"; |
|
187 |
|
|
188 |
return baseSimpleFunctions(0,msg1,msg2); |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
*Obtiene el tama�o en pixeles de la im�gen en el eje de las Y |
|
193 |
*@return Tama�o en pixeles del eje Y |
|
194 |
*@throws GdalException |
|
195 |
*/ |
|
196 |
|
|
197 |
public int getRasterBandYSize()throws GdalException { |
|
198 |
String msg1="Error en getRasterBandYSize(). La llamada getRasterBand no tuvo exito"; |
|
199 |
String msg2="Tama�o de banda erroneo devuelto por GetRasterBandYSize"; |
|
200 |
|
|
201 |
return baseSimpleFunctions(1,msg1,msg2); |
|
202 |
} |
|
203 |
|
|
204 |
|
|
205 |
/** |
|
206 |
* Devuelve el n�mero de overviews que contiene la banda. |
|
207 |
* @return N�mero de overviews |
|
208 |
* @throws GdalException |
|
209 |
*/ |
|
210 |
|
|
211 |
public int getOverviewCount()throws GdalException { |
|
212 |
String msg1="Error en getOverviewCount(). La llamada getRasterBand no tuvo exito"; |
|
213 |
String msg2="Error al obtener el n�mero de overviews"; |
|
214 |
|
|
215 |
return baseSimpleFunctions(2,msg1,msg2); |
|
216 |
} |
|
217 |
|
|
218 |
|
|
219 |
/** |
|
220 |
* Obtiene el overview indicado por el �ndice "i". |
|
221 |
* |
|
222 |
* @param i indice del overview que se quiere recuperar. |
|
223 |
* @return GdalRasterBand Banda correspondiente al overview selecccionado |
|
224 |
* @throws GdalException |
|
225 |
*/ |
|
226 |
|
|
227 |
public GdalRasterBand getOverview(int i)throws GdalException { |
|
228 |
long cPtr_ov; |
|
229 |
|
|
230 |
if((i < 0) || (i >= getOverviewCount())) |
|
231 |
throw new GdalException("El overview seleccionado no existe"); |
|
232 |
|
|
233 |
cPtr_ov = getOverviewNat(cPtr,i); |
|
234 |
|
|
235 |
if (cPtr_ov == 0) |
|
236 |
throw new GdalException("No se ha podido obtener el overview"); |
|
237 |
|
|
238 |
return new GdalRasterBand(cPtr_ov); |
|
239 |
} |
|
240 |
|
|
241 |
|
|
242 |
/** |
|
243 |
* Devuelve el tama�o en X del bloque para esa banda |
|
244 |
* @return Tama�o en pixeles del bloque en el eje X |
|
245 |
* @throws GdalException |
|
246 |
*/ |
|
247 |
|
|
248 |
public int getBlockXSize()throws GdalException { |
|
249 |
String msg1="Error en getBlockXSize(). La llamada getRasterBand no tuvo exito"; |
|
250 |
String msg2="Tama�o de bloque erroneo devuelto por GetBlockXSize"; |
|
251 |
|
|
252 |
return baseSimpleFunctions(3,msg1,msg2); |
|
253 |
} |
|
254 |
|
|
255 |
|
|
256 |
/** |
|
257 |
* Devuelve el tama�o en Y del bloque para esa banda |
|
258 |
* @return Tama�o en pixeles del bloque en el eje Y |
|
259 |
* @throws GdalException |
|
260 |
*/ |
|
261 |
|
|
262 |
public int getBlockYSize()throws GdalException { |
|
263 |
String msg1="Error en getBlockXSize(). La llamada getRasterBand no tuvo exito"; |
|
264 |
String msg2="Tama�o de bloque erroneo devuelto por GetBlockYSize"; |
|
265 |
|
|
266 |
return baseSimpleFunctions(4,msg1,msg2); |
|
267 |
} |
|
268 |
|
|
269 |
/** |
|
270 |
* Devuelve el tipo de datos de la banda |
|
271 |
* @return Tama�o en pixeles del bloque en el eje Y |
|
272 |
* @throws GdalException |
|
273 |
*/ |
|
274 |
|
|
275 |
public int getRasterDataType()throws GdalException { |
|
276 |
String msg1="Error en getRasterDataType(). La llamada getRasterBand no tuvo exito"; |
|
277 |
String msg2="Tipo de dato devuelto por GetRasterDataType erroneo"; |
|
278 |
|
|
279 |
return baseSimpleFunctions(9,msg1,msg2); |
|
280 |
} |
|
281 |
|
|
282 |
/** |
|
283 |
* Obtiene la tabla de color asociada a la imagen |
|
284 |
*/ |
|
285 |
public GdalColorTable getRasterColorTable()throws GdalException { |
|
286 |
GdalColorTable gct = null; |
|
287 |
|
|
288 |
if (cPtr == 0) |
|
289 |
throw new GdalException("No se ha podido acceder al archivo."); |
|
290 |
|
|
291 |
long cPtr_ct = getRasterColorTableNat(cPtr); |
|
292 |
|
|
293 |
if ((cPtr_ct == 0) || (cPtr_ct == -1)) |
|
294 |
return null; |
|
295 |
|
|
296 |
gct = new GdalColorTable(cPtr_ct); |
|
297 |
|
|
298 |
return gct; |
|
299 |
} |
|
300 |
|
|
301 |
/** |
|
302 |
* Lee datos de la banda de la im�gen con una paleta asociada |
|
303 |
* |
|
304 |
* @return Devuelve un vector de bytes con el trozo de raster le�do. |
|
305 |
* @param nXOff El desplazamiento del pixel desde la esquina superior derecha |
|
306 |
* de la banda accedida. |
|
307 |
* @param nYOff El desplazamiento de l�nea desde la esquina superior derecha |
|
308 |
* de la banda accedida. |
|
309 |
* @param nXSize Ancho de la regi�n en pixels de la banda que ser� accedida |
|
310 |
* @param nYSize Altura de la regi�n en l�neas de la banda que ser� accedida |
|
311 |
* @param BufXSize Ancho del buffer donde la regi�n de la im�gen ser� guardada |
|
312 |
* @param BufYSize Altura del buffer donde la regi�n de la im�gen ser� guardada |
|
313 |
* En caso de que bufXSize o bufYSize sean menores que 1, pasan a tener el mismo valor que |
|
314 |
* nXSize y nYSize respectivamente para evitar buffers con tama?o 0. |
|
315 |
* @param eBufType |
|
316 |
*/ |
|
317 |
|
|
318 |
public GdalBuffer readRasterWithPalette(int nXOff, int nYOff, int nXSize, int nYSize, |
|
319 |
int bufXSize, int bufYSize, |
|
320 |
int eBufType)throws GdalException { |
|
321 |
|
|
322 |
if (cPtr == 0) |
|
323 |
throw new GdalException("No se ha podido acceder al archivo."); |
|
324 |
|
|
325 |
if ((nXOff<0) || (nXOff > baseSimpleFunctions(5, "", "")) || (nYOff < 0) || (nYOff > baseSimpleFunctions(6, "", ""))) |
|
326 |
throw new GdalException("Desplazamiento de la ventana fuera de rango."); |
|
327 |
|
|
328 |
if ((nXSize < 1) || (nXSize > baseSimpleFunctions(5, "", "")) || (nYSize<1) || (nYSize > baseSimpleFunctions(6, "", ""))) |
|
329 |
throw new GdalException("Tama?o de ventana incorrecto."); |
|
330 |
|
|
331 |
if (((nXSize + nXOff) > (baseSimpleFunctions(5, "", ""))) || ((nYSize + nYOff) > (baseSimpleFunctions(6, "", "")))) |
|
332 |
throw new GdalException("Posicion de la ventana incorrecta."); |
|
333 |
|
|
334 |
if ((eBufType < 1) || (eBufType > 11)) |
|
335 |
throw new GdalException("Tipo de datos incorrecto."); |
|
336 |
|
|
337 |
if (bufXSize < 1) |
|
338 |
bufXSize = nXSize; |
|
339 |
|
|
340 |
if (bufYSize < 1) |
|
341 |
bufYSize = nYSize; |
|
342 |
|
|
343 |
|
|
344 |
GdalBuffer buffer = readRasterWithPaletteNat(cPtr, nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType); |
|
345 |
|
|
346 |
|
|
347 |
if(buffer!=null) |
|
348 |
return buffer; |
|
349 |
else |
|
350 |
return null; |
|
351 |
} |
|
352 |
|
|
353 |
/** |
|
354 |
*Devuelve el valor de NoData |
|
355 |
*/ |
|
356 |
public double getRasterNoDataValue()throws GdalException { |
|
357 |
if (cPtr == 0) |
|
358 |
throw new GdalException("No se ha podido acceder al archivo."); |
|
359 |
|
|
360 |
return getRasterNoDataValueNat(cPtr); |
|
361 |
} |
|
362 |
|
|
363 |
/** |
|
364 |
* Obtiene el valorDevuelve el valor de NoData |
|
365 |
*/ |
|
366 |
public boolean existsNoDataValue()throws GdalException { |
|
367 |
if (cPtr == 0) |
|
368 |
throw new GdalException("No se ha podido acceder al archivo."); |
|
369 |
|
|
370 |
int result = existsNoDataValueNat(cPtr); |
|
371 |
|
|
372 |
if(result == 1) |
|
373 |
return true; |
|
374 |
else |
|
375 |
return false; |
|
376 |
} |
|
377 |
|
|
378 |
/** |
|
379 |
* Obtiene un array de Strings con los metadatos |
|
380 |
* |
|
381 |
* @throws GdalException |
|
382 |
* @return Array de Strings que corresponden a los metadatos que ofrece la im�gen |
|
383 |
*/ |
|
384 |
|
|
385 |
public String[] getMetadata()throws GdalException { |
|
386 |
if (cPtr == 0) |
|
387 |
throw new GdalException("No se ha podido acceder al archivo."); |
|
388 |
|
|
389 |
String[] res = getMetadataNat(cPtr,null); |
|
390 |
if(res == null) |
|
391 |
return new String[0]; |
|
392 |
else return res; |
|
393 |
} |
|
394 |
|
|
395 |
/** |
|
396 |
* Obtiene identificador que representa el tipo de banda de color. |
|
397 |
* @return identificador del tipo de banda de color |
|
398 |
* @throws GdalException |
|
399 |
*/ |
|
400 |
|
|
401 |
public int getRasterColorInterpretation()throws GdalException { |
|
402 |
if (cPtr == 0) |
|
403 |
throw new GdalException("No se ha podido acceder al archivo."); |
|
404 |
|
|
405 |
int bandType = getRasterColorInterpretationNat(cPtr); |
|
406 |
return bandType; |
|
407 |
} |
|
408 |
|
|
409 |
|
|
410 |
/** |
|
411 |
* Asigna la interpretaci?n de color de la banda. |
|
412 |
* Con algunos formatos no es posible modificar la interpretaci?n de color, |
|
413 |
* tales como tiff y jpg. En el caso de tif, no hay error pero tampoco se |
|
414 |
* produce el cambio en la interpretaci?n. En el caso de jpg, gdal lanza un error. |
|
415 |
* 0 = "Undefined" |
|
416 |
* 1 = "Gray"; |
|
417 |
* 2 = "Palette"; |
|
418 |
* 3 = "Red"; |
|
419 |
* 4 = "Green"; |
|
420 |
* 5 = "Blue"; |
|
421 |
* 6 = "Alpha"; |
|
422 |
* 7 = "Hue"; |
|
423 |
* 8 = "Saturation"; |
|
424 |
* 9 = "Lightness"; |
|
425 |
* 10 = "Cyan"; |
|
426 |
* 11 = "Magenta"; |
|
427 |
* 12 = "Yellow"; |
|
428 |
* 13 = "Black"; |
|
429 |
* 14 = "YCbCr_Y"; |
|
430 |
* 15 = "YCbCr_Cb"; |
|
431 |
* 16 = "YCbCr_Cr"; |
|
432 |
* @param bandType |
Also available in: Unified diff