Changeset 12147 in josm


Ignore:
Timestamp:
2017-05-14T21:21:19+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #14793 - fix WMTS CRS identification as per OGC specification (case-insensitive & version optional)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/GetCapabilitiesParseHelper.java

    r11921 r12147  
    55import java.net.MalformedURLException;
    66import java.net.URL;
     7import java.util.Locale;
    78
    89import javax.xml.namespace.QName;
     
    202203     * @param crsIdentifier CRS identifier
    203204     * @return CRS Identifier as it is used within JOSM (without prefix)
     205     * @see <a href="https://portal.opengeospatial.org/files/?artifact_id=24045">
     206     *     Definition identifier URNs in OGC namespace, chapter 7.2: URNs for single objects</a>
    204207     */
    205208    public static String crsToCode(String crsIdentifier) {
    206209        if (crsIdentifier.startsWith("urn:ogc:def:crs:")) {
    207             return crsIdentifier.replaceFirst("urn:ogc:def:crs:([^:]*):.*:(.*)$", "$1:$2");
     210            return crsIdentifier.replaceFirst("urn:ogc:def:crs:([^:]*)(?::.*)?:(.*)$", "$1:$2").toUpperCase(Locale.ENGLISH);
    208211        }
    209212        return crsIdentifier;
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/GetCapabilitiesParseHelperTest.java

    r11921 r12147  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.imagery;
     3
     4import static org.junit.Assert.assertEquals;
    35
    46import org.junit.Rule;
     
    2931        UtilityClassTestUtil.assertUtilityClassWellDefined(GetCapabilitiesParseHelper.class);
    3032    }
     33
     34    /**
     35     * Unit test of {@code GetCapabilitiesParseHelper#crsToCode} method.
     36     */
     37    @Test
     38    public void testCrsToCode() {
     39        assertEquals("EPSG:3127", GetCapabilitiesParseHelper.crsToCode("urn:ogc:def:crs:epsg:3127"));
     40        assertEquals("EPSG:3127", GetCapabilitiesParseHelper.crsToCode("urn:ogc:def:crs:epsg::3127"));
     41        assertEquals("EPSG:3127", GetCapabilitiesParseHelper.crsToCode("urn:ogc:def:crs:epsg:6.6:3127"));
     42    }
    3143}
Note: See TracChangeset for help on using the changeset viewer.