Changeset 33657 in osm for applications/editors/josm/plugins/cadastre-fr
- Timestamp:
- 2017-09-23T01:25:16+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileSCD.java
r33649 r33657 8 8 9 9 import org.openstreetmap.josm.data.osm.DataSet; 10 import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoFileDIC.AttributeDef; 11 import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoFileDIC.ObjectDef; 12 import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoFileDIC.RelationDef; 10 13 import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoFileSCD.ScdBlock; 11 14 import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoFileTHF.ChildBlock; … … 27 30 28 31 /** 29 * MCD Object definition. 30 */ 31 public static class McdObjectDef extends ScdBlock { 32 33 /** DIP */ String dictRef = ""; 34 /** KND */ String kind = ""; 32 * MCD definition with attributes. 33 */ 34 abstract static class ScdTaggedDef extends ScdBlock { 35 35 /** AAC */ int nAttributes; 36 36 /** AAP */ final List<String> attributes = new ArrayList<>(); 37 37 /** QAC */ int nQualities; 38 39 McdObjectDef(Lot lot, String type) { 40 super(lot, type); 41 } 42 43 @Override 44 void processRecord(EdigeoRecord r) { 45 switch (r.name) { 46 case "DIP": safeGet(r, s -> dictRef += s); break; 47 case "KND": safeGet(r, s -> kind += s); break; 38 // TODO: qualities ? 39 40 ScdTaggedDef(Lot lot, String type) { 41 super(lot, type); 42 } 43 44 @Override 45 void processRecord(EdigeoRecord r) { 46 switch (r.name) { 48 47 case "AAC": nAttributes = safeGetInt(r); break; 49 48 case "AAP": safeGet(r, attributes); break; … … 53 52 } 54 53 } 54 55 @Override 56 boolean isValid() { 57 return super.isValid() && areSameSize(nAttributes, attributes); 58 } 59 } 60 61 /** 62 * MCD Object definition. 63 */ 64 public static class McdObjectDef extends ScdTaggedDef { 65 66 enum ObjectKind { 67 COMPLEX("CPX"), 68 POINT("PCT"), 69 LINE("LIN"), 70 AREA("ARE"); 71 72 final String code; 73 ObjectKind(String code) { 74 this.code = code; 75 } 76 77 public static ObjectKind of(String code) { 78 for (ObjectKind s : values()) { 79 if (s.code.equals(code)) { 80 return s; 81 } 82 } 83 throw new IllegalArgumentException(code); 84 } 85 } 86 87 /** DIP */ ObjectDef dictRef; 88 /** KND */ ObjectKind kind; 89 90 McdObjectDef(Lot lot, String type) { 91 super(lot, type); 92 } 93 94 @Override 95 void processRecord(EdigeoRecord r) { 96 switch (r.name) { 97 case "DIP": dictRef = lot.dic.find(r.values, ObjectDef.class); break; 98 case "KND": safeGet(r, s -> kind = ObjectKind.of(s)); break; 99 default: 100 super.processRecord(r); 101 } 102 } 103 104 @Override 105 boolean isValid() { 106 return super.isValid() && areNotNull(dictRef, kind); 107 } 55 108 } 56 109 … … 60 113 public static class McdAttributeDef extends ScdBlock { 61 114 62 /** DIP */ String dictRef = "";115 /** DIP */ AttributeDef dictRef; 63 116 /** CAN */ int nMaxChars; 64 117 /** CAD */ int nMaxDigits; … … 75 128 void processRecord(EdigeoRecord r) { 76 129 switch (r.name) { 77 case "DIP": safeGet(r, s -> dictRef +=s); break;130 case "DIP": dictRef = lot.dic.find(r.values, AttributeDef.class); break; 78 131 case "CAN": nMaxChars = safeGetInt(r); break; 79 132 case "CAD": nMaxDigits = safeGetInt(r); break; … … 86 139 } 87 140 } 141 142 @Override 143 boolean isValid() { 144 return super.isValid() && areNotNull(dictRef); 145 } 88 146 } 89 147 … … 91 149 * MCD Primitive definition. 92 150 */ 93 public static class McdPrimitiveDef extends Scd Block{151 public static class McdPrimitiveDef extends ScdTaggedDef { 94 152 95 153 enum PrimitiveKind { … … 114 172 115 173 /** KND */ PrimitiveKind kind; 116 /** AAC */ int nAttributes;117 /** QAC */ int nQualities;118 174 119 175 McdPrimitiveDef(Lot lot, String type) { … … 125 181 switch (r.name) { 126 182 case "KND": safeGet(r, s -> kind = PrimitiveKind.of(s)); break; 127 case "AAC": nAttributes = safeGetInt(r); break; 128 case "QAC": nQualities = safeGetInt(r); break; 129 default: 130 super.processRecord(r); 131 } 183 default: 184 super.processRecord(r); 185 } 186 } 187 188 @Override 189 boolean isValid() { 190 return super.isValid() && areNotNull(kind); 132 191 } 133 192 } … … 136 195 * MCD Relation definition. 137 196 */ 138 abstract static class McdRelationDef extends Scd Block{197 abstract static class McdRelationDef extends ScdTaggedDef { 139 198 140 199 /** CA1 */ int minCardinal; … … 143 202 /** SCP */ final List<ScdBlock> scdRef = new ArrayList<>(); 144 203 /** OCC */ final List<Integer> nOccurences = new ArrayList<>(); 145 /** AAC */ int nAttributes;146 /** QAC */ int nQualities;147 204 148 205 McdRelationDef(Lot lot, String type) { … … 158 215 case "SCP": scdRef.add(lot.scd.find(r.values)); break; 159 216 case "OCC": nOccurences.add(safeGetInt(r)); break; 160 case "AAC": nAttributes = safeGetInt(r); break; 161 case "QAC": nQualities = safeGetInt(r); break; 162 default: 163 super.processRecord(r); 164 } 217 default: 218 super.processRecord(r); 219 } 220 } 221 222 @Override 223 boolean isValid() { 224 return super.isValid() && areNotNull(minCardinal, maxCardinal) && areSameSize(nTypes, scdRef, nOccurences); 165 225 } 166 226 } … … 171 231 public static class McdSemanticRelationDef extends McdRelationDef { 172 232 173 /** DIP */ String dictRef = "";233 /** DIP */ RelationDef dictRef; 174 234 175 235 McdSemanticRelationDef(Lot lot, String type) { … … 180 240 void processRecord(EdigeoRecord r) { 181 241 switch (r.name) { 182 case "DIP": safeGet(r, s -> dictRef += s); break; 183 default: 184 super.processRecord(r); 185 } 242 case "DIP": dictRef = lot.dic.find(r.values, RelationDef.class); break; 243 default: 244 super.processRecord(r); 245 } 246 } 247 248 @Override 249 boolean isValid() { 250 return super.isValid() && areNotNull(dictRef); 186 251 } 187 252 } … … 232 297 } 233 298 } 299 300 @Override 301 boolean isValid() { 302 return super.isValid() && areNotNull(kind); 303 } 234 304 } 235 305
Note:
See TracChangeset
for help on using the changeset viewer.