Changeset 33656 in osm for applications/editors/josm/plugins
- Timestamp:
- 2017-09-23T00:31:35+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
r33653 r33656 72 72 boolean isValid() { 73 73 return type.length() == 3 && areNotEmpty(identifier); 74 } 75 76 void resolve() { 77 // To be overriden if relevant 74 78 } 75 79 … … 199 203 200 204 abstract boolean isValid(); 205 206 void resolve() { 207 // To be overriden if relevant 208 } 201 209 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileTHF.java
r33655 r33656 265 265 allFiles.add(new EdigeoFileVEC(this, vecId.get(i), dir.resolve(name + vecName.get(i) + ".VEC")).read(ds)); 266 266 } 267 allFiles.forEach(EdigeoFile::resolve); 267 268 for (EdigeoFile f : allFiles) { 268 269 boolean valid = f.isValid(); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileVEC.java
r33653 r33656 60 60 } 61 61 } 62 63 @Override 64 boolean isValid() { 65 return super.isValid() && areNotNull(scdRef) 66 && areSameSize(nAttributes, attributeDefs, attributeValues) 67 && areSameSize(nQualities, qualityIndics); 68 } 62 69 } 63 70 … … 227 234 228 235 /** 229 * Object descriptor block. 236 * Object descriptor block. 7.5.1.4 230 237 */ 231 238 public static class ObjectBlock extends BoundedBlock<McdObjectDef> { 232 /** REF */ String pointRef = "";239 /** REF */ EastNorth refPoint; 233 240 234 241 ObjectBlock(Lot lot, String type) { … … 239 246 void processRecord(EdigeoRecord r) { 240 247 switch (r.name) { 241 case "REF": safeGet(r, s -> pointRef += s); break;242 default: 243 super.processRecord(r); 244 } 245 } 246 } 247 248 /** 249 * Relation descriptor block. 248 case "REF": refPoint = safeGetEastNorth(r); break; 249 default: 250 super.processRecord(r); 251 } 252 } 253 } 254 255 /** 256 * Relation descriptor block. 7.5.1.5 250 257 */ 251 258 public static class RelationBlock extends VecBlock<McdRelationDef> { … … 271 278 272 279 /** FTC */ int nElements; 273 /** FTP */ final List<String> elements = new ArrayList<>(); 274 /** SNS */ final Map<String, Composition> compositions = new HashMap<>(); 280 /** FTP */ final List<List<String>> lElements = new ArrayList<>(); 281 /** SNS */ final Map<List<String>, Composition> mCompositions = new HashMap<>(); 282 283 // Resolution of elements must be done when all VEC files are read 284 final List<VecBlock<?>> elements = new ArrayList<>(); 285 final Map<VecBlock<?>, Composition> compositions = new HashMap<>(); 275 286 276 287 RelationBlock(Lot lot, String type) { … … 282 293 switch (r.name) { 283 294 case "FTC": nElements = safeGetInt(r); break; 284 case "FTP": safeGet(r, elements); break; 285 case "SNS": compositions.put(elements.get(elements.size()-1), Composition.of(safeGetChar(r))); break; 286 default: 287 super.processRecord(r); 288 } 295 case "FTP": lElements.add(r.values); break; 296 case "SNS": mCompositions.put(lElements.get(lElements.size()-1), Composition.of(safeGetChar(r))); break; 297 default: 298 super.processRecord(r); 299 } 300 } 301 302 @Override 303 boolean isValid() { 304 return super.isValid() && nElements >= 2 && areSameSize(nElements, elements) && compositions.size() <= nElements; 305 } 306 307 @Override 308 final void resolve() { 309 for (List<String> values : lElements) { 310 VecBlock<?> b = lot.vec.stream().filter(v -> v.subsetId.equals(values.get(1))).findAny() 311 .orElseThrow(() -> new IllegalArgumentException(values.toString())) 312 .find(values, VecBlock.class); 313 elements.add(b); 314 compositions.put(b, mCompositions.get(values)); 315 } 316 lElements.clear(); 317 mCompositions.clear(); 289 318 } 290 319 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoLotFile.java
r33653 r33656 23 23 24 24 protected final Lot lot; 25 pr ivatefinal String subsetId;25 protected final String subsetId; 26 26 27 27 private final Map<String, Class<? extends B>> classes = new HashMap<>(); … … 52 52 53 53 @Override 54 boolean isValid() {54 final boolean isValid() { 55 55 return blocks.values().stream().allMatch(l -> l.stream().allMatch(Block::isValid)); 56 } 57 58 @Override 59 final void resolve() { 60 blocks.forEach((k, v) -> v.forEach(Block::resolve)); 56 61 } 57 62 … … 84 89 public final <T extends B> T find(List<String> values, Class<T> klass) { 85 90 assert values.size() == 4 : values; 86 assert values.get(0).equals(lot.identifier) : values ;87 assert values.get(1).equals(subsetId) : values ;91 assert values.get(0).equals(lot.identifier) : values + " / " + lot.identifier; 92 assert values.get(1).equals(subsetId) : values + " / " + subsetId; 88 93 assert klass.isAssignableFrom(classes.get(values.get(2))) : values; 89 94 List<T> list = blocks.getInstances(klass);
Note:
See TracChangeset
for help on using the changeset viewer.