Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have an OpenLayers map using OSM as the baselayer with several layers coming from MapServer via WMS. The OL map is in EPSG:3857 and my mapfile (and shapefiles) are in EPSG:4326. In my mapfile I have 'epsg:3857' as one of the values for 'wms_srs'.

So my WMS layers produce the correct images at high zoom levels (zoomed in to the area they cover) around some islands in Hawaii. But when I zoom out (lower than OL zoom level 6 or so) these WMS layers disappear. What is more confusing is that if I make the map very small I can get it to show up down to level 3. This indicates to me that is a projection issue and it is the requested extents that matter. Here is an example request where it does work:

http://localhost:8080/cgi-bin/mapserv?map=/vagrant/djangoproject/djangoproject/site_media/media/outputs/HAKOU_v2/118/result_wave_deter.map&LAYERS=wave&FORMAT=image%2Fpng&TRANSPARENT=true&ISBASELAYER=false&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A3857&BBOX=-19159399.70874,918467.30427795,-16055444.864568,3714228.0504472&WIDTH=1269&HEIGHT=1143

and where it doesn't:

http://localhost:8080/cgi-bin/mapserv?map=/vagrant/djangoproject/djangoproject/site_media/media/outputs/HAKOU_v2/118/result_wave_deter.map&LAYERS=wave&FORMAT=image%2Fpng&TRANSPARENT=true&ISBASELAYER=false&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A3857&BBOX=-20848352.285494,-452507.23485414,-14640442.59715,5139014.2574847&WIDTH=1269&HEIGHT=1143

Here is an example mapfile:

MAP
  NAME 'wave'
  STATUS ON
  # Map image size
  SIZE 512 256
  MAXSIZE 4096
  UNITS METERS
  FONTSET '/vagrant/djangoproject/djangoproject/data/fonts/font.list'

  EXTENT -159.87 20.33 -156.3 22.7
  PROJECTION
    'init=epsg:4326'
  END

  # Background color for the map canvas -- change as desired
  #IMAGECOLOR 195 220 252
  IMAGECOLOR 255 255 255
  IMAGEQUALITY 95
  IMAGETYPE png24

  #CONFIG "MS_ERRORFILE" "/var/log/mapserver/ms_error.txt"
  #DEBUG 1

  #OUTPUTFORMAT
  #  NAME png
  #  DRIVER 'GD/PNG'
  #  MIMETYPE 'image/png'
  #  IMAGEMODE PC256
  #  EXTENSION 'png'
  #  TRANSPARENT ON
  #END

  OUTPUTFORMAT
    NAME 'png24'
    MIMETYPE 'image/png'
    DRIVER 'AGG/PNG'
    EXTENSION 'png'
    IMAGEMODE RGBA
    TRANSPARENT ON
  END # OUTPUTFORMAT


  # Legend
  LEGEND
      IMAGECOLOR 255 255 255
    STATUS ON
    KEYSIZE 18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
  END

  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH '/tmp/'

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '/tmp/'

    LOG '/tmp/zoowps/mapserver.log'

    # WMS server settings
    METADATA
      'wms_title'           'wave'
      'wms_onlineresource'  'http://cybereye.crc.nd.edu/portal/mapserver/?map=/vagrant/djangoproject/djangoproject/site_media/media/outputs/HAKOU_v2/118/result_wave_deter.map'
      'wms_srs'             'epsg:4326 epsg:3857'
      'wms_enable_request'  '*'
    END

    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See MapServer documentation
#    TEMPLATE 'fooOnlyForWMSGetFeatureInfo'
  END



  LAYER
    NAME 'wave'
    TYPE POLYGON
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
    EXTENT -159.87 20.33 -156.3 22.7
    DATA '/vagrant/djangoproject/djangoproject/site_media/media/outputs/HAKOU_v2/118/result_wave_deter.shp'
    METADATA
      'ows_title' 'wave'
    END
    STATUS ON
    TRANSPARENCY 100
    PROJECTION
    'init=epsg:4326'
    END

    LABELITEM 'HEIGHT_STR'
    #LABELMAXSCALEDENOM 1451339.3664

    CLASSITEM 'HEIGHT_STR'

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '0.001')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 0 0 242
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '1')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 0 48 242
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '2')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 0 96 242
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '3')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 0 145 242
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '4')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 0 193 242
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '5')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 0 242 242
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '6')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 0 242 193
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '7')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 0 242 145
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '8')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 0 242 96
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '9')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 0 242 48
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '10')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 0 242 0
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '11')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 48 242 0
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '12')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 96 242 0
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '13')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 145 242 0
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '14')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 193 242 0
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '15')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 242 242 0
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '16')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 242 193 0
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '17')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 242 145 0
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '18')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 242 96 0
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '19')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 242 48 0
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

        CLASS
            EXPRESSION ('[HEIGHT_STR]' eq '20')
            LABEL
                ANGLE FOLLOW
                MAXOVERLAPANGLE 20
                FONT 'arial'
                MAXSIZE 10
                MINSIZE 10
                SIZE 10
                BUFFER 2
                COLOR 255 255 255
                MINDISTANCE 75
                MINFEATURESIZE 20
                OFFSET 0 0
                OUTLINECOLOR 0 0 0
                PARTIALS FALSE
                POSITION CC
                #SHADOWSIZE 1 1
                TYPE TRUETYPE
            END # LABEL
            STYLE
                COLOR 242 0 0
                WIDTH 0.91
                OUTLINECOLOR 0 0 0
            END
        END

  END
END

Any ideas on how to go about fixing this? In the end I would like it to show up at all zoom levels. Thanks in advance.

share|improve this question
    
Could you reproject your 4326 data into 3857? I can see in the URL that doesn't work, the bounding box minimum x value -20848352.285494 is slightly out of bounds for WGS84 web mercator. –  Mintx May 8 '13 at 21:01
    
I can if I have to, these layers are generated dynamically by user request so it'd be another couple steps per calculation to reproject. Sounds like the issue is MapServer not knowing how to wrap around the west edge of the coordinate system extents. What are the extents of the web mercator projection? I've been looking around, but can't seem to find a definite answer anywhere. –  Nathan Smith May 8 '13 at 21:45
    
It really depends on how your basemap is set up, but usually your X bounds is -20 million to +20 million from dateline to dateline and Y bounds is less than +-10 million due to distortion at the poles. –  Mintx May 8 '13 at 22:43
    
Reprojected my shapefile to 3857 and updated my mapfile and the problem still occurs. –  Nathan Smith May 9 '13 at 15:07
    
Well, try replace the projection from epsg:3857 to epsg:900913. They look quite same but they are a little different. Copy the WMS request and paste into a new browser tab. With a little lucky, if problem on Mapserver, then he will report the error on output. This should be an problem with OpenLayers computed bounds. –  cavila May 10 '13 at 2:08

1 Answer 1

In the end I decided to avoid the issue by making my OL layers multitiled (singleTile: false) with the appropriate maxExtent to prevent requests outside of the appropriate area. This way, since my layers are around Hawaii and never actually cross the date line, I won't have issues with OL making bad requests with respect to the IDL.

The only downside is more requests per view, but theoretically each request should have a lower computational cost since it's a smaller area. Thanks for your help in discovering the issue.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.