Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#22391 closed enhancement (fixed)

[PATCH] Support "image/png; mode=8bit" imagery

Reported by: nkamapper Owned by: taylor.smock
Priority: normal Milestone: 22.09
Component: Core imagery Version:
Keywords: Cc:

Description

I believe JOSM is not supporting 8 bit palette PNG at the moment.

It turned up as a problem when trying to use the WMTS service of Oslo municipality, where only one of eight layers are usable in JOSM: https://od2.pbe.oslo.kommune.no/mapcache/wmts?service=wmts&request=getcapabilities

Change History (8)

comment:1 by taylor.smock, 3 years ago

Milestone: 22.10
Summary: Support "image/png; mode=8bit" imagery[PATCH] Support "image/png; mode=8bit" imagery

This is a fairly simple patch.

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

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java b/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
    a b  
    549549        List<String> supportedMimeTypes = new ArrayList<>(Arrays.asList(ImageIO.getReaderMIMETypes()));
    550550        supportedMimeTypes.add("image/jpgpng");         // used by ESRI
    551551        supportedMimeTypes.add("image/png8");           // used by geoserver
     552        supportedMimeTypes.add("image/png; mode=8bit"); // used by MapServer
    552553        if (supportedMimeTypes.contains("image/jpeg")) {
    553554            supportedMimeTypes.add("image/jpg"); // sometimes misspelled by Arcgis
    554555        }
     
    606607        }
    607608        if (layer.format == null) {
    608609            // no format found - it's mandatory parameter - can't use this layer
    609             Logging.warn(tr("Can''t use layer {0} because no supported formats where found. Layer is available in formats: {1}",
     610            Logging.warn(tr("Can''t use layer {0} because no supported formats were found. Layer is available in formats: {1}",
    610611                    layer.getUserTitle(),
    611612                    String.join(", ", unsupportedFormats)));
    612613            return null;
    613614        }
     615        // Java has issues if spaces are not URL encoded. Ensure that we URL encode the spaces.
     616        if (layer.format.contains(" ")) {
     617            layer.format = layer.format.replace(" ", "&20");
     618        }
    614619        return layer;
    615620    }
    616621

comment:2 by taylor.smock, 3 years ago

Owner: changed from team to taylor.smock
Status: newassigned

comment:3 by taylor.smock, 3 years ago

Resolution: fixed
Status: assignedclosed

In 18567/josm:

Fix #22391: Support "image/png; mode=8bit" imagery

comment:4 by stoecker, 3 years ago

Ähm. URL encoded is %20, not &20!

comment:5 by taylor.smock, 3 years ago

That is funny. I wonder why &20 worked when I tested it. I would have expected the server to not return data.

comment:6 by taylor.smock, 3 years ago

In 18568/josm:

See #22391/r18567: fix typo (&20 -> %20 for ' ' url encoding)

comment:7 by taylor.smock, 3 years ago

In 22.09 hotfix.

comment:8 by taylor.smock, 3 years ago

Milestone: 22.1022.09

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.