root / branches / Mobile_Compatible_Hito_1 / libFMap / src / es / prodevelop / gvsig / mobile / fmap / driver / raster / ecw / EcwReader.java @ 21606
History | View | Annotate | Download (5.43 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 Prodevelop and 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 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* http://www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL
|
34 |
* Conde Salvatierra de ?lava , 34-10
|
35 |
* 46004 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963 510 612
|
39 |
* +34 963 510 968
|
40 |
* gis@prodevelop.es
|
41 |
* http://www.prodevelop.es
|
42 |
*
|
43 |
* or
|
44 |
*
|
45 |
* Instituto de Rob?tica
|
46 |
* Apartado de correos 2085
|
47 |
* 46071 Valencia
|
48 |
* (Spain)
|
49 |
*
|
50 |
* +34 963 543 577
|
51 |
* jjordan@robotica.uv.es
|
52 |
* http://robotica.uv.es
|
53 |
*
|
54 |
*/
|
55 |
|
56 |
package es.prodevelop.gvsig.mobile.fmap.driver.raster.ecw; |
57 |
|
58 |
import es.prodevelop.gvsig.mobile.fmap.util.Utils; |
59 |
|
60 |
/**
|
61 |
* Utility class to access Ermapper's libraries through JNI
|
62 |
*
|
63 |
* @see es.prodevelop.gvsig.mobile.fmap.driver.raster.ecw.EcwRasterDriver
|
64 |
*
|
65 |
* @author jldominguez
|
66 |
*
|
67 |
*/
|
68 |
public class EcwReader { |
69 |
|
70 |
/**
|
71 |
* Opens ECW file
|
72 |
*
|
73 |
* @param full_file_path ecw full file path
|
74 |
* @return the file handler as an long value, or zero if the file was not opened
|
75 |
*
|
76 |
* @throws Throwable
|
77 |
*/
|
78 |
public static native long openEcwFile(String full_file_path) throws Throwable; |
79 |
|
80 |
/**
|
81 |
* Closes the ECW file.
|
82 |
*
|
83 |
* @param ptr handler of the previously opened file
|
84 |
* @return whether the file was successfully closed
|
85 |
*/
|
86 |
public static native boolean closeEcwFile(long ptr); |
87 |
|
88 |
/**
|
89 |
* Renders the ECW raster as an array of RGB values (one int value for each pixel)
|
90 |
*
|
91 |
* @param ptr ECW file handler
|
92 |
* @param geo_min_x minimum x in map units of the zone of interest
|
93 |
* @param geo_min_y minimum y in map units of the zone of interest
|
94 |
* @param geo_w width of the zone of interest in map units
|
95 |
* @param geo_h height of the zone of interest in map units
|
96 |
* @param filemingeox minimum x in map units of the raster
|
97 |
* @param filemingeoy minimum y in map units of the raster
|
98 |
* @param filexcell width of each pixels in map units
|
99 |
* @param ffileycell height of each pixels in map units
|
100 |
* @param filew width of the raster in pixels
|
101 |
* @param fileh height of the raster in pixels
|
102 |
* @param out_w width of the output image in pixels
|
103 |
* @param out_h height of the output image in pixels
|
104 |
* @param band1 first band requested
|
105 |
* @param band2 second band requested
|
106 |
* @param band3 third band requested
|
107 |
* @return array of integers representing the zone of interest
|
108 |
*/
|
109 |
public static native int[] getEcwView( |
110 |
long ptr,
|
111 |
double geo_min_x,
|
112 |
double geo_min_y,
|
113 |
double geo_w,
|
114 |
double geo_h,
|
115 |
|
116 |
double filemingeox,
|
117 |
double filemingeoy,
|
118 |
double filexcell,
|
119 |
double ffileycell,
|
120 |
int filew, int fileh, |
121 |
|
122 |
int out_w,
|
123 |
int out_h,
|
124 |
int band1,
|
125 |
int band2,
|
126 |
int band3);
|
127 |
|
128 |
/**
|
129 |
* Gets metadata from the ECW raster
|
130 |
* @param ptr the file handler
|
131 |
* @return array of doubles with the raster metadata
|
132 |
*/
|
133 |
public static native double[] getEcwImageInfo(long ptr); |
134 |
|
135 |
/**
|
136 |
* Utility method to convert an array of integers into an
|
137 |
* array of bytes in the PNG format.
|
138 |
*
|
139 |
* @param bitmap raster as an array of integers
|
140 |
* @param w image width in pixels
|
141 |
* @param h image height in pixels
|
142 |
* @param offset offset in the array of integers
|
143 |
* @param has_transp whether the integers include an alpha band
|
144 |
* @return an array of bytes in the PNG format.
|
145 |
*/
|
146 |
public static native byte[] paintArray( |
147 |
int[] bitmap, int w, int h, int offset, boolean has_transp); |
148 |
|
149 |
/**
|
150 |
* Test method.
|
151 |
*
|
152 |
* @return an irrelevant value
|
153 |
*/
|
154 |
public static native int test(); |
155 |
|
156 |
/**
|
157 |
* Sets the cache that Ermapper's DLL is allowed to use. It must be set
|
158 |
* to zero to avoid memory leaks.
|
159 |
*
|
160 |
* @param size cache limits in kilobytes
|
161 |
*/
|
162 |
public static native void setCacheInKBytes(int size); |
163 |
|
164 |
/**
|
165 |
* gets the array of bytes (PNG format) representing a white image of the given size.
|
166 |
* @param w image width
|
167 |
* @param h image height
|
168 |
* @return an array of bytes (PNG format) representing a white image
|
169 |
*/
|
170 |
public static byte[] getWhiteImage(int w, int h) { |
171 |
int size = w * h;
|
172 |
int[] wimage = new int[size]; |
173 |
for (int i=0; i<size; i++) { wimage[i] = 16777216; } |
174 |
return paintArray(wimage, w, h, 0, false); |
175 |
} |
176 |
|
177 |
static {
|
178 |
|
179 |
try {
|
180 |
System.loadLibrary("NCSUtil"); |
181 |
System.loadLibrary("NCScnet"); |
182 |
System.loadLibrary("NCSEcw"); |
183 |
|
184 |
if (Utils.USING_PDA) {
|
185 |
System.loadLibrary("j9ecw"); |
186 |
setCacheInKBytes(0);
|
187 |
} else {
|
188 |
System.loadLibrary("j2seecw"); |
189 |
} |
190 |
|
191 |
} catch (Throwable th) { |
192 |
System.err.println("Unable to load Ermapper libraries!"); |
193 |
} |
194 |
|
195 |
} |
196 |
|
197 |
/**
|
198 |
* Utility method to force the load of the associated DLL.
|
199 |
*
|
200 |
*/
|
201 |
public static void touch() { } |
202 |
|
203 |
} |