root / branches / Mobile_Compatible_Hito_1 / libFMap / src / es / prodevelop / gvsig / mobile / fmap / driver / vect / shp / ShpReader.java @ 21606
History | View | Annotate | Download (6.64 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.vect.shp; |
57 |
|
58 |
import es.prodevelop.gvsig.mobile.fmap.util.Utils; |
59 |
|
60 |
/**
|
61 |
* This class accesses the SHP/DBF file via static JNI functions.
|
62 |
*
|
63 |
* @author jldominguez
|
64 |
*
|
65 |
*/
|
66 |
public class ShpReader { |
67 |
|
68 |
static {
|
69 |
|
70 |
try {
|
71 |
if (Utils.USING_PDA) {
|
72 |
System.loadLibrary("j9shp"); |
73 |
} else {
|
74 |
System.loadLibrary("j2seshp"); |
75 |
} |
76 |
} catch (Throwable th) { |
77 |
System.err.println("Unable to load SHP libraries!"); |
78 |
} |
79 |
|
80 |
} |
81 |
|
82 |
/**
|
83 |
* Opens a SHP file
|
84 |
*
|
85 |
* @param full_file_path file path
|
86 |
* @param write_access whether a write access is needed
|
87 |
*
|
88 |
* @return the handler to the opened file
|
89 |
*/
|
90 |
public static native long openShpFile(String full_file_path, boolean write_access); |
91 |
|
92 |
/**
|
93 |
* Closes a SHP file
|
94 |
* @param ptr the handler of the file to be closed
|
95 |
* @return whether the file was successfully closed
|
96 |
*/
|
97 |
public static native boolean closeShpFile(long ptr); |
98 |
|
99 |
/**
|
100 |
* Gets SHP metadata
|
101 |
* @param ptr handler to the SHP file
|
102 |
* @return an array containing metadata: [0] = shape type, [1] = extent min x,
|
103 |
* [2] = extent min y, [3] = extent width, [4] = extent height, [5] = row count,
|
104 |
*
|
105 |
*/
|
106 |
public static native double[] getShpMetadata(long ptr); |
107 |
|
108 |
/**
|
109 |
* Gets the shape as an array of coordinates
|
110 |
* @param ptr handler of the SHP file
|
111 |
* @param index index of the geometry of interest
|
112 |
* @return the shape as an array of coordinates: [minx, miny, w, h, type,
|
113 |
* n_parts, n_parts_start_index, nvertices, vertices]
|
114 |
*/
|
115 |
public static native double[] getShapeWithBox(long ptr, int index); |
116 |
|
117 |
/**
|
118 |
* Gets the shapebounds of a geometry
|
119 |
* @param ptr handler of the SHP file
|
120 |
* @param index index of the geometry of interest
|
121 |
* @return bounding box [x, y, w, h]
|
122 |
*/
|
123 |
public static native double[] getShapeBounds(long ptr, int index); |
124 |
|
125 |
/**
|
126 |
* Utility method to transform a geometry with a given affine transform.
|
127 |
* This method is incomplete and should not be used.
|
128 |
*
|
129 |
* @param data the corrdinates to be transformed
|
130 |
* @param size the number of vertices
|
131 |
* @param m00 component of the affine transform matrix
|
132 |
* @param m11 component of the affine transform matrix
|
133 |
* @param m02 component of the affine transform matrix
|
134 |
* @param m12 component of the affine transform matrix
|
135 |
* @param dim the dimension of the geometry
|
136 |
* @return
|
137 |
*/
|
138 |
public static native int[] getPixelTransformedShape( |
139 |
double[] data, |
140 |
int size,
|
141 |
double m00,
|
142 |
double m11,
|
143 |
double m02,
|
144 |
double m12,
|
145 |
int dim);
|
146 |
|
147 |
/**
|
148 |
* Opens a DBF file.
|
149 |
*
|
150 |
* @param canonicalPath file path
|
151 |
* @param write_access whether write access is needed
|
152 |
* @return the handler to the file
|
153 |
*/
|
154 |
public static native long openDbfFile(String canonicalPath, boolean write_access); |
155 |
|
156 |
/**
|
157 |
* Gets the field count of a DBF file
|
158 |
* @param fileHandler teh handler of the file of interest
|
159 |
* @return the field count
|
160 |
*/
|
161 |
public static native int getDbfFileFieldCount(long fileHandler); |
162 |
|
163 |
/**
|
164 |
* Gets the field types of a DBF file
|
165 |
* @param fileHandler the handler of the file of interest
|
166 |
* @param size field count
|
167 |
* @return the field types as an array of chars (treated as integers)
|
168 |
*/
|
169 |
public static native char[] getDbfFileFieldTypes(long fileHandler, int size); |
170 |
|
171 |
/**
|
172 |
* Gets the field names of a DBF file
|
173 |
* @param fileHandler the handler of the file of interest
|
174 |
* @param size field count
|
175 |
* @return the field types as a comma separated list
|
176 |
*/
|
177 |
public static native String getDbfFileFieldNames(long fileHandler, int size); |
178 |
|
179 |
/**
|
180 |
* Closes the file
|
181 |
* @param fileHandler the handler of the DBF file to be closed
|
182 |
* @return whether the file was successfully closed
|
183 |
*/
|
184 |
public static native boolean closeDbfFile(long fileHandler); |
185 |
|
186 |
/**
|
187 |
* Gets row count
|
188 |
* @param fileHandler the handler of the file of interest
|
189 |
* @return the row count
|
190 |
*/
|
191 |
public static native int getDbfFileRowCount(long fileHandler); |
192 |
|
193 |
/**
|
194 |
* Gets the field widths of a DBF file
|
195 |
* @param fileHandler the handler of the file of interest
|
196 |
* @param size field count
|
197 |
* @return the field types as a comma separated list
|
198 |
*/
|
199 |
public static native int[] getDbfFileFieldWidths(long fileHandler, int size); |
200 |
|
201 |
/**
|
202 |
* Gets a numeric value from a row and field
|
203 |
*
|
204 |
* @param handler the handler of the file of interest
|
205 |
* @param row the row index
|
206 |
* @param fieldindex the field index
|
207 |
* @return the numeric value of that cell (row, field)
|
208 |
*/
|
209 |
public static native double getDbfNumberFieldValue(long handler, int row, int fieldindex); |
210 |
|
211 |
/**
|
212 |
* Gets a string value from a row and field
|
213 |
*
|
214 |
* @param handler the handler of the file of interest
|
215 |
* @param row the row index
|
216 |
* @param fieldindex the field index
|
217 |
* @return the string value of that cell (row, field)
|
218 |
*/
|
219 |
public static native String getDbfStringFieldValue(long handler, int row, int fieldindex); |
220 |
|
221 |
/**
|
222 |
* Gets a boolean value from a row and field
|
223 |
*
|
224 |
* @param handler the handler of the file of interest
|
225 |
* @param row the row index
|
226 |
* @param fieldindex the field index
|
227 |
* @return the boolean value of that cell (row, field)
|
228 |
*/
|
229 |
public static native boolean getDbfBooleanFieldValue(long handler, int row, int fieldindex); |
230 |
|
231 |
/**
|
232 |
* Utility method to force the load of the DLL library
|
233 |
*
|
234 |
*/
|
235 |
public static void touch() { } |
236 |
|
237 |
} |