Changeset 8584 in josm for trunk/src/org
- Timestamp:
- 2015-07-08T20:59:09+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java
r8540 r8584 139 139 if (baseUrl.toLowerCase().contains("crs=epsg:4326")) { 140 140 switchLatLon = true; 141 } else if (baseUrl.toLowerCase().contains("crs=") && "EPSG:4326".equals(myProjCode)) { 142 switchLatLon = true; 141 } else if (baseUrl.toLowerCase().contains("crs=")) { 142 // assume WMS 1.3.0 143 switchLatLon = Main.getProjection().switchXY(); 143 144 } 144 145 String bbox; -
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r8571 r8584 47 47 import org.openstreetmap.josm.data.coor.LatLon; 48 48 import org.openstreetmap.josm.data.projection.Projection; 49 import org.openstreetmap.josm.data.projection.Projections; 49 50 import org.openstreetmap.josm.gui.ExtendedDialog; 50 51 import org.openstreetmap.josm.io.CachedFile; … … 66 67 private static final String PATTERN_HEADER = "\\{header\\(([^,]+),([^}]+)\\)\\}"; 67 68 68 private static final String URL_GET_ENCODING_PARAMS = "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER={layer}&STYLE={ style}&"69 private static final String URL_GET_ENCODING_PARAMS = "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER={layer}&STYLE={Style}&" 69 70 + "FORMAT={format}&tileMatrixSet={TileMatrixSet}&tileMatrix={TileMatrix}&tileRow={TileRow}&tileCol={TileCol}"; 70 71 … … 229 230 230 231 } catch (Exception e) { 231 Main.error(e); 232 } 233 return null; 232 throw new IllegalArgumentException(e); 233 } 234 234 } 235 235 … … 268 268 matrixSet.crs = crsToCode(getStringByXpath(matrixSetNode, "SupportedCRS")); 269 269 NodeList tileMatrixList = getByXpath(matrixSetNode, "TileMatrix"); 270 Projection matrixProj = Projections.getProjectionByCode(matrixSet.crs); 271 if (matrixProj == null) { 272 // use current projection if none found. Maybe user is using custom string 273 matrixProj = Main.getProjection(); 274 } 270 275 for (int matrixId = 0; matrixId < tileMatrixList.getLength(); matrixId++) { 271 276 Node tileMatrixNode = tileMatrixList.item(matrixId); … … 274 279 tileMatrix.scaleDenominator = Double.parseDouble(getStringByXpath(tileMatrixNode, "ScaleDenominator")); 275 280 String[] topLeftCorner = getStringByXpath(tileMatrixNode, "TopLeftCorner").split(" "); 276 tileMatrix.topLeftCorner = new EastNorth(Double.parseDouble(topLeftCorner[1]), Double.parseDouble(topLeftCorner[0])); 281 282 if(matrixProj.switchXY()) { 283 tileMatrix.topLeftCorner = new EastNorth(Double.parseDouble(topLeftCorner[1]), Double.parseDouble(topLeftCorner[0])); 284 } else { 285 tileMatrix.topLeftCorner = new EastNorth(Double.parseDouble(topLeftCorner[0]), Double.parseDouble(topLeftCorner[1])); 286 } 277 287 tileMatrix.tileHeight = Integer.parseInt(getStringByXpath(tileMatrixNode, "TileHeight")); 278 288 tileMatrix.tileWidth = Integer.parseInt(getStringByXpath(tileMatrixNode, "TileHeight")); … … 291 301 private static String crsToCode(String crsIdentifier) { 292 302 if (crsIdentifier.startsWith("urn:ogc:def:crs:")) { 293 return crsIdentifier.replaceFirst("urn:ogc:def:crs:([^:]*): [^:]*:(.*)$", "$1:$2");303 return crsIdentifier.replaceFirst("urn:ogc:def:crs:([^:]*):.*:(.*)$", "$1:$2"); 294 304 } 295 305 return crsIdentifier; … … 439 449 } 440 450 double scale = matrix.scaleDenominator * this.crsScale; 441 EastNorth ret = new EastNorth(matrix.topLeftCorner. getX() + x * scale, matrix.topLeftCorner.getY() - y * scale);451 EastNorth ret = new EastNorth(matrix.topLeftCorner.east() + x * scale, matrix.topLeftCorner.north() - y * scale); 442 452 return Main.getProjection().eastNorth2latlon(ret).toCoordinate(); 443 453 } … … 589 599 EastNorth min = proj.latlon2eastNorth(bounds.getMin()); 590 600 EastNorth max = proj.latlon2eastNorth(bounds.getMax()); 591 return (int) Math.ceil(Math.abs(max. getY() - min.getY()) / scale);601 return (int) Math.ceil(Math.abs(max.north() - min.north()) / scale); 592 602 } 593 603 … … 601 611 EastNorth min = proj.latlon2eastNorth(bounds.getMin()); 602 612 EastNorth max = proj.latlon2eastNorth(bounds.getMax()); 603 return (int) Math.ceil(Math.abs(max. getX() - min.getX()) / scale);613 return (int) Math.ceil(Math.abs(max.east() - min.east()) / scale); 604 614 } 605 615 } -
trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r8570 r8584 50 50 protected Bounds bounds; 51 51 private double metersPerUnit = METER_PER_UNIT_DEGREE; // default to degrees 52 private String axis = "enu"; // default axis orientation is East, North, Up 52 53 53 54 /** … … 98 99 no_defs("no_defs", false), 99 100 init("init", true), 101 /** crs units to meter multiplier */ 100 102 to_meter("to_meter", true), 103 /** definition of axis for projection */ 104 axis("axis", true), 101 105 // JOSM extensions, not present in PROJ.4 102 106 wmssrs("wmssrs", true), … … 212 216 if (s != null) { 213 217 this.metersPerUnit = parseDouble(s, Param.to_meter.key); 218 } 219 s = parameters.get(Param.axis.key); 220 if (s != null) { 221 this.axis = s; 214 222 } 215 223 } … … 548 556 } 549 557 558 @Override 559 public boolean switchXY() { 560 // TODO: support for other axis orientation such as West South, and Up Down 561 return this.axis.startsWith("ne"); 562 } 563 550 564 private static Map<String, Double> getUnitsToMeters() { 551 565 Map<String, Double> ret = new ConcurrentHashMap<>(); -
trunk/src/org/openstreetmap/josm/data/projection/Projection.java
r8568 r8584 79 79 */ 80 80 double getMetersPerUnit(); 81 82 /** 83 * Does this projection natural order of coordinates is North East, 84 * instead of East North 85 * 86 * @return true if natural order of coordinates is North East, false if East North 87 */ 88 boolean switchXY(); 81 89 } -
trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java
r8570 r8584 69 69 return tileSource; 70 70 } 71 } catch (Exception e) {72 Main.warn("Could not create imagery layer:");71 return null; 72 } catch (IOException e) { 73 73 Main.warn(e); 74 throw new IllegalArgumentException(e); 74 75 } 75 return null;76 76 } 77 77
Note:
See TracChangeset
for help on using the changeset viewer.