Revision 2196 trunk/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; |
64 |
import org.cresques.px.gml.InsPoint3D; |
|
63 | 65 |
import org.cresques.px.gml.LineString; |
66 |
import org.cresques.px.gml.LineString3D; |
|
64 | 67 |
import org.cresques.px.gml.Point; |
65 | 68 |
import org.cresques.px.gml.Polygon; |
69 |
import org.cresques.px.gml.Polygon3D; |
|
66 | 70 |
|
67 | 71 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
68 | 72 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
69 | 73 |
import com.hardcode.gdbms.engine.values.IntValue; |
70 | 74 |
import com.hardcode.gdbms.engine.values.Value; |
71 | 75 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
76 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
72 | 77 |
import com.iver.cit.gvsig.fmap.core.FPoint3D; |
73 | 78 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
79 |
import com.iver.cit.gvsig.fmap.core.FPolygon3D; |
|
74 | 80 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
81 |
import com.iver.cit.gvsig.fmap.core.FPolyline3D; |
|
75 | 82 |
import com.iver.cit.gvsig.fmap.core.FShape; |
76 | 83 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
77 | 84 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
... | ... | |
89 | 96 |
*/ |
90 | 97 |
public class DXFMemoryDriver extends MemoryDriver implements WithDefaultLegend { |
91 | 98 |
private final int ID_FIELD_ID=0; |
92 |
private final int ID_FIELD_ENTITY=1; |
|
93 |
private final int ID_FIELD_LAYER=2; |
|
94 |
private final int ID_FIELD_COLOR=3; |
|
95 |
private final int ID_FIELD_ELEVATION=4; |
|
96 |
private final int ID_FIELD_THICKNESS=5; |
|
97 |
private final int ID_FIELD_TEXT=6; |
|
98 |
private final int ID_FIELD_HEIGHTTEXT=7; |
|
99 |
private final int ID_FIELD_ROTATIONTEXT=8; |
|
99 |
private final int ID_FIELD_FSHAPE=1; |
|
100 |
private final int ID_FIELD_ENTITY=2; |
|
101 |
private final int ID_FIELD_LAYER=3; |
|
102 |
private final int ID_FIELD_COLOR=4; |
|
103 |
private final int ID_FIELD_ELEVATION=5; |
|
104 |
private final int ID_FIELD_THICKNESS=6; |
|
105 |
private final int ID_FIELD_TEXT=7; |
|
106 |
private final int ID_FIELD_HEIGHTTEXT=8; |
|
107 |
private final int ID_FIELD_ROTATIONTEXT=9; |
|
100 | 108 |
|
101 | 109 |
VectorialUniqueValueLegend defaultLegend; |
102 | 110 |
private String path; |
... | ... | |
129 | 137 |
dxfFeatureFile = new DxfFile(proj, m_Fich.getAbsolutePath(), featureMaker); |
130 | 138 |
dxfFeatureFile.load(); |
131 | 139 |
features = (IObjList.vector)((DxfFeatureMaker)featureMaker).getObjects(); |
132 |
|
|
140 |
if (!featureMaker.isDxf3DFile()) { |
|
141 |
Feature[] features2D = new Feature[features.size()]; |
|
142 |
for (int i=0;i<features.size();i++) { |
|
143 |
Feature fea = (Feature)features.get(i); |
|
144 |
if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) { |
|
145 |
Point point = (Point)fea.getGeometry(); |
|
146 |
Point point2 = new Point(); |
|
147 |
for (int j=0;j<point.pointNr();j++) { |
|
148 |
point2.add(point.get(j)); |
|
149 |
} |
|
150 |
point2.setTextPoint(point.isTextPoint()); |
|
151 |
fea.setGeometry(point2); |
|
152 |
features2D[i] = fea; |
|
153 |
//} else if (fea.getGeometry() instanceof InsPoint3D) { |
|
154 |
// InsPoint insPoint = (InsPoint)fea.getGeometry(); |
|
155 |
// InsPoint insPoint2 = new InsPoint(); |
|
156 |
// for (int j=0;j<insPoint.pointNr();j++) { |
|
157 |
// insPoint2.add(insPoint.get(j)); |
|
158 |
// } |
|
159 |
// fea.setGeometry(insPoint2); |
|
160 |
// features2D[i] = fea; |
|
161 |
} else if (fea.getGeometry() instanceof LineString3D) { |
|
162 |
LineString lineString = (LineString)fea.getGeometry(); |
|
163 |
LineString lineString2 = new LineString(); |
|
164 |
for (int j=0;j<lineString.pointNr();j++) { |
|
165 |
lineString2.add(lineString.get(j)); |
|
166 |
} |
|
167 |
fea.setGeometry(lineString2); |
|
168 |
features2D[i] = fea; |
|
169 |
} else if (fea.getGeometry() instanceof Polygon3D) { |
|
170 |
Polygon polygon = (Polygon)fea.getGeometry(); |
|
171 |
Polygon polygon2 = new Polygon(); |
|
172 |
for (int j=0;j<polygon.pointNr();j++) { |
|
173 |
polygon2.add(polygon.get(j)); |
|
174 |
} |
|
175 |
fea.setGeometry(polygon2); |
|
176 |
features2D[i] = fea; |
|
177 |
} |
|
178 |
} |
|
179 |
features.clear(); |
|
180 |
for (int i=0;i<features2D.length;i++) { |
|
181 |
features.add(features2D[i]); |
|
182 |
} |
|
183 |
} |
|
133 | 184 |
//String acadVersion = (String)((DxfHeaderManager)headerManager).getAcadVersion(); |
134 | 185 |
//System.out.println("initialize(): acadVersion = " + acadVersion); |
135 | 186 |
|
136 | 187 |
int nAtt = featureMaker.getAttributes().size(); |
137 | 188 |
|
138 | 189 |
// Campos de las MemoryLayer: |
139 |
Value[] auxRow = new Value[9+nAtt];
|
|
190 |
Value[] auxRow = new Value[10+nAtt];
|
|
140 | 191 |
ArrayList arrayFields = new ArrayList(); |
141 | 192 |
arrayFields.add("ID"); |
193 |
arrayFields.add("FShape"); |
|
142 | 194 |
arrayFields.add("Entity"); |
143 | 195 |
arrayFields.add("Layer"); |
144 | 196 |
arrayFields.add("Color"); |
... | ... | |
157 | 209 |
|
158 | 210 |
for (int i=0;i<features.size();i++) { |
159 | 211 |
|
160 |
auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0); |
|
161 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0); |
|
212 |
auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0.0);
|
|
213 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0.0);
|
|
162 | 214 |
auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue(); |
163 | 215 |
|
164 | 216 |
Feature fea = (Feature)features.get(i); |
165 |
if (fea.getGeometry() instanceof Point) { |
|
166 |
Point point = (Point)fea.getGeometry();
|
|
217 |
if (fea.getGeometry() instanceof Point && !(fea.getGeometry() instanceof org.cresques.px.gml.Point3D)) {
|
|
218 |
Point point = (Point)fea.getGeometry();
|
|
167 | 219 |
Point2D pto = new Point2D.Double(); |
168 |
pto = (Point2D.Double)point.get(0);
|
|
220 |
pto = (Point2D)point.get(0); |
|
169 | 221 |
FShape nuevoShp; |
170 | 222 |
if (point.isTextPoint()) { |
171 | 223 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
224 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String("FPoint2D")); |
|
172 | 225 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
173 | 226 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
174 | 227 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
... | ... | |
186 | 239 |
for (int j=0;j<nAtt;j++) { |
187 | 240 |
String[] attributes = new String[2]; |
188 | 241 |
attributes = (String[])featureMaker.getAttributes().get(j); |
189 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
242 |
auxRow[10+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
190 | 243 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
191 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
244 |
auxRow[10+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
192 | 245 |
} |
193 | 246 |
} |
194 |
nuevoShp = new FPoint3D(pto.getX(),pto.getY(),0);
|
|
247 |
nuevoShp = new FPoint2D(pto.getX(),pto.getY());
|
|
195 | 248 |
addShape(nuevoShp, auxRow); |
196 | 249 |
} else { |
197 | 250 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
251 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String("FPoint2D")); |
|
198 | 252 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
199 | 253 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
200 | 254 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
... | ... | |
207 | 261 |
for (int j=0;j<nAtt;j++) { |
208 | 262 |
String[] attributes = new String[2]; |
209 | 263 |
attributes = (String[])featureMaker.getAttributes().get(j); |
210 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
264 |
auxRow[10+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
211 | 265 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
212 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
266 |
auxRow[10+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
213 | 267 |
} |
214 | 268 |
} |
215 |
nuevoShp = new FPoint3D(pto.getX(),pto.getY(),0);
|
|
269 |
nuevoShp = new FPoint2D(pto.getX(),pto.getY());
|
|
216 | 270 |
addShape(nuevoShp, auxRow); |
217 | 271 |
} |
218 |
} else if (fea.getGeometry() instanceof InsPoint) { |
|
272 |
} else if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) { |
|
273 |
org.cresques.px.gml.Point3D point = (org.cresques.px.gml.Point3D)fea.getGeometry(); |
|
274 |
Point3D pto = new Point3D(); |
|
275 |
pto = (Point3D)point.getPoint3D(0); |
|
276 |
FShape nuevoShp; |
|
277 |
if (point.isTextPoint()) { |
|
278 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
|
279 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String("FPoint3D")); |
|
280 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
|
281 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
|
282 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
|
283 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
|
284 |
auxRow[ID_FIELD_TEXT] = ValueFactory.createValue(new String(fea.getProp("text"))); |
|
285 |
heightText = Float.parseFloat(fea.getProp("textHeight")); |
|
286 |
auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(heightText); |
|
287 |
double auxR = Double.parseDouble(fea.getProp("textRotation")); |
|
288 |
auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(auxR); |
|
289 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
|
290 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
|
291 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
|
292 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
|
293 |
// Attributes |
|
294 |
for (int j=0;j<nAtt;j++) { |
|
295 |
String[] attributes = new String[2]; |
|
296 |
attributes = (String[])featureMaker.getAttributes().get(j); |
|
297 |
auxRow[10+j] = ValueFactory.createValue(new String((String)attributes[1])); |
|
298 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
|
299 |
auxRow[10+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
|
300 |
} |
|
301 |
} |
|
302 |
nuevoShp = new FPoint3D(pto.getX(),pto.getY(),pto.getZ()); |
|
303 |
addShape(nuevoShp, auxRow); |
|
304 |
} else { |
|
305 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
|
306 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String("FPoint3D")); |
|
307 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
|
308 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
|
309 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
|
310 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
|
311 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
|
312 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
|
313 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
|
314 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
|
315 |
// Attributes |
|
316 |
for (int j=0;j<nAtt;j++) { |
|
317 |
String[] attributes = new String[2]; |
|
318 |
attributes = (String[])featureMaker.getAttributes().get(j); |
|
319 |
auxRow[10+j] = ValueFactory.createValue(new String((String)attributes[1])); |
|
320 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
|
321 |
auxRow[10+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
|
322 |
} |
|
323 |
} |
|
324 |
nuevoShp = new FPoint3D(pto.getX(),pto.getY(),pto.getZ()); |
|
325 |
addShape(nuevoShp, auxRow); |
|
326 |
} |
|
327 |
/*} else if (fea.getGeometry() instanceof InsPoint && !(fea.getGeometry() instanceof InsPoint3D)) { |
|
219 | 328 |
InsPoint insPoint = (InsPoint)fea.getGeometry(); |
220 | 329 |
Point2D pto = new Point2D.Double(); |
221 |
pto = (Point2D.Double)insPoint.get(0);
|
|
330 |
pto = (Point2D)insPoint.get(0); |
|
222 | 331 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
332 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String("PointZ")); |
|
223 | 333 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
224 | 334 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
225 | 335 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
... | ... | |
235 | 345 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
236 | 346 |
} |
237 | 347 |
} |
238 |
FShape nuevoShp = new FPoint3D(pto.getX(),pto.getY(),0); |
|
239 |
addShape(nuevoShp, auxRow); |
|
240 |
} else if (fea.getGeometry() instanceof LineString) { |
|
348 |
FShape nuevoShp = new FPoint2D(pto.getX(),pto.getY()); |
|
349 |
addShape(nuevoShp, auxRow); |
|
350 |
} else if (fea.getGeometry() instanceof InsPoint3D) { |
|
351 |
InsPoint3D insPoint = (InsPoint3D)fea.getGeometry(); |
|
352 |
Point3D pto = new Point3D(); |
|
353 |
pto = (Point3D)insPoint.getPoint3D(0); |
|
354 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
|
355 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String("PointZ")); |
|
356 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
|
357 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
|
358 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
|
359 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
|
360 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
|
361 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
|
362 |
// Attributes |
|
363 |
for (int j=0;j<nAtt;j++) { |
|
364 |
String[] attributes = new String[2]; |
|
365 |
attributes = (String[])featureMaker.getAttributes().get(j); |
|
366 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1])); |
|
367 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
|
368 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
|
369 |
} |
|
370 |
} |
|
371 |
FShape nuevoShp = new FPoint3D(pto.getX(),pto.getY(),pto.getZ()); |
|
372 |
addShape(nuevoShp, auxRow);*/ |
|
373 |
} else if (fea.getGeometry() instanceof LineString && !(fea.getGeometry() instanceof LineString3D)) { |
|
241 | 374 |
GeneralPathX genPathX = new GeneralPathX(); |
242 | 375 |
Point2D[] pts = new Point2D[fea.getGeometry().pointNr()]; |
243 | 376 |
for (int j=0; j<fea.getGeometry().pointNr(); j++) { |
244 | 377 |
pts[j] = (Point2D)fea.getGeometry().get(j); |
245 | 378 |
} |
246 | 379 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
247 |
for (int j=1; j < pts.length; j++) {
|
|
380 |
for (int j=1;j<pts.length;j++) {
|
|
248 | 381 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
249 | 382 |
} |
383 |
//double[] elevations = new double[pts.length]; |
|
384 |
//for (int j=0;j<pts.length;j++) { |
|
385 |
// elevations[j]=pts[j].getZ(); |
|
386 |
//} |
|
250 | 387 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
388 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String("FPolyline2D")); |
|
251 | 389 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
252 | 390 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
253 | 391 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
... | ... | |
260 | 398 |
for (int j=0;j<nAtt;j++) { |
261 | 399 |
String[] attributes = new String[2]; |
262 | 400 |
attributes = (String[])featureMaker.getAttributes().get(j); |
263 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
401 |
auxRow[10+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
264 | 402 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
265 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
403 |
auxRow[10+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
266 | 404 |
} |
267 | 405 |
} |
268 | 406 |
FShape nuevoShp = new FPolyline2D(genPathX); |
269 | 407 |
addShape(nuevoShp, auxRow); |
270 |
} else if (fea.getGeometry() instanceof Polygon) {
|
|
408 |
} else if (fea.getGeometry() instanceof LineString3D) {
|
|
271 | 409 |
GeneralPathX genPathX = new GeneralPathX(); |
410 |
Point3D[] pts = new Point3D[fea.getGeometry().pointNr()]; |
|
411 |
for (int j=0; j<fea.getGeometry().pointNr(); j++) { |
|
412 |
pts[j] = ((LineString3D)fea.getGeometry()).getPoint3D(j); |
|
413 |
} |
|
414 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
|
415 |
for (int j=1;j<pts.length;j++) { |
|
416 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
|
417 |
} |
|
418 |
double[] elevations = new double[pts.length]; |
|
419 |
for (int j=0;j<pts.length;j++) { |
|
420 |
elevations[j]=pts[j].getZ(); |
|
421 |
} |
|
422 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
|
423 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String("FPolyline3D")); |
|
424 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
|
425 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
|
426 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
|
427 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
|
428 |
if (fea.getProp("elevation")!=null) { |
|
429 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
|
430 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
|
431 |
} |
|
432 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
|
433 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
|
434 |
// Attributes |
|
435 |
for (int j=0;j<nAtt;j++) { |
|
436 |
String[] attributes = new String[2]; |
|
437 |
attributes = (String[])featureMaker.getAttributes().get(j); |
|
438 |
auxRow[10+j] = ValueFactory.createValue(new String((String)attributes[1])); |
|
439 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
|
440 |
auxRow[10+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
|
441 |
} |
|
442 |
} |
|
443 |
FShape nuevoShp = new FPolyline3D(genPathX, elevations); |
|
444 |
addShape(nuevoShp, auxRow); |
|
445 |
} else if (fea.getGeometry() instanceof Polygon && !(fea.getGeometry() instanceof Polygon3D)) { |
|
446 |
GeneralPathX genPathX = new GeneralPathX(); |
|
272 | 447 |
// 050112: A?ado una posici?n m?s para el punto que cierra y |
273 | 448 |
// creo el objeto firstPt. |
274 | 449 |
Point2D firstPt = new Point2D.Double(); |
... | ... | |
283 | 458 |
for (int j=1; j < pts.length; j++) { |
284 | 459 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
285 | 460 |
} |
461 |
//double[] elevations = new double[pts.length]; |
|
462 |
//for (int j=0;j<pts.length;j++) { |
|
463 |
// elevations[j]=pts[j].getZ(); |
|
464 |
//} |
|
286 | 465 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
466 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String("FPolygon2D")); |
|
287 | 467 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
288 | 468 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
289 | 469 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
... | ... | |
296 | 476 |
for (int j=0;j<nAtt;j++) { |
297 | 477 |
String[] attributes = new String[2]; |
298 | 478 |
attributes = (String[])featureMaker.getAttributes().get(j); |
299 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
479 |
auxRow[10+j] = ValueFactory.createValue(new String((String)attributes[1]));
|
|
300 | 480 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
301 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
481 |
auxRow[10+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
|
|
302 | 482 |
} |
303 | 483 |
} |
304 | 484 |
FShape nuevoShp = new FPolygon2D(genPathX); |
305 | 485 |
addShape(nuevoShp, auxRow); |
486 |
} else if (fea.getGeometry() instanceof Polygon3D) { |
|
487 |
GeneralPathX genPathX = new GeneralPathX(); |
|
488 |
// 050112: A?ado una posici?n m?s para el punto que cierra y |
|
489 |
// creo el objeto firstPt. |
|
490 |
Point3D firstPt = new Point3D(); |
|
491 |
firstPt = (Point3D)((Polygon3D)fea.getGeometry()).getPoint3D(0); |
|
492 |
Point3D[] pts = new Point3D[fea.getGeometry().pointNr()+1]; |
|
493 |
for (int j=0; j<fea.getGeometry().pointNr(); j++) { |
|
494 |
pts[j] = (Point3D)((Polygon3D)fea.getGeometry()).getPoint3D(j); |
|
495 |
} |
|
496 |
// 050112: A?ado el primer punto al final para cerrar los pol?gonos. |
|
497 |
pts[fea.getGeometry().pointNr()] = firstPt; |
|
498 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
|
499 |
for (int j=1; j < pts.length; j++) { |
|
500 |
genPathX.lineTo(pts[j].getX(), pts[j].getY()); |
|
501 |
} |
|
502 |
double[] elevations = new double[pts.length]; |
|
503 |
for (int j=0;j<pts.length;j++) { |
|
504 |
elevations[j]=pts[j].getZ(); |
|
505 |
} |
|
506 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
|
507 |
auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String("FPolygon3D")); |
|
508 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(fea.getProp("dxfEntity"))); |
|
509 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(fea.getProp("layer"))); |
|
510 |
int auxInt = Integer.parseInt(fea.getProp("color")); |
|
511 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt); |
|
512 |
if (fea.getProp("elevation")!=null) { |
|
513 |
double auxE = Double.parseDouble(fea.getProp("elevation")); |
|
514 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); |
|
515 |
} |
|
516 |
double auxT = Double.parseDouble(fea.getProp("thickness")); |
|
517 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT); |
|
518 |
// Attributes |
|
519 |
for (int j=0;j<nAtt;j++) { |
|
520 |
String[] attributes = new String[2]; |
|
521 |
attributes = (String[])featureMaker.getAttributes().get(j); |
|
522 |
auxRow[10+j] = ValueFactory.createValue(new String((String)attributes[1])); |
|
523 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
|
524 |
auxRow[10+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
|
525 |
} |
|
526 |
} |
|
527 |
FShape nuevoShp = new FPolygon3D(genPathX, elevations); |
|
528 |
addShape(nuevoShp, auxRow); |
|
306 | 529 |
} else { |
307 |
System.out.println("Detectado feature desconocido"); |
|
530 |
//System.out.println("Detectado feature desconocido");
|
|
308 | 531 |
} |
309 | 532 |
} |
310 | 533 |
|
Also available in: Unified diff