Changeset 15739 in josm
- Timestamp:
- 2020-01-20T21:59:53+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
r15306 r15739 12 12 import java.net.MalformedURLException; 13 13 import java.nio.file.InvalidPathException; 14 import java.time.Year; 15 import java.time.ZoneOffset; 14 16 import java.util.Collection; 15 17 import java.util.Collections; … … 95 97 private static ImageryInfo convertImagery(ImageryInfo info) { 96 98 try { 99 if (info.getUrl().contains("{time}")) { 100 final String instant = Year.now().atDay(1).atStartOfDay(ZoneOffset.UTC).toInstant().toString(); 101 final String example = String.join("/", instant, instant); 102 final String initialSelectionValue = info.getDate() != null ? info.getDate() : example; 103 final String userDate = JOptionPane.showInputDialog(MainApplication.getMainFrame(), 104 tr("Time filter for \"{0}\" such as \"{1}\"", info.getName(), example), 105 initialSelectionValue); 106 if (userDate == null) { 107 return null; 108 } 109 info.setDate(userDate); 110 // TODO persist new {time} value (via ImageryLayerInfo.save?) 111 } 97 112 switch(info.getImageryType()) { 98 113 case WMS_ENDPOINT: -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r15736 r15739 277 277 /** 278 278 * creation date of the imagery (in the form YYYY-MM-DD;YYYY-MM-DD, where 279 * DD and MM as well as a second date are optional) 279 * DD and MM as well as a second date are optional). 280 * 281 * Also used as time filter for WMS time={time} parameter (such as Sentinel-2) 280 282 * @since 11570 281 283 */ -
trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java
r15736 r15739 22 22 import org.openstreetmap.josm.gui.layer.WMSLayer; 23 23 import org.openstreetmap.josm.tools.CheckParameterUtil; 24 import org.openstreetmap.josm.tools.Utils; 24 25 25 26 /** … … 30 31 */ 31 32 public class TemplatedWMSTileSource extends AbstractWMSTileSource implements TemplatedTileSource { 32 private final Map<String, String> headers = new ConcurrentHashMap<>();33 private final Set<String> serverProjections;34 33 // CHECKSTYLE.OFF: SingleSpaceSeparator 35 34 private static final Pattern PATTERN_HEADER = Pattern.compile("\\{header\\(([^,]+),([^}]+)\\)\\}"); … … 43 42 private static final Pattern PATTERN_WIDTH = Pattern.compile("\\{width\\}"); 44 43 private static final Pattern PATTERN_HEIGHT = Pattern.compile("\\{height\\}"); 44 private static final Pattern PATTERN_TIME = Pattern.compile("\\{time\\}"); // Sentinel-2 45 45 private static final Pattern PATTERN_PARAM = Pattern.compile("\\{([^}]+)\\}"); 46 46 // CHECKSTYLE.ON: SingleSpaceSeparator … … 49 49 50 50 private static final Pattern[] ALL_PATTERNS = { 51 PATTERN_HEADER, PATTERN_PROJ, PATTERN_WKID, PATTERN_BBOX, PATTERN_W, PATTERN_S, PATTERN_E, PATTERN_N, PATTERN_WIDTH, PATTERN_HEIGHT 51 PATTERN_HEADER, PATTERN_PROJ, PATTERN_WKID, PATTERN_BBOX, 52 PATTERN_W, PATTERN_S, PATTERN_E, PATTERN_N, 53 PATTERN_WIDTH, PATTERN_HEIGHT, PATTERN_TIME, 52 54 }; 53 55 56 private final Set<String> serverProjections; 57 private final Map<String, String> headers = new ConcurrentHashMap<>(); 58 private final String date; 54 59 private final boolean switchLatLon; 60 55 61 /** 56 62 * Creates a tile source based on imagery info … … 62 68 this.serverProjections = new TreeSet<>(info.getServerProjections()); 63 69 this.headers.putAll(info.getCustomHttpHeaders()); 70 this.date = info.getDate(); 64 71 handleTemplate(); 65 72 initProjection(); … … 144 151 replacement = String.valueOf(getTileSize()); 145 152 break; 153 case "time": 154 replacement = Utils.encodeUrl(date); 155 break; 146 156 default: 147 157 replacement = '{' + matcher.group(1) + '}';
Note:
See TracChangeset
for help on using the changeset viewer.