Changeset 33644 in osm for applications/editors/josm
- Timestamp:
- 2017-09-21T00:17:41+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/EdigeoFileGEN.java
r33643 r33644 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.fr.cadastre.edigeo; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.IOException; … … 9 11 */ 10 12 public class EdigeoFileGEN extends EdigeoFile { 13 14 /** 15 * Geographic bounds. 16 */ 17 public static class GeoBounds extends Block { 18 String cm1; 19 String cm2; 20 21 GeoBounds(String type) { 22 super(type); 23 } 24 25 @Override 26 void processRecord(EdigeoRecord r) { 27 switch (r.name) { 28 case "CM1": cm1 = safeGet(r); break; 29 case "CM2": cm2 = safeGet(r); break; 30 default: 31 super.processRecord(r); 32 } 33 } 34 35 /** 36 * Returns the minimal coordinates. 37 * @return the minimal coordinates 38 */ 39 public final String getCm1() { 40 return cm1; 41 } 42 43 /** 44 * Returns the maximal coordinates. 45 * @return the maximal coordinates 46 */ 47 public final String getCm2() { 48 return cm2; 49 } 50 } 51 52 /** 53 * Geographic data. 54 */ 55 public static class GeoData extends Block { 56 57 /** 58 * Data structure. 59 */ 60 enum Structure { 61 TOPO_VECTOR(1), 62 NETWORK(2), 63 SPAGHETTI(3), 64 REAL_MATRIX(4), 65 CODED_MATRIX(5); 66 67 final int code; 68 Structure(int code) { 69 this.code = code; 70 } 71 72 public static Structure of(int code) { 73 for (Structure s : values()) { 74 if (s.code == code) { 75 return s; 76 } 77 } 78 throw new IllegalArgumentException(Integer.toString(code)); 79 } 80 } 81 82 String information; 83 Structure structure; 84 String offsetId; 85 86 GeoData(String type) { 87 super(type); 88 } 89 90 @Override 91 void processRecord(EdigeoRecord r) { 92 switch (r.name) { 93 case "INF": information = safeGetAndLog(r, tr("Information")); break; 94 case "STR": structure = Structure.of(safeGetInt(r)); break; 95 case "REG": offsetId = safeGet(r); break; 96 default: 97 super.processRecord(r); 98 } 99 } 100 101 /** 102 * Returns general information. 103 * @return general information 104 */ 105 public final String getInformation() { 106 return information; 107 } 108 109 /** 110 * Returns data structure. 111 * @return data structure 112 */ 113 public final Structure getStructure() { 114 return structure; 115 } 116 117 /** 118 * Returns offset identifier. 119 * @return offset identifier 120 */ 121 public final String getOffsetId() { 122 return offsetId; 123 } 124 } 125 126 GeoBounds bounds; 127 GeoData geodata; 11 128 12 129 /** … … 21 138 @Override 22 139 protected Block createBlock(String type) { 23 // TODO Auto-generated method stub 24 return null; 140 switch (type) { 141 case "DEG": 142 bounds = new GeoBounds(type); 143 return bounds; 144 case "GSE": 145 geodata = new GeoData(type); 146 return geodata; 147 default: 148 throw new IllegalArgumentException(type); 149 } 25 150 } 26 27 151 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileGEO.java
r33643 r33644 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.fr.cadastre.edigeo; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.IOException; … … 9 11 */ 10 12 public class EdigeoFileGEO extends EdigeoFile { 13 14 /** 15 * Coordinates reference. 16 */ 17 public static class CoorReference extends Block { 18 19 enum ReferenceType { 20 CARTESIAN("CAR"), 21 GEOGRAPHIC("GEO"), 22 PROJECTED("MAP"); 23 24 String code; 25 ReferenceType(String code) { 26 this.code = code; 27 } 28 29 public static ReferenceType of(String code) { 30 for (ReferenceType r : values()) { 31 if (r.code.equals(code)) { 32 return r; 33 } 34 } 35 throw new IllegalArgumentException(code); 36 } 37 } 38 39 enum AltitudeSystem { 40 TWO_DIM_PLUS_ALTITUDE(1), 41 THREE_DIM_OR_NO_ALTITUDE(2); 42 43 int code; 44 AltitudeSystem(int code) { 45 this.code = code; 46 } 47 48 public static AltitudeSystem of(int code) { 49 for (AltitudeSystem s : values()) { 50 if (s.code == code) { 51 return s; 52 } 53 } 54 throw new IllegalArgumentException(Integer.toString(code)); 55 } 56 } 57 58 ReferenceType type; 59 String name; 60 String code; 61 int nDim; 62 AltitudeSystem altitudeSystem; 63 String unit; 64 65 CoorReference(String type) { 66 super(type); 67 } 68 69 @Override 70 void processRecord(EdigeoRecord r) { 71 switch (r.name) { 72 case "RET": type = ReferenceType.of(safeGet(r)); break; 73 case "REN": name = safeGetAndLog(r, tr("Projection")); break; 74 case "REL": code = safeGetAndLog(r, tr("Projection")); break; 75 case "DIM": nDim = safeGetInt(r); break; 76 case "ALS": altitudeSystem = AltitudeSystem.of(safeGetInt(r)); break; 77 case "UNH": unit = safeGet(r); break; 78 default: 79 super.processRecord(r); 80 } 81 } 82 83 /** 84 * Returns reference type. 85 * @return reference type 86 */ 87 public final ReferenceType getReferenceType() { 88 return type; 89 } 90 91 /** 92 * Returns reference name. 93 * @return reference name 94 */ 95 public final String getReferenceName() { 96 return name; 97 } 98 99 /** 100 * Returns reference code. 101 * @return reference code 102 */ 103 public final String getReferenceCode() { 104 return code; 105 } 106 107 /** 108 * Returns number of dimensions. 109 * @return number of dimensions 110 */ 111 public final int getNumberOfDimensions() { 112 return nDim; 113 } 114 115 /** 116 * Returns altitude system. 117 * @return altitude system 118 */ 119 public final AltitudeSystem getAltitudeSystem() { 120 return altitudeSystem; 121 } 122 123 /** 124 * Returns unit. 125 * @return unit 126 */ 127 public final String getUnit() { 128 return unit; 129 } 130 } 11 131 12 132 /** … … 21 141 @Override 22 142 protected Block createBlock(String type) { 23 // TODO Auto-generated method stub 24 return null; 143 if ("GEO".equals(type)) { 144 return new CoorReference(type); 145 } 146 throw new IllegalArgumentException(type); 25 147 } 26 27 148 }
Note:
See TracChangeset
for help on using the changeset viewer.