On Tue, Nov 22, 2011 at 12:10 PM, Andrea Aime
<[email protected]> wrote:
> Wondering how to handle this one?
> The one solution I've found is to still support image/png8 in the
> requests, but stop advertising it in the
> capabilites, and advertise and use a "image/png; mode=8bit" mime type
> instead, this one is properly
> understood by browsers too (at least Chrome and Firefox)

Here is a reference patch implementing the above

Cheers
Andrea


-- 
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy

phone: +39 0584 962313
fax:      +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-------------------------------------------------------
diff --git a/src/wms/src/main/java/applicationContext.xml b/src/wms/src/main/java/applicationContext.xml
index f9676b6..a3e4618 100644
--- a/src/wms/src/main/java/applicationContext.xml
+++ b/src/wms/src/main/java/applicationContext.xml
@@ -393,12 +393,13 @@
     <bean id="PNG8MapProducer" class="org.geoserver.wms.map.RenderedImageMapOutputFormat">
       <constructor-arg>
         <description>The prescribed output format MIME-Type</description>
-        <value>image/png8</value>
+        <value>image/png; mode=8bit</value>
       </constructor-arg>
       <constructor-arg>
         <description>The declared output format MIME-Types in the capabilities document</description>
         <list>
           <value>image/png8</value>
+          <value>image/png; mode=8bit</value>
         </list>
       </constructor-arg>
       <constructor-arg ref="wms" />
diff --git a/src/wms/src/main/java/org/geoserver/wms/map/PNGMapResponse.java b/src/wms/src/main/java/org/geoserver/wms/map/PNGMapResponse.java
index 63403ac..17dc3d1 100644
--- a/src/wms/src/main/java/org/geoserver/wms/map/PNGMapResponse.java
+++ b/src/wms/src/main/java/org/geoserver/wms/map/PNGMapResponse.java
@@ -14,6 +14,7 @@ import java.util.logging.Logger;
 
 import org.geoserver.platform.Operation;
 import org.geoserver.platform.ServiceException;
+import org.geoserver.wms.GetMapRequest;
 import org.geoserver.wms.RasterCleaner;
 import org.geoserver.wms.MapProducerCapabilities;
 import org.geoserver.wms.WMS;
@@ -34,8 +35,10 @@ public class PNGMapResponse extends RenderedImageMapResponse {
     private static final Logger LOGGER = Logging.getLogger(PNGMapResponse.class);
 
     private static final String MIME_TYPE = "image/png";
+    
+    private static final String MIME_TYPE_8BIT = "image/png; mode=8bit";
 
-    private static final String[] OUTPUT_FORMATS = { MIME_TYPE, "image/png8" };
+    private static final String[] OUTPUT_FORMATS = { MIME_TYPE, MIME_TYPE_8BIT, "image/png8" };
     
     /** 
      * Default capabilities for PNG format.
@@ -61,7 +64,12 @@ public class PNGMapResponse extends RenderedImageMapResponse {
     
     @Override
     public String getMimeType(Object value, Operation operation) throws ServiceException {
-        return MIME_TYPE;
+        GetMapRequest request = (GetMapRequest) operation.getParameters()[0];
+        if(request.getFormat().contains("8")) {
+            return MIME_TYPE_8BIT;
+        } else {
+            return MIME_TYPE;
+        }
     }
 
     /**
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to