Changeset 36433 in osm
- Timestamp:
- 2025-04-25T18:34:30+02:00 (4 weeks ago)
- Location:
- applications/viewer/jmapviewer
- Files:
-
- 3 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer
-
Property ReleaseVersion
changed from
2.24
to2.25
-
Property ReleaseVersion
changed from
-
applications/viewer/jmapviewer/bin
- Property svn:ignore
-
old new 1 1 org 2 module-info.class
-
- Property svn:ignore
-
applications/viewer/jmapviewer/build.xml
r36373 r36433 183 183 <!-- resolver.repositories makes it global --> 184 184 <mvn:remoterepos id="resolver.repositories"> 185 <mvn:remoterepo id="JOSM-central" url="https://josm.openstreetmap.de/ nexus/content/repositories/central/" />185 <mvn:remoterepo id="JOSM-central" url="https://josm.openstreetmap.de/repository/public/" /> 186 186 </mvn:remoterepos> 187 187 <mvn:resolve> -
applications/viewer/jmapviewer/pom.xml
r36381 r36433 6 6 <groupId>org.openstreetmap.jmapviewer</groupId> 7 7 <artifactId>jmapviewer</artifactId> 8 <version>2.2 5-SNAPSHOT</version>8 <version>2.26-SNAPSHOT</version> 9 9 10 10 <name>JMapViewer</name> … … 71 71 <id>josm-nexus-releases</id> 72 72 <name>JOSM Nexus (Releases)</name> 73 <url>https://josm.openstreetmap.de/ nexus/content/repositories/releases/</url>73 <url>https://josm.openstreetmap.de/repository/releases/</url> 74 74 </repository> 75 75 <snapshotRepository> 76 76 <id>josm-nexus-snapshot</id> 77 77 <name>JOSM Nexus (Snapshot)</name> 78 <url>https://josm.openstreetmap.de/ nexus/content/repositories/snapshots/</url>78 <url>https://josm.openstreetmap.de/repository/snapshots/</url> 79 79 </snapshotRepository> 80 80 </distributionManagement> … … 83 83 <repository> 84 84 <id>JOSM-central</id> 85 <url>https://josm.openstreetmap.de/ nexus/content/repositories/central/</url>85 <url>https://josm.openstreetmap.de/repository/public/</url> 86 86 </repository> 87 87 </repositories> … … 89 89 <pluginRepository> 90 90 <id>JOSM-central</id> 91 <url>https://josm.openstreetmap.de/ nexus/content/repositories/central/</url>91 <url>https://josm.openstreetmap.de/repository/public/</url> 92 92 </pluginRepository> 93 93 </pluginRepositories> -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java
r36223 r36433 30 30 * <li>{!y} - substituted with Yahoo Y tile number</li> 31 31 * <li>{-y} - substituted with reversed Y tile number</li> 32 * <li>{quad} - Microsoft style quadkey</li> 32 33 * <li>{apikey} - substituted with API key retrieved for the imagery id</li> 33 34 * <li>{switch:VAL_A,VAL_B,VAL_C,...} - substituted with one of VAL_A, VAL_B, VAL_C. Usually … … 45 46 private static final Pattern PATTERN_Y_YAHOO = Pattern.compile("\\{!y}"); 46 47 private static final Pattern PATTERN_NEG_Y = Pattern.compile("\\{-y}"); 48 private static final Pattern PATTERN_QUAD = Pattern.compile("\\{quad}"); 47 49 private static final Pattern PATTERN_SWITCH = Pattern.compile("\\{switch:([^}]+)}"); 48 50 private static final Pattern PATTERN_HEADER = Pattern.compile("\\{header\\(([^,]+),([^}]+)\\)}"); 49 51 private static final Pattern PATTERN_API_KEY = Pattern.compile("\\{apikey}"); 50 private static final Pattern PATTERN_PARAM = Pattern.compile("\\{((?:\\d+-)?z(?:oom)?(:?[+-]\\d+)?|x|y|!y|-y|switch:([^}]+))}"); 52 private static final Pattern PATTERN_PARAM = Pattern.compile("\\{((?:\\d+-)?z(?:oom)?(:?[+-]\\d+)?|x|y|!y|-y|quad|switch:([^}]+))}"); 51 53 52 54 // CHECKSTYLE.ON: SingleSpaceSeparator 53 55 54 56 private static final Pattern[] ALL_PATTERNS = { 55 PATTERN_HEADER, PATTERN_ZOOM, PATTERN_X, PATTERN_Y, PATTERN_Y_YAHOO, PATTERN_NEG_Y, PATTERN_SWITCH, PATTERN_API_KEY 57 PATTERN_HEADER, PATTERN_ZOOM, PATTERN_X, PATTERN_Y, PATTERN_Y_YAHOO, PATTERN_NEG_Y, PATTERN_SWITCH, PATTERN_API_KEY, 58 PATTERN_QUAD 56 59 }; 57 60 … … 156 159 replacement = getRandomPart(randomParts); 157 160 break; 161 case "quad": // PATTERN_QUAD 162 replacement = xyzToQuadKey(tilex, tiley, zoom); 163 break; 158 164 default: 159 165 // handle switch/zoom here, as group will contain parameters and switch will not work … … 170 176 matcher.appendTail(url); 171 177 return url.toString().replace(" ", "%20"); 178 } 179 180 /** 181 * Convert an x y z coordinate to a quadkey 182 * @param x The x coordinate 183 * @param y The y coordinate 184 * @param z The z coordinate 185 * @return The quadkey 186 */ 187 private static String xyzToQuadKey(int x, int y, int z) { 188 final char[] string = new char[z]; 189 for (int i = z; i > 0; i--) { 190 char digit = '0'; 191 final int mask = 1 << (i - 1); 192 if ((x & mask) != 0) { 193 digit++; 194 } 195 if ((y & mask) != 0) { 196 digit += 2; 197 } 198 string[z - i] = digit; 199 } 200 return String.valueOf(string); 172 201 } 173 202 -
applications/viewer/jmapviewer/test/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSourceTest.java
r36223 r36433 30 30 * triple of: 31 31 * * baseUrl 32 * * expected tile url for zoom= 1, x=2, y=332 * * expected tile url for zoom=4, x=5, y=6 33 33 * * expected tile url for zoom=3, x=2, y=1 34 34 */ … … 39 39 new String[] { 40 40 "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z={zoom}&x={x}&y={-y}", 41 "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z= 1&x=2&y=-2",41 "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z=4&x=5&y=9", 42 42 "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z=3&x=2&y=6" 43 43 } … … 51 51 checkGetTileUrl( 52 52 "http://localhost/{z}/{x}/{y}", 53 "http://localhost/ 1/2/3",53 "http://localhost/4/5/6", 54 54 "http://localhost/3/1/2" 55 55 ); … … 63 63 checkGetTileUrl( 64 64 "http://localhost/{zoom+5}/{x}/{y}", 65 "http://localhost/ 6/2/3",65 "http://localhost/9/5/6", 66 66 "http://localhost/8/1/2" 67 67 ); … … 75 75 checkGetTileUrl( 76 76 "http://localhost/{zoom-5}/{x}/{y}", 77 "http://localhost/- 4/2/3",77 "http://localhost/-1/5/6", 78 78 "http://localhost/-2/1/2" 79 79 ); … … 87 87 checkGetTileUrl( 88 88 "http://localhost/{5-zoom}/{x}/{y}", 89 "http://localhost/ 4/2/3",89 "http://localhost/1/5/6", 90 90 "http://localhost/2/1/2" 91 91 ); … … 99 99 checkGetTileUrl( 100 100 "http://localhost/{10-zoom-5}/{x}/{y}", 101 "http://localhost/ 4/2/3",101 "http://localhost/1/5/6", 102 102 "http://localhost/2/1/2" 103 103 ); … … 112 112 TileSourceInfo testImageryTMS = new TileSourceInfo("test imagery", "http://localhost/{zoom}/{x}/{y}?token={apikey}&foo=bar", "id1"); 113 113 TemplatedTMSTileSource ts = new TemplatedTMSTileSource(testImageryTMS); 114 assertEquals("http://localhost/ 1/2/3?token=wololo&foo=bar", ts.getTileUrl(1, 2, 3));114 assertEquals("http://localhost/4/5/6?token=wololo&foo=bar", ts.getTileUrl(4, 5, 6)); 115 115 } 116 116 … … 161 161 checkGetTileUrl( 162 162 "http://localhost/{z}/{x}/{!y}", 163 "http://localhost/ 1/2/-3",163 "http://localhost/4/5/1", 164 164 "http://localhost/3/1/1" 165 165 ); … … 171 171 checkGetTileUrl( 172 172 "http://localhost/{z}/{x}/{-y}", 173 "http://localhost/ 1/2/-2",173 "http://localhost/4/5/9", 174 174 "http://localhost/3/1/5" 175 ); 176 177 } 178 179 @Test 180 void testGetTileUrl_quad() { 181 checkGetTileUrl( 182 "http://localhost/{quad}", 183 "http://localhost/0321", 184 "http://localhost/021" 175 185 ); 176 186 … … 180 190 TileSourceInfo testImageryTMS = new TileSourceInfo("test imagery", url, "id1"); 181 191 TemplatedTMSTileSource ts = new TemplatedTMSTileSource(testImageryTMS); 182 assertEquals(expected123, ts.getTileUrl( 1, 2, 3));192 assertEquals(expected123, ts.getTileUrl(4, 5, 6)); 183 193 assertEquals(expected312, ts.getTileUrl(3, 1, 2)); 184 194 } … … 192 202 TileSourceInfo testImageryTMS = new TileSourceInfo("test imagery", test[0], "id1"); 193 203 TemplatedTMSTileSource ts = new TemplatedTMSTileSource(testImageryTMS); 194 assertEquals(test[1], ts.getTileUrl( 1, 2, 3));204 assertEquals(test[1], ts.getTileUrl(4, 5, 6)); 195 205 assertEquals(test[2], ts.getTileUrl(3, 2, 1)); 196 206 } … … 202 212 TemplatedTMSTileSource ts = new TemplatedTMSTileSource(testImageryTMS); 203 213 System.out.println(MessageFormat.format("new String[]{\"{0}\", \"{1}\", \"{2}\"},", 204 url, ts.getTileUrl( 1, 2, 3), ts.getTileUrl(3, 2, 1)));214 url, ts.getTileUrl(4, 5, 6), ts.getTileUrl(3, 2, 1))); 205 215 } 206 216 }
Note:
See TracChangeset
for help on using the changeset viewer.