83 |
83 |
|
84 |
84 |
public static final int LOAD_MODE_PLAIN = 0;
|
85 |
85 |
public static final int LOAD_MODE_GROUP1 = 1;
|
86 |
|
|
|
86 |
|
|
87 |
public static final int CROP_OPERATION_NONE = 0;
|
|
88 |
private static final int CROP_OPERATION_CONTAINS = 1;
|
|
89 |
private static final int CROP_OPERATION_COVERS = 2;
|
|
90 |
private static final int CROP_OPERATION_COVEREDBY = 3;
|
|
91 |
private static final int CROP_OPERATION_CROSSES = 4;
|
|
92 |
private static final int CROP_OPERATION_DISJOINT = 5;
|
|
93 |
private static final int CROP_OPERATION_INTERSECT = 6;
|
|
94 |
private static final int CROP_OPERATION_OVERLAPS = 7;
|
|
95 |
private static final int CROP_OPERATION_TOUCHES = 8;
|
|
96 |
private static final int CROP_OPERATION_WITHIN = 9;
|
|
97 |
|
87 |
98 |
private static final String NAME_FIELD_ID = "ID";
|
88 |
99 |
private static final String NAME_FIELD_GEOMETRY = "Geometry";
|
89 |
100 |
private static final String NAME_FIELD_TYPE = "Type";
|
... | ... | |
112 |
123 |
private int ID_FIELD_STYPE;
|
113 |
124 |
private int ID_FIELD_ENTITY;
|
114 |
125 |
private int ID_FIELD_LEVEL;
|
115 |
|
private int ID_FIELD_COLOR ;
|
116 |
|
private int ID_FIELD_FILLCOLOR ;
|
|
126 |
private int ID_FIELD_COLOR;
|
|
127 |
private int ID_FIELD_FILLCOLOR;
|
117 |
128 |
private int ID_FIELD_ELEVATION;
|
118 |
129 |
private int ID_FIELD_WEIGHT;
|
119 |
130 |
private int ID_FIELD_TEXT;
|
... | ... | |
138 |
149 |
protected GeometryManager geomManager = GeometryLocator.getGeometryManager();
|
139 |
150 |
|
140 |
151 |
DGNData dgndata = null;
|
141 |
|
|
|
152 |
|
142 |
153 |
public DGNStoreProvider(DGNStoreParameters parameters,
|
143 |
154 |
DataStoreProviderServices storeServices) throws InitializeException {
|
144 |
155 |
super(
|
... | ... | |
202 |
213 |
return legendBuilder.getLabeling();
|
203 |
214 |
}
|
204 |
215 |
|
205 |
|
|
206 |
216 |
private class DGNData {
|
207 |
217 |
|
208 |
218 |
public List data = null;
|
... | ... | |
230 |
240 |
}
|
231 |
241 |
|
232 |
242 |
public boolean isActiveOption(String option) {
|
233 |
|
if( option == null ) {
|
|
243 |
if (option == null) {
|
234 |
244 |
return false;
|
235 |
245 |
}
|
236 |
246 |
String options = getDGNParameters().getDebugOptions();
|
237 |
|
if( options==null ) {
|
|
247 |
if (options == null) {
|
238 |
248 |
return false;
|
239 |
249 |
}
|
240 |
|
option = " "+option.toLowerCase()+" ";
|
|
250 |
option = " " + option.toLowerCase() + " ";
|
241 |
251 |
options = " " + options.toLowerCase() + " ";
|
242 |
252 |
return options.contains(option);
|
243 |
253 |
}
|
244 |
|
|
|
254 |
|
245 |
255 |
public void open() throws OpenException {
|
246 |
256 |
if (this.data != null) {
|
247 |
257 |
return;
|
... | ... | |
250 |
260 |
getResource().execute(new ResourceAction() {
|
251 |
261 |
public Object run() throws Exception {
|
252 |
262 |
FeatureStoreProviderServices store = getStoreServices();
|
253 |
|
if( dgndata == null &&
|
254 |
|
! (getDGNParameters().useReload() || isActiveOption("reload")) ) {
|
|
263 |
if (dgndata == null
|
|
264 |
&& !(getDGNParameters().useReload() || isActiveOption("reload"))) {
|
255 |
265 |
if (resource.getData() != null) {
|
256 |
266 |
dgndata = (DGNData) ((Map) resource.getData()).get(projection.getAbrev()); // OJO
|
257 |
267 |
// no es del todo correcto (puede llevar reproyeccion)
|
... | ... | |
259 |
269 |
resource.setData(new HashMap());
|
260 |
270 |
}
|
261 |
271 |
}
|
262 |
|
|
|
272 |
|
263 |
273 |
if (dgndata == null) {
|
264 |
274 |
dgndata = new DGNData();
|
265 |
275 |
dgndata.data = new ArrayList();
|
... | ... | |
293 |
303 |
dgndata.legendBuilder = legendBuilder;
|
294 |
304 |
dgndata.projection = projection;
|
295 |
305 |
reader.end();
|
296 |
|
if( resource.getData()==null ) {
|
|
306 |
if (resource.getData() == null) {
|
297 |
307 |
resource.setData(new HashMap());
|
298 |
308 |
}
|
299 |
309 |
((Map) resource.getData()).put(
|
... | ... | |
323 |
333 |
|
324 |
334 |
private void sortRows() {
|
325 |
335 |
List rows = this.data;
|
326 |
|
|
|
336 |
|
327 |
337 |
Collections.sort(rows, new Comparator<FeatureProvider>() {
|
328 |
338 |
public int compare(FeatureProvider o1, FeatureProvider o2) {
|
329 |
339 |
Geometry g1 = o1.getDefaultGeometry();
|
330 |
340 |
Geometry g2 = o2.getDefaultGeometry();
|
331 |
|
if( g1==null ) {
|
332 |
|
if( g2==null ) {
|
|
341 |
if (g1 == null) {
|
|
342 |
if (g2 == null) {
|
333 |
343 |
return 0;
|
334 |
344 |
} else {
|
335 |
345 |
return -1;
|
336 |
346 |
}
|
337 |
|
} else if( g2==null ) {
|
|
347 |
} else if (g2 == null) {
|
338 |
348 |
return 1;
|
339 |
|
}
|
|
349 |
}
|
340 |
350 |
return g2.getType() - g1.getType();
|
341 |
351 |
}
|
342 |
352 |
});
|
343 |
353 |
}
|
344 |
|
|
|
354 |
|
345 |
355 |
public DataServerExplorer getExplorer() throws ReadException {
|
346 |
356 |
DataManager manager = DALLocator.getDataManager();
|
347 |
357 |
FilesystemServerExplorerParameters params;
|
... | ... | |
371 |
381 |
private Pattern weighFilter = null;
|
372 |
382 |
private Pattern typeFilter = null;
|
373 |
383 |
private Pattern stypeFilter = null;
|
|
384 |
private Pattern idFilter = null;
|
|
385 |
private Pattern groupFilter = null;
|
|
386 |
private Pattern textFilter = null;
|
374 |
387 |
private Point pointForCheckGeometries = null;
|
375 |
388 |
private boolean hasfilter = false;
|
376 |
389 |
private boolean skipCurruptGeometries = true;
|
377 |
390 |
private int geometryTypeFilter = Geometry.TYPES.GEOMETRY;
|
378 |
391 |
private int counter_exceptions = 0;
|
|
392 |
private int cropOperationFilter;
|
|
393 |
private Geometry cropFilter = null;
|
379 |
394 |
|
380 |
|
Filter(DGNStoreParameters parameters, DGNReader dgnReader ) {
|
|
395 |
Filter(DGNStoreParameters parameters, DGNReader dgnReader) {
|
381 |
396 |
geometryTypeFilter = getDGNParameters().getGeometryTypeFilter();
|
382 |
397 |
skipCurruptGeometries = getDGNParameters().skipCorruptGeometries();
|
383 |
|
if( parameters.getLevelFilter() != null ) {
|
|
398 |
if (parameters.getLevelFilter() != null) {
|
384 |
399 |
this.levelFilter = Pattern.compile(parameters.getLevelFilter());
|
385 |
400 |
this.hasfilter = true;
|
386 |
401 |
}
|
387 |
|
if( parameters.getColorFilter() != null ) {
|
|
402 |
if (parameters.getColorFilter() != null) {
|
388 |
403 |
colorFilter = Pattern.compile(parameters.getColorFilter());
|
389 |
404 |
this.hasfilter = true;
|
390 |
405 |
}
|
391 |
|
if( parameters.getStyleFilter() != null ) {
|
|
406 |
if (parameters.getStyleFilter() != null) {
|
392 |
407 |
styleFilter = Pattern.compile(parameters.getStyleFilter());
|
393 |
408 |
this.hasfilter = true;
|
394 |
409 |
}
|
395 |
|
if( parameters.getWeightFilter() != null ) {
|
|
410 |
if (parameters.getWeightFilter() != null) {
|
396 |
411 |
weighFilter = Pattern.compile(parameters.getWeightFilter());
|
397 |
412 |
this.hasfilter = true;
|
398 |
413 |
}
|
399 |
|
if( parameters.getTypeFilter() != null ) {
|
|
414 |
if (parameters.getTypeFilter() != null) {
|
400 |
415 |
this.typeFilter = Pattern.compile(parameters.getTypeFilter());
|
401 |
416 |
this.hasfilter = true;
|
402 |
417 |
}
|
403 |
|
if( parameters.getSTypeFilter() != null ) {
|
|
418 |
if (parameters.getSTypeFilter() != null) {
|
404 |
419 |
this.stypeFilter = Pattern.compile(parameters.getSTypeFilter());
|
405 |
420 |
this.hasfilter = true;
|
406 |
421 |
}
|
407 |
|
if( parameters.getWeightFilter() != null ) {
|
|
422 |
if (parameters.getWeightFilter() != null) {
|
408 |
423 |
weighFilter = Pattern.compile(parameters.getWeightFilter());
|
409 |
424 |
this.hasfilter = true;
|
410 |
425 |
}
|
411 |
|
if( this.geometryTypeFilter != Geometry.TYPES.GEOMETRY ) {
|
|
426 |
if (parameters.getGroupFilter() != null) {
|
|
427 |
groupFilter = Pattern.compile(parameters.getGroupFilter());
|
412 |
428 |
this.hasfilter = true;
|
413 |
429 |
}
|
414 |
|
|
|
430 |
if (parameters.getIDFilter() != null) {
|
|
431 |
idFilter = Pattern.compile(parameters.getIDFilter());
|
|
432 |
this.hasfilter = true;
|
|
433 |
}
|
|
434 |
if (parameters.getTextFilter() != null) {
|
|
435 |
textFilter = Pattern.compile(parameters.getTextFilter());
|
|
436 |
this.hasfilter = true;
|
|
437 |
}
|
|
438 |
if (this.geometryTypeFilter != Geometry.TYPES.GEOMETRY) {
|
|
439 |
this.hasfilter = true;
|
|
440 |
}
|
|
441 |
this.cropFilter = getDGNParameters().getCropFilter();
|
|
442 |
if (this.cropFilter != null) {
|
|
443 |
this.hasfilter = true;
|
|
444 |
}
|
|
445 |
this.cropOperationFilter = getDGNParameters().getCropOperationFilter();
|
|
446 |
if( this.cropOperationFilter==CROP_OPERATION_NONE ) {
|
|
447 |
this.cropFilter = null;
|
|
448 |
}
|
415 |
449 |
this.pointForCheckGeometries = null;
|
416 |
|
if( skipCurruptGeometries ) {
|
|
450 |
if (skipCurruptGeometries) {
|
417 |
451 |
try {
|
418 |
|
if( dgnReader.getInfo().dimension==3 ) {
|
419 |
|
this.pointForCheckGeometries = geomManager.createPoint(1, 1,Geometry.SUBTYPES.GEOM3D);
|
|
452 |
if (dgnReader.getInfo().dimension == 3) {
|
|
453 |
this.pointForCheckGeometries = geomManager.createPoint(1, 1, Geometry.SUBTYPES.GEOM3D);
|
420 |
454 |
this.pointForCheckGeometries.setCoordinateAt(2, 1);
|
421 |
455 |
} else {
|
422 |
|
this.pointForCheckGeometries = geomManager.createPoint(1, 1,Geometry.SUBTYPES.GEOM2D);
|
|
456 |
this.pointForCheckGeometries = geomManager.createPoint(1, 1, Geometry.SUBTYPES.GEOM2D);
|
423 |
457 |
}
|
424 |
|
} catch(Exception ex) {
|
|
458 |
} catch (Exception ex) {
|
425 |
459 |
this.pointForCheckGeometries = null;
|
426 |
460 |
}
|
427 |
461 |
}
|
428 |
462 |
}
|
429 |
463 |
|
430 |
464 |
private boolean match(Pattern exp, Object value) {
|
431 |
|
if( exp == null ) {
|
|
465 |
if (exp == null) {
|
432 |
466 |
return true;
|
433 |
467 |
}
|
434 |
|
if( value == null ) {
|
|
468 |
if (value == null) {
|
435 |
469 |
return false;
|
436 |
470 |
}
|
437 |
471 |
return exp.matcher(value.toString()).matches();
|
... | ... | |
439 |
473 |
|
440 |
474 |
public boolean accept(FeatureProvider data) {
|
441 |
475 |
|
442 |
|
if( !this.hasfilter ) {
|
|
476 |
if (!this.hasfilter) {
|
443 |
477 |
return true;
|
444 |
478 |
}
|
445 |
479 |
|
446 |
480 |
Geometry geometry = data.getDefaultGeometry();
|
447 |
|
if( this.pointForCheckGeometries != null ) {
|
448 |
|
if(geometry!=null) {
|
|
481 |
if (this.pointForCheckGeometries != null) {
|
|
482 |
if (geometry != null) {
|
449 |
483 |
try {
|
450 |
484 |
this.pointForCheckGeometries.intersects(geometry);
|
451 |
485 |
} catch (Exception ex) {
|
... | ... | |
454 |
488 |
geometry = null;
|
455 |
489 |
}
|
456 |
490 |
}
|
457 |
|
}
|
458 |
|
|
|
491 |
}
|
|
492 |
|
459 |
493 |
try {
|
460 |
|
if( !match(levelFilter,data.get(ID_FIELD_LEVEL)) ) {
|
|
494 |
if (!match(levelFilter, data.get(ID_FIELD_LEVEL))) {
|
461 |
495 |
return false;
|
462 |
496 |
}
|
463 |
|
if( !match(colorFilter,data.get(ID_FIELD_COLOR)) ) {
|
|
497 |
if (!match(colorFilter, data.get(ID_FIELD_COLOR))) {
|
464 |
498 |
return false;
|
465 |
499 |
}
|
466 |
|
if( !match(styleFilter,data.get(ID_FIELD_STYLE)) ) {
|
|
500 |
if (!match(styleFilter, data.get(ID_FIELD_STYLE))) {
|
467 |
501 |
return false;
|
468 |
502 |
}
|
469 |
|
if( !match(weighFilter,data.get(ID_FIELD_WEIGHT)) ) {
|
|
503 |
if (!match(weighFilter, data.get(ID_FIELD_WEIGHT))) {
|
470 |
504 |
return false;
|
471 |
505 |
}
|
472 |
|
if( !match(typeFilter,data.get(ID_FIELD_TYPE)) ) {
|
|
506 |
if (!match(typeFilter, data.get(ID_FIELD_TYPE))) {
|
473 |
507 |
return false;
|
474 |
508 |
}
|
475 |
|
if( !match(stypeFilter,data.get(ID_FIELD_STYPE)) ) {
|
|
509 |
if (!match(stypeFilter, data.get(ID_FIELD_STYPE))) {
|
476 |
510 |
return false;
|
477 |
511 |
}
|
|
512 |
if (!match(groupFilter, data.get(ID_FIELD_GROUP))) {
|
|
513 |
return false;
|
|
514 |
}
|
|
515 |
if (!match(idFilter, data.get(ID_FIELD_ID))) {
|
|
516 |
return false;
|
|
517 |
}
|
|
518 |
if (!match(textFilter, data.get(ID_FIELD_TEXT))) {
|
|
519 |
return false;
|
|
520 |
}
|
478 |
521 |
|
479 |
|
if( geometryTypeFilter != Geometry.TYPES.GEOMETRY ) {
|
480 |
|
if( geometry != null) {
|
|
522 |
if (geometry != null) {
|
|
523 |
if (geometryTypeFilter != Geometry.TYPES.GEOMETRY) {
|
481 |
524 |
GeometryType geomtype = geometry.getGeometryType();
|
482 |
|
switch(geometryTypeFilter) {
|
483 |
|
case Geometry.TYPES.POINT:
|
484 |
|
if( ! geomtype.isTypeOf(Geometry.TYPES.POINT) &&
|
485 |
|
! geomtype.isTypeOf(Geometry.TYPES.MULTIPOINT)) {
|
486 |
|
return false;
|
487 |
|
}
|
488 |
|
break;
|
489 |
|
case Geometry.TYPES.CURVE:
|
490 |
|
if( ! geomtype.isTypeOf(Geometry.TYPES.CURVE) &&
|
491 |
|
! geomtype.isTypeOf(Geometry.TYPES.MULTICURVE)) {
|
492 |
|
return false;
|
493 |
|
}
|
494 |
|
break;
|
495 |
|
case Geometry.TYPES.SURFACE:
|
496 |
|
if( ! geomtype.isTypeOf(Geometry.TYPES.SURFACE) &&
|
497 |
|
! geomtype.isTypeOf(Geometry.TYPES.MULTISURFACE)) {
|
498 |
|
return false;
|
499 |
|
}
|
500 |
|
break;
|
501 |
|
default:
|
502 |
|
break;
|
|
525 |
switch (geometryTypeFilter) {
|
|
526 |
case Geometry.TYPES.POINT:
|
|
527 |
if (!geomtype.isTypeOf(Geometry.TYPES.POINT)
|
|
528 |
&& !geomtype.isTypeOf(Geometry.TYPES.MULTIPOINT)) {
|
|
529 |
return false;
|
|
530 |
}
|
|
531 |
break;
|
|
532 |
case Geometry.TYPES.CURVE:
|
|
533 |
if (!geomtype.isTypeOf(Geometry.TYPES.CURVE)
|
|
534 |
&& !geomtype.isTypeOf(Geometry.TYPES.MULTICURVE)) {
|
|
535 |
return false;
|
|
536 |
}
|
|
537 |
break;
|
|
538 |
case Geometry.TYPES.SURFACE:
|
|
539 |
if (!geomtype.isTypeOf(Geometry.TYPES.SURFACE)
|
|
540 |
&& !geomtype.isTypeOf(Geometry.TYPES.MULTISURFACE)) {
|
|
541 |
return false;
|
|
542 |
}
|
|
543 |
break;
|
|
544 |
default:
|
|
545 |
break;
|
503 |
546 |
}
|
504 |
547 |
}
|
|
548 |
if (this.cropFilter != null) {
|
|
549 |
switch (this.cropOperationFilter) {
|
|
550 |
case CROP_OPERATION_CONTAINS:
|
|
551 |
if (!this.cropFilter.contains(geometry)) {
|
|
552 |
return false;
|
|
553 |
}
|
|
554 |
break;
|
|
555 |
case CROP_OPERATION_COVEREDBY:
|
|
556 |
if (!this.cropFilter.coveredBy(geometry)) {
|
|
557 |
return false;
|
|
558 |
}
|
|
559 |
break;
|
|
560 |
case CROP_OPERATION_COVERS:
|
|
561 |
if (!this.cropFilter.covers(geometry)) {
|
|
562 |
return false;
|
|
563 |
}
|
|
564 |
break;
|
|
565 |
case CROP_OPERATION_CROSSES:
|
|
566 |
if (!this.cropFilter.crosses(geometry)) {
|
|
567 |
return false;
|
|
568 |
}
|
|
569 |
break;
|
|
570 |
case CROP_OPERATION_DISJOINT:
|
|
571 |
if (!this.cropFilter.disjoint(geometry)) {
|
|
572 |
return false;
|
|
573 |
}
|
|
574 |
break;
|
|
575 |
case CROP_OPERATION_INTERSECT:
|
|
576 |
if (!this.cropFilter.intersects(geometry)) {
|
|
577 |
return false;
|
|
578 |
}
|
|
579 |
break;
|
|
580 |
case CROP_OPERATION_OVERLAPS:
|
|
581 |
if (!this.cropFilter.overlaps(geometry)) {
|
|
582 |
return false;
|
|
583 |
}
|
|
584 |
break;
|
|
585 |
case CROP_OPERATION_TOUCHES:
|
|
586 |
if (!this.cropFilter.touches(geometry)) {
|
|
587 |
return false;
|
|
588 |
}
|
|
589 |
break;
|
|
590 |
case CROP_OPERATION_WITHIN:
|
|
591 |
if (!this.cropFilter.within(geometry)) {
|
|
592 |
return false;
|
|
593 |
}
|
|
594 |
break;
|
|
595 |
}
|
|
596 |
}
|
505 |
597 |
}
|
506 |
|
} catch(Exception ex) {
|
507 |
|
if( ++counter_exceptions < 10 ) {
|
508 |
|
logger.warn("Can't filter data, accept it.",ex);
|
509 |
|
} else if( counter_exceptions==10 ) {
|
510 |
|
logger.warn("Can't filter data, accept it.",ex);
|
511 |
|
logger.warn("Too many exceptions, dont show more.",ex);
|
|
598 |
} catch (Exception ex) {
|
|
599 |
if (++counter_exceptions < 10) {
|
|
600 |
logger.warn("Can't filter data, accept it.", ex);
|
|
601 |
} else if (counter_exceptions == 10) {
|
|
602 |
logger.warn("Can't filter data, accept it.", ex);
|
|
603 |
logger.warn("Too many exceptions, dont show more.");
|
512 |
604 |
}
|
513 |
605 |
return true;
|
514 |
606 |
}
|
... | ... | |
517 |
609 |
|
518 |
610 |
}
|
519 |
611 |
|
520 |
|
|
521 |
612 |
public class Reader {
|
522 |
613 |
|
523 |
614 |
private File file;
|
... | ... | |
527 |
618 |
private AbstractMemoryStoreProvider store;
|
528 |
619 |
private Envelope envelope;
|
529 |
620 |
private Filter filter = null;
|
530 |
|
|
|
621 |
|
531 |
622 |
public Reader initialice(AbstractMemoryStoreProvider store, File file,
|
532 |
623 |
IProjection projection,
|
533 |
624 |
LegendBuilder leyendBuilder) {
|
... | ... | |
555 |
646 |
.setDefaultValue(Integer.valueOf(0))
|
556 |
647 |
.getIndex();
|
557 |
648 |
|
558 |
|
ID_FIELD_PARENT = featureType.add(NAME_FIELD_PARENTID,DataTypes.INT)
|
|
649 |
ID_FIELD_PARENT = featureType.add(NAME_FIELD_PARENTID, DataTypes.INT)
|
559 |
650 |
.setDefaultValue(Integer.valueOf(0))
|
560 |
651 |
.getIndex();
|
561 |
652 |
|
562 |
653 |
// FIXME: Cual es el size y el valor por defecto para Entity ?
|
563 |
|
ID_FIELD_ENTITY = featureType.add(NAME_FIELD_ENTITY,DataTypes.STRING, 100)
|
|
654 |
ID_FIELD_ENTITY = featureType.add(NAME_FIELD_ENTITY, DataTypes.STRING, 100)
|
564 |
655 |
.setDefaultValue("")
|
565 |
656 |
.getIndex();
|
566 |
657 |
|
567 |
658 |
// FIXME: Cual es el size de Layer ?
|
568 |
|
ID_FIELD_LEVEL = featureType.add(NAME_FIELD_LEVEL,DataTypes.STRING, 100)
|
|
659 |
ID_FIELD_LEVEL = featureType.add(NAME_FIELD_LEVEL, DataTypes.STRING, 100)
|
569 |
660 |
.setDefaultValue("default")
|
570 |
661 |
.getIndex();
|
571 |
662 |
ID_FIELD_LAYER = ID_FIELD_LEVEL;
|
572 |
663 |
|
573 |
|
ID_FIELD_COLOR = featureType.add(NAME_FIELD_COLOR,DataTypes.INT)
|
|
664 |
ID_FIELD_COLOR = featureType.add(NAME_FIELD_COLOR, DataTypes.INT)
|
574 |
665 |
.setDefaultValue(Integer.valueOf(0))
|
575 |
666 |
.getIndex();
|
576 |
667 |
|
577 |
668 |
// FIXME: Cual es el size de Text ?
|
578 |
|
ID_FIELD_TEXT = featureType.add(NAME_FIELD_TEXT,DataTypes.STRING, 100)
|
|
669 |
ID_FIELD_TEXT = featureType.add(NAME_FIELD_TEXT, DataTypes.STRING, 100)
|
579 |
670 |
.setDefaultValue("")
|
580 |
671 |
.getIndex();
|
581 |
672 |
|
582 |
|
ID_FIELD_HEIGHTTEXT = featureType.add(NAME_FIELD_HEIGHTTEXT,DataTypes.DOUBLE)
|
|
673 |
ID_FIELD_HEIGHTTEXT = featureType.add(NAME_FIELD_HEIGHTTEXT, DataTypes.DOUBLE)
|
583 |
674 |
.setDefaultValue(Double.valueOf(10))
|
584 |
675 |
.getIndex();
|
585 |
676 |
|
586 |
|
ID_FIELD_HEIGHTTEXTRAW = featureType.add(NAME_FIELD_HEIGHTTEXTRAW,DataTypes.DOUBLE)
|
|
677 |
ID_FIELD_HEIGHTTEXTRAW = featureType.add(NAME_FIELD_HEIGHTTEXTRAW, DataTypes.DOUBLE)
|
587 |
678 |
.setDefaultValue(Double.valueOf(10))
|
588 |
679 |
.getIndex();
|
589 |
680 |
|
590 |
|
ID_FIELD_ROTATIONTEXT = featureType.add(NAME_FIELD_ROTATIONTEXT,DataTypes.DOUBLE)
|
|
681 |
ID_FIELD_ROTATIONTEXT = featureType.add(NAME_FIELD_ROTATIONTEXT, DataTypes.DOUBLE)
|
591 |
682 |
.setDefaultValue(Double.valueOf(0))
|
592 |
683 |
.getIndex();
|
593 |
684 |
|
... | ... | |
599 |
690 |
.setDefaultValue(Integer.valueOf(0))
|
600 |
691 |
.getIndex();
|
601 |
692 |
|
602 |
|
ID_FIELD_FILLCOLOR = featureType.add(NAME_FIELD_FILLCOLOR,DataTypes.INT)
|
|
693 |
ID_FIELD_FILLCOLOR = featureType.add(NAME_FIELD_FILLCOLOR, DataTypes.INT)
|
603 |
694 |
.setDefaultValue(Integer.valueOf(0))
|
604 |
695 |
.getIndex();
|
605 |
696 |
|
606 |
|
ID_FIELD_STYLE = featureType.add(NAME_FIELD_STYLE,DataTypes.INT)
|
|
697 |
ID_FIELD_STYLE = featureType.add(NAME_FIELD_STYLE, DataTypes.INT)
|
607 |
698 |
.setDefaultValue(Integer.valueOf(0))
|
608 |
699 |
.getIndex();
|
609 |
700 |
|
610 |
|
ID_FIELD_ELEVATION = featureType.add(NAME_FIELD_ELEVATION,DataTypes.DOUBLE)
|
|
701 |
ID_FIELD_ELEVATION = featureType.add(NAME_FIELD_ELEVATION, DataTypes.DOUBLE)
|
611 |
702 |
.setDefaultValue(Double.valueOf(0))
|
612 |
703 |
.getIndex();
|
613 |
704 |
|
... | ... | |
615 |
706 |
.setDefaultValue(Double.valueOf(0))
|
616 |
707 |
.getIndex();
|
617 |
708 |
|
618 |
|
ID_FIELD_GROUP = featureType.add(NAME_FIELD_GROUP,DataTypes.INT)
|
|
709 |
ID_FIELD_GROUP = featureType.add(NAME_FIELD_GROUP, DataTypes.INT)
|
619 |
710 |
.setDefaultValue(Integer.valueOf(0))
|
620 |
711 |
.getIndex();
|
621 |
712 |
|
622 |
|
ID_FIELD_ISSHAPE = featureType.add(NAME_FIELD_ISSHAPE,DataTypes.BOOLEAN)
|
|
713 |
ID_FIELD_ISSHAPE = featureType.add(NAME_FIELD_ISSHAPE, DataTypes.BOOLEAN)
|
623 |
714 |
.setDefaultValue(Boolean.FALSE)
|
624 |
715 |
.getIndex();
|
625 |
716 |
|
626 |
|
ID_FIELD_ISCOMPLEXSHAPEHEADER = featureType.add(NAME_FIELD_ISCOMPLEXSHAPEHEADER,DataTypes.BOOLEAN)
|
|
717 |
ID_FIELD_ISCOMPLEXSHAPEHEADER = featureType.add(NAME_FIELD_ISCOMPLEXSHAPEHEADER, DataTypes.BOOLEAN)
|
627 |
718 |
.setDefaultValue(Boolean.FALSE)
|
628 |
719 |
.getIndex();
|
629 |
720 |
|
630 |
|
ID_FIELD_ISHOLE = featureType.add(NAME_FIELD_ISHOLE,DataTypes.BOOLEAN)
|
|
721 |
ID_FIELD_ISHOLE = featureType.add(NAME_FIELD_ISHOLE, DataTypes.BOOLEAN)
|
631 |
722 |
.setDefaultValue(Boolean.FALSE)
|
632 |
723 |
.getIndex();
|
633 |
724 |
|
634 |
|
ID_FIELD_ISCOMPLEX = featureType.add(NAME_FIELD_ISCOMPLEX,DataTypes.BOOLEAN)
|
|
725 |
ID_FIELD_ISCOMPLEX = featureType.add(NAME_FIELD_ISCOMPLEX, DataTypes.BOOLEAN)
|
635 |
726 |
.setDefaultValue(Boolean.FALSE)
|
636 |
727 |
.getIndex();
|
637 |
728 |
|
638 |
|
ID_FIELD_SCALE = featureType.add(NAME_FIELD_SCALE,DataTypes.INT)
|
|
729 |
ID_FIELD_SCALE = featureType.add(NAME_FIELD_SCALE, DataTypes.INT)
|
639 |
730 |
.setDefaultValue(Integer.valueOf(0))
|
640 |
731 |
.getIndex();
|
641 |
|
|
|
732 |
|
642 |
733 |
EditableFeatureAttributeDescriptor attr = featureType.add(NAME_FIELD_GEOMETRY, DataTypes.GEOMETRY);
|
643 |
734 |
attr.setSRS(this.projection);
|
644 |
735 |
attr.setGeometryType(Geometry.TYPES.GEOMETRY);
|
645 |
736 |
attr.setGeometrySubType(Geometry.SUBTYPES.GEOM3D);
|
646 |
737 |
|
647 |
|
|
648 |
738 |
featureType.setDefaultGeometryAttributeName(NAME_FIELD_GEOMETRY);
|
649 |
739 |
|
650 |
740 |
// FIXME: Parece que el DGN puede tener mas atributos opcionales.
|
... | ... | |
678 |
768 |
// }
|
679 |
769 |
// return Double.valueOf(value);
|
680 |
770 |
// }
|
681 |
|
|
682 |
771 |
public void load() throws DataException {
|
683 |
|
switch(getDGNParameters().getLoadMode()) {
|
|
772 |
switch (getDGNParameters().getLoadMode()) {
|
684 |
773 |
case LOAD_MODE_PLAIN:
|
685 |
774 |
default:
|
686 |
775 |
load_plain();
|
... | ... | |
697 |
786 |
BufferedWriter xmlbfw = null;
|
698 |
787 |
|
699 |
788 |
this.envelope = null;
|
|
789 |
boolean ignoreZs = getDGNParameters().ignoreZs();
|
700 |
790 |
|
701 |
791 |
try {
|
702 |
792 |
if (getDGNParameters().getXMLFile() != null) {
|
... | ... | |
725 |
815 |
FeatureType type = getDefaultType().getNotEditableCopy();
|
726 |
816 |
|
727 |
817 |
filter = new Filter(getDGNParameters(), dgnReader);
|
728 |
|
|
|
818 |
|
729 |
819 |
int counterOfElement = 0;
|
730 |
820 |
DGNElemComplexHeader parentElement = null;
|
731 |
821 |
for (int id = 0; id < dgnReader.getNumEntities(); id++) {
|
... | ... | |
735 |
825 |
if (elemento == null) {
|
736 |
826 |
continue;
|
737 |
827 |
}
|
738 |
|
|
739 |
|
if( parentElement!=null ) {
|
|
828 |
|
|
829 |
if (parentElement != null) {
|
740 |
830 |
counterOfElement++;
|
741 |
|
if( parentElement.getNumElements()<counterOfElement ) {
|
|
831 |
if (parentElement.getNumElements() < counterOfElement) {
|
742 |
832 |
// Ya hemos terminado de recorrer el elemento complejo.
|
743 |
|
parentElement = null;
|
|
833 |
parentElement = null;
|
744 |
834 |
}
|
745 |
835 |
}
|
746 |
|
|
|
836 |
|
747 |
837 |
if (xmlbfw != null) {
|
748 |
838 |
// Volcamos el elemnto del DGN a fichero en formato XML
|
749 |
839 |
try {
|
... | ... | |
759 |
849 |
}
|
760 |
850 |
|
761 |
851 |
FeatureProvider data = createFeatureProvider(type);
|
762 |
|
|
|
852 |
|
763 |
853 |
data.set(ID_FIELD_ID, elemento.getID());
|
764 |
854 |
data.set(ID_FIELD_TYPE, elemento.getType());
|
765 |
855 |
data.set(ID_FIELD_STYPE, elemento.getSType());
|
... | ... | |
780 |
870 |
data.set(ID_FIELD_ROTATIONTEXT, 0);
|
781 |
871 |
data.set(ID_FIELD_TEXT, null);
|
782 |
872 |
data.set(ID_FIELD_SCALE, dgnReader.getInfo().scale);
|
783 |
|
if( parentElement==null ) {
|
|
873 |
if (parentElement == null) {
|
784 |
874 |
data.set(ID_FIELD_PARENT, elemento.getID());
|
785 |
875 |
} else {
|
786 |
876 |
data.set(ID_FIELD_PARENT, parentElement.getID());
|
... | ... | |
790 |
880 |
switch (elemento.stype) {
|
791 |
881 |
case DGNFileHeader.DGNST_COMPLEX_HEADER:
|
792 |
882 |
parentElement = (DGNElemComplexHeader) elemento;
|
793 |
|
counterOfElement=0;
|
|
883 |
counterOfElement = 0;
|
794 |
884 |
break;
|
795 |
|
|
|
885 |
|
796 |
886 |
case DGNFileHeader.DGNST_MULTIPOINT:
|
797 |
887 |
DGNElemMultiPoint dgnmultipoint = (DGNElemMultiPoint) elemento;
|
798 |
888 |
if (dgnmultipoint.isPoint()) {
|
799 |
889 |
DGNPoint p = dgnmultipoint.getPoint(0);
|
800 |
|
Point point = createPoint3D(p.x, p.y, p.z);
|
|
890 |
Point point = createPoint3D(p.x, p.y, ignoreZs?0:p.z);
|
801 |
891 |
data.setDefaultGeometry(point);
|
802 |
892 |
|
803 |
|
} else {
|
|
893 |
} else {
|
804 |
894 |
OrientablePrimitive geom = null;
|
805 |
895 |
if (dgnmultipoint.isPolygon()) {
|
806 |
896 |
geom = geomManager.createSurface(
|
... | ... | |
819 |
909 |
// Si es una curva nos saltamos los dos primeros y los dos ultimos vertices.
|
820 |
910 |
int first = 0;
|
821 |
911 |
int numVertices = dgnmultipoint.getNumVertices();
|
822 |
|
if( dgnmultipoint.isCurve() ) {
|
|
912 |
if (dgnmultipoint.isCurve()) {
|
823 |
913 |
first = 2;
|
824 |
|
numVertices = dgnmultipoint.getNumVertices()-2;
|
|
914 |
numVertices = dgnmultipoint.getNumVertices() - 2;
|
825 |
915 |
}
|
826 |
|
|
|
916 |
|
827 |
917 |
if (dgnmultipoint.isHole()) {
|
828 |
918 |
// Invertimos el orden porque es un agujero
|
829 |
919 |
for (int i = numVertices - 2; i >= first; i--) {
|
830 |
920 |
DGNPoint p = dgnmultipoint.getVertex(i);
|
831 |
|
geom.addVertex(p.getX(), p.getY(), p.getZ());
|
|
921 |
geom.addVertex(p.getX(), p.getY(), ignoreZs?0:p.getZ());
|
832 |
922 |
}
|
833 |
923 |
} else {
|
834 |
|
for (int i = first; i < numVertices ; i++) {
|
|
924 |
for (int i = first; i < numVertices; i++) {
|
835 |
925 |
DGNPoint p = dgnmultipoint.getVertex(i);
|
836 |
|
geom.addVertex(p.getX(), p.getY(), p.getZ());
|
|
926 |
geom.addVertex(p.getX(), p.getY(), ignoreZs?0:p.getZ());
|
837 |
927 |
}
|
838 |
928 |
}
|
839 |
929 |
data.setDefaultGeometry(geom);
|
840 |
|
}
|
|
930 |
}
|
841 |
931 |
break;
|
842 |
932 |
|
843 |
933 |
case DGNFileHeader.DGNST_ARC:
|
... | ... | |
898 |
988 |
Point point = createPoint3D(
|
899 |
989 |
dgntext.getPoint().getX(),
|
900 |
990 |
dgntext.getPoint().getY(),
|
901 |
|
dgntext.getPoint().getZ()
|
|
991 |
ignoreZs?0:dgntext.getPoint().getZ()
|
902 |
992 |
);
|
903 |
993 |
data.set(ID_FIELD_HEIGHTTEXT, dgntext.getHeight());
|
904 |
994 |
data.set(ID_FIELD_HEIGHTTEXTRAW, dgntext.getRawHeight());
|
... | ... | |
913 |
1003 |
|
914 |
1004 |
} // switch
|
915 |
1005 |
} catch (Exception ex) {
|
916 |
|
logger.warn("Can't process element",ex);
|
|
1006 |
logger.warn("Can't process element", ex);
|
917 |
1007 |
}
|
918 |
1008 |
addFeature(data, dgnReader);
|
919 |
1009 |
} // for
|
... | ... | |
925 |
1015 |
logger.warn("Can't write to the xml file.", ex);
|
926 |
1016 |
}
|
927 |
1017 |
}
|
928 |
|
|
929 |
|
if( getDGNParameters().sortByGeometryType() ) {
|
|
1018 |
|
|
1019 |
if (getDGNParameters().sortByGeometryType()) {
|
930 |
1020 |
sortRows();
|
931 |
1021 |
}
|
932 |
1022 |
|
933 |
|
} catch(Exception ex) {
|
934 |
|
logger.warn("Can't process DGN file",ex);
|
|
1023 |
} catch (Exception ex) {
|
|
1024 |
logger.warn("Can't process DGN file", ex);
|
935 |
1025 |
} finally {
|
936 |
1026 |
IOUtils.closeQuietly(xmlbfw);
|
937 |
1027 |
IOUtils.closeQuietly(xmlfw);
|
... | ... | |
939 |
1029 |
|
940 |
1030 |
}
|
941 |
1031 |
|
942 |
|
|
943 |
1032 |
private void fillRow(Object[] row, DGNElemCore elemento, DGNElemComplexHeader parentElement, DGNReader dgnReader) {
|
944 |
1033 |
row[ID_FIELD_HEIGHTTEXT] = new Double(0);
|
945 |
1034 |
row[ID_FIELD_HEIGHTTEXTRAW] = new Double(0);
|
... | ... | |
962 |
1051 |
row[ID_FIELD_ISHOLE] = elemento.isHole();
|
963 |
1052 |
row[ID_FIELD_ISCOMPLEX] = elemento.isComplex();
|
964 |
1053 |
row[ID_FIELD_PARENT] = elemento.getID();
|
965 |
|
if( parentElement!=null ) {
|
|
1054 |
if (parentElement != null) {
|
966 |
1055 |
row[ID_FIELD_PARENT] = parentElement.getID();
|
967 |
1056 |
}
|
968 |
1057 |
row[ID_FIELD_SCALE] = dgnReader.getInfo().scale;
|
969 |
|
|
|
1058 |
|
970 |
1059 |
}
|
971 |
|
|
972 |
|
public void load_group1() throws DataException {
|
973 |
1060 |
|
974 |
|
this.envelope = null;
|
975 |
|
|
976 |
|
FileWriter xmlfw = null;
|
977 |
|
BufferedWriter xmlbfw = null;
|
978 |
|
if (getDGNParameters().getXMLFile() != null) {
|
979 |
|
File xmlfile = getDGNParameters().getXMLFile();
|
980 |
|
try {
|
981 |
|
xmlfw = new FileWriter(xmlfile);
|
982 |
|
xmlbfw = new BufferedWriter(xmlfw);
|
|
1061 |
public void load_group1() throws DataException {
|
983 |
1062 |
|
984 |
|
} catch (Exception ex) {
|
985 |
|
xmlfw = null;
|
986 |
|
xmlbfw = null;
|
987 |
|
logger.warn("Can't open xmfile for output (" + xmlfile.getAbsolutePath() + "'.", ex);
|
988 |
|
}
|
989 |
|
if (xmlbfw != null) {
|
990 |
|
try {
|
991 |
|
xmlbfw.write("<DGN>\n");
|
992 |
|
} catch (IOException ex) {
|
993 |
|
logger.warn("Can't write to the xml file.", ex);
|
994 |
|
}
|
995 |
|
}
|
|
1063 |
this.envelope = null;
|
996 |
1064 |
|
997 |
|
}
|
998 |
|
DGNReader dgnReader = new DGNReader(file.getAbsolutePath());
|
|
1065 |
FileWriter xmlfw = null;
|
|
1066 |
BufferedWriter xmlbfw = null;
|
|
1067 |
if (getDGNParameters().getXMLFile() != null) {
|
|
1068 |
File xmlfile = getDGNParameters().getXMLFile();
|
|
1069 |
try {
|
|
1070 |
xmlfw = new FileWriter(xmlfile);
|
|
1071 |
xmlbfw = new BufferedWriter(xmlfw);
|
999 |
1072 |
|
1000 |
|
FeatureType type = getDefaultType().getNotEditableCopy();
|
1001 |
|
int fTypeSize = type.size();
|
1002 |
|
Object[] auxRow = new Object[fTypeSize];
|
1003 |
|
Object[] cellRow = new Object[fTypeSize];
|
1004 |
|
Object[] complexRow = new Object[fTypeSize];
|
|
1073 |
} catch (Exception ex) {
|
|
1074 |
xmlfw = null;
|
|
1075 |
xmlbfw = null;
|
|
1076 |
logger.warn("Can't open xmfile for output (" + xmlfile.getAbsolutePath() + "'.", ex);
|
|
1077 |
}
|
|
1078 |
if (xmlbfw != null) {
|
|
1079 |
try {
|
|
1080 |
xmlbfw.write("<DGN>\n");
|
|
1081 |
} catch (IOException ex) {
|
|
1082 |
logger.warn("Can't write to the xml file.", ex);
|
|
1083 |
}
|
|
1084 |
}
|
1005 |
1085 |
|
1006 |
|
boolean bElementoCompuesto = false;
|
1007 |
|
boolean bEsPoligono = false;
|
1008 |
|
boolean bInsideCell = false;
|
1009 |
|
boolean bFirstHoleEntity = false;
|
1010 |
|
boolean bConnect = false; // Se usa para que los pol?gonos cierren
|
1011 |
|
// bien cuando son formas compuestas
|
|
1086 |
}
|
|
1087 |
DGNReader dgnReader = new DGNReader(file.getAbsolutePath());
|
|
1088 |
|
|
1089 |
FeatureType type = getDefaultType().getNotEditableCopy();
|
|
1090 |
int fTypeSize = type.size();
|
|
1091 |
Object[] auxRow = new Object[fTypeSize];
|
|
1092 |
Object[] cellRow = new Object[fTypeSize];
|
|
1093 |
Object[] complexRow = new Object[fTypeSize];
|
|
1094 |
|
|
1095 |
boolean bElementoCompuesto = false;
|
|
1096 |
boolean bEsPoligono = false;
|
|
1097 |
boolean bInsideCell = false;
|
|
1098 |
boolean bFirstHoleEntity = false;
|
|
1099 |
boolean bConnect = false; // Se usa para que los pol?gonos cierren
|
|
1100 |
// bien cuando son formas compuestas
|
1012 |
1101 |
// int contadorSubElementos = 0;
|
1013 |
1102 |
// int numSubElementos = 0;
|
1014 |
|
int complex_index_fill_color = -1;
|
1015 |
|
int nClass; // Para filtrar los elementos de construcci?n, etc.
|
1016 |
|
GeneralPathX elementoCompuesto = new GeneralPathX(
|
1017 |
|
GeneralPathX.WIND_EVEN_ODD);
|
|
1103 |
int complex_index_fill_color = -1;
|
|
1104 |
int nClass; // Para filtrar los elementos de construcci?n, etc.
|
|
1105 |
GeneralPathX elementoCompuesto = new GeneralPathX(
|
|
1106 |
GeneralPathX.WIND_EVEN_ODD);
|
1018 |
1107 |
|
1019 |
|
int counterOfElement = 0;
|
1020 |
|
DGNElemComplexHeader parentElement = null;
|
1021 |
|
|
1022 |
|
filter = new Filter(getDGNParameters(), dgnReader);
|
1023 |
|
|
1024 |
|
for (int id = 0; id < dgnReader.getNumEntities(); id++) {
|
1025 |
|
dgnReader.DGNGotoElement(id);
|
|
1108 |
int counterOfElement = 0;
|
|
1109 |
DGNElemComplexHeader parentElement = null;
|
1026 |
1110 |
|
1027 |
|
DGNElemCore elemento = dgnReader.DGNReadElement();
|
1028 |
|
if( parentElement!=null ) {
|
1029 |
|
counterOfElement++;
|
1030 |
|
if( parentElement.getNumElements()<counterOfElement ) {
|
1031 |
|
// Ya hemos terminado de recorrer el elemento complejo.
|
1032 |
|
parentElement = null;
|
1033 |
|
}
|
1034 |
|
}
|
1035 |
|
|
1036 |
|
if (xmlbfw != null && elemento != null ) {
|
1037 |
|
// Volcamos el elemnto del DGN a fichero en formato XML
|
1038 |
|
try {
|
1039 |
|
xmlbfw.write(dgnReader.DGNDumpElement(dgnReader.getInfo(), elemento));
|
1040 |
|
} catch (IOException ex) {
|
1041 |
|
logger.warn("Can't write to the xml file.", ex);
|
1042 |
|
}
|
1043 |
|
}
|
|
1111 |
filter = new Filter(getDGNParameters(), dgnReader);
|
1044 |
1112 |
|
1045 |
|
nClass = 0;
|
1046 |
|
fillRow(auxRow, elemento, parentElement, dgnReader);
|
1047 |
|
auxRow[ID_FIELD_HEIGHTTEXT] = new Double(0);
|
1048 |
|
auxRow[ID_FIELD_ROTATIONTEXT] = new Double(0);
|
1049 |
|
auxRow[ID_FIELD_TEXT] = null;
|
|
1113 |
for (int id = 0; id < dgnReader.getNumEntities(); id++) {
|
|
1114 |
dgnReader.DGNGotoElement(id);
|
1050 |
1115 |
|
|
1116 |
DGNElemCore elemento = dgnReader.DGNReadElement();
|
|
1117 |
if (parentElement != null) {
|
|
1118 |
counterOfElement++;
|
|
1119 |
if (parentElement.getNumElements() < counterOfElement) {
|
|
1120 |
// Ya hemos terminado de recorrer el elemento complejo.
|
|
1121 |
parentElement = null;
|
|
1122 |
}
|
|
1123 |
}
|
1051 |
1124 |
|
1052 |
|
if (elemento.properties != 0) {
|
1053 |
|
nClass = elemento.properties & DGNFileHeader.DGNPF_CLASS;
|
1054 |
|
}
|
|
1125 |
if (xmlbfw != null && elemento != null) {
|
|
1126 |
// Volcamos el elemnto del DGN a fichero en formato XML
|
|
1127 |
try {
|
|
1128 |
xmlbfw.write(dgnReader.DGNDumpElement(dgnReader.getInfo(), elemento));
|
|
1129 |
} catch (IOException ex) {
|
|
1130 |
logger.warn("Can't write to the xml file.", ex);
|
|
1131 |
}
|
|
1132 |
}
|
1055 |
1133 |
|
1056 |
|
if ((elemento != null) && (elemento.deleted == 0)
|
1057 |
|
&& (nClass == 0)) // Leer un elemento
|
1058 |
|
{
|
|
1134 |
nClass = 0;
|
|
1135 |
fillRow(auxRow, elemento, parentElement, dgnReader);
|
|
1136 |
auxRow[ID_FIELD_HEIGHTTEXT] = new Double(0);
|
|
1137 |
auxRow[ID_FIELD_ROTATIONTEXT] = new Double(0);
|
|
1138 |
auxRow[ID_FIELD_TEXT] = null;
|
1059 |
1139 |
|
|
1140 |
if (elemento.properties != 0) {
|
|
1141 |
nClass = elemento.properties & DGNFileHeader.DGNPF_CLASS;
|
|
1142 |
}
|
|
1143 |
|
|
1144 |
if ((elemento != null) && (elemento.deleted == 0)
|
|
1145 |
&& (nClass == 0)) // Leer un elemento
|
|
1146 |
{
|
|
1147 |
|
1060 |
1148 |
// if ((elemento.element_id > 3800) && (elemento.element_id
|
1061 |
|
// < 3850))
|
1062 |
|
// dgnReader.DGNDumpElement(dgnReader.getInfo(),elemento,"");
|
1063 |
|
if ((elemento.stype == DGNFileHeader.DGNST_MULTIPOINT)
|
1064 |
|
|| (elemento.stype == DGNFileHeader.DGNST_ARC)
|
1065 |
|
|| (elemento.stype == DGNFileHeader.DGNST_CELL_HEADER)
|
1066 |
|
|| (elemento.stype == DGNFileHeader.DGNST_SHARED_CELL_DEFN)
|
1067 |
|
|| (elemento.stype == DGNFileHeader.DGNST_COMPLEX_HEADER)) {
|
1068 |
|
if (elemento.complex != 0) {
|
1069 |
|
bElementoCompuesto = true;
|
1070 |
|
} else {
|
1071 |
|
if (bElementoCompuesto) {
|
1072 |
|
if (bInsideCell) {
|
1073 |
|
auxRow[ID_FIELD_ENTITY] = cellRow[ID_FIELD_ENTITY];
|
1074 |
|
} else {
|
1075 |
|
auxRow = complexRow;
|
1076 |
|
}
|
1077 |
|
addShape(createMultiCurve(elementoCompuesto),
|
1078 |
|
auxRow, type, dgnReader);
|
|
1149 |
// < 3850))
|
|
1150 |
// dgnReader.DGNDumpElement(dgnReader.getInfo(),elemento,"");
|
|
1151 |
if ((elemento.stype == DGNFileHeader.DGNST_MULTIPOINT)
|
|
1152 |
|| (elemento.stype == DGNFileHeader.DGNST_ARC)
|
|
1153 |
|| (elemento.stype == DGNFileHeader.DGNST_CELL_HEADER)
|
|
1154 |
|| (elemento.stype == DGNFileHeader.DGNST_SHARED_CELL_DEFN)
|
|
1155 |
|| (elemento.stype == DGNFileHeader.DGNST_COMPLEX_HEADER)) {
|
|
1156 |
if (elemento.complex != 0) {
|
|
1157 |
bElementoCompuesto = true;
|
|
1158 |
} else {
|
|
1159 |
if (bElementoCompuesto) {
|
|
1160 |
if (bInsideCell) {
|
|
1161 |
auxRow[ID_FIELD_ENTITY] = cellRow[ID_FIELD_ENTITY];
|
|
1162 |
} else {
|
|
1163 |
auxRow = complexRow;
|
|
1164 |
}
|
|
1165 |
addShape(createMultiCurve(elementoCompuesto),
|
|
1166 |
auxRow, type, dgnReader);
|
1079 |
1167 |
|
1080 |
|
if (bEsPoligono) {
|
1081 |
|
if (complex_index_fill_color != -1) {
|
1082 |
|
auxRow[ID_FIELD_COLOR] = complex_index_fill_color;
|
1083 |
|
}
|
|
1168 |
if (bEsPoligono) {
|
|
1169 |
if (complex_index_fill_color != -1) {
|
|
1170 |
auxRow[ID_FIELD_COLOR] = complex_index_fill_color;
|
|
1171 |
}
|
1084 |
1172 |
|
1085 |
|
addShape(
|
1086 |
|
createMultiSurface(elementoCompuesto),
|
1087 |
|
auxRow, type, dgnReader);
|
1088 |
|
}
|
|
1173 |
addShape(
|
|
1174 |
createMultiSurface(elementoCompuesto),
|
|
1175 |
auxRow, type, dgnReader);
|
|
1176 |
}
|
1089 |
1177 |
|
1090 |
|
elementoCompuesto = new GeneralPathX(
|
1091 |
|
GeneralPathX.WIND_EVEN_ODD);
|
1092 |
|
}
|
|
1178 |
elementoCompuesto = new GeneralPathX(
|
|
1179 |
GeneralPathX.WIND_EVEN_ODD);
|
|
1180 |
}
|
1093 |
1181 |
|
1094 |
|
bElementoCompuesto = false;
|
1095 |
|
bEsPoligono = false;
|
1096 |
|
bConnect = false;
|
|
1182 |
bElementoCompuesto = false;
|
|
1183 |
bEsPoligono = false;
|
|
1184 |
bConnect = false;
|
1097 |
1185 |
|
1098 |
|
bInsideCell = false;
|
1099 |
|
}
|
1100 |
|
}
|
|
1186 |
bInsideCell = false;
|
|
1187 |
}
|
|
1188 |
}
|
1101 |
1189 |
|
1102 |
|
switch (elemento.stype) {
|
1103 |
|
case DGNFileHeader.DGNST_SHARED_CELL_DEFN:
|
1104 |
|
bInsideCell = true;
|
1105 |
|
fillRow(cellRow, elemento, parentElement, dgnReader);
|
1106 |
|
cellRow[ID_FIELD_ID] = elemento.element_id;
|
1107 |
|
cellRow[ID_FIELD_LAYER] = String.valueOf(elemento.level);
|
1108 |
|
cellRow[ID_FIELD_COLOR] = elemento.color;
|
1109 |
|
cellRow[ID_FIELD_ENTITY] = "Shared Cell";
|
|
1190 |
switch (elemento.stype) {
|
|
1191 |
case DGNFileHeader.DGNST_SHARED_CELL_DEFN:
|
|
1192 |
bInsideCell = true;
|
|
1193 |
fillRow(cellRow, elemento, parentElement, dgnReader);
|
|
1194 |
cellRow[ID_FIELD_ID] = elemento.element_id;
|
|
1195 |
cellRow[ID_FIELD_LAYER] = String.valueOf(elemento.level);
|
|
1196 |
cellRow[ID_FIELD_COLOR] = elemento.color;
|
|
1197 |
cellRow[ID_FIELD_ENTITY] = "Shared Cell";
|
1110 |
1198 |
|
1111 |
|
break;
|
|
1199 |
break;
|
1112 |
1200 |
|
1113 |
|
case DGNFileHeader.DGNST_CELL_HEADER:
|
1114 |
|
bInsideCell = true;
|
|
1201 |
case DGNFileHeader.DGNST_CELL_HEADER:
|
|
1202 |
bInsideCell = true;
|
1115 |
1203 |
|
1116 |
|
fillRow(cellRow, elemento, parentElement, dgnReader);
|
1117 |
|
cellRow[ID_FIELD_ID] = elemento.element_id;
|
1118 |
|
cellRow[ID_FIELD_LAYER] = String.valueOf(elemento.level);
|
1119 |
|
cellRow[ID_FIELD_COLOR] = elemento.color;
|
1120 |
|
cellRow[ID_FIELD_ENTITY] = "Cell";
|
1121 |
|
complex_index_fill_color = dgnReader
|
1122 |
|
.DGNGetShapeFillInfo(elemento);
|
1123 |
|
break;
|
|
1204 |
fillRow(cellRow, elemento, parentElement, dgnReader);
|
|
1205 |
cellRow[ID_FIELD_ID] = elemento.element_id;
|
|
1206 |
cellRow[ID_FIELD_LAYER] = String.valueOf(elemento.level);
|
|
1207 |
cellRow[ID_FIELD_COLOR] = elemento.color;
|
|
1208 |
cellRow[ID_FIELD_ENTITY] = "Cell";
|
|
1209 |
complex_index_fill_color = dgnReader
|
|
1210 |
.DGNGetShapeFillInfo(elemento);
|
|
1211 |
break;
|
1124 |
1212 |
|
1125 |
|
case DGNFileHeader.DGNST_COMPLEX_HEADER:
|
|
1213 |
case DGNFileHeader.DGNST_COMPLEX_HEADER:
|
1126 |
1214 |
|
1127 |
1215 |
// bElementoCompuesto = true;
|
1128 |
1216 |
// contadorSubElementos = 0;
|
|
1217 |
DGNElemComplexHeader psComplexHeader = (DGNElemComplexHeader) elemento;
|
1129 |
1218 |
|
1130 |
|
DGNElemComplexHeader psComplexHeader = (DGNElemComplexHeader) elemento;
|
1131 |
|
|
1132 |
|
parentElement = psComplexHeader;
|
1133 |
|
counterOfElement = parentElement.getNumElements();
|
1134 |
|
|
|
1219 |
parentElement = psComplexHeader;
|
|
1220 |
counterOfElement = parentElement.getNumElements();
|
|
1221 |
|
1135 |
1222 |
// numSubElementos = psComplexHeader.numelems;
|
1136 |
|
fillRow(complexRow, elemento, parentElement, dgnReader);
|
1137 |
|
complexRow[ID_FIELD_ID] = elemento.element_id;
|
1138 |
|
complexRow[ID_FIELD_LAYER] = String.valueOf(elemento.level);
|
1139 |
|
complexRow[ID_FIELD_COLOR] = elemento.color;
|
1140 |
|
complexRow[ID_FIELD_ENTITY] = "Complex";
|
|
1223 |
fillRow(complexRow, elemento, parentElement, dgnReader);
|
|
1224 |
complexRow[ID_FIELD_ID] = elemento.element_id;
|
|
1225 |
complexRow[ID_FIELD_LAYER] = String.valueOf(elemento.level);
|
|
1226 |
complexRow[ID_FIELD_COLOR] = elemento.color;
|
|
1227 |
complexRow[ID_FIELD_ENTITY] = "Complex";
|
1141 |
1228 |
|
1142 |
|
if (psComplexHeader.type == DGNFileHeader.DGNT_COMPLEX_SHAPE_HEADER) {
|
1143 |
|
bEsPoligono = true;
|
|
1229 |
if (psComplexHeader.type == DGNFileHeader.DGNT_COMPLEX_SHAPE_HEADER) {
|
|
1230 |
bEsPoligono = true;
|
1144 |
1231 |
|
1145 |
|
// Si es un agujero, no conectamos con el anterior
|
1146 |
|
if ((psComplexHeader.properties & 0x8000) != 0) {
|
1147 |
|
bFirstHoleEntity = true;
|
1148 |
|
} else {
|
|
1232 |
// Si es un agujero, no conectamos con el anterior
|
|
1233 |
if ((psComplexHeader.properties & 0x8000) != 0) {
|
|
1234 |
bFirstHoleEntity = true;
|
|
1235 |
} else {
|
1149 |
1236 |
// Miramos si tiene color de relleno
|
1150 |
|
// complex_index_fill_color = -1;
|
1151 |
|
// if (elemento.attr_bytes > 0) {
|
1152 |
|
complex_index_fill_color = dgnReader
|
1153 |
|
.DGNGetShapeFillInfo(elemento);
|
|
1237 |
// complex_index_fill_color = -1;
|
|
1238 |
// if (elemento.attr_bytes > 0) {
|
|
1239 |
complex_index_fill_color = dgnReader
|
|
1240 |
.DGNGetShapeFillInfo(elemento);
|
1154 |
1241 |
|
1155 |
|
// }
|
1156 |
|
}
|
|
1242 |
// }
|
|
1243 |
}
|
1157 |
1244 |
|
1158 |
|
bConnect = true;
|
1159 |
|
} else {
|
1160 |
|
bEsPoligono = false;
|
1161 |
|
bConnect = false;
|
1162 |
|
}
|
|
1245 |
bConnect = true;
|
|
1246 |
} else {
|
|
1247 |
bEsPoligono = false;
|
|
1248 |
bConnect = false;
|
|
1249 |
}
|
1163 |
1250 |
|
1164 |
|
break;
|
|
1251 |
break;
|
1165 |
1252 |
|
1166 |
|
case DGNFileHeader.DGNST_MULTIPOINT:
|
|
1253 |
case DGNFileHeader.DGNST_MULTIPOINT:
|
1167 |
1254 |
|
1168 |
1255 |
// OJO: Si lo que viene en este multipoint es un
|
1169 |
|
// elemento con type=11 (curve), se trata de una
|
1170 |
|
// "parametric
|
1171 |
|
// spline curve". La vamos a tratar como si no fuera
|
1172 |
|
// curva, pero seg?n la documentaci?n, los 2 primeros
|
1173 |
|
// puntos
|
1174 |
|
// y los 2 ?ltimos puntos definen "endpoint derivatives"
|
1175 |
|
// y NO se muestran.
|
1176 |
|
// TODAV?A HAY UN PEQUE?O FALLO CON EL FICHERO
|
1177 |
|
// dgn-sample.dgn, pero lo dejo por ahora.
|
1178 |
|
// Es posible que tenga que ver con lo de los arcos
|
1179 |
|
// (arco distorsionado), que
|
1180 |
|
// todav?a no est? metido.
|
1181 |
|
DGNElemMultiPoint psLine = (DGNElemMultiPoint) elemento;
|
1182 |
|
fillRow(auxRow, elemento, parentElement, dgnReader);
|
1183 |
|
auxRow[ID_FIELD_ID] = elemento.element_id;
|
1184 |
|
auxRow[ID_FIELD_ENTITY] = "Multipoint";
|
1185 |
|
auxRow[ID_FIELD_LAYER] = String.valueOf(elemento.level);
|
1186 |
|
auxRow[ID_FIELD_COLOR] = elemento.color;
|
|
1256 |
// elemento con type=11 (curve), se trata de una
|
|
1257 |
// "parametric
|
|
1258 |
// spline curve". La vamos a tratar como si no fuera
|
|
1259 |
// curva, pero seg?n la documentaci?n, los 2 primeros
|
|
1260 |
// puntos
|
|
1261 |
// y los 2 ?ltimos puntos definen "endpoint derivatives"
|
|
1262 |
// y NO se muestran.
|
|
1263 |
// TODAV?A HAY UN PEQUE?O FALLO CON EL FICHERO
|
|
1264 |
// dgn-sample.dgn, pero lo dejo por ahora.
|
|
1265 |
// Es posible que tenga que ver con lo de los arcos
|
|
1266 |
// (arco distorsionado), que
|
|
1267 |
// todav?a no est? metido.
|
|
1268 |
DGNElemMultiPoint psLine = (DGNElemMultiPoint) elemento;
|
|
1269 |
fillRow(auxRow, elemento, parentElement, dgnReader);
|
|
1270 |
auxRow[ID_FIELD_ID] = elemento.element_id;
|
|
1271 |
auxRow[ID_FIELD_ENTITY] = "Multipoint";
|
|
1272 |
auxRow[ID_FIELD_LAYER] = String.valueOf(elemento.level);
|
|
1273 |
auxRow[ID_FIELD_COLOR] = elemento.color;
|
1187 |
1274 |
|
1188 |
|
if ((psLine.num_vertices == 2)
|
1189 |
|
&& (psLine.vertices[0].x == psLine.vertices[1].x)
|
1190 |
|
&& (psLine.vertices[0].y == psLine.vertices[1].y)) {
|
1191 |
|
auxRow[ID_FIELD_ENTITY] = "Point";
|
1192 |
|
addShape(
|
1193 |
|
createPoint3D(psLine.vertices[0].x,
|
1194 |
|
psLine.vertices[0].y,
|
1195 |
|
psLine.vertices[0].z), auxRow,
|
1196 |
|
type, dgnReader);
|
1197 |
|
} else {
|
1198 |
|
GeneralPathX elShape = new GeneralPathX(
|
1199 |
|
GeneralPathX.WIND_EVEN_ODD);
|
|
1275 |
if ((psLine.num_vertices == 2)
|
|
1276 |
&& (psLine.vertices[0].x == psLine.vertices[1].x)
|
|
1277 |
&& (psLine.vertices[0].y == psLine.vertices[1].y)) {
|
|
1278 |
auxRow[ID_FIELD_ENTITY] = "Point";
|
|
1279 |
addShape(
|
|
1280 |
createPoint3D(psLine.vertices[0].x,
|
|
1281 |
psLine.vertices[0].y,
|
|
1282 |
psLine.vertices[0].z), auxRow,
|
|
1283 |
type, dgnReader);
|
|
1284 |
} else {
|
|
1285 |
GeneralPathX elShape = new GeneralPathX(
|
|
1286 |
GeneralPathX.WIND_EVEN_ODD);
|
1200 |
1287 |
|
1201 |
|
if (psLine.type == DGNFileHeader.DGNT_CURVE) {
|
1202 |
|
psLine.num_vertices = psLine.num_vertices - 4;
|
|
1288 |
if (psLine.type == DGNFileHeader.DGNT_CURVE) {
|
|
1289 |
psLine.num_vertices = psLine.num_vertices - 4;
|
1203 |
1290 |
|
1204 |
|
for (int aux_n = 0; aux_n < psLine.num_vertices; aux_n++) {
|
1205 |
|
psLine.vertices[aux_n] = psLine.vertices[aux_n + 2];
|
1206 |
|
}
|
1207 |
|
}
|
|
1291 |
for (int aux_n = 0; aux_n < psLine.num_vertices; aux_n++) {
|
|
1292 |
psLine.vertices[aux_n] = psLine.vertices[aux_n + 2];
|
|
1293 |
}
|
|
1294 |
}
|
1208 |
1295 |
|
1209 |
|
if ((psLine.type == DGNFileHeader.DGNT_SHAPE)
|
1210 |
|
&& ((psLine.properties & 0x8000) != 0)) {
|
1211 |
|
// Invertimos el orden porque es un agujero
|
1212 |
|
elShape
|
1213 |
|
.moveTo(
|
1214 |
|
psLine.vertices[psLine.num_vertices - 1].x,
|
1215 |
|
psLine.vertices[psLine.num_vertices - 1].y);
|
|
1296 |
if ((psLine.type == DGNFileHeader.DGNT_SHAPE)
|
|
1297 |
&& ((psLine.properties & 0x8000) != 0)) {
|
|
1298 |
// Invertimos el orden porque es un agujero
|
|
1299 |
elShape
|
|
1300 |
.moveTo(
|
|
1301 |
psLine.vertices[psLine.num_vertices - 1].x,
|
|
1302 |
psLine.vertices[psLine.num_vertices - 1].y);
|
1216 |
1303 |
|
1217 |
|
for (int i = psLine.num_vertices - 2; i >= 0; i--) {
|
1218 |
|
elShape.lineTo(psLine.vertices[i].x,
|
1219 |
|
psLine.vertices[i].y);
|
1220 |
|
}
|
1221 |
|
} else {
|
1222 |
|
elShape.moveTo(psLine.vertices[0].x,
|
1223 |
|
psLine.vertices[0].y);
|
|
1304 |
for (int i = psLine.num_vertices - 2; i >= 0; i--) {
|
|
1305 |
elShape.lineTo(psLine.vertices[i].x,
|
|
1306 |
psLine.vertices[i].y);
|
|
1307 |
}
|
|
1308 |
} else {
|
|
1309 |
elShape.moveTo(psLine.vertices[0].x,
|
|
1310 |
psLine.vertices[0].y);
|
1224 |
1311 |
|
1225 |
|
for (int i = 1; i < psLine.num_vertices; i++) {
|
1226 |
|
elShape.lineTo(psLine.vertices[i].x,
|
1227 |
|
psLine.vertices[i].y);
|
1228 |
|
}
|
1229 |
|
}
|
|
1312 |
for (int i = 1; i < psLine.num_vertices; i++) {
|
|
1313 |
elShape.lineTo(psLine.vertices[i].x,
|
|
1314 |
psLine.vertices[i].y);
|
|
1315 |
}
|
|
1316 |
}
|
1230 |
1317 |
|
1231 |
|
if ((psLine.vertices[0].x == psLine.vertices[psLine.num_vertices - 1].x)
|
1232 |
|
&& (psLine.vertices[0].y == psLine.vertices[psLine.num_vertices - 1].y)) {
|
1233 |
|
// Lo a?adimos tambi?n como pol?gono
|
1234 |
|
bEsPoligono = true;
|
|
1318 |
if ((psLine.vertices[0].x == psLine.vertices[psLine.num_vertices - 1].x)
|
|
1319 |
&& (psLine.vertices[0].y == psLine.vertices[psLine.num_vertices - 1].y)) {
|
|
1320 |
// Lo a?adimos tambi?n como pol?gono
|
|
1321 |
bEsPoligono = true;
|
1235 |
1322 |
|
1236 |
|
// Miramos si tiene color de relleno
|
1237 |
|
if (elemento.attr_bytes > 0) {
|
1238 |
|
elemento.color = dgnReader
|
1239 |
|
.DGNGetShapeFillInfo(elemento);
|
|
1323 |
// Miramos si tiene color de relleno
|
|
1324 |
if (elemento.attr_bytes > 0) {
|
|
1325 |
elemento.color = dgnReader
|
|
1326 |
.DGNGetShapeFillInfo(elemento);
|
1240 |
1327 |
|
1241 |
|
if (elemento.color != -1) {
|
1242 |
|
auxRow[ID_FIELD_COLOR] = elemento.color;
|
1243 |
|
}
|
1244 |
|
}
|
|
1328 |
if (elemento.color != -1) {
|
|
1329 |
auxRow[ID_FIELD_COLOR] = elemento.color;
|
|
1330 |
}
|
|
1331 |
}
|
1245 |
1332 |
|
1246 |
|
if (elemento.complex == 0) {
|
1247 |
|
addShape(createSurface(elShape), auxRow,
|
1248 |
|
type, dgnReader);
|
1249 |
|
}
|
1250 |
|
}
|
|
1333 |
if (elemento.complex == 0) {
|
|
1334 |
addShape(createSurface(elShape), auxRow,
|
|
1335 |
type, dgnReader);
|
|
1336 |
}
|
|
1337 |
}
|
1251 |
1338 |
|
1252 |
|
if (elemento.complex != 0) {
|
|
1339 |
if (elemento.complex != 0) {
|
1253 |
1340 |
// Si es un agujero o
|
1254 |
|
// es la primera entidad del agujero, lo
|
1255 |
|
// a?adimos sin unir al anterior
|
1256 |
|
if (bFirstHoleEntity
|
1257 |
|
|| ((psLine.type == DGNFileHeader.DGNT_SHAPE) && ((psLine.properties & 0x8000) != 0))) {
|
1258 |
|
elementoCompuesto.append(elShape.getPathIterator(null), false);
|
1259 |
|
bFirstHoleEntity = false;
|
1260 |
|
} else {
|
1261 |
|
elementoCompuesto.append(elShape.getPathIterator(null), bConnect);
|
1262 |
|
}
|
1263 |
|
} else {
|
1264 |
|
addShape(createMultiCurve(elShape), auxRow,
|
1265 |
|
type, dgnReader);
|
1266 |
|
}
|
1267 |
|
}
|
|
1341 |
// es la primera entidad del agujero, lo
|
|
1342 |
// a?adimos sin unir al anterior
|
|
1343 |
if (bFirstHoleEntity
|
|
1344 |
|| ((psLine.type == DGNFileHeader.DGNT_SHAPE) && ((psLine.properties & 0x8000) != 0))) {
|
|
1345 |
elementoCompuesto.append(elShape.getPathIterator(null), false);
|
|
1346 |
bFirstHoleEntity = false;
|
|
1347 |
} else {
|
|
1348 |
elementoCompuesto.append(elShape.getPathIterator(null), bConnect);
|
|
1349 |
}
|
|
1350 |
} else {
|
|
1351 |
addShape(createMultiCurve(elShape), auxRow,
|
|
1352 |
type, dgnReader);
|
|
1353 |
}
|
|
1354 |
}
|
1268 |
1355 |
|
1269 |
|
break;
|
|
1356 |
break;
|
1270 |
1357 |
|
1271 |
|
case DGNFileHeader.DGNST_ARC:
|
|
1358 |
case DGNFileHeader.DGNST_ARC:
|
1272 |
1359 |
|
1273 |
1360 |
// dgnReader.DGNDumpElement(dgnReader.getInfo(),
|
1274 |
|
// elemento,"");
|
1275 |
|
DGNElemArc psArc = (DGNElemArc) elemento;
|
|
1361 |
// elemento,"");
|
|
1362 |
DGNElemArc psArc = (DGNElemArc) elemento;
|
1276 |
1363 |
|
1277 |
1364 |
// La definici?n de arco de MicroStation es distinta a
|
1278 |
|
// la de Java.
|
1279 |
|
// En el dgn el origin se entiende que es el centro del
|
1280 |
|
// arco,
|
1281 |
|
// y a la hora de crear un Arc2D las 2 primeras
|
1282 |
|
// coordenadas son
|
1283 |
|
// la esquina inferior izquierda del rect?ngulo que
|
1284 |
|
// rodea al arco.
|
1285 |
|
// 1.- Creamos la elipse sin rotaci?n.
|
1286 |
|
// 2.- Creamos el arco
|
1287 |
|
// 3.- Rotamos el resultado
|
|
1365 |
// la de Java.
|
|
1366 |
// En el dgn el origin se entiende que es el centro del
|
|
1367 |
// arco,
|
|
1368 |
// y a la hora de crear un Arc2D las 2 primeras
|
|
1369 |
// coordenadas son
|
|
1370 |
// la esquina inferior izquierda del rect?ngulo que
|
|
1371 |
// rodea al arco.
|
|
1372 |
// 1.- Creamos la elipse sin rotaci?n.
|
|
1373 |
// 2.- Creamos el arco
|
|
1374 |
// 3.- Rotamos el resultado
|
|
1375 |
AffineTransform mT = AffineTransform.getRotateInstance(
|
|
1376 |
Math.toRadians(psArc.rotation), psArc.origin.x,
|
|
1377 |
psArc.origin.y);
|
1288 |
1378 |
|
1289 |
|
AffineTransform mT = AffineTransform.getRotateInstance(
|
1290 |
|
Math.toRadians(psArc.rotation), psArc.origin.x,
|
1291 |
|
psArc.origin.y);
|
|
1379 |
// mT.preConcatenate(AffineTransform.getScaleInstance(100.0,100.0));
|
|
1380 |
Arc2D.Double elArco = new Arc2D.Double(psArc.origin.x
|
|
1381 |
- psArc.primary_axis, psArc.origin.y
|
|
1382 |
- psArc.secondary_axis,
|
|
1383 |
2.0 * psArc.primary_axis,
|
|
1384 |
2.0 * psArc.secondary_axis, -psArc.startang,
|
|
1385 |
-psArc.sweepang, Arc2D.OPEN);
|
1292 |
1386 |
|
1293 |
|
// mT.preConcatenate(AffineTransform.getScaleInstance(100.0,100.0));
|
1294 |
|
Arc2D.Double elArco = new Arc2D.Double(psArc.origin.x
|
1295 |
|
- psArc.primary_axis, psArc.origin.y
|
1296 |
|
- psArc.secondary_axis,
|
1297 |
|
2.0 * psArc.primary_axis,
|
1298 |
|
2.0 * psArc.secondary_axis, -psArc.startang,
|
1299 |
|
-psArc.sweepang, Arc2D.OPEN);
|
1300 |
|
|
1301 |
1387 |
// Ellipse2D.Double elArco = new
|
1302 |
|
// Ellipse2D.Double(psArc.origin.x - psArc.primary_axis,
|
1303 |
|
// psArc.origin.y - psArc.secondary_axis,2.0 *
|
1304 |
|
// psArc.primary_axis, 2.0 * psArc.secondary_axis);
|
1305 |
|
GeneralPathX elShapeArc = new GeneralPathX(elArco.getPathIterator(null));
|
|
1388 |
// Ellipse2D.Double(psArc.origin.x - psArc.primary_axis,
|
|
1389 |
// psArc.origin.y - psArc.secondary_axis,2.0 *
|
|
1390 |
// psArc.primary_axis, 2.0 * psArc.secondary_axis);
|
|
1391 |
GeneralPathX elShapeArc = new GeneralPathX(elArco.getPathIterator(null));
|
1306 |
1392 |
|
1307 |
1393 |
// Transformamos el GeneralPahtX porque si transformamos
|
1308 |
|
// elArco nos lo convierte
|
1309 |
|
// a GeneralPath y nos guarda las coordenadas en float,
|
1310 |
|
// con la correspondiente p?rdida de precisi?n
|
1311 |
|
elShapeArc.transform(mT);
|
|
1394 |
// elArco nos lo convierte
|
|
1395 |
// a GeneralPath y nos guarda las coordenadas en float,
|
|
1396 |
// con la correspondiente p?rdida de precisi?n
|
|
1397 |
elShapeArc.transform(mT);
|
1312 |
1398 |
|
1313 |
|
if (dgnReader.getInfo().dimension == 3) {
|
1314 |
|
// Aqu? podr?amos hacer cosas con la coordenada Z
|
1315 |
|
}
|
|
1399 |
if (dgnReader.getInfo().dimension == 3) {
|
|
1400 |
// Aqu? podr?amos hacer cosas con la coordenada Z
|
|
1401 |
}
|
1316 |
1402 |
|
1317 |
|
fillRow(auxRow, elemento, parentElement, dgnReader);
|
1318 |
|
auxRow[ID_FIELD_ID] = elemento.element_id;
|
1319 |
|
auxRow[ID_FIELD_ENTITY] = "Arc";
|
1320 |
|
auxRow[ID_FIELD_LAYER] = String.valueOf(elemento.level);
|
1321 |
|
auxRow[ID_FIELD_COLOR] = elemento.color;
|
|
1403 |
fillRow(auxRow, elemento, parentElement, dgnReader);
|
|
1404 |
auxRow[ID_FIELD_ID] = elemento.element_id;
|
|
1405 |
auxRow[ID_FIELD_ENTITY] = "Arc";
|
|
1406 |
auxRow[ID_FIELD_LAYER] = String.valueOf(elemento.level);
|
|
1407 |
auxRow[ID_FIELD_COLOR] = elemento.color;
|
1322 |
1408 |
|
1323 |
|
/*
|
1324 |
|
* Line2D.Double ejeMayor = new
|
1325 |
|
* Line2D.Double(psArc.origin.x - psArc.primary_axis,
|
1326 |
|
* psArc.origin.y, psArc.origin.x + psArc.primary_axis,
|
1327 |
|
* psArc.origin.y);
|
1328 |
|
*
|
1329 |
|
* lyrLines.addShape(new
|
1330 |
|
* FShape(FConstant.SHAPE_TYPE_POLYLINE, new
|
1331 |
|
* GeneralPathX(ejeMayor)), auxRow);
|
1332 |
|
*/
|
1333 |
|
|
|
1409 |
/*
|
|
1410 |
* Line2D.Double ejeMayor = new
|
|
1411 |
* Line2D.Double(psArc.origin.x - psArc.primary_axis,
|
|
1412 |
* psArc.origin.y, psArc.origin.x + psArc.primary_axis,
|
|
1413 |
* psArc.origin.y);
|
|
1414 |
*
|
|
1415 |
* lyrLines.addShape(new
|
|
1416 |
* FShape(FConstant.SHAPE_TYPE_POLYLINE, new
|
|
1417 |
* GeneralPathX(ejeMayor)), auxRow);
|
|
1418 |
*/
|
1334 |
1419 |
// lyrLines.addShape(new
|
1335 |
|
// FShape(FConstant.SHAPE_TYPE_POLYLINE, elShapeArc),
|
1336 |
|
// auxRow);
|
1337 |
|
if (elemento.complex != 0) {
|
|
1420 |
// FShape(FConstant.SHAPE_TYPE_POLYLINE, elShapeArc),
|
|
1421 |
// auxRow);
|
|
1422 |
if (elemento.complex != 0) {
|
1338 |
1423 |
// Esto es una posible fuente de fallos si detr?s de
|
1339 |
|
// una
|
1340 |
|
// elipse vienen m?s cosas pegadas. Deber?amos
|
1341 |
|
// volver
|
1342 |
|
// a conectar una vez pasada la elipse.
|
1343 |
|
if (elemento.type == DGNFileHeader.DGNT_ELLIPSE) {
|
1344 |
|
bConnect = false;
|
1345 |
|
}
|
|
1424 |
// una
|
|
1425 |
// elipse vienen m?s cosas pegadas. Deber?amos
|
|
1426 |
// volver
|
|
1427 |
// a conectar una vez pasada la elipse.
|
|
1428 |
if (elemento.type == DGNFileHeader.DGNT_ELLIPSE) {
|
|
1429 |
bConnect = false;
|
|
1430 |
}
|
1346 |
1431 |
|
1347 |
1432 |
// SI LA ELIPSE ES UN AGUJERO, SE A?ADE SIN PEGAR
|
1348 |
|
// Y EL ELEMENTO ES UN POLIGONO
|
1349 |
|
if (bFirstHoleEntity
|
1350 |
|
|| ((elemento.type == DGNFileHeader.DGNT_SHAPE) && ((elemento.properties & 0x8000) != 0))) {
|
1351 |
|
elementoCompuesto.append(elShapeArc.getPathIterator(null), false);
|
1352 |
|
bFirstHoleEntity = false;
|
1353 |
|
} else {
|
1354 |
|
elementoCompuesto.append(elShapeArc.getPathIterator(null), bConnect);
|
1355 |
|
}
|
1356 |
|
} else {
|
1357 |
|
addShape(createMultiCurve(elShapeArc), auxRow,
|
1358 |
|
type, dgnReader);
|
|
1433 |
// Y EL ELEMENTO ES UN POLIGONO
|
|
1434 |
if (bFirstHoleEntity
|
|
1435 |
|| ((elemento.type == DGNFileHeader.DGNT_SHAPE) && ((elemento.properties & 0x8000) != 0))) {
|
|
1436 |
elementoCompuesto.append(elShapeArc.getPathIterator(null), false);
|
|
1437 |
bFirstHoleEntity = false;
|