[OpenLayers-Users] AW: [mapserver-users] "Low-resolution" raster image problem when usingOpenlayers

Arnd Wippermann arnd.wippermann at web.de
Tue Jun 28 14:28:12 EDT 2011


use some image viewer to get information of your images.
 
tile_topleft_remote.png is a 8bit image (256 color image), where only 45
colors used.
 
tile_topleft_local.png is a 24bit image (16,7 Mill. colors), where 13274
colors used.
 
The requests ask for map_imagetype=png. So it seems, that your mapfiles are
different, because the response of the servers delivers a different image
for the same imagetype. Or do you use different MapServer versions?
 
The problem has to be an issue with MapServer and not with OpenLayers.
 
Arnd
 
  _____  

Von: kensei3000 [mailto:kensei3000 at yahoo.com] 
Gesendet: Dienstag, 28. Juni 2011 04:32
An: Arnd Wippermann
Cc: users at openlayers.org
Betreff: Re: AW: [mapserver-users] "Low-resolution" raster image problem
when usingOpenlayers


Hi Arnd,


Thanks a lot for the tip. I copied the image url of the top-left most tile
for both local pc and remote server tests.
Here is what I got:


Local:
http://localhost/cgi-bin/mapserv?map=%2Fopt%2Fmaps%2Fsandbox%2Fmapserver_ope
nlayers_if%2Fsample.map&layers=sample_raster&mode=map&map_imagetype=png&mape
xt=-90+0+0+90&imgext=-90+0+0+90&map_size=256+256&imgx=128&imgy=128&imgxy=256
+256


Remote:
http://remotehost/cgi-bin/mapserv?map=%2Fopt%2Fmaps%2Fsandbox%2Fmapserver_op
enlayers_if%2Fsample.map&layers=sample_raster&mode=map&map_imagetype=png&map
ext=-180+-90+0+90&imgext=-180+-90+0+90&map_size=256+256&imgx=128&imgy=128&im
gxy=256+256


The only significant difference of the two urls appear to be the 'mapext'
and 'imgext' parameters. When I checked the resulting images after inputting
the urls in the browser, I noticed that the tile images had different sizes
and positions. I believe this was due to the said parameters. I tried
changing the 'mapext' and 'imagext' parameters of the server test url to
match that of the local test url, and indeed the size and position of the
remote server tile image changed. However, I am still unable to figure out
what causes the color distortion or "downsampling" of the image in the
remote server.


For further reference, I've attached the tile images I got using the above
urls.


Here is the openlayers code I used. It is the same for both local and remote
server tests except for the host in line 18. 


//sample.html


     1 <html xmlns="http://www.w3.org/1999/xhtml">
     2  <head>
     3    <style type="text/css">
     4        #map {
     5            width: 1024px;
     6            height: 768px;
     7            border: 1px solid black;
     8        }
     9    </style>
    10    <script
src="http://openlayers.org/dev/lib/OpenLayers.js"></script>
    11    <script type="text/javascript">
    12        <!--
    13        var map, layer;
    14 
    15        function init(){
    16            map = new OpenLayers.Map( 'map' );
    17            layer = new OpenLayers.Layer.MapServer("World Map", 
    18                    "http://localhost/cgi-bin/mapserv",
    19                    {map:
'/opt/maps/sandbox/mapserver_openlayers_if/sample.map', layers:
'sample_raster'});
    20            map.addLayer(layer);
    21            map.zoomToMaxExtent();
    22        }
    23        // -->
    24    </script>
    25  </head>
    26  <body onload="init()">
    27    <div id="map"></div>
    28  </body>
    29 </html>


And below is the common .map file I created with the help of the Quantum GIS
Mapserver Export tool.
The raster image has an associated World file (.wld) for georeferencing.


     1 # Map file created from QGIS project file
/var/maps/sandbox/mapserver_openlayers_if/sample.qgs
     2 # Edit this file to customize for your map interface
     3 # (Created with PyQgis MapServer Export plugin)
     4 MAP
     5  NAME "QGIS-MAP"
     6  # Map image size
     7  SIZE 8180 4930
     8  UNITS meters
     9 
    10  EXTENT -86.515507 -50.290979 88.076495 48.225271
    11  PROJECTION
    12    'proj=longlat'
    13    'ellps=WGS84'
    14    'towgs84=0,0,0,0,0,0,0'
    15    'no_defs'
    16  END
    17 
    18  # Background color for the map canvas -- change as desired
    19  IMAGECOLOR 255 255 255
    20  IMAGEQUALITY 95
    21  IMAGETYPE jpeg
    22 
    23  # Legend
    24  LEGEND
    25      IMAGECOLOR 255 255 255
    26    STATUS ON
    27    KEYSIZE 18 12
    28    LABEL
    29      TYPE BITMAP
    30      SIZE MEDIUM
    31      COLOR 0 0 89
    32    END
    33  END
    34 
    35  # Web interface definition. Only the template parameter
    36  # is required to display a map. See MapServer documentation
    37  WEB
    38    # Set IMAGEPATH to the path where MapServer should
    39    # write its output.
    40    IMAGEPATH '/tmp/'
    41 
    42    # Set IMAGEURL to the url that points to IMAGEPATH
    43    # as defined in your web server configuration
    44    IMAGEURL '/tmp/'
    45 
    46    #Scale range at which web interface will operate
    47    # Template and header/footer settings
    48    # Only the template parameter is required to display a map. See
MapServer documentation
    49    TEMPLATE 'fooOnlyForWMSGetFeatureInfo'
    50  END
    51 
    52  LAYER
    53    NAME 'sample_raster'
    54    TYPE RASTER
    55    DUMP true
    56    TEMPLATE fooOnlyForWMSGetFeatureInfo
    57  EXTENT -86.515507 -50.290979 88.076495 48.225271
    58    DATA 'sec_field.jpg'
    59    STATUS DEFAULT
    60    TRANSPARENCY 100
    61    PROJECTION
    62    'proj=longlat'
    63    'ellps=WGS84'
    64    'towgs84=0,0,0,0,0,0,0'
    65    'no_defs'
    66    END
    67  END
    68 
    69 END


Hope you could provide further assistance.


Ken



  _____  

From: Arnd Wippermann <arnd.wippermann at web.de>
To: 'kensei3000' <kensei3000 at yahoo.com>
Cc: users at openlayers.org
Sent: Tuesday, June 28, 2011 1:53 AM
Subject: AW: [mapserver-users] "Low-resolution" raster image problem when
usingOpenlayers


hi,
 
if you do a right click on a tile to get the context menu, you should be
able to copy the url (if the tiles of your server is the most top of the
visible layers). Compare the different urls. If you load them in your
browser you should get a response for a single tile from your server.
 
Perhaps that gives you an idea, what goes wrong.
 
Arnd

  _____  

Von: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] Im Auftrag von kensei3000
Gesendet: Montag, 27. Juni 2011 05:37
An: mapserver-users at lists.osgeo.org
Betreff: [mapserver-users] "Low-resolution" raster image problem when
usingOpenlayers


Hi!

I am trying to use MapServer as a WMS layer in Openlayers. I setup the
MapServer in our server machine, using my own PC as the test client. I
created a simple .map file in our server that contains one raster image.
Using the mapserver tool 'mapserv' in a URL string, I was able to load the
output map with full resolution correctly in a browser (Google Chrome).
However, when I tried to load the map using a simple Openlayers script
(HMTL) which I created on our server (accessible via browser), the map image
appeared to have a much lower-resolution (i.e. 256-colors only) and was
pixelized. Also, I could see white lines representing the tile edges of the
map. 

I did another test. This time, I installed MapServer in my own PC. I created
a .map file similar to the one I used in our server, with the same raster
image. I created a similar Openlayers script (HTML) in my own PC, but this
time it would call the MapServer from my own PC. I loaded the script using a
browser and the image displayed correctly with full resolution. 

Does anyone have an idea what the problem could be?

I would appreciate any help in this matter.

Thanks in advance! :)  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110628/5219af9a/attachment-0001.html


More information about the Users mailing list