Changeset 36115 in osm for applications/editors/josm/plugins
- Timestamp:
- 2023-08-10T22:53:52+02:00 (16 months ago)
- Location:
- applications/editors/josm/plugins/pmtiles/src
- Files:
-
- 6 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pmtiles/src/main/java/org/openstreetmap/josm/plugins/pmtiles/gui/layers/PMTilesImageLayer.java
r36112 r36115 59 59 return new PMTilesImageSource((PMTilesImageryInfo) this.info); 60 60 } 61 62 @Override 63 public PMTilesImageryInfo getInfo() { 64 return (PMTilesImageryInfo) super.getInfo(); 65 } 66 67 @Override 68 public String getChangesetSourceTag() { 69 return PMTilesLayer.super.getChangesetSourceTag(); 70 } 61 71 } -
applications/editors/josm/plugins/pmtiles/src/main/java/org/openstreetmap/josm/plugins/pmtiles/gui/layers/PMTilesLayer.java
r36112 r36115 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.pmtiles.gui.layers; 3 4 import static org.openstreetmap.josm.tools.Utils.getSystemProperty; 5 6 import org.openstreetmap.josm.plugins.pmtiles.data.imagery.PMTilesImageryInfo; 7 import org.openstreetmap.josm.tools.TextUtils; 8 import org.openstreetmap.josm.tools.Utils; 3 9 4 10 /** … … 6 12 */ 7 13 interface PMTilesLayer { 14 15 /** 16 * Returns imagery info. 17 * @return imagery info 18 */ 19 PMTilesImageryInfo getInfo(); 20 21 /** 22 * Get the source tag for the layer 23 * @return The source tag 24 */ 25 default String getChangesetSourceTag() { 26 final var sb = new StringBuilder(); 27 final var info = getInfo(); 28 if (info.hasAttribution()) { 29 sb.append(getInfo().getAttributionText(0, null, null) 30 .replaceAll("<a [^>]*>|</a>", "") 31 .replaceAll(" +", " ")); 32 } 33 if (info.getName() != null) { 34 if (!sb.isEmpty()) { 35 sb.append(" - "); 36 } 37 sb.append(info.getName()); 38 } 39 if (sb.isEmpty()) { 40 final var location = info.header().location().toString(); 41 if (Utils.isLocalUrl(location)) { 42 final String userName = getSystemProperty("user.name"); 43 final String userNameAlt = "<user.name>"; 44 sb.append(location.replace(userName, userNameAlt)); 45 } else { 46 sb.append(TextUtils.stripUrl(location)); 47 } 48 } 49 return sb.toString(); 50 } 8 51 } -
applications/editors/josm/plugins/pmtiles/src/main/java/org/openstreetmap/josm/plugins/pmtiles/gui/layers/PMTilesMVTLayer.java
r36112 r36115 60 60 return new PMTilesMVTTileSource((PMTilesImageryInfo) this.info); 61 61 } 62 63 @Override 64 public PMTilesImageryInfo getInfo() { 65 return (PMTilesImageryInfo) super.getInfo(); 66 } 67 68 @Override 69 public String getChangesetSourceTag() { 70 return PMTilesLayer.super.getChangesetSourceTag(); 71 } 62 72 } -
applications/editors/josm/plugins/pmtiles/src/test/java/org/openstreetmap/josm/plugins/pmtiles/lib/PMTilesTest.java
r36112 r36115 7 7 import static org.junit.jupiter.api.Assertions.assertSame; 8 8 import static org.junit.jupiter.api.Assertions.assertTrue; 9 import static org.openstreetmap.josm.plugins.pmtiles.PMTestUtils.ODBL_RASTER_STAMEN; 10 import static org.openstreetmap.josm.plugins.pmtiles.PMTestUtils.ODBL_VECTOR_FIRENZE; 9 11 10 import java.io.File;11 12 import java.io.IOException; 12 import java.net.URI;13 13 14 14 import org.junit.jupiter.api.Test; … … 18 18 */ 19 19 class PMTilesTest { 20 private static final URI ODBL_VECTOR_FIRENZE = new File("protomaps(vector)ODbL_firenze.pmtiles").exists() ?21 new File("protomaps(vector)ODbL_firenze.pmtiles").toURI() :22 URI.create("https://github.com/protomaps/PMTiles/raw/main/spec/v3/protomaps(vector)ODbL_firenze.pmtiles");23 24 private static final URI ODBL_RASTER_STAMEN = new File("stamen_toner(raster)CC-BY%2BODbL_z3.pmtiles").exists() ?25 new File("stamen_toner(raster)CC-BY%2BODbL_z3.pmtiles").toURI() :26 URI.create("https://github.com/protomaps/PMTiles/raw/main/spec/v3/stamen_toner(raster)CC-BY%2BODbL_z3.pmtiles");27 28 20 @Test 29 21 void testHeader() {
Note:
See TracChangeset
for help on using the changeset viewer.