Changeset 13733 in josm for trunk/src/org/openstreetmap/josm/data/imagery/DefaultLayer.java
- Timestamp:
- 2018-05-12T14:18:57+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/DefaultLayer.java
r11257 r13733 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.imagery; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import javax.json.Json; 7 import javax.json.JsonObject; 8 import javax.json.JsonObjectBuilder; 9 10 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; 3 11 4 12 /** … … 12 20 */ 13 21 public class DefaultLayer { 14 15 protected String layerName; 22 private final String layerName; 23 private final String tileMatrixSet; 24 private final String style; 16 25 17 26 /** 18 27 * Constructor 19 * @param layerName that is the DefaultLayer 28 * @param imageryType for which this layer is defined 29 * @param layerName as returned by getIdentifier for WMTS and getName for WMS 30 * @param style of the layer 31 * @param tileMatrixSet only for WMTS - tileMatrixSet to use 20 32 */ 21 public DefaultLayer(String layerName) { 22 this.layerName = layerName; 33 public DefaultLayer(ImageryType imageryType, String layerName, String style, String tileMatrixSet) { 34 this.layerName = layerName == null ? "" : layerName; 35 this.style = style == null ? "" : style; 36 if (!imageryType.equals(ImageryType.WMTS) && !(tileMatrixSet == null || "".equals(tileMatrixSet))) { 37 throw new IllegalArgumentException(tr("{0} imagery has tileMatrixSet defined to: {1}", imageryType, tileMatrixSet)); 38 } 39 this.tileMatrixSet = tileMatrixSet == null ? "" : tileMatrixSet; 23 40 } 24 41 … … 30 47 } 31 48 49 /** 50 * @return default tileMatrixSet. Only usable for WMTS 51 */ 52 public String getTileMatrixSet() { 53 return tileMatrixSet; 54 } 55 56 /** 57 * @return style for this WMS / WMTS layer to use 58 */ 59 public String getStyle() { 60 return style; 61 } 62 63 /** 64 * @return JSON representation of the default layer object 65 */ 66 public JsonObject toJson() { 67 JsonObjectBuilder ret = Json.createObjectBuilder(); 68 ret.add("layerName", layerName); 69 ret.add("style", style); 70 ret.add("tileMatrixSet", tileMatrixSet); 71 return ret.build(); 72 } 73 74 /** 75 * Factory method creating DefaultLayer from JSON objects 76 * @param o serialized DefaultLayer object 77 * @param type of ImageryType serialized 78 * @return DefaultLayer instance based on JSON object 79 */ 80 public static DefaultLayer fromJson(JsonObject o, ImageryType type) { 81 return new DefaultLayer(type, o.getString("layerName"), o.getString("style"), o.getString("tileMatrixSet")); 82 } 32 83 }
Note:
See TracChangeset
for help on using the changeset viewer.