Changeset 33685 in osm for applications/editors/josm/plugins/cadastre-fr
- Timestamp:
- 2017-09-30T02:22:48+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
r33665 r33685 455 455 } 456 456 457 /** 458 * Adds a predicate to ignore special types of objects based on their SCD identifier. 459 * @param types SCD identifiers to ignore 460 */ 461 public static void addIgnoredScdObjects(String... types) { 462 addIgnoredObject(o -> Arrays.asList(types).contains(o.scdRef.identifier)); 463 } 464 457 465 private static Predicate<ObjectBlock> predicate(String key, String... values) { 458 466 return o -> { … … 564 572 private static <T extends OsmPrimitive> T addPrimitiveAndTags(DataSet ds, ObjectBlock obj, T osm) { 565 573 if (osm != null) { 566 osm.put("cadastre_scd", obj.scdRef.identifier);567 574 for (int i = 0; i < obj.nAttributes; i++) { 568 osm.put(obj.attributeDefs.get(i).identifier, obj.attributeValues.get(i)); 575 String key = obj.attributeDefs.get(i).identifier; 576 if (!key.startsWith("ID_S_ATT_")) { // Ignore Z_1_2_2 text attributes 577 osm.put(key, obj.attributeValues.get(i)); 578 } 569 579 } 570 580 if (osm.getDataSet() == null) { -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/pci/EdigeoPciReader.java
r33671 r33685 14 14 import java.util.Map; 15 15 import java.util.Map.Entry; 16 import java.util.function.Predicate; 16 17 17 18 import org.apache.commons.compress.archivers.tar.TarArchiveEntry; … … 19 20 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; 20 21 import org.apache.commons.compress.utils.IOUtils; 22 import org.apache.commons.lang3.StringUtils; 23 import org.apache.commons.text.WordUtils; 21 24 import org.openstreetmap.josm.data.osm.DataSet; 22 25 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy; 23 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 import org.openstreetmap.josm.data.osm.Way; 24 28 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 25 29 import org.openstreetmap.josm.io.AbstractReader; … … 42 46 43 47 // Ignored objects 44 EdigeoFileVEC.addIgnoredObject("PTCANV_id"); // Canvas point 45 EdigeoFileVEC.addIgnoredObject("BORNE_id"); // Property boundary marker 46 EdigeoFileVEC.addIgnoredObject("BOULON_id"); // Property boundary marker for Alsace and Moselle 47 EdigeoFileVEC.addIgnoredObject("CROIX_id"); // Property boundary marker for Alsace and Moselle 48 EdigeoFileVEC.addIgnoredObject("SYMBLIM_id"); // Common wall symbol 48 EdigeoFileVEC.addIgnoredScdObjects( 49 "PTCANV_id", // Canvas point 50 "BORNE_id", // Property boundary marker 51 "BOULON_id", // Property boundary marker for Alsace and Moselle 52 "CROIX_id", // Property boundary marker for Alsace and Moselle 53 "SYMBLIM_id"); // Common wall symbol 49 54 EdigeoFileVEC.addIgnoredObject("SYM_id", 50 55 "30", // Water stream arrow … … 64 69 EdigeoFileVEC.addObjectPostProcessor("21", "highway=road"); // Way 65 70 EdigeoFileVEC.addObjectPostProcessor("22", "highway=road"); // Road trigger 66 EdigeoFileVEC.addObjectPostProcessor("23", "highway=path"); // Path 71 EdigeoFileVEC.addObjectPostProcessor((o, p) -> { // Path / Footway 72 String highwayValue = "path"; 73 if (p instanceof Way) { 74 Way w = (Way) p; 75 Predicate<Way> isBuilding = x -> x.hasKey("building"); 76 if (w.firstNode().getParentWays().stream().anyMatch(isBuilding) 77 || w.lastNode().getParentWays().stream().anyMatch(isBuilding)) { 78 highwayValue = "footway"; 79 } 80 } 81 p.put("highway", highwayValue); 82 p.remove("SYM_id"); 83 }, "SYM_id", "23"); // Path / Footway 67 84 EdigeoFileVEC.addObjectPostProcessor("24", "man_made=pipeline"); // Pipeline 68 85 EdigeoFileVEC.addObjectPostProcessor("25", "man_made=pipeline"); // Aqueduct … … 83 100 EdigeoFileVEC.addObjectPostProcessor("65", "leisure=swimming_pool;access=private"); // Swimming pool 84 101 85 // Mapping TEX*_id => name 102 // Mapping TEX*_id => name (first step) 86 103 EdigeoFileVEC.addObjectPostProcessor((o, p) -> { 87 104 StringBuffer sb = new StringBuffer(p.get("TEX_id").trim()); … … 95 112 p.remove(t); 96 113 } 97 p.put("name", sb.toString().replaceAll(" ", " ").replaceAll(" ", " ").replaceAll(" ", " "));114 setName(p, sb.toString()); 98 115 }, "TEX_id"); 99 116 … … 120 137 p.put("admin_level", "8"); 121 138 p.put("ref:INSEE", "XX"+p.get("IDU_id")); // TODO: find department number 122 p.put("name", p.get("TEX2_id")); // TODO: lowercase139 p.put("name", WordUtils.capitalizeFully(p.get("TEX2_id"))); 123 140 p.remove("IDU_id"); 124 141 p.remove("TEX2_id"); … … 129 146 p.put("ref", p.get("IDU_id")); 130 147 p.remove("IDU_id"); 148 p.remove("ICL_id"); 149 p.remove("COAR_id"); 150 p.remove("COPL_id"); 151 p.remove("DEDI_id"); 152 p.remove("DIS_id"); 153 p.remove("DRED_id"); 154 p.remove("EOR_id"); 155 p.remove("INDP_id"); 156 p.remove("INP_id"); 157 p.remove("QUPL_id"); 158 p.remove("SUPF_id"); 131 159 }, o -> o.hasScdIdentifier("SECTION_id") || o.hasScdIdentifier("SUBDSECT_id") 132 160 || o.hasScdIdentifier("PARCELLE_id") || o.hasScdIdentifier("SUBDFISC_id") || o.hasScdIdentifier("CHARGE_id")); … … 144 172 145 173 EdigeoFileVEC.addObjectPostProcessor((o, p) -> { 146 p.put("place", " isolated_dwelling");174 p.put("place", "unknown"); 147 175 }, o -> o.hasScdIdentifier("LIEUDIT_id")); 176 177 EdigeoFileVEC.addObjectPostProcessor((o, p) -> { 178 p.remove("ORI_id"); 179 }, o -> o.hasScdIdentifier("TPOINT_id")); 148 180 149 181 EdigeoFileVEC.addObjectPostProcessor((o, p) -> { … … 155 187 p.put("waterway", "riverbank"); 156 188 }, o -> o.hasScdIdentifier("TRONFLUV_id")); 189 190 // Mapping TEX*_id => name (last step) 191 for (String t : Arrays.asList("TEX2_id", "TEX3_id", "TEX4_id", "TEX5_id", "TEX6_id", "TEX7_id", "TEX8_id", "TEX9_id")) { 192 EdigeoFileVEC.addObjectPostProcessor((o, p) -> { 193 setName(p, p.get(t)); 194 p.remove(t); 195 }, t); 196 } 197 } 198 199 private static void setName(OsmPrimitive p, String input) { 200 if (input != null) { 201 String name = input.replaceAll(" ", " ").replaceAll(" ", " ").replaceAll(" ", " "); 202 if (name.length() > 2 && StringUtils.isAllUpperCase(name)) { 203 name = WordUtils.capitalizeFully(name); 204 } 205 p.put("name", name); 206 } 157 207 } 158 208
Note:
See TracChangeset
for help on using the changeset viewer.