Revision 2133 branches/FMap_SLD/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dxf/DXFMemoryDriver.java
DXFMemoryDriver.java | ||
---|---|---|
54 | 54 |
|
55 | 55 |
import org.cresques.cts.IProjection; |
56 | 56 |
import org.cresques.cts.ProjectionPool; |
57 |
import org.cresques.geo.Point3D; |
|
57 | 58 |
import org.cresques.io.DxfFile; |
58 | 59 |
import org.cresques.px.IObjList; |
59 | 60 |
import org.cresques.px.dxf.AcadColor; |
60 | 61 |
import org.cresques.px.dxf.DxfFeatureMaker; |
61 | 62 |
import org.cresques.px.gml.Feature; |
62 | 63 |
import org.cresques.px.gml.InsPoint; |
63 |
import org.cresques.px.gml.LineString; |
|
64 |
import org.cresques.px.gml.LineString3D;
|
|
64 | 65 |
import org.cresques.px.gml.Point; |
65 |
import org.cresques.px.gml.Polygon; |
|
66 |
import org.cresques.px.gml.Polygon3D;
|
|
66 | 67 |
|
67 | 68 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
68 | 69 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
... | ... | |
70 | 71 |
import com.hardcode.gdbms.engine.values.Value; |
71 | 72 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
72 | 73 |
import com.iver.cit.gvsig.fmap.core.FPoint3D; |
73 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
|
|
74 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D;
|
|
74 |
import com.iver.cit.gvsig.fmap.core.FPolygon3D;
|
|
75 |
import com.iver.cit.gvsig.fmap.core.FPolyline3D;
|
|
75 | 76 |
import com.iver.cit.gvsig.fmap.core.FShape; |
76 | 77 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
77 | 78 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
... | ... | |
191 | 192 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
192 | 193 |
} |
193 | 194 |
} |
194 |
nuevoShp = new FPoint3D(pto.getX(),pto.getY(),0);
|
|
195 |
nuevoShp = new FPoint3D(pto.getX(),pto.getY(),auxE);
|
|
195 | 196 |
addShape(nuevoShp, auxRow); |
196 | 197 |
} else { |
197 | 198 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
... | ... | |
212 | 213 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
213 | 214 |
} |
214 | 215 |
} |
215 |
nuevoShp = new FPoint3D(pto.getX(),pto.getY(),0);
|
|
216 |
nuevoShp = new FPoint3D(pto.getX(),pto.getY(),auxE);
|
|
216 | 217 |
addShape(nuevoShp, auxRow); |
217 | 218 |
} |
218 | 219 |
} else if (fea.getGeometry() instanceof InsPoint) { |
... | ... | |
235 | 236 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
236 | 237 |
} |
237 | 238 |
} |
238 |
FShape nuevoShp = new FPoint3D(pto.getX(),pto.getY(),0);
|
|
239 |
addShape(nuevoShp, auxRow);
|
|
240 |
} else if (fea.getGeometry() instanceof LineString) {
|
|
239 |
FShape nuevoShp = new FPoint3D(pto.getX(),pto.getY(),auxE);
|
|
240 |
addShape(nuevoShp, auxRow); |
|
241 |
/*} else if (fea.getGeometry() instanceof LineString && !(fea.getGeometry() instanceof LineString3D)) {
|
|
241 | 242 |
GeneralPathX genPathX = new GeneralPathX(); |
242 | 243 |
Point2D[] pts = new Point2D[fea.getGeometry().pointNr()]; |
243 | 244 |
for (int j=0; j<fea.getGeometry().pointNr(); j++) { |
244 | 245 |
pts[j] = (Point2D)fea.getGeometry().get(j); |
245 | 246 |
} |
246 | 247 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
247 |
for (int j=1; j < pts.length; j++) {
|
|
248 |
for (int j=1;j<pts.length;j++) {
|
|
248 | 249 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
249 | 250 |
} |
251 |
//double[] elevations = new double[pts.length]; |
|
252 |
//for (int j=0;j<pts.length;j++) { |
|
253 |
// elevations[j]=pts[j].getZ(); |
|
254 |
//} |
|
250 | 255 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
251 | 256 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
252 | 257 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
... | ... | |
266 | 271 |
} |
267 | 272 |
} |
268 | 273 |
FShape nuevoShp = new FPolyline2D(genPathX); |
274 |
addShape(nuevoShp, auxRow);*/ |
|
275 |
} else if (fea.getGeometry() instanceof LineString3D) { |
|
276 |
GeneralPathX genPathX = new GeneralPathX(); |
|
277 |
Point3D[] pts = new Point3D[fea.getGeometry().pointNr()]; |
|
278 |
for (int j=0; j<fea.getGeometry().pointNr(); j++) { |
|
279 |
pts[j] = ((LineString3D)fea.getGeometry()).getPoint3D(j); |
|
280 |
} |
|
281 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
|
282 |
for (int j=1;j<pts.length;j++) { |
|
283 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
|
284 |
} |
|
285 |
double[] elevations = new double[pts.length]; |
|
286 |
for (int j=0;j<pts.length;j++) { |
|
287 |
elevations[j]=pts[j].getZ(); |
|
288 |
} |
|
289 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
|
290 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
|
291 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
|
292 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
|
293 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
|
294 |
if (fea.getProp("elevation")!=null) { |
|
295 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
|
296 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
|
297 |
} |
|
298 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
|
299 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
|
300 |
// Attributes |
|
301 |
for (int j=0;j<nAtt;j++) { |
|
302 |
String[] attributes = new String[2]; |
|
303 |
attributes = (String[])featureMaker.getAttributes().get(j); |
|
304 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1])); |
|
305 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
|
306 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
|
307 |
} |
|
308 |
} |
|
309 |
FShape nuevoShp = new FPolyline3D(genPathX, elevations); |
|
269 | 310 |
addShape(nuevoShp, auxRow); |
270 |
} else if (fea.getGeometry() instanceof Polygon) {
|
|
311 |
/*} else if (fea.getGeometry() instanceof Polygon && !(fea.getGeometry() instanceof Polygon3D)) {
|
|
271 | 312 |
GeneralPathX genPathX = new GeneralPathX(); |
272 | 313 |
// 050112: A?ado una posici?n m?s para el punto que cierra y |
273 | 314 |
// creo el objeto firstPt. |
... | ... | |
283 | 324 |
for (int j=1; j < pts.length; j++) { |
284 | 325 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
285 | 326 |
} |
327 |
//double[] elevations = new double[pts.length]; |
|
328 |
//for (int j=0;j<pts.length;j++) { |
|
329 |
// elevations[j]=pts[j].getZ(); |
|
330 |
//} |
|
286 | 331 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
287 | 332 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
288 | 333 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
... | ... | |
302 | 347 |
} |
303 | 348 |
} |
304 | 349 |
FShape nuevoShp = new FPolygon2D(genPathX); |
350 |
addShape(nuevoShp, auxRow);*/ |
|
351 |
} else if (fea.getGeometry() instanceof Polygon3D) { |
|
352 |
GeneralPathX genPathX = new GeneralPathX(); |
|
353 |
// 050112: A?ado una posici?n m?s para el punto que cierra y |
|
354 |
// creo el objeto firstPt. |
|
355 |
Point3D firstPt = new Point3D(); |
|
356 |
firstPt = (Point3D)((Polygon3D)fea.getGeometry()).getPoint3D(0); |
|
357 |
Point3D[] pts = new Point3D[fea.getGeometry().pointNr()+1]; |
|
358 |
for (int j=0; j<fea.getGeometry().pointNr(); j++) { |
|
359 |
pts[j] = (Point3D)((Polygon3D)fea.getGeometry()).getPoint3D(j); |
|
360 |
} |
|
361 |
// 050112: A?ado el primer punto al final para cerrar los pol?gonos. |
|
362 |
pts[fea.getGeometry().pointNr()] = firstPt; |
|
363 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
|
364 |
for (int j=1; j < pts.length; j++) { |
|
365 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
|
366 |
} |
|
367 |
double[] elevations = new double[pts.length]; |
|
368 |
for (int j=0;j<pts.length;j++) { |
|
369 |
elevations[j]=pts[j].getZ(); |
|
370 |
System.out.println("elevations[j] = " + elevations[j]); |
|
371 |
} |
|
372 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
|
373 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
|
374 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
|
375 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
|
376 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
|
377 |
if (fea.getProp("elevation")!=null) { |
|
378 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
|
379 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
|
380 |
} |
|
381 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
|
382 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
|
383 |
// Attributes |
|
384 |
for (int j=0;j<nAtt;j++) { |
|
385 |
String[] attributes = new String[2]; |
|
386 |
attributes = (String[])featureMaker.getAttributes().get(j); |
|
387 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1])); |
|
388 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
|
389 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
|
390 |
} |
|
391 |
} |
|
392 |
FShape nuevoShp = new FPolygon3D(genPathX, elevations); |
|
305 | 393 |
addShape(nuevoShp, auxRow); |
306 | 394 |
} else { |
307 |
System.out.println("Detectado feature desconocido"); |
|
395 |
//System.out.println("Detectado feature desconocido");
|
|
308 | 396 |
} |
309 | 397 |
} |
310 | 398 |
|
Also available in: Unified diff