Changeset 33664 in osm for applications/editors
- Timestamp:
- 2017-09-25T00:31:04+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileVEC.java
r33663 r33664 16 16 import java.util.stream.Stream; 17 17 18 import org.openstreetmap.josm.actions.CreateMultipolygonAction; 19 import org.openstreetmap.josm.command.SequenceCommand; 18 20 import org.openstreetmap.josm.data.coor.EastNorth; 19 21 import org.openstreetmap.josm.data.coor.LatLon; … … 314 316 } 315 317 } 318 319 boolean isClosed() { 320 return nPoints >= 4 && points.get(0).equals(points.get(nPoints - 1)); 321 } 316 322 } 317 323 … … 557 563 558 564 private static <T extends OsmPrimitive> T addPrimitiveAndTags(DataSet ds, ObjectBlock obj, T osm) { 559 for (int i = 0; i < obj.nAttributes; i++) { 560 osm.put(obj.attributeDefs.get(i).identifier, obj.attributeValues.get(i)); 561 } 562 if (osm.getDataSet() == null) { 563 ds.addPrimitive(osm); 565 if (osm != null) { 566 for (int i = 0; i < obj.nAttributes; i++) { 567 osm.put(obj.attributeDefs.get(i).identifier, obj.attributeValues.get(i)); 568 } 569 if (osm.getDataSet() == null) { 570 ds.addPrimitive(osm); 571 } 564 572 } 565 573 return osm; … … 660 668 661 669 private static OsmPrimitive faceToOsmPrimitive(DataSet ds, Projection proj, FaceBlock face) { 662 List<ArcBlock> leftArcs = extract(ArcBlock.class, face.getConstructionRelations(), RelationKind.HAS_FOR_LEFT_FACE); 663 List<ArcBlock> rightArcs = extract(ArcBlock.class, face.getConstructionRelations(), RelationKind.HAS_FOR_RIGHT_FACE); 664 assert leftArcs.size() >= 1 || rightArcs.size() >= 1; 665 if ((leftArcs.size() == 1 && rightArcs.isEmpty()) || (leftArcs.isEmpty() && rightArcs.size() == 1)) { 666 Way w = new Way(); 667 ArcBlock ab = (leftArcs.isEmpty() ? rightArcs : leftArcs).get(0); 668 for (EastNorth en : ab.points) { 669 w.addNode(getNodeAt(ds, proj, en)); 670 } 671 return w; 670 List<ArcBlock> allArcs = new ArrayList<>(); 671 allArcs.addAll(extract(ArcBlock.class, face.getConstructionRelations(), RelationKind.HAS_FOR_LEFT_FACE)); 672 allArcs.addAll(extract(ArcBlock.class, face.getConstructionRelations(), RelationKind.HAS_FOR_RIGHT_FACE)); 673 assert allArcs.size() >= 1; 674 if (allArcs.size() == 1) { 675 ArcBlock ab = allArcs.get(0); 676 assert ab.isClosed(); 677 return arcToWay(ds, proj, ab); 672 678 } else { 673 // TODO 674 return new Way(); 679 List<Way> ways = allArcs.stream().map(ab -> arcToWay(ds, proj, ab)).filter(w -> w != null).collect(Collectors.toList()); 680 Pair<SequenceCommand, Relation> cmd = CreateMultipolygonAction.createMultipolygonCommand(ways, null); 681 if (cmd != null) { 682 cmd.a.executeCommand(); 683 return cmd.b; 684 } else { 685 ways.forEach(w -> ds.removePrimitive(w.getPrimitiveId())); 686 return null; 687 } 688 } 689 } 690 691 private static Way arcToWay(DataSet ds, Projection proj, ArcBlock ab) { 692 Way way = new Way(); 693 for (int i = 0; i < ab.nPoints; i++) { 694 Node n = getNodeAt(ds, proj, ab.points.get(i)); 695 if (i == 0 || !n.equals(way.lastNode())) { 696 way.addNode(n); 697 } 698 } 699 if (way.getNodesCount() < 2) { 700 return null; 701 } 702 List<Way> existingWays = ds.searchWays(way.getBBox()).stream().filter( 703 w -> w.hasEqualSemanticAttributes(way)).collect(Collectors.toList()); 704 if (existingWays.isEmpty()) { 705 ds.addPrimitive(way); 706 return way; 707 } else { 708 return existingWays.get(0); 675 709 } 676 710 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/pci/EdigeoPciReader.java
r33663 r33664 60 60 p.remove(t); 61 61 } 62 p.put("name", sb.toString().replaceAll(" ", " ").replaceAll(" ", " "));62 p.put("name", sb.toString().replaceAll(" ", " ").replaceAll(" ", " ").replaceAll(" ", " ")); 63 63 }, "TEX_id"); 64 64
Note:
See TracChangeset
for help on using the changeset viewer.