Ticket #20343: fix_parsing_of_topleft.diff

File fix_parsing_of_topleft.diff, 6.6 KB (added by nagisa, 5 years ago)

Patch for the issue

  • src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

     
    754754    }
    755755
    756756    private static EastNorth parseEastNorth(String coor, boolean switchXY) {
    757         return parseCoor(coor, switchXY, (e, n) -> new EastNorth(Double.parseDouble(e), Double.parseDouble(n)));
     757        return parseCoor(coor, switchXY, (n, e) -> new EastNorth(Double.parseDouble(e), Double.parseDouble(n)));
    758758    }
    759759
    760760    private static LatLon parseLatLon(String coor, boolean switchXY) {
  • test/data/wmts/WMTSCapabilities-Lithuania.xml

     
     1<?xml version="1.0" encoding="UTF-8"?>
     2<Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0">
     3    <Contents>
     4        <Layer>
     5            <ows:Title>NZT_ORT2LT_2018</ows:Title>
     6            <ows:Identifier>NZT_ORT2LT_2018</ows:Identifier>
     7            <ows:BoundingBox crs="urn:ogc:def:crs:EPSG::3346">
     8                <ows:LowerCorner>6022999.8655913975 316000.06350012776</ows:LowerCorner>
     9                <ows:UpperCorner>6211000.061383456 605999.984124969</ows:UpperCorner>
     10            </ows:BoundingBox>
     11            <ows:WGS84BoundingBox crs="urn:ogc:def:crs:OGC:2:84">
     12                <ows:LowerCorner>21.05003442434057 54.31083718956931</ows:LowerCorner>
     13                <ows:UpperCorner>25.70028436683549 56.0330467679823</ows:UpperCorner>
     14            </ows:WGS84BoundingBox>
     15            <Style isDefault="true">
     16                <ows:Title>Default Style</ows:Title>
     17                <ows:Identifier>default</ows:Identifier>
     18            </Style>
     19            <Format>image/png</Format>
     20            <TileMatrixSetLink>
     21                <TileMatrixSet>default028mm</TileMatrixSet>
     22            </TileMatrixSetLink>
     23            <ResourceURL format="image/png" resourceType="tile" template="https://this_is_test/tile/{TileMatrix}/{TileRow}/{TileCol}"/>
     24        </Layer>
     25        <TileMatrixSet>
     26            <ows:Title>TileMatrix using 0.28mm</ows:Title>
     27            <ows:Abstract>The tile matrix set that has scale values calculated based on the dpi defined by OGC specification (dpi assumes 0.28mm as the physical distance of a pixel).</ows:Abstract>
     28            <ows:Identifier>default028mm</ows:Identifier>
     29            <ows:SupportedCRS>urn:ogc:def:crs:EPSG::3346</ows:SupportedCRS>
     30            <TileMatrix>
     31                <ows:Identifier>0</ows:Identifier>
     32                <ScaleDenominator>2834827.0982252685</ScaleDenominator>
     33                <TopLeftCorner>1.00001E7 -5122000.0</TopLeftCorner>
     34                <TileWidth>256</TileWidth>
     35                <TileHeight>256</TileHeight>
     36                <MatrixWidth>29</MatrixWidth>
     37                <MatrixHeight>20</MatrixHeight>
     38            </TileMatrix>
     39            <TileMatrix>
     40                <ows:Identifier>1</ows:Identifier>
     41                <ScaleDenominator>1889884.7321501793</ScaleDenominator>
     42                <TopLeftCorner>1.00001E7 -5122000.0</TopLeftCorner>
     43                <TileWidth>256</TileWidth>
     44                <TileHeight>256</TileHeight>
     45                <MatrixWidth>43</MatrixWidth>
     46                <MatrixHeight>30</MatrixHeight>
     47            </TileMatrix>
     48            <TileMatrix>
     49                <ows:Identifier>2</ows:Identifier>
     50                <ScaleDenominator>944942.3660750897</ScaleDenominator>
     51                <TopLeftCorner>1.00001E7 -5122000.0</TopLeftCorner>
     52                <TileWidth>256</TileWidth>
     53                <TileHeight>256</TileHeight>
     54                <MatrixWidth>85</MatrixWidth>
     55                <MatrixHeight>59</MatrixHeight>
     56            </TileMatrix>
     57        </TileMatrixSet>
     58    </Contents>
     59    <ServiceMetadataURL xlink:href="http://www.geoportal.lt/arcgis/rest/services/NZT/ORT2LT_2018/MapServer/WMTS/1.0.0/WMTSCapabilities.xml"/>
     60</Capabilities>
  • test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java

     
    6161    private final ImageryInfo testImageryOntario = getImagery(TestUtils.getTestDataRoot() + "wmts/WMTSCapabilities-Ontario.xml");
    6262    private final ImageryInfo testImageryGeoAdminCh = getImagery(TestUtils.getTestDataRoot() + "wmts/WMTSCapabilities-GeoAdminCh.xml");
    6363    private final ImageryInfo testImagery12168 = getImagery(TestUtils.getTestDataRoot() + "wmts/bug12168-WMTSCapabilities.xml");
     64    private final ImageryInfo testImageryORT2LT = getImagery(TestUtils.getTestDataRoot() + "wmts/WMTSCapabilities-Lithuania.xml");
    6465    private final ImageryInfo testLotsOfLayers = getImagery(TestUtils.getTestDataRoot() + "wmts/getCapabilities-lots-of-layers.xml");
    6566    private final ImageryInfo testDuplicateTags = getImagery(TestUtils.getTestDataRoot() + "wmts/bug12573-wmts-identifier.xml");
    6667    private final ImageryInfo testMissingStyleIdentifier = getImagery(TestUtils.getTestDataRoot() +
     
    251252    }
    252253
    253254    @Test
     255    public void testWMTSTopLeftParsing() throws IOException, WMTSGetCapabilitiesException {
     256        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3346"));
     257        WMTSTileSource testSource = new WMTSTileSource(testImageryORT2LT);
     258        testSource.initProjection(ProjectionRegistry.getProjection());
     259        TileXY tileXY0 = testSource.latLonToTileXY(55.31083718860799, 22.172052608196587, 0);
     260        assertEquals(27, (int)tileXY0.getX());
     261        assertEquals(19, (int)tileXY0.getY());
     262        TileXY tileXY2 = testSource.latLonToTileXY(55.31083718860799, 22.172052608196587, 2);
     263        assertEquals(81, (int)tileXY2.getX());
     264        assertEquals(57, (int)tileXY2.getY());
     265    }
     266
     267    @Test
    254268    public void testTwoTileSetsForOneProjection() throws Exception {
    255269        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    256270        ImageryInfo ontario = getImagery(TestUtils.getTestDataRoot() + "wmts/WMTSCapabilities-Ontario.xml");