Changeset 13199 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2017-12-12T01:11:39+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #15666 - Display "Abstract" field of WMS layers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r13120 r13199  
    340340        String name = getChildContent(element, "Title", null, null);
    341341        String ident = getChildContent(element, "Name", null, null);
     342        String abstr = getChildContent(element, "Abstract", null, null);
    342343
    343344        // The set of supported CRS/SRS for this layer
     
    385386        List<LayerDetails> childLayers = parseLayers(layerChildren, crsList);
    386387
    387         return new LayerDetails(name, ident, crsList, josmSupportsThisLayer, bounds, childLayers);
     388        return new LayerDetails(name, ident, abstr, crsList, josmSupportsThisLayer, bounds, childLayers);
    388389    }
    389390
     
    448449
    449450    /**
    450      * The details of a layer of this wms server.
     451     * The details of a layer of this WMS server.
    451452     */
    452453    public static class LayerDetails {
    453454
    454455        /**
    455          * The layer name
     456         * The layer name (WMS {@code Title})
    456457         */
    457458        public final String name;
     459        /**
     460         * The layer ident (WMS {@code Name})
     461         */
    458462        public final String ident;
    459463        /**
     464         * The layer abstract (WMS {@code Abstract})
     465         * @since xxx
     466         */
     467        public final String abstr;
     468        /**
    460469         * The child layers of this layer
    461470         */
     
    465474         */
    466475        public final Bounds bounds;
     476        /**
     477         * the CRS/SRS pulled out of this layer's XML element
     478         */
    467479        public final Set<String> crsList;
     480        /**
     481         * {@code true} if any of the specified projections are supported by JOSM
     482         */
    468483        public final boolean supported;
    469484
    470         public LayerDetails(String name, String ident, Set<String> crsList, boolean supportedLayer, Bounds bounds,
     485        /**
     486         * Constructs a new {@code LayerDetails}.
     487         * @param name The layer name (WMS {@code Title})
     488         * @param ident The layer ident (WMS {@code Name})
     489         * @param abstr The layer abstract (WMS {@code Abstract})
     490         * @param crsList The CRS/SRS pulled out of this layer's XML element
     491         * @param supportedLayer {@code true} if any of the specified projections are supported by JOSM
     492         * @param bounds The bounds this layer can be used for
     493         * @param childLayers The child layers of this layer
     494         * @since xxx
     495         */
     496        public LayerDetails(String name, String ident, String abstr, Set<String> crsList, boolean supportedLayer, Bounds bounds,
    471497                List<LayerDetails> childLayers) {
    472498            this.name = name;
    473499            this.ident = ident;
     500            this.abstr = abstr;
    474501            this.supported = supportedLayer;
    475502            this.children = childLayers;
     
    478505        }
    479506
     507        /**
     508         * Determines if any of the specified projections are supported by JOSM.
     509         * @return {@code true} if any of the specified projections are supported by JOSM
     510         */
    480511        public boolean isSupported() {
    481512            return this.supported;
    482513        }
    483514
     515        /**
     516         * Returns the CRS/SRS pulled out of this layer's XML element.
     517         * @return the CRS/SRS pulled out of this layer's XML element
     518         */
    484519        public Set<String> getProjections() {
    485520            return crsList;
     
    488523        @Override
    489524        public String toString() {
    490             if (this.name == null || this.name.isEmpty())
    491                 return this.ident;
    492             else
    493                 return this.name;
     525            String baseName = (name == null || name.isEmpty()) ? ident : name;
     526            return abstr == null || abstr.equalsIgnoreCase(baseName) ? baseName : baseName + " (" + abstr + ')';
    494527        }
    495528    }
Note: See TracChangeset for help on using the changeset viewer.