Revision 21927
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-comp/org/gvsig/datasources/impljse/RandomAccessFileJSE.java | ||
---|---|---|
4 | 4 |
import java.io.FileNotFoundException; |
5 | 5 |
import java.io.IOException; |
6 | 6 |
import java.io.RandomAccessFile; |
7 |
import java.nio.ByteBuffer; |
|
8 | 7 |
import java.nio.channels.FileChannel; |
9 | 8 |
|
10 | 9 |
import org.gvsig.datasources.common.IRandomAccessFile; |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-comp/org/gvsig/datasources/impljse/ImplJ2SE.java | ||
---|---|---|
11 | 11 |
import org.gvsig.datasources.common.IRandomAccessFile; |
12 | 12 |
import org.gvsig.datasources.common.IRandomFileChannel; |
13 | 13 |
import org.gvsig.datasources.impljme.Impl; |
14 |
import org.gvsig.datasources.impljse.CharsetJSE; |
|
15 | 14 |
|
16 | 15 |
|
17 | 16 |
public class ImplJ2SE { |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-comp/org/gvsig/datasources/impljse/ByteBufferJSE.java | ||
---|---|---|
1 | 1 |
package org.gvsig.datasources.impljse; |
2 | 2 |
|
3 |
import java.nio.Buffer; |
|
4 | 3 |
import java.nio.ByteBuffer; |
5 | 4 |
import java.nio.ByteOrder; |
6 | 5 |
|
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-comp/org/gvsig/datasources/impljse/BigByteBufferJSE.java | ||
---|---|---|
44 | 44 |
package org.gvsig.datasources.impljse; |
45 | 45 |
|
46 | 46 |
import java.io.IOException; |
47 |
import java.nio.ByteBuffer; |
|
48 | 47 |
import java.nio.ByteOrder; |
49 | 48 |
import java.nio.channels.FileChannel; |
50 | 49 |
|
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-comp/org/gvsig/datasources/impljme/BufferedBigByteBufferJME.java | ||
---|---|---|
1 | 1 |
package org.gvsig.datasources.impljme; |
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 |
import java.nio.ByteBuffer; |
|
5 | 4 |
import java.nio.ByteOrder; |
6 | 5 |
|
7 | 6 |
import org.apache.log4j.Logger; |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-comp/org/gvsig/datasources/impljme/ByteUtil.java | ||
---|---|---|
1 | 1 |
package org.gvsig.datasources.impljme; |
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 |
import java.io.FileNotFoundException; |
|
5 |
import java.io.FileReader; |
|
6 | 4 |
import java.io.RandomAccessFile; |
7 |
import java.nio.ByteOrder; |
|
8 | 5 |
|
9 | 6 |
/** |
10 | 7 |
* Utility class with static methods |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-comp/org/gvsig/datasources/impljme/Impl.java | ||
---|---|---|
4 | 4 |
import java.io.FileNotFoundException; |
5 | 5 |
import java.io.IOException; |
6 | 6 |
|
7 |
import org.apache.log4j.Logger; |
|
8 | 7 |
import org.gvsig.datasources.common.IBigByteBuffer; |
9 | 8 |
import org.gvsig.datasources.common.IByteBuffer; |
10 | 9 |
import org.gvsig.datasources.common.ICharset; |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp_mem/simplify/DbfMemoryDataSource.java | ||
---|---|---|
3 | 3 |
import java.io.File; |
4 | 4 |
import java.io.IOException; |
5 | 5 |
import java.sql.Types; |
6 |
import java.text.DateFormat; |
|
7 |
import java.text.ParseException; |
|
8 |
import java.text.SimpleDateFormat; |
|
9 |
import java.util.Date; |
|
10 | 6 |
|
11 | 7 |
import org.apache.log4j.Logger; |
12 | 8 |
import org.gvsig.data.datastores.vectorial.file.shp_mem.DbaseFileNIO; |
9 |
import org.gvsig.data.datastores.vectorial.file.shp_util.BaseReadException; |
|
13 | 10 |
import org.gvsig.data.datastores.vectorial.file.shp_util.DBFDataSource; |
14 | 11 |
import org.gvsig.data.datastores.vectorial.file.shp_util.DbfUtil; |
15 | 12 |
import org.gvsig.exceptions.DriverException; |
... | ... | |
258 | 255 |
* the index of the field of interest |
259 | 256 |
* @return teh field type |
260 | 257 |
*/ |
261 |
public int getFieldType(int arg0) throws DriverException {
|
|
258 |
public int getFieldType(int arg0) throws BaseReadException {
|
|
262 | 259 |
return dbFileAccess.getFieldIntType(arg0); |
263 | 260 |
} |
264 | 261 |
|
... | ... | |
269 | 266 |
* the index of the field of interest |
270 | 267 |
* @return teh field width |
271 | 268 |
*/ |
272 |
public int getFieldWidth(int arg0) throws DriverException {
|
|
269 |
public int getFieldWidth(int arg0) throws BaseReadException {
|
|
273 | 270 |
return dbFileAccess.getFieldLength(arg0); |
274 | 271 |
} |
275 | 272 |
|
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp_mem/simplify/MemoryShpDriver.java | ||
---|---|---|
338 | 338 |
// el shape tal con tema tal y n?mro tal es null |
339 | 339 |
if (shapeType == SHP.SHPT_NULL) { |
340 | 340 |
logger.warn("Found a null geometry in file " + fileShp.getName() |
341 |
+ " (shape index: " + index);
|
|
341 |
+ " ( shape index: " + index + " )");
|
|
342 | 342 |
return new NullGeometry(); |
343 | 343 |
} |
344 | 344 |
|
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp_mem/MemSHPStore.java | ||
---|---|---|
14 | 14 |
import org.gvsig.data.OpenException; |
15 | 15 |
import org.gvsig.data.ReadException; |
16 | 16 |
import org.gvsig.data.WriteException; |
17 |
import org.gvsig.data.datastores.vectorial.file.Utils; |
|
18 | 17 |
import org.gvsig.data.datastores.vectorial.file.shp.SHPStoreParameters; |
19 | 18 |
import org.gvsig.data.datastores.vectorial.file.shp_mem.simplify.DbfMemoryDataSource; |
20 | 19 |
import org.gvsig.data.datastores.vectorial.file.shp_mem.simplify.MemoryShpDriver; |
... | ... | |
27 | 26 |
import org.gvsig.data.spatialprovisionalold.IExtent; |
28 | 27 |
import org.gvsig.data.vectorial.AbstractFeatureStore; |
29 | 28 |
import org.gvsig.data.vectorial.AttributeDescriptor; |
30 |
import org.gvsig.data.vectorial.DefaultAttributeDescriptor; |
|
31 | 29 |
import org.gvsig.data.vectorial.DefaultFeatureType; |
32 | 30 |
import org.gvsig.data.vectorial.Feature; |
33 | 31 |
import org.gvsig.data.vectorial.FeatureAttributeDescriptor; |
34 | 32 |
import org.gvsig.data.vectorial.FeatureID; |
35 | 33 |
import org.gvsig.data.vectorial.FeatureType; |
36 | 34 |
import org.gvsig.data.vectorial.IsNotAttributeSettingException; |
37 |
import org.gvsig.data.vectorial.NewFeatureStoreParameters; |
|
38 | 35 |
import org.gvsig.exceptions.BaseException; |
39 |
import org.gvsig.exceptions.DriverException; |
|
40 | 36 |
import org.gvsig.fmap.geom.Geometry; |
41 | 37 |
import org.gvsig.metadata.IMetadata; |
42 | 38 |
import org.opengis.filter.Filter; |
... | ... | |
255 | 251 |
return null; |
256 | 252 |
} |
257 | 253 |
|
258 |
@Override |
|
254 |
// @Override
|
|
259 | 255 |
protected void doRefresh() throws OpenException, InitializeException { |
260 | 256 |
// TODO Auto-generated method stub |
261 | 257 |
|
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/ShpFeature.java | ||
---|---|---|
38 | 38 |
.get(i); |
39 | 39 |
String fieldType = descriptor.getDataType(); |
40 | 40 |
if (fieldType.equals(FeatureAttributeDescriptor.TYPE_GEOMETRY)) { |
41 |
loading(); |
|
41 | 42 |
setGeometry(i, geometry); |
43 |
stopLoading(); |
|
42 | 44 |
} |
43 | 45 |
} |
44 | 46 |
} |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/SHPStore.java | ||
---|---|---|
27 | 27 |
import org.gvsig.data.spatialprovisionalold.Extent; |
28 | 28 |
import org.gvsig.data.spatialprovisionalold.IExtent; |
29 | 29 |
import org.gvsig.data.vectorial.AttributeDescriptor; |
30 |
import org.gvsig.data.vectorial.DefaultAttributeDescriptor; |
|
31 | 30 |
import org.gvsig.data.vectorial.DefaultFeatureType; |
32 | 31 |
import org.gvsig.data.vectorial.Feature; |
33 | 32 |
import org.gvsig.data.vectorial.FeatureAttributeDescriptor; |
... | ... | |
235 | 234 |
} |
236 | 235 |
|
237 | 236 |
public List getFeatureTypes() { |
238 |
featureTypes.set(0, getDefaultFeatureType()); |
|
237 |
if (featureTypes.size() == 0) { |
|
238 |
featureTypes.add(new Integer(0)); |
|
239 |
featureTypes.set(0, getDefaultFeatureType()); |
|
240 |
} |
|
239 | 241 |
return featureTypes; |
240 | 242 |
} |
241 | 243 |
|
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/utils/SHPMultiLine.java | ||
---|---|---|
45 | 45 |
import java.nio.ByteBuffer; |
46 | 46 |
import java.nio.MappedByteBuffer; |
47 | 47 |
import java.util.ArrayList; |
48 |
|
|
48 | 49 |
import org.gvsig.datasources.common.IByteBuffer; |
49 | 50 |
import org.gvsig.fmap.geom.Geometry; |
50 | 51 |
import org.gvsig.fmap.geom.primitive.AbstractPrimitive; |
... | ... | |
53 | 54 |
import org.gvsig.fmap.geom.primitive.Point2D; |
54 | 55 |
import org.gvsig.fmap.geom.util.Converter; |
55 | 56 |
|
56 |
|
|
57 | 57 |
/** |
58 | 58 |
* Elemento shape de tipo multil?nea. |
59 |
* |
|
59 |
*
|
|
60 | 60 |
* @author Vicente Caballero Navarro |
61 | 61 |
*/ |
62 | 62 |
public class SHPMultiLine implements SHPShape { |
63 | 63 |
protected int m_type; |
64 |
|
|
64 | 65 |
protected int[] parts; |
66 |
|
|
65 | 67 |
protected Point2D[] points; |
68 |
|
|
66 | 69 |
protected double[] zs; |
67 |
//double flatness = 0.8; // Por ejemplo. Cuanto m?s peque?o, m?s segmentos necesitar? la curva |
|
68 | 70 |
|
71 |
// double flatness = 0.8; // Por ejemplo. Cuanto m?s peque?o, m?s segmentos |
|
72 |
// necesitar? la curva |
|
73 |
|
|
69 | 74 |
/** |
70 | 75 |
* Crea un nuevo SHPMultiLine. |
71 | 76 |
*/ |
... | ... | |
75 | 80 |
|
76 | 81 |
/** |
77 | 82 |
* Crea un nuevo SHPMultiLine. |
78 |
* |
|
79 |
* @param type Tipo de multil?nea. |
|
80 |
* |
|
83 |
* |
|
84 |
* @param type |
|
85 |
* Tipo de multil?nea. |
|
86 |
* |
|
81 | 87 |
* @throws ShapefileException |
82 | 88 |
*/ |
83 | 89 |
public SHPMultiLine(int type) { |
84 |
if ((type != SHP.POLYLINE2D) && |
|
85 |
(type != SHP.POLYLINEM) && |
|
86 |
(type != SHP.POLYLINE3D)) { |
|
87 |
// throw new ShapefileException("No es de tipo 3,13 ni 23"); |
|
90 |
if ((type != SHP.POLYLINE2D) && (type != SHP.POLYLINEM) |
|
91 |
&& (type != SHP.POLYLINE3D)) { |
|
92 |
// throw new ShapefileException("No es de tipo 3,13 ni 23"); |
|
88 | 93 |
} |
89 | 94 |
|
90 | 95 |
m_type = type; |
... | ... | |
105 | 110 |
double minY = buffer.getDouble(); |
106 | 111 |
double maxX = buffer.getDouble(); |
107 | 112 |
double maxY = buffer.getDouble(); |
108 |
Rectangle2D rec = new Rectangle2D.Double(minX, minY, maxX - minX, |
|
109 |
maxY - maxY);
|
|
113 |
Rectangle2D rec = new Rectangle2D.Double(minX, minY, maxX - minX, maxY
|
|
114 |
- maxY); |
|
110 | 115 |
|
111 | 116 |
int numParts = buffer.getInt(); |
112 |
int numPoints = buffer.getInt(); //total number of points |
|
117 |
int numPoints = buffer.getInt(); // total number of points
|
|
113 | 118 |
|
114 | 119 |
int[] partOffsets = new int[numParts]; |
115 | 120 |
|
... | ... | |
123 | 128 |
points[t] = new Point2D(buffer.getDouble(), buffer.getDouble()); |
124 | 129 |
} |
125 | 130 |
|
126 |
/* if (type == FConstant.SHAPE_TYPE_POLYLINEZ) { |
|
127 |
//z min, max |
|
128 |
buffer.position(buffer.position() + (2 * 8)); |
|
129 |
for (int t = 0; t < numPoints; t++) { |
|
130 |
points[t].z = buffer.getDouble(); //z value |
|
131 |
} |
|
132 |
} |
|
131 |
/* |
|
132 |
* if (type == FConstant.SHAPE_TYPE_POLYLINEZ) { //z min, max |
|
133 |
* buffer.position(buffer.position() + (2 * 8)); for (int t = 0; t < |
|
134 |
* numPoints; t++) { points[t].z = buffer.getDouble(); //z value } } |
|
133 | 135 |
*/ |
134 | 136 |
return (Geometry) new Curve2D(getGeneralPathX(points, partOffsets)); |
135 | 137 |
} |
... | ... | |
157 | 159 |
buffer.putDouble(points[t].getY()); |
158 | 160 |
} |
159 | 161 |
|
160 |
if (m_type == SHP.POLYLINE3D) {
|
|
161 |
double[] zExtreame = SHP.getZMinMax(zs);
|
|
162 |
if (Double.isNaN(zExtreame[0])) {
|
|
163 |
buffer.putDouble(0.0);
|
|
164 |
buffer.putDouble(0.0);
|
|
165 |
} else {
|
|
166 |
buffer.putDouble(zExtreame[0]);
|
|
167 |
buffer.putDouble(zExtreame[1]);
|
|
168 |
}
|
|
169 |
for (int t = 0; t < npoints; t++) {
|
|
170 |
double z = zs[t];
|
|
171 |
if (Double.isNaN(z)) {
|
|
172 |
buffer.putDouble(0.0);
|
|
173 |
} else {
|
|
174 |
buffer.putDouble(z);
|
|
175 |
}
|
|
176 |
}
|
|
162 |
if (m_type == SHP.POLYLINE3D) { |
|
163 |
double[] zExtreame = SHP.getZMinMax(zs);
|
|
164 |
if (Double.isNaN(zExtreame[0])) {
|
|
165 |
buffer.putDouble(0.0);
|
|
166 |
buffer.putDouble(0.0);
|
|
167 |
} else {
|
|
168 |
buffer.putDouble(zExtreame[0]);
|
|
169 |
buffer.putDouble(zExtreame[1]);
|
|
170 |
}
|
|
171 |
for (int t = 0; t < npoints; t++) {
|
|
172 |
double z = zs[t];
|
|
173 |
if (Double.isNaN(z)) {
|
|
174 |
buffer.putDouble(0.0);
|
|
175 |
} else {
|
|
176 |
buffer.putDouble(z);
|
|
177 |
}
|
|
178 |
}
|
|
177 | 179 |
|
178 |
}
|
|
179 |
if (m_type == SHP.POLYLINEM) {
|
|
180 |
buffer.putDouble(-10E40);
|
|
181 |
buffer.putDouble(-10E40);
|
|
182 |
for (int t = 0; t < npoints; t++) {
|
|
183 |
buffer.putDouble(-10E40);
|
|
184 |
}
|
|
185 |
}
|
|
180 |
} |
|
181 |
if (m_type == SHP.POLYLINEM) { |
|
182 |
buffer.putDouble(-10E40);
|
|
183 |
buffer.putDouble(-10E40);
|
|
184 |
for (int t = 0; t < npoints; t++) {
|
|
185 |
buffer.putDouble(-10E40);
|
|
186 |
}
|
|
187 |
} |
|
186 | 188 |
|
187 | 189 |
} |
188 | 190 |
|
... | ... | |
199 | 201 |
if (m_type == SHP.POLYLINE2D) { |
200 | 202 |
length = 44 + (4 * numlines) + (numpoints * 16); |
201 | 203 |
} else if (m_type == SHP.POLYLINEM) { |
202 |
length = 44 + (4 * numlines) + (numpoints * 16) + 8 + 8 +
|
|
203 |
(8 * numpoints); |
|
204 |
length = 44 + (4 * numlines) + (numpoints * 16) + 8 + 8 |
|
205 |
+ (8 * numpoints);
|
|
204 | 206 |
} else if (m_type == SHP.POLYLINE3D) { |
205 |
length = 44 + (4 * numlines) + (numpoints * 16) + |
|
206 |
(8 * numpoints) + 8 + 8;
|
|
207 |
length = 44 + (4 * numlines) + (numpoints * 16) + (8 * numpoints)
|
|
208 |
+ 8 + 8;
|
|
207 | 209 |
} else { |
208 |
throw new IllegalStateException("Expected ShapeType of Arc, got " +
|
|
209 |
m_type); |
|
210 |
throw new IllegalStateException("Expected ShapeType of Arc, got " |
|
211 |
+ m_type);
|
|
210 | 212 |
} |
211 | 213 |
|
212 | 214 |
return length; |
... | ... | |
214 | 216 |
|
215 | 217 |
/** |
216 | 218 |
* DOCUMENT ME! |
217 |
* |
|
218 |
* @param po DOCUMENT ME! |
|
219 |
* @param pa DOCUMENT ME! |
|
220 |
* |
|
219 |
* |
|
220 |
* @param po |
|
221 |
* DOCUMENT ME! |
|
222 |
* @param pa |
|
223 |
* DOCUMENT ME! |
|
224 |
* |
|
221 | 225 |
* @return DOCUMENT ME! |
222 | 226 |
*/ |
223 | 227 |
protected GeneralPathX getGeneralPathX(Point2D[] po, int[] pa) { |
... | ... | |
244 | 248 |
* @see com.iver.cit.gvsig.fmap.shp.SHPShape#obtainsPoints(com.iver.cit.gvsig.fmap.core.GeneralPathXIterator) |
245 | 249 |
*/ |
246 | 250 |
public void obtainsPoints(Geometry g) { |
247 |
if (SHP.POLYLINE3D == m_type || SHP.POLYGON3D == m_type){ |
|
248 |
zs=((AbstractPrimitive)g).getZs();
|
|
251 |
if (SHP.POLYLINE3D == m_type || SHP.POLYGON3D == m_type) {
|
|
252 |
zs = ((AbstractPrimitive) g).getZs();
|
|
249 | 253 |
} |
250 | 254 |
ArrayList arrayPoints = null; |
251 | 255 |
ArrayList arrayParts = new ArrayList(); |
252 |
PathIterator theIterator = g.getPathIterator(null, Converter.FLATNESS); //polyLine.getPathIterator(null, flatness); |
|
256 |
PathIterator theIterator = g.getPathIterator(null, Converter.FLATNESS); // polyLine.getPathIterator(null, |
|
257 |
// flatness); |
|
253 | 258 |
double[] theData = new double[6]; |
254 | 259 |
int numParts = 0; |
255 | 260 |
while (!theIterator.isDone()) { |
256 |
//while not done |
|
261 |
// while not done
|
|
257 | 262 |
int theType = theIterator.currentSegment(theData); |
258 | 263 |
|
259 |
//Populate a segment of the new |
|
264 |
// Populate a segment of the new
|
|
260 | 265 |
// GeneralPathX object. |
261 |
//Process the current segment to populate a new |
|
266 |
// Process the current segment to populate a new
|
|
262 | 267 |
// segment of the new GeneralPathX object. |
263 | 268 |
|
264 | 269 |
switch (theType) { |
265 |
case PathIterator.SEG_MOVETO:
|
|
270 |
case PathIterator.SEG_MOVETO: |
|
266 | 271 |
|
267 |
// System.out.println("SEG_MOVETO");
|
|
268 |
if (arrayPoints == null) {
|
|
269 |
arrayPoints = new ArrayList();
|
|
270 |
arrayParts.add(new Integer(0));
|
|
271 |
} else {
|
|
272 |
arrayParts.add(new Integer(arrayPoints.size()));
|
|
273 |
}
|
|
272 |
// System.out.println("SEG_MOVETO"); |
|
273 |
if (arrayPoints == null) { |
|
274 |
arrayPoints = new ArrayList(); |
|
275 |
arrayParts.add(new Integer(0)); |
|
276 |
} else { |
|
277 |
arrayParts.add(new Integer(arrayPoints.size())); |
|
278 |
} |
|
274 | 279 |
|
275 |
numParts++;
|
|
280 |
numParts++; |
|
276 | 281 |
|
277 |
arrayPoints.add(new Point2D(theData[0], theData[1]));
|
|
282 |
arrayPoints.add(new Point2D(theData[0], theData[1])); |
|
278 | 283 |
|
279 |
break;
|
|
284 |
break; |
|
280 | 285 |
|
281 |
case PathIterator.SEG_LINETO:
|
|
286 |
case PathIterator.SEG_LINETO: |
|
282 | 287 |
|
283 |
// System.out.println("SEG_LINETO");
|
|
284 |
arrayPoints.add(new Point2D(theData[0], theData[1]));
|
|
288 |
// System.out.println("SEG_LINETO"); |
|
289 |
arrayPoints.add(new Point2D(theData[0], theData[1])); |
|
285 | 290 |
|
286 |
break;
|
|
291 |
break; |
|
287 | 292 |
|
288 |
case PathIterator.SEG_QUADTO:
|
|
289 |
System.out.println("Not supported here");
|
|
293 |
case PathIterator.SEG_QUADTO: |
|
294 |
System.out.println("Not supported here"); |
|
290 | 295 |
|
291 |
break;
|
|
296 |
break; |
|
292 | 297 |
|
293 |
case PathIterator.SEG_CUBICTO:
|
|
294 |
System.out.println("Not supported here");
|
|
298 |
case PathIterator.SEG_CUBICTO: |
|
299 |
System.out.println("Not supported here"); |
|
295 | 300 |
|
296 |
break;
|
|
301 |
break; |
|
297 | 302 |
|
298 |
case PathIterator.SEG_CLOSE:
|
|
299 |
// System.out.println("SEG_CLOSE");
|
|
303 |
case PathIterator.SEG_CLOSE: |
|
304 |
// System.out.println("SEG_CLOSE");
|
|
300 | 305 |
|
301 |
// A?adimos el primer punto para cerrar.
|
|
302 |
Point2D firstPoint = (Point2D) arrayPoints.get(0);
|
|
303 |
arrayPoints.add(new Point2D(firstPoint.getX(),
|
|
304 |
firstPoint.getY()));
|
|
306 |
// A?adimos el primer punto para cerrar. |
|
307 |
Point2D firstPoint = (Point2D) arrayPoints.get(0); |
|
308 |
arrayPoints.add(new Point2D(firstPoint.getX(), firstPoint
|
|
309 |
.getY())); |
|
305 | 310 |
|
306 |
break;
|
|
307 |
} //end switch |
|
311 |
break; |
|
312 |
} // end switch
|
|
308 | 313 |
|
309 | 314 |
theIterator.next(); |
310 | 315 |
} |
... | ... | |
314 | 319 |
for (int i = 0; i < integers.length; i++) { |
315 | 320 |
parts[i] = integers[i].intValue(); |
316 | 321 |
} |
317 |
if (arrayPoints==null){
|
|
318 |
points=new Point2D[0];
|
|
322 |
if (arrayPoints == null) {
|
|
323 |
points = new Point2D[0];
|
|
319 | 324 |
return; |
320 | 325 |
} |
321 | 326 |
points = (Point2D[]) arrayPoints.toArray(new Point2D[0]); |
322 | 327 |
|
323 | 328 |
} |
324 | 329 |
|
325 |
// public void setFlatness(double flatness) {
|
|
326 |
// this.flatness=flatness;
|
|
327 |
// }
|
|
330 |
// public void setFlatness(double flatness) {
|
|
331 |
// this.flatness=flatness;
|
|
332 |
// }
|
|
328 | 333 |
} |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/utils/SHPMultiPoint.java | ||
---|---|---|
54 | 54 |
|
55 | 55 |
/** |
56 | 56 |
* Elemento shape de tipo multipunto. |
57 |
* |
|
57 |
*
|
|
58 | 58 |
* @author Vicente Caballero Navarro |
59 | 59 |
*/ |
60 | 60 |
public class SHPMultiPoint implements SHPShape { |
61 | 61 |
private int m_type; |
62 |
|
|
62 | 63 |
private int numpoints; |
64 |
|
|
63 | 65 |
private Point2D[] points; |
66 |
|
|
64 | 67 |
private double[] zs; |
65 | 68 |
|
66 | 69 |
/** |
... | ... | |
72 | 75 |
|
73 | 76 |
/** |
74 | 77 |
* Crea un nuevo SHPMultiPoint. |
75 |
* |
|
76 |
* @param type Tipo de multipunto. |
|
77 |
* |
|
78 |
* |
|
79 |
* @param type |
|
80 |
* Tipo de multipunto. |
|
81 |
* |
|
78 | 82 |
* @throws ShapefileException |
79 | 83 |
*/ |
80 | 84 |
public SHPMultiPoint(int type) { |
81 |
if ((type != SHP.MULTIPOINT2D) && |
|
82 |
(type != SHP.MULTIPOINTM) && |
|
83 |
(type != SHP.MULTIPOINT3D)) { |
|
84 |
// throw new ShapefileException("No es de tipo 8, 18, o 28"); |
|
85 |
if ((type != SHP.MULTIPOINT2D) && (type != SHP.MULTIPOINTM) |
|
86 |
&& (type != SHP.MULTIPOINT3D)) { |
|
87 |
// throw new ShapefileException("No es de tipo 8, 18, o 28"); |
|
85 | 88 |
} |
86 | 89 |
|
87 | 90 |
m_type = type; |
... | ... | |
89 | 92 |
|
90 | 93 |
/** |
91 | 94 |
* Devuelve el tipo de multipoint en concreto. |
92 |
* |
|
95 |
*
|
|
93 | 96 |
* @return Tipo de multipoint. |
94 | 97 |
*/ |
95 | 98 |
public int getShapeType() { |
... | ... | |
104 | 107 |
double minY = buffer.getDouble(); |
105 | 108 |
double maxX = buffer.getDouble(); |
106 | 109 |
double maxY = buffer.getDouble(); |
107 |
Rectangle2D rec = new Rectangle2D.Double(minX, minY, maxX - minX, |
|
108 |
maxY - maxY);
|
|
110 |
Rectangle2D rec = new Rectangle2D.Double(minX, minY, maxX - minX, maxY
|
|
111 |
- maxY); |
|
109 | 112 |
int numpoints = buffer.getInt(); |
110 | 113 |
org.gvsig.fmap.geom.primitive.Point2D[] p = new org.gvsig.fmap.geom.primitive.Point2D[numpoints]; |
111 | 114 |
|
... | ... | |
115 | 118 |
p[t] = new org.gvsig.fmap.geom.primitive.Point2D(x, y); |
116 | 119 |
} |
117 | 120 |
|
118 |
/* if (m_type == FConstant.SHAPE_TYPE_MULTIPOINTZ) { |
|
119 |
buffer.position(buffer.position() + (2 * 8)); |
|
120 |
for (int t = 0; t < numpoints; t++) { |
|
121 |
p[t].z = buffer.getDouble(); //z |
|
122 |
} |
|
123 |
} |
|
121 |
/* |
|
122 |
* if (m_type == FConstant.SHAPE_TYPE_MULTIPOINTZ) { |
|
123 |
* buffer.position(buffer.position() + (2 * 8)); for (int t = 0; t < |
|
124 |
* numpoints; t++) { p[t].z = buffer.getDouble(); //z } } |
|
124 | 125 |
*/ |
125 | 126 |
return (Geometry) new MultiPoint2D(p); |
126 | 127 |
} |
... | ... | |
137 | 138 |
buffer.putDouble(box.getMinY()); |
138 | 139 |
buffer.putDouble(box.getMaxX()); |
139 | 140 |
buffer.putDouble(box.getMaxY()); |
140 |
///obtainsPoints(geometry.getGeneralPathXIterator()); |
|
141 |
// /obtainsPoints(geometry.getGeneralPathXIterator());
|
|
141 | 142 |
buffer.putInt(numpoints); |
142 | 143 |
|
143 | 144 |
for (int t = 0, tt = numpoints; t < tt; t++) { |
... | ... | |
146 | 147 |
buffer.putDouble(point.getY()); |
147 | 148 |
} |
148 | 149 |
|
149 |
if (m_type == SHP.MULTIPOINT3D) { |
|
150 |
double[] zExtreame = SHP.getZMinMax(zs); |
|
151 |
if (Double.isNaN(zExtreame[0])) { |
|
152 |
buffer.putDouble(0.0); |
|
153 |
buffer.putDouble(0.0); |
|
154 |
} else { |
|
155 |
buffer.putDouble(zExtreame[0]); |
|
156 |
buffer.putDouble(zExtreame[1]); |
|
157 |
} |
|
158 |
for (int t = 0; t < numpoints; t++) { |
|
159 |
double z = zs[t]; |
|
160 |
if (Double.isNaN(z)) { |
|
161 |
buffer.putDouble(0.0); |
|
162 |
} else { |
|
163 |
buffer.putDouble(z); |
|
164 |
} |
|
165 |
} |
|
166 |
} |
|
167 |
if ((m_type == SHP.MULTIPOINTM) || |
|
168 |
(m_type == SHP.MULTIPOINT3D)) { |
|
169 |
buffer.putDouble(-10E40); |
|
170 |
buffer.putDouble(-10E40); |
|
171 |
for (int t = 0; t < numpoints; t++) { |
|
172 |
buffer.putDouble(-10E40); |
|
173 |
} |
|
174 |
} |
|
150 |
if (m_type == SHP.MULTIPOINT3D) { |
|
151 |
double[] zExtreame = SHP.getZMinMax(zs); |
|
152 |
if (Double.isNaN(zExtreame[0])) { |
|
153 |
buffer.putDouble(0.0); |
|
154 |
buffer.putDouble(0.0); |
|
155 |
} else { |
|
156 |
buffer.putDouble(zExtreame[0]); |
|
157 |
buffer.putDouble(zExtreame[1]); |
|
158 |
} |
|
159 |
for (int t = 0; t < numpoints; t++) { |
|
160 |
double z = zs[t]; |
|
161 |
if (Double.isNaN(z)) { |
|
162 |
buffer.putDouble(0.0); |
|
163 |
} else { |
|
164 |
buffer.putDouble(z); |
|
165 |
} |
|
166 |
} |
|
167 |
} |
|
168 |
if ((m_type == SHP.MULTIPOINTM) || (m_type == SHP.MULTIPOINT3D)) { |
|
169 |
buffer.putDouble(-10E40); |
|
170 |
buffer.putDouble(-10E40); |
|
171 |
for (int t = 0; t < numpoints; t++) { |
|
172 |
buffer.putDouble(-10E40); |
|
173 |
} |
|
174 |
} |
|
175 | 175 |
|
176 | 176 |
} |
177 | 177 |
|
... | ... | |
179 | 179 |
* @see com.iver.cit.gvsig.fmap.shp.SHPShape#getLength(com.iver.cit.gvsig.core.BasicShape.FGeometry) |
180 | 180 |
*/ |
181 | 181 |
public int getLength(Geometry fgeometry) { |
182 |
//FMultiPoint2D mp = (FMultiPoint2D) fgeometry.getShape(); |
|
183 |
///obtainsPoints(fgeometry.getGeneralPathXIterator()); |
|
182 |
// FMultiPoint2D mp = (FMultiPoint2D) fgeometry.getShape();
|
|
183 |
// /obtainsPoints(fgeometry.getGeneralPathXIterator());
|
|
184 | 184 |
|
185 | 185 |
int length; |
186 | 186 |
|
... | ... | |
194 | 194 |
// add the additional ZMin,ZMax, plus 8 per Z |
195 | 195 |
length = (numpoints * 16) + 40 + 16 + (8 * numpoints); |
196 | 196 |
} else { |
197 |
throw new IllegalStateException("Expected ShapeType of Arc, got " +
|
|
198 |
m_type); |
|
197 |
throw new IllegalStateException("Expected ShapeType of Arc, got " |
|
198 |
+ m_type);
|
|
199 | 199 |
} |
200 | 200 |
|
201 | 201 |
return length; |
... | ... | |
205 | 205 |
* @see com.iver.cit.gvsig.fmap.drivers.shp.write.SHPShape#obtainsPoints(com.iver.cit.gvsig.fmap.core.GeneralPathXIterator) |
206 | 206 |
*/ |
207 | 207 |
public void obtainsPoints(Geometry g) { |
208 |
if (SHP.MULTIPOINT3D == m_type){ |
|
209 |
zs=((AbstractPrimitive)g).getZs();
|
|
208 |
if (SHP.MULTIPOINT3D == m_type) {
|
|
209 |
zs = ((AbstractPrimitive) g).getZs();
|
|
210 | 210 |
} |
211 |
PathIterator theIterator = g.getPathIterator(null); //polyLine.getPathIterator(null, flatness); |
|
211 |
PathIterator theIterator = g.getPathIterator(null); // polyLine.getPathIterator(null, |
|
212 |
// flatness); |
|
212 | 213 |
double[] theData = new double[6]; |
213 |
ArrayList ps=new ArrayList();
|
|
214 |
ArrayList ps = new ArrayList();
|
|
214 | 215 |
while (!theIterator.isDone()) { |
215 |
//while not done |
|
216 |
// while not done
|
|
216 | 217 |
int theType = theIterator.currentSegment(theData); |
217 | 218 |
|
218 | 219 |
ps.add(new Point2D.Double(theData[0], theData[1])); |
219 | 220 |
theIterator.next(); |
220 |
} //end while loop |
|
221 |
points=(Point2D[])ps.toArray(new Point2D.Double[0]);
|
|
222 |
numpoints=points.length;
|
|
221 |
} // end while loop
|
|
222 |
points = (Point2D[]) ps.toArray(new Point2D.Double[0]);
|
|
223 |
numpoints = points.length;
|
|
223 | 224 |
} |
224 |
// public void setFlatness(double flatness) {
|
|
225 |
// //this.flatness=flatness;
|
|
226 |
// }
|
|
225 |
// public void setFlatness(double flatness) {
|
|
226 |
// //this.flatness=flatness;
|
|
227 |
// }
|
|
227 | 228 |
|
228 | 229 |
} |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/utils/SHPPolygon.java | ||
---|---|---|
50 | 50 |
|
51 | 51 |
/** |
52 | 52 |
* Elemento shape de tipo Pol?gono. |
53 |
* |
|
53 |
*
|
|
54 | 54 |
* @author Vicente Caballero Navarro |
55 | 55 |
*/ |
56 | 56 |
public class SHPPolygon extends SHPMultiLine { |
... | ... | |
64 | 64 |
|
65 | 65 |
/** |
66 | 66 |
* Crea un nuevo SHPPolygon. |
67 |
* |
|
68 |
* @param type Tipo de shape. |
|
69 |
* |
|
67 |
* |
|
68 |
* @param type |
|
69 |
* Tipo de shape. |
|
70 |
* |
|
70 | 71 |
* @throws ShapefileException |
71 | 72 |
*/ |
72 | 73 |
public SHPPolygon(int type) { |
73 |
if ((type != SHP.POLYGON2D) && |
|
74 |
(type != SHP.POLYGONM) && |
|
75 |
(type != SHP.POLYGON3D)) { |
|
76 |
// throw new ShapefileException("No es de tipo 5, 15, o 25"); |
|
74 |
if ((type != SHP.POLYGON2D) && (type != SHP.POLYGONM) |
|
75 |
&& (type != SHP.POLYGON3D)) { |
|
76 |
// throw new ShapefileException("No es de tipo 5, 15, o 25"); |
|
77 | 77 |
} |
78 | 78 |
|
79 | 79 |
m_type = type; |
... | ... | |
94 | 94 |
double minY = buffer.getDouble(); |
95 | 95 |
double maxX = buffer.getDouble(); |
96 | 96 |
double maxY = buffer.getDouble(); |
97 |
Rectangle2D rec = new Rectangle2D.Double(minX, minY, maxX - minX, |
|
98 |
maxY - maxY);
|
|
97 |
Rectangle2D rec = new Rectangle2D.Double(minX, minY, maxX - minX, maxY
|
|
98 |
- maxY); |
|
99 | 99 |
int numParts = buffer.getInt(); |
100 | 100 |
int numPoints = buffer.getInt(); |
101 | 101 |
|
... | ... | |
107 | 107 |
|
108 | 108 |
Point2D[] points = readPoints(buffer, numPoints); |
109 | 109 |
|
110 |
/* if (m_type == FConstant.SHAPE_TYPE_POLYGONZ) { |
|
111 |
//z |
|
112 |
buffer.position(buffer.position() + (2 * 8)); |
|
113 |
for (int t = 0; t < numPoints; t++) { |
|
114 |
points[t].z = buffer.getDouble(); |
|
115 |
} |
|
116 |
} |
|
110 |
/* |
|
111 |
* if (m_type == FConstant.SHAPE_TYPE_POLYGONZ) { //z |
|
112 |
* buffer.position(buffer.position() + (2 * 8)); for (int t = 0; t < |
|
113 |
* numPoints; t++) { points[t].z = buffer.getDouble(); } } |
|
117 | 114 |
*/ |
118 | 115 |
int offset = 0; |
119 | 116 |
int start; |
... | ... | |
143 | 140 |
|
144 | 141 |
/** |
145 | 142 |
* Lee los puntos del buffer. |
146 |
* |
|
143 |
*
|
|
147 | 144 |
* @param buffer |
148 |
* @param numPoints N?mero de puntos. |
|
149 |
* |
|
145 |
* @param numPoints |
|
146 |
* N?mero de puntos. |
|
147 |
* |
|
150 | 148 |
* @return Vector de Puntos. |
151 | 149 |
*/ |
152 | 150 |
private synchronized Point2D[] readPoints(final MappedByteBuffer buffer, |
153 |
final int numPoints) { |
|
151 |
final int numPoints) {
|
|
154 | 152 |
Point2D[] points = new Point2D[numPoints]; |
155 | 153 |
|
156 | 154 |
for (int t = 0; t < numPoints; t++) { |
... | ... | |
164 | 162 |
* @see com.iver.cit.gvsig.fmap.shp.SHPShape#write(ByteBuffer, IGeometry) |
165 | 163 |
*/ |
166 | 164 |
public synchronized void write(ByteBuffer buffer, Geometry geometry) { |
167 |
//FPolygon2D polyLine; |
|
168 |
//polyLine = (FPolygon2D) geometry.getShape(); |
|
165 |
// FPolygon2D polyLine;
|
|
166 |
// polyLine = (FPolygon2D) geometry.getShape();
|
|
169 | 167 |
Rectangle2D rec = geometry.getBounds2D(); |
170 | 168 |
buffer.putDouble(rec.getMinX()); |
171 | 169 |
buffer.putDouble(rec.getMinY()); |
172 | 170 |
buffer.putDouble(rec.getMaxX()); |
173 | 171 |
buffer.putDouble(rec.getMaxY()); |
174 | 172 |
|
175 |
////// |
|
176 |
///obtainsPoints(geometry.getGeneralPathXIterator()); |
|
173 |
// ////
|
|
174 |
// /obtainsPoints(geometry.getGeneralPathXIterator());
|
|
177 | 175 |
|
178 |
//int[] parts=polyLine.getParts(); |
|
179 |
//FPoint2D[] points=polyLine.getPoints(); |
|
176 |
// int[] parts=polyLine.getParts();
|
|
177 |
// FPoint2D[] points=polyLine.getPoints();
|
|
180 | 178 |
int nparts = parts.length; |
181 | 179 |
int npoints = points.length; |
182 | 180 |
|
183 |
////// |
|
184 |
///int npoints = polyLine.getNumPoints(); |
|
185 |
///int nparts = polyLine.getNumParts(); |
|
181 |
// ////
|
|
182 |
// /int npoints = polyLine.getNumPoints();
|
|
183 |
// /int nparts = polyLine.getNumParts();
|
|
186 | 184 |
buffer.putInt(nparts); |
187 | 185 |
buffer.putInt(npoints); |
188 | 186 |
|
189 | 187 |
int count = 0; |
190 | 188 |
|
191 | 189 |
for (int t = 0; t < nparts; t++) { |
192 |
///buffer.putInt(polyLine.getPart(t)); |
|
190 |
// /buffer.putInt(polyLine.getPart(t));
|
|
193 | 191 |
buffer.putInt(parts[t]); |
194 | 192 |
} |
195 | 193 |
|
196 |
///FPoint[] points = polyLine.getPoints(); |
|
194 |
// /FPoint[] points = polyLine.getPoints();
|
|
197 | 195 |
for (int t = 0; t < points.length; t++) { |
198 |
///buffer.putDouble(points[t].x); |
|
199 |
///buffer.putDouble(points[t].y); |
|
196 |
// /buffer.putDouble(points[t].x);
|
|
197 |
// /buffer.putDouble(points[t].y);
|
|
200 | 198 |
buffer.putDouble(points[t].getX()); |
201 | 199 |
buffer.putDouble(points[t].getY()); |
202 | 200 |
} |
203 | 201 |
|
204 |
if (m_type == SHP.POLYGON3D) {
|
|
205 |
double[] zExtreame = SHP.getZMinMax(zs);
|
|
206 |
if (Double.isNaN(zExtreame[0])) {
|
|
207 |
buffer.putDouble(0.0);
|
|
208 |
buffer.putDouble(0.0);
|
|
209 |
} else {
|
|
210 |
buffer.putDouble(zExtreame[0]);
|
|
211 |
buffer.putDouble(zExtreame[1]);
|
|
212 |
}
|
|
213 |
for (int t = 0; t < npoints; t++) {
|
|
214 |
double z = zs[t];
|
|
215 |
if (Double.isNaN(z)) {
|
|
216 |
buffer.putDouble(0.0);
|
|
217 |
} else {
|
|
218 |
buffer.putDouble(z);
|
|
219 |
}
|
|
220 |
}
|
|
221 |
}
|
|
202 |
if (m_type == SHP.POLYGON3D) { |
|
203 |
double[] zExtreame = SHP.getZMinMax(zs);
|
|
204 |
if (Double.isNaN(zExtreame[0])) {
|
|
205 |
buffer.putDouble(0.0);
|
|
206 |
buffer.putDouble(0.0);
|
|
207 |
} else {
|
|
208 |
buffer.putDouble(zExtreame[0]);
|
|
209 |
buffer.putDouble(zExtreame[1]);
|
|
210 |
}
|
|
211 |
for (int t = 0; t < npoints; t++) {
|
|
212 |
double z = zs[t];
|
|
213 |
if (Double.isNaN(z)) {
|
|
214 |
buffer.putDouble(0.0);
|
|
215 |
} else {
|
|
216 |
buffer.putDouble(z);
|
|
217 |
}
|
|
218 |
}
|
|
219 |
} |
|
222 | 220 |
|
223 |
if ((m_type == SHP.POLYGONM) || |
|
224 |
(m_type == SHP.POLYGON3D)) { |
|
221 |
if ((m_type == SHP.POLYGONM) || (m_type == SHP.POLYGON3D)) { |
|
225 | 222 |
buffer.putDouble(-10E40); |
226 | 223 |
buffer.putDouble(-10E40); |
227 | 224 |
|
... | ... | |
236 | 233 |
*/ |
237 | 234 |
public synchronized int getLength(Geometry fgeometry) { |
238 | 235 |
// FPolygon2D multi; |
239 |
//multi = (FPolygon2D) fgeometry.getShape(); |
|
240 |
///int nrings = 0; |
|
241 |
///obtainsPoints(fgeometry.getGeneralPathXIterator()); |
|
236 |
// multi = (FPolygon2D) fgeometry.getShape();
|
|
237 |
// /int nrings = 0;
|
|
238 |
// /obtainsPoints(fgeometry.getGeneralPathXIterator());
|
|
242 | 239 |
|
243 |
//int[] parts=multi.getParts(); |
|
244 |
//FPoint2D[] points; |
|
245 |
///////// |
|
246 |
//points = multi.getPoints(); |
|
240 |
// int[] parts=multi.getParts();
|
|
241 |
// FPoint2D[] points;
|
|
242 |
// ///////
|
|
243 |
// points = multi.getPoints();
|
|
247 | 244 |
int npoints = points.length; |
248 | 245 |
|
249 |
/////////// |
|
250 |
///nrings = multi.getNumParts(); |
|
251 |
///int npoints = multi.getNumPoints(); |
|
246 |
// /////////
|
|
247 |
// /nrings = multi.getNumParts();
|
|
248 |
// /int npoints = multi.getNumPoints();
|
|
252 | 249 |
int length; |
253 | 250 |
|
254 | 251 |
if (m_type == SHP.POLYGON3D) { |
255 |
length = 44 + (4 * parts.length) + (16 * npoints) + (8 * npoints) +
|
|
256 |
16 + (8 * npoints) + 16; |
|
252 |
length = 44 + (4 * parts.length) + (16 * npoints) + (8 * npoints) |
|
253 |
+ 16 + (8 * npoints) + 16;
|
|
257 | 254 |
} else if (m_type == SHP.POLYGONM) { |
258 |
length = 44 + (4 * parts.length) + (16 * npoints) + (8 * npoints) +
|
|
259 |
16; |
|
255 |
length = 44 + (4 * parts.length) + (16 * npoints) + (8 * npoints) |
|
256 |
+ 16;
|
|
260 | 257 |
} else if (m_type == SHP.POLYGON2D) { |
261 | 258 |
length = 44 + (4 * parts.length) + (16 * npoints); |
262 | 259 |
} else { |
263 | 260 |
throw new IllegalStateException( |
264 |
"Expected ShapeType of Polygon, got " + m_type); |
|
261 |
"Expected ShapeType of Polygon, got " + m_type);
|
|
265 | 262 |
} |
266 | 263 |
|
267 | 264 |
return length; |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/utils/SHPPoint.java | ||
---|---|---|
43 | 43 |
import java.awt.geom.PathIterator; |
44 | 44 |
import java.nio.ByteBuffer; |
45 | 45 |
import java.nio.MappedByteBuffer; |
46 |
|
|
46 | 47 |
import org.gvsig.datasources.common.IByteBuffer; |
47 | 48 |
import org.gvsig.fmap.geom.Geometry; |
48 | 49 |
import org.gvsig.fmap.geom.primitive.AbstractPrimitive; |
49 | 50 |
import org.gvsig.fmap.geom.primitive.Point2D; |
50 | 51 |
|
51 |
|
|
52 | 52 |
/** |
53 | 53 |
* DOCUMENT ME! |
54 |
* |
|
54 |
*
|
|
55 | 55 |
* @author Vicente Caballero Navarro |
56 | 56 |
*/ |
57 | 57 |
public class SHPPoint implements SHPShape { |
58 | 58 |
private int m_type; |
59 |
|
|
59 | 60 |
private Point2D point; |
61 |
|
|
60 | 62 |
private double z; |
61 | 63 |
|
62 | 64 |
/** |
63 | 65 |
* Crea un nuevo SHPPoint. |
64 |
* |
|
65 |
* @param type DOCUMENT ME! |
|
66 |
* |
|
67 |
* @throws ShapefileException DOCUMENT ME! |
|
66 |
* |
|
67 |
* @param type |
|
68 |
* DOCUMENT ME! |
|
69 |
* |
|
70 |
* @throws ShapefileException |
|
71 |
* DOCUMENT ME! |
|
68 | 72 |
*/ |
69 |
public SHPPoint(int type) { |
|
70 |
if ((type != SHP.POINT2D) && |
|
71 |
(type != SHP.POINTM) && |
|
72 |
(type != SHP.POINT3D)) { // 2d, 2d+m, 3d+m |
|
73 |
// throw new ShapefileException("No es un punto 1,11 ni 21"); |
|
73 |
public SHPPoint(int type) { |
|
74 |
if ((type != SHP.POINT2D) && (type != SHP.POINTM) |
|
75 |
&& (type != SHP.POINT3D)) { // 2d, 2d+m, 3d+m |
|
76 |
// throw new ShapefileException("No es un punto 1,11 ni 21"); |
|
74 | 77 |
} |
75 | 78 |
|
76 | 79 |
m_type = type; |
... | ... | |
80 | 83 |
* Crea un nuevo SHPPoint. |
81 | 84 |
*/ |
82 | 85 |
public SHPPoint() { |
83 |
m_type = SHP.POINT2D; //2d |
|
86 |
m_type = SHP.POINT2D; // 2d
|
|
84 | 87 |
} |
85 | 88 |
|
86 | 89 |
/** |
... | ... | |
113 | 116 |
* @see com.iver.cit.gvsig.fmap.shp.SHPShape#write(ByteBuffer, IGeometry) |
114 | 117 |
*/ |
115 | 118 |
public void write(IByteBuffer buffer, Geometry geometry) { |
116 |
//FPoint2D p2d = ((FPoint2D) geometry.getShape()); |
|
117 |
///obtainsPoints(geometry.getGeneralPathXIterator()); |
|
119 |
// FPoint2D p2d = ((FPoint2D) geometry.getShape());
|
|
120 |
// /obtainsPoints(geometry.getGeneralPathXIterator());
|
|
118 | 121 |
buffer.putDouble(point.getX()); |
119 | 122 |
buffer.putDouble(point.getY()); |
120 | 123 |
|
121 |
if (m_type == SHP.POINT3D) { |
|
122 |
if (Double.isNaN(z)) { // nan means not defined |
|
123 |
buffer.putDouble(0.0); |
|
124 |
} else { |
|
125 |
buffer.putDouble(z); |
|
126 |
} |
|
127 |
} |
|
128 |
if ((m_type == SHP.POINT3D) || |
|
129 |
(m_type == SHP.POINTM)) { |
|
130 |
buffer.putDouble(-10E40); //M |
|
131 |
} |
|
124 |
if (m_type == SHP.POINT3D) { |
|
125 |
if (Double.isNaN(z)) { // nan means not defined |
|
126 |
buffer.putDouble(0.0); |
|
127 |
} else { |
|
128 |
buffer.putDouble(z); |
|
129 |
} |
|
130 |
} |
|
131 |
if ((m_type == SHP.POINT3D) || (m_type == SHP.POINTM)) { |
|
132 |
buffer.putDouble(-10E40); // M |
|
133 |
} |
|
132 | 134 |
|
133 | 135 |
} |
134 | 136 |
|
... | ... | |
145 | 147 |
} else if (m_type == SHP.POINT3D) { |
146 | 148 |
length = 36; |
147 | 149 |
} else { |
148 |
throw new IllegalStateException("Expected ShapeType of Point, got" +
|
|
149 |
m_type); |
|
150 |
throw new IllegalStateException("Expected ShapeType of Point, got" |
|
151 |
+ m_type);
|
|
150 | 152 |
} |
151 | 153 |
|
152 | 154 |
return length; |
... | ... | |
156 | 158 |
* @see com.iver.cit.gvsig.fmap.drivers.shp.write.SHPShape#obtainsPoints(com.iver.cit.gvsig.fmap.core.GeneralPathXIterator) |
157 | 159 |
*/ |
158 | 160 |
public void obtainsPoints(Geometry g) { |
159 |
if (SHP.POINT3D == m_type){ |
|
160 |
z=((AbstractPrimitive)g).getZs()[0];
|
|
161 |
if (SHP.POINT3D == m_type) {
|
|
162 |
z = ((AbstractPrimitive) g).getZs()[0];
|
|
161 | 163 |
} |
162 |
PathIterator theIterator = g.getPathIterator(null); //polyLine.getPathIterator(null, flatness); |
|
164 |
PathIterator theIterator = g.getPathIterator(null); // polyLine.getPathIterator(null, |
|
165 |
// flatness); |
|
163 | 166 |
double[] theData = new double[6]; |
164 | 167 |
|
165 | 168 |
while (!theIterator.isDone()) { |
166 |
//while not done |
|
169 |
// while not done
|
|
167 | 170 |
int theType = theIterator.currentSegment(theData); |
168 | 171 |
|
169 | 172 |
point = new Point2D(theData[0], theData[1]); |
170 | 173 |
|
171 | 174 |
theIterator.next(); |
172 |
} //end while loop |
|
175 |
} // end while loop
|
|
173 | 176 |
} |
174 |
// public void setFlatness(double flatness) {
|
|
175 |
// // this.flatness=flatness;
|
|
176 |
// }
|
|
177 |
// public void setFlatness(double flatness) {
|
|
178 |
// // this.flatness=flatness;
|
|
179 |
// }
|
|
177 | 180 |
} |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/utils/SHPFileWrite.java | ||
---|---|---|
50 | 50 |
import org.gvsig.datasources.common.IRandomFileChannel; |
51 | 51 |
import org.gvsig.datasources.impljme.Impl; |
52 | 52 |
import org.gvsig.fmap.geom.Geometry; |
53 |
import org.gvsig.fmap.geom.primitive.FShape; |
|
54 | 53 |
|
55 | 54 |
// import com.iver.cit.gvsig.fmap.core.FShape; |
56 | 55 |
// import com.iver.cit.gvsig.fmap.core.Geometry; |
... | ... | |
366 | 365 |
*/ |
367 | 366 |
public int getShapeType(int geometryType) { |
368 | 367 |
|
369 |
if (geometryType>=Geometry.TYPES.Z){
|
|
368 |
if (geometryType >= Geometry.TYPES.Z) {
|
|
370 | 369 |
switch (geometryType - Geometry.TYPES.Z) { |
371 | 370 |
case Geometry.TYPES.POINT: |
372 | 371 |
return SHP.POINT3D; |
... | ... | |
381 | 380 |
return SHP.POLYGON3D; |
382 | 381 |
|
383 | 382 |
case Geometry.TYPES.MULTIPOINT: |
384 |
return SHP.MULTIPOINT3D; //TODO falta aclarar cosas aqu?. |
|
385 |
} |
|
383 |
return SHP.MULTIPOINT3D; // TODO falta aclarar cosas aqu?.
|
|
384 |
}
|
|
386 | 385 |
|
387 |
}else{
|
|
386 |
} else {
|
|
388 | 387 |
switch (geometryType) { |
389 |
case Geometry.TYPES.POINT:
|
|
390 |
return SHP.POINT2D;
|
|
388 |
case Geometry.TYPES.POINT: |
|
389 |
return SHP.POINT2D; |
|
391 | 390 |
|
392 |
case Geometry.TYPES.CURVE:
|
|
393 |
case Geometry.TYPES.ELLIPSE:
|
|
394 |
case Geometry.TYPES.CIRCLE:
|
|
395 |
case Geometry.TYPES.ARC:
|
|
396 |
return SHP.POLYLINE2D;
|
|
391 |
case Geometry.TYPES.CURVE: |
|
392 |
case Geometry.TYPES.ELLIPSE: |
|
393 |
case Geometry.TYPES.CIRCLE: |
|
394 |
case Geometry.TYPES.ARC: |
|
395 |
return SHP.POLYLINE2D; |
|
397 | 396 |
|
398 |
case Geometry.TYPES.SURFACE:
|
|
399 |
return SHP.POLYGON2D;
|
|
397 |
case Geometry.TYPES.SURFACE: |
|
398 |
return SHP.POLYGON2D; |
|
400 | 399 |
|
401 |
case Geometry.TYPES.MULTIPOINT:
|
|
402 |
return SHP.MULTIPOINT2D; //TODO falta aclarar cosas aqu?.
|
|
400 |
case Geometry.TYPES.MULTIPOINT: |
|
401 |
return SHP.MULTIPOINT2D; // TODO falta aclarar cosas aqu?.
|
|
403 | 402 |
} |
404 | 403 |
} |
405 |
return SHP.NULL;
|
|
406 |
}
|
|
404 |
return SHP.NULL; |
|
405 |
} |
|
407 | 406 |
|
408 |
|
|
409 | 407 |
// public void setFlatness(double flatness) { |
410 | 408 |
// this.flatness=flatness; |
411 | 409 |
// } |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/utils/SHPNull.java | ||
---|---|---|
1 | 1 |
package org.gvsig.data.datastores.vectorial.file.shp.utils; |
2 | 2 |
|
3 |
import java.nio.ByteBuffer; |
|
4 | 3 |
import java.nio.MappedByteBuffer; |
4 |
|
|
5 | 5 |
import org.gvsig.datasources.common.IByteBuffer; |
6 | 6 |
import org.gvsig.fmap.geom.Geometry; |
7 | 7 |
|
... | ... | |
10 | 10 |
return Geometry.TYPES.NULL; |
11 | 11 |
} |
12 | 12 |
|
13 |
public SHPNull(int type) {
|
|
13 |
public SHPNull(int type) { |
|
14 | 14 |
} |
15 |
|
|
15 | 16 |
public SHPNull() { |
16 | 17 |
} |
18 |
|
|
17 | 19 |
public Geometry read(MappedByteBuffer buffer, int type) { |
18 | 20 |
return null; |
19 | 21 |
} |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/utils/SHP.java | ||
---|---|---|
66 | 66 |
public static final int POLYGON3D = 15; |
67 | 67 |
|
68 | 68 |
public static final int MULTIPOINT3D = 18; |
69 |
|
|
69 |
|
|
70 | 70 |
public final static int POINTM = 21; |
71 |
|
|
71 |
|
|
72 | 72 |
public final static int POLYLINEM = 23; |
73 |
|
|
73 | 74 |
public final static int POLYGONM = 25; |
75 |
|
|
74 | 76 |
public final static int MULTIPOINTM = 28; |
75 | 77 |
|
76 | 78 |
/** |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/utils/SHPShape.java | ||
---|---|---|
41 | 41 |
package org.gvsig.data.datastores.vectorial.file.shp.utils; |
42 | 42 |
|
43 | 43 |
import java.nio.MappedByteBuffer; |
44 |
|
|
44 | 45 |
import org.gvsig.datasources.common.IByteBuffer; |
45 | 46 |
import org.gvsig.fmap.geom.Geometry; |
46 | 47 |
|
47 | 48 |
/** |
48 | 49 |
* Interfaz de todos los tipos de formato shape. |
49 |
* |
|
50 |
*
|
|
50 | 51 |
* @author Vicente Caballero Navarro |
51 | 52 |
*/ |
52 | 53 |
public interface SHPShape { |
53 | 54 |
/** |
54 | 55 |
* Devuelve el tipo de shape de que se trata. |
55 |
* |
|
56 |
*
|
|
56 | 57 |
* @return Tipo de shape. |
57 | 58 |
*/ |
58 | 59 |
public int getShapeType(); |
59 | 60 |
|
60 | 61 |
/** |
61 | 62 |
* Lee del buffer el shape y crea una nueva geometr?a. |
62 |
* |
|
63 |
* @param buffer Buffer de donde se lee. |
|
64 |
* @param type Tipo de shape en concreto. |
|
65 |
* |
|
63 |
* |
|
64 |
* @param buffer |
|
65 |
* Buffer de donde se lee. |
|
66 |
* @param type |
|
67 |
* Tipo de shape en concreto. |
|
68 |
* |
|
66 | 69 |
* @return Nueva geometr?a. |
67 | 70 |
*/ |
68 | 71 |
public Geometry read(MappedByteBuffer buffer, int type); |
69 | 72 |
|
70 | 73 |
/** |
71 | 74 |
* Escribe en el buffer la geometr?a que se pasa como par?metro. |
72 |
* |
|
73 |
* @param buffer Buffer donde escribir. |
|
74 |
* @param geometry Geometr?a a escribir. |
|
75 |
* |
|
76 |
* @param buffer |
|
77 |
* Buffer donde escribir. |
|
78 |
* @param geometry |
|
79 |
* Geometr?a a escribir. |
|
75 | 80 |
*/ |
76 | 81 |
public void write(IByteBuffer buffer, Geometry geometry); |
77 | 82 |
|
78 | 83 |
/** |
79 | 84 |
* Devuelve el tama?o de la geometr?a. |
80 |
* |
|
81 |
* @param fgeometry Geometr?a a medir. |
|
82 |
* |
|
85 |
* |
|
86 |
* @param fgeometry |
|
87 |
* Geometr?a a medir. |
|
88 |
* |
|
83 | 89 |
* @return Tama?o de la geometr?a. |
84 | 90 |
*/ |
85 | 91 |
public int getLength(Geometry fgeometry); |
86 | 92 |
|
87 | 93 |
/** |
88 | 94 |
* Obtiene los puntos y partes del GeneralPathXIterator del shape. |
89 |
* |
|
95 |
*
|
|
90 | 96 |
* @param iter |
91 | 97 |
*/ |
92 | 98 |
public void obtainsPoints(Geometry g); |
93 | 99 |
|
94 |
// public void setFlatness(double flatness);
|
|
100 |
// public void setFlatness(double flatness);
|
|
95 | 101 |
} |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/SHPDataExplorer.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
import org.gvsig.data.DataExplorerParameters; |
6 | 6 |
import org.gvsig.data.DataStoreParameters; |
7 |
import org.gvsig.data.InitializeException; |
|
7 | 8 |
import org.gvsig.data.NewDataStoreParameters; |
8 |
import org.gvsig.data.InitializeException; |
|
9 | 9 |
import org.gvsig.data.WriteException; |
10 | 10 |
import org.gvsig.data.datastores.vectorial.file.IFileStoreParameters; |
11 | 11 |
import org.gvsig.data.datastores.vectorial.file.dbf.DBFDataExplorer; |
branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp_jni/simplify/DbfDiskDataSource.java | ||
---|---|---|
3 | 3 |
import java.io.File; |
4 | 4 |
import java.io.IOException; |
5 | 5 |
import java.sql.Types; |
6 |
import java.util.Date; |
|
7 | 6 |
|
8 | 7 |
import org.apache.log4j.Logger; |
9 | 8 |
import org.gvsig.compatible.StringUtil; |
9 |
import org.gvsig.data.datastores.vectorial.file.shp_util.BaseReadException; |
|
10 | 10 |
import org.gvsig.data.datastores.vectorial.file.shp_util.DBFDataSource; |
11 |
import org.gvsig.exceptions.DriverException;
|
|
11 |
import org.gvsig.data.datastores.vectorial.file.shp_util.DbfUtil;
|
|
12 | 12 |
|
13 | 13 |
import es.prodevelop.gvsig.mobile.fmap.driver.vect.shp.ShpReader; |
14 | 14 |
|
... | ... | |
56 | 56 |
/** |
57 | 57 |
* Initializes the dfata source (reads the file metadata) |
58 | 58 |
*/ |
59 |
public void start() throws DriverException {
|
|
59 |
public void start() throws BaseReadException {
|
|
60 | 60 |
|
61 | 61 |
try { |
62 | 62 |
fileHandler = ShpReader.openDbfFile(dbFile.getCanonicalPath(), |
... | ... | |
74 | 74 |
} catch (IOException e) { |
75 | 75 |
logger.error("Error while opening db file " |
76 | 76 |
+ dbFile.getAbsolutePath() + ": " + e.getMessage()); |
77 |
throw new DriverException(e.getMessage());
|
|
77 |
throw new BaseReadException(e.getMessage());
|
|
78 | 78 |
} |
79 | 79 |
} |
80 | 80 |
|
... | ... | |
117 | 117 |
/** |
118 | 118 |
* Stops the datasource. Tries to close the DBF file. |
119 | 119 |
*/ |
120 |
public void stop() throws DriverException {
|
|
120 |
public void stop() throws BaseReadException {
|
|
121 | 121 |
if (!ShpReader.closeDbfFile(fileHandler)) { |
122 |
throw new DriverException("While closing DBF file: "
|
|
122 |
throw new BaseReadException("While closing DBF file: "
|
|
123 | 123 |
+ dbFile.getAbsolutePath()); |
124 | 124 |
} |
125 | 125 |
} |
... | ... | |
143 | 143 |
* @return a string representing the datasource. Unused. Simply redirects to |
144 | 144 |
* <code>getName()</code> |
145 | 145 |
*/ |
146 |
public String getAsString() throws DriverException {
|
|
146 |
public String getAsString() throws BaseReadException {
|
|
147 | 147 |
logger.warn("Method getAsString() was called, returned getName()"); |
148 | 148 |
return getName(); |
149 | 149 |
} |
... | ... | |
152 | 152 |
* Called when the layer is removed. Tries to prevent memory leaks. |
153 | 153 |
* |
154 | 154 |
*/ |
155 |
public void remove() throws DriverException {
|
|
155 |
public void remove() throws BaseReadException {
|
|
156 | 156 |
logger.warn("Method remove() was called, nothing done."); |
157 | 157 |
} |
158 | 158 |
|
159 | 159 |
/** |
160 | 160 |
* @return an array with the indices of the primary keys. |
161 | 161 |
*/ |
162 |
public int[] getPrimaryKeys() throws DriverException {
|
|
162 |
public int[] getPrimaryKeys() throws BaseReadException {
|
|
163 | 163 |
logger |
164 | 164 |
.warn("Method getPrimaryKeys() was called, returned all indices."); |
165 | 165 |
int[] resp = new int[fieldCount]; |
... | ... | |
175 | 175 |
* the index of the PK field of interest |
176 | 176 |
* @return the name of the field of interest |
177 | 177 |
*/ |
178 |
public String getPKName(int arg0) throws DriverException {
|
|
178 |
public String getPKName(int arg0) throws BaseReadException {
|
|
179 | 179 |
logger.warn("Method getPKName(" + arg0 + ") was called, returned NULL"); |
180 | 180 |
return null; |
181 | 181 |
} |
... | ... | |
184 | 184 |
* @return the names of the fields that compose the PK. |
185 | 185 |
* |
186 | 186 |
*/ |
187 |
public String[] getPKNames() throws DriverException {
|
|
187 |
public String[] getPKNames() throws BaseReadException {
|
|
188 | 188 |
logger.warn("Method getPKNames() was called, returned NULL"); |
189 | 189 |
return null; |
190 | 190 |
} |
... | ... | |
196 | 196 |
* the index of the field of interest |
197 | 197 |
* @return the type of the field of interest |
198 | 198 |
*/ |
199 |
public int getPKType(int arg0) throws DriverException {
|
|
199 |
public int getPKType(int arg0) throws BaseReadException {
|
|
200 | 200 |
logger.warn("Method getPKType(" + arg0 |
201 | 201 |
+ ") was called, returned getFieldType(...)"); |
202 | 202 |
return fieldTypes[arg0]; |
... | ... | |
205 | 205 |
/** |
206 | 206 |
* @return the cumber of fields that compose the PK. |
207 | 207 |
*/ |
208 |
public int getPKCardinality() throws DriverException {
|
|
208 |
public int getPKCardinality() throws BaseReadException {
|
|
209 | 209 |
return fieldCount; |
210 | 210 |
} |
211 | 211 |
|
... | ... | |
233 | 233 |
|
234 | 234 |
case Types.DATE: |
235 | 235 |
|
236 |
resp = Date.parse(ShpReader.getDbfStringFieldValue(fileHandler, row, fieldindex));
|
|
236 |
resp = DbfUtil.stringToDate(ShpReader.getDbfStringFieldValue(fileHandler, row, fieldindex));
|
|
237 | 237 |
break; |
238 | 238 |
|
239 | 239 |
case Types.BOOLEAN: |
... | ... | |
263 | 263 |
/** |
264 | 264 |
* @return an array with all the field names |
265 | 265 |
*/ |
266 |
public String[] getFieldNames() throws DriverException {
|
|
266 |
public String[] getFieldNames() throws BaseReadException {
|
|
267 | 267 |
return fieldNames; |
268 | 268 |
} |
269 | 269 |
|
... | ... | |
274 | 274 |
* the name of the field of interest |
275 | 275 |
* @return the index of the field of interest |
276 | 276 |
*/ |
277 |
public int getFieldIndexByName(String arg0) throws DriverException {
|
|
277 |
public int getFieldIndexByName(String arg0) throws BaseReadException {
|
|
278 | 278 |
for (int i = 0; i < fieldCount; i++) { |
279 | 279 |
if (arg0.compareToIgnoreCase(fieldNames[i]) == 0) |
280 | 280 |
return i; |
... | ... | |
291 | 291 |
* @return whether it is a virtual field. |
292 | 292 |
* |
293 | 293 |
*/ |
294 |
public boolean isVirtualField(int arg0) throws DriverException {
|
|
294 |
public boolean isVirtualField(int arg0) throws BaseReadException {
|
|
295 | 295 |
return false; |
296 | 296 |
} |
297 | 297 |
|
... | ... | |
306 | 306 |
/** |
307 | 307 |
* Reloads the data source (stops and starts) |
308 | 308 |
*/ |
309 |
public void reload() throws DriverException, IOException {
|
|
309 |
public void reload() throws BaseReadException, IOException {
|
|
310 | 310 |
stop(); |
311 | 311 |
start(); |
312 | 312 |
} |
... | ... | |
321 | 321 |
* |
322 | 322 |
* @return the value of the given row and field |
323 | 323 |
*/ |
324 |
public Object getFieldValue(long arg0, int arg1) throws DriverException {
|
|
324 |
public Object getFieldValue(long arg0, int arg1) throws BaseReadException {
|
|
325 | 325 |
return getValueOfItsType(arg1, (int) arg0); |
326 | 326 |
} |
327 | 327 |
|
328 | 328 |
/** |
329 | 329 |
* @return the number of fields in this datasource |
330 | 330 |
*/ |
331 |
public int getFieldCount() throws DriverException {
|
|
331 |
public int getFieldCount() throws BaseReadException {
|
|
332 | 332 |
return fieldCount; |
333 | 333 |
} |
334 | 334 |
|
... | ... | |
339 | 339 |
* the index of the field of interest |
340 | 340 |
* @return the name of the field |
341 | 341 |
*/ |
342 |
public String getFieldName(int arg0) throws DriverException {
|
|
342 |
public String getFieldName(int arg0) throws BaseReadException {
|
|
343 | 343 |
return fieldNames[arg0]; |
344 | 344 |
} |
345 | 345 |
|
Also available in: Unified diff