Changeset 13792 in josm for trunk/src/org
- Timestamp:
- 2018-05-20T17:28:55+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r13753 r13792 73 73 private final String typeString; 74 74 75 ImageryType(String urlString) {76 this.typeString = urlString;75 ImageryType(String typeString) { 76 this.typeString = typeString; 77 77 } 78 78 … … 95 95 if (type.getTypeString().equals(s)) { 96 96 return type; 97 } 98 } 99 return null; 100 } 101 } 102 103 /** 104 * Category of imagery entry. 105 * @since 13792 106 */ 107 public enum ImageryCategory { 108 /** A aerial or satellite photo. **/ 109 PHOTO("photo", tr("Aerial or satellite photo")), 110 /** A map. **/ 111 MAP("map", tr("Map")), 112 /** A historic or otherwise outdated map. */ 113 HISTORICMAP("historicmap", tr("Historic or otherwise outdated map")), 114 /** A map based on OSM data. **/ 115 OSMBASEDMAP("osmbasedmap", tr("Map based on OSM data")), 116 /** A historic or otherwise outdated aerial or satellite photo. **/ 117 HISTORICPHOTO("historicphoto", tr("Historic or otherwise outdated aerial or satellite photo")), 118 /** Any other type of imagery **/ 119 OTHER("other", tr("Imagery not matching any other category")); 120 121 private final String category; 122 private final String description; 123 124 ImageryCategory(String category, String description) { 125 this.category = category; 126 this.description = description; 127 } 128 129 /** 130 * Returns the unique string identifying this category. 131 * @return the unique string identifying this category 132 */ 133 public final String getCategoryString() { 134 return category; 135 } 136 137 /** 138 * Returns the description of this category. 139 * @return the description of this category 140 */ 141 public final String getDescription() { 142 return description; 143 } 144 145 /** 146 * Returns the imagery category from the given category string. 147 * @param s The category string 148 * @return the imagery category matching the given category string 149 */ 150 public static ImageryCategory fromString(String s) { 151 for (ImageryCategory category : ImageryCategory.values()) { 152 if (category.getCategoryString().equals(s)) { 153 return category; 97 154 } 98 155 } … … 230 287 private boolean transparent = true; 231 288 private int minimumTileExpire = (int) TimeUnit.MILLISECONDS.toSeconds(TMSCachedTileLoaderJob.MINIMUM_EXPIRES.get()); 289 /** category of the imagery */ 290 private ImageryCategory category; 291 /** category of the imagery (input string, not saved, copied or used otherwise except for error checks) */ 292 private String categoryOriginalString; 232 293 /** when adding a field, also adapt the: 233 294 * {@link #ImageryPreferenceEntry ImageryPreferenceEntry object} … … 278 339 @StructEntry boolean transparent; 279 340 @StructEntry int minimumTileExpire; 341 @StructEntry String category; 280 342 281 343 /** … … 313 375 icon = i.icon; 314 376 description = i.description; 377 category = i.category != null ? i.category.getCategoryString() : null; 315 378 if (i.bounds != null) { 316 379 bounds = i.bounds.encodeAsString(","); … … 502 565 transparent = e.transparent; 503 566 minimumTileExpire = e.minimumTileExpire; 567 category = ImageryCategory.fromString(e.category); 504 568 } 505 569 … … 549 613 this.transparent = i.transparent; 550 614 this.minimumTileExpire = i.minimumTileExpire; 615 this.category = i.category; 551 616 } 552 617 … … 603 668 Objects.equals(this.customHttpHeaders, other.customHttpHeaders) && 604 669 Objects.equals(this.transparent, other.transparent) && 605 Objects.equals(this.minimumTileExpire, other.minimumTileExpire); 670 Objects.equals(this.minimumTileExpire, other.minimumTileExpire) && 671 Objects.equals(this.category, other.category); 606 672 // CHECKSTYLE.ON: BooleanExpressionComplexity 607 673 } … … 990 1056 html = true; 991 1057 } 1058 if (category != null && category.getDescription() != null) { 1059 res.append("<br>").append(tr("Imagery category: {0}", category.getDescription())); 1060 html = true; 1061 } 992 1062 if (bestMarked) { 993 1063 res.append("<br>").append(tr("This imagery is marked as best in this region in other editors.")); … … 1203 1273 public void setImageryType(ImageryType imageryType) { 1204 1274 this.imageryType = imageryType; 1275 } 1276 1277 /** 1278 * Returns the imagery category. 1279 * @return The imagery category 1280 * @since 13792 1281 */ 1282 public ImageryCategory getImageryCategory() { 1283 return category; 1284 } 1285 1286 /** 1287 * Sets the imagery category. 1288 * @param category The imagery category 1289 * @since 13792 1290 */ 1291 public void setImageryCategory(ImageryCategory category) { 1292 this.category = category; 1293 } 1294 1295 /** 1296 * Returns the imagery category original string (don't use except for error checks). 1297 * @return The imagery category original string 1298 * @since 13792 1299 */ 1300 public String getImageryCategoryOriginalString() { 1301 return categoryOriginalString; 1302 } 1303 1304 /** 1305 * Sets the imagery category original string (don't use except for error checks). 1306 * @param categoryOriginalString The imagery category original string 1307 * @since 13792 1308 */ 1309 public void setImageryCategoryOriginalString(String categoryOriginalString) { 1310 this.categoryOriginalString = categoryOriginalString; 1205 1311 } 1206 1312 -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r13757 r13792 18 18 import org.openstreetmap.josm.data.imagery.ImageryInfo; 19 19 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryBounds; 20 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryCategory; 20 21 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; 21 22 import org.openstreetmap.josm.data.imagery.Shape; … … 220 221 "permission-ref", 221 222 "country-code", 223 "category", 222 224 "icon", 223 225 "date", … … 425 427 break; 426 428 case "type": 427 boolean found = false; 428 for (ImageryType type : ImageryType.values()) { 429 if (Objects.equals(accumulator.toString(), type.getTypeString())) { 430 entry.setImageryType(type); 431 found = true; 432 break; 433 } 434 } 435 if (!found) { 429 ImageryType type = ImageryType.fromString(accumulator.toString()); 430 if(type != null) 431 entry.setImageryType(type); 432 else 436 433 skipEntry = true; 437 }438 434 break; 439 435 case "default": … … 524 520 case "minimum-tile-expire": 525 521 entry.setMinimumTileExpire(Integer.parseInt(accumulator.toString())); 522 break; 523 case "category": 524 String cat = accumulator.toString(); 525 ImageryCategory category = ImageryCategory.fromString(cat); 526 if(category != null) 527 entry.setImageryCategory(category); 528 entry.setImageryCategoryOriginalString(cat); 526 529 break; 527 530 default: // Do nothing
Note:
See TracChangeset
for help on using the changeset viewer.