Changeset 33661 in osm for applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap
- Timestamp:
- 2017-09-24T18:59:50+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFile.java
r33659 r33661 74 74 } 75 75 76 void resolve() { 77 // To be overriden if relevant 76 void resolvePhase1() { 77 // To be overriden if relevant (before relations are resolved) 78 } 79 80 void resolvePhase2() { 81 // To be overriden if relevant (after relations are resolved) 78 82 } 79 83 -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileSCD.java
r33660 r33661 55 55 56 56 @Override 57 void resolve () {58 super.resolve ();57 void resolvePhase1() { 58 super.resolvePhase1(); 59 59 for (List<String> values : lAttributes) { 60 60 attributes.add(lot.scd.find(values, McdAttributeDef.class)); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileVEC.java
r33660 r33661 77 77 78 78 @Override 79 void resolve () {80 super.resolve ();79 void resolvePhase1() { 80 super.resolvePhase1(); 81 81 for (EdigeoRecord r : lAttributeValues) { 82 // Does not work for composed attributes, the value is overriden in phase 2 83 attributeValues.add(r.values.get(0)); 84 } 85 } 86 87 @Override 88 void resolvePhase2() { 89 super.resolvePhase2(); 90 for (int i = 0; i < nAttributes; i++) { 91 EdigeoRecord r = lAttributeValues.get(i); 82 92 if (r.nature == Nature.COMPOSED) { 83 //attributeValues.add(lot.scd.find(r.values, McdAttributeDef.class).dictRef); 84 attributeValues.add(r.values.toString()); // FIXME 85 } else { 86 attributeValues.add(r.values.get(0)); 93 assert !parentRelations.isEmpty(); 94 McdAttributeDef def = lot.scd.find(r.values, McdAttributeDef.class); 95 List<RelationBlock> relations = getSemanticRelations().stream().filter( 96 rel -> rel.elements.stream().anyMatch(e -> e.attributeDefs.contains(def))).collect(Collectors.toList()); 97 assert relations.size() == 1; 98 List<VecBlock<?>> elements = relations.get(0).elements.stream().filter( 99 e -> e.attributeDefs.contains(def)).collect(Collectors.toList()); 100 assert elements.size() == 1; 101 VecBlock<?> e = elements.get(0); 102 attributeValues.set(i, e.attributeValues.get(e.attributeDefs.indexOf(def))); 103 attributeDefs.set(i, def); 87 104 } 88 105 } … … 384 401 385 402 @Override 386 final void resolve () {387 super.resolve ();403 final void resolvePhase1() { 404 super.resolvePhase1(); 388 405 for (List<String> values : lElements) { 389 406 VecBlock<?> b = lot.vec.stream().filter(v -> v.subsetId.equals(values.get(1))).findAny() … … 472 489 for (ObjectBlock obj : getObjects()) { 473 490 if (!ignoredObjects.stream().anyMatch(p -> p.test(obj))) { 474 List<RelationBlock> constructionRelations = obj.getConstructionRelations();475 491 switch (obj.scdRef.kind) { 476 case POINT: fillPoint(ds, proj, obj, constructionRelations); break;477 case LINE: fillLine(ds, proj, obj, constructionRelations); break;478 case AREA: fillArea(ds, proj, obj, constructionRelations); break;492 case POINT: fillPoint(ds, proj, obj, obj.getConstructionRelations(), obj.getSemanticRelations()); break; 493 case LINE: fillLine(ds, proj, obj, obj.getConstructionRelations(), obj.getSemanticRelations()); break; 494 case AREA: fillArea(ds, proj, obj, obj.getConstructionRelations(), obj.getSemanticRelations()); break; 479 495 case COMPLEX: break; // TODO (not used in PCI) 480 496 default: throw new IllegalArgumentException(obj.toString()); … … 492 508 } 493 509 494 private static void fillPoint(DataSet ds, Projection proj, ObjectBlock obj, List<RelationBlock> constructionRelations) { 495 assert constructionRelations.size() == 1 : constructionRelations; 496 RelationBlock rel = constructionRelations.get(0); 497 assert rel.scdRef instanceof McdConstructionRelationDef : rel; 498 if (rel.scdRef instanceof McdConstructionRelationDef) { 499 McdConstructionRelationDef crd = (McdConstructionRelationDef) rel.scdRef; 500 assert crd.kind == RelationKind.IS_MADE_OF; 501 assert crd.nAttributes == 0; 502 } 503 for (VecBlock<?> e : rel.elements) { 504 if (e instanceof NodeBlock) { 505 NodeBlock nb = (NodeBlock) e; 506 assert nb.nAttributes == 0; 507 LatLon ll = proj.eastNorth2latlon(nb.getCoordinate()); 508 //if (ds.searchNodes(around(ll)).isEmpty()) { 509 addPrimitiveAndTags(ds, obj, new Node(ll)); 510 //} 511 break; 512 } 513 } 514 } 515 516 private static void fillLine(DataSet ds, Projection proj, ObjectBlock obj, List<RelationBlock> constructionRelations) { 517 assert constructionRelations.size() >= 1 : constructionRelations; 518 // Retrieve all arcs for the linear object 519 final List<ArcBlock> arcs = new ArrayList<>(); 510 @SuppressWarnings("unchecked") 511 private static <T extends VecBlock<?>> List<T> extract(Class<T> klass, List<RelationBlock> constructionRelations, RelationKind kind) { 512 final List<T> list = new ArrayList<>(); 520 513 for (RelationBlock rel : constructionRelations) { 521 514 assert rel.scdRef instanceof McdConstructionRelationDef : rel; 522 515 if (rel.scdRef instanceof McdConstructionRelationDef) { 523 516 McdConstructionRelationDef crd = (McdConstructionRelationDef) rel.scdRef; 524 assert crd.kind == RelationKind.IS_MADE_OF_ARC;517 assert crd.kind == kind; 525 518 assert crd.nAttributes == 0; 526 519 } 527 520 for (VecBlock<?> e : rel.elements) { 528 if ( e instanceof ArcBlock) {529 arcs.add((ArcBlock) e);521 if (klass.isInstance(e)) { 522 list.add((T) e); 530 523 } 531 524 } 532 525 } 526 return list; 527 } 528 529 private static void fillPoint(DataSet ds, Projection proj, ObjectBlock obj, 530 List<RelationBlock> constructionRelations, List<RelationBlock> semanticRelations) { 531 assert constructionRelations.size() == 1 : constructionRelations; 532 List<NodeBlock> nodes = extract(NodeBlock.class, constructionRelations, RelationKind.IS_MADE_OF); 533 assert nodes.size() == 1 : nodes; 534 NodeBlock nb = nodes.get(0); 535 assert nb.nAttributes == 0; 536 LatLon ll = proj.eastNorth2latlon(nb.getCoordinate()); 537 //if (ds.searchNodes(around(ll)).isEmpty()) { 538 addPrimitiveAndTags(ds, obj, new Node(ll)); 539 //} 540 } 541 542 private static void fillLine(DataSet ds, Projection proj, ObjectBlock obj, 543 List<RelationBlock> constructionRelations, List<RelationBlock> semanticRelations) { 544 assert constructionRelations.size() >= 1 : constructionRelations; 545 // Retrieve all arcs for the linear object 546 final List<ArcBlock> arcs = extract(ArcBlock.class, constructionRelations, RelationKind.IS_MADE_OF_ARC); 533 547 final double EPSILON = 1e-2; 534 548 assert arcs.size() >= 1; 535 Way w = new Way();536 549 // Some lines are made of several arcs, but they need to be sorted 537 550 if (arcs.size() > 1) { … … 553 566 arcs.clear(); 554 567 arcs.addAll(newArcs); 555 w.put(new Tag("fixme", "several_arcs")); // FIXME556 }568 } 569 Way w = new Way(); 557 570 // Add first node of first arc 558 571 w.addNode(getNodeAt(ds, proj, arcs.get(0).points.get(0))); … … 569 582 } 570 583 571 private static void fillArea(DataSet ds, Projection proj, ObjectBlock obj, List<RelationBlock> constructionRelations) { 584 private static void fillArea(DataSet ds, Projection proj, ObjectBlock obj, 585 List<RelationBlock> constructionRelations, List<RelationBlock> semanticRelations) { 572 586 assert constructionRelations.size() >= 1 : constructionRelations; 587 // TODO 573 588 } 574 589 -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoLotFile.java
r33659 r33661 57 57 @Override 58 58 final void resolve() { 59 blocks.forEach((k, v) -> v.forEach(Block::resolve)); 59 blocks.forEach((k, v) -> v.forEach(Block::resolvePhase1)); 60 blocks.forEach((k, v) -> v.forEach(Block::resolvePhase2)); 60 61 } 61 62
Note:
See TracChangeset
for help on using the changeset viewer.