Fwd: [MAPSERVER-USERS] Problems calculating MAXSCALES

Rob gis at vanbooth.com
Wed Aug 13 10:36:27 EDT 2008


Sorry - didnt reply to whole list


---------- Forwarded message ----------
From: Rob <gis at vanbooth.com>
Date: 2008/8/13
Subject: Re: [MAPSERVER-USERS] Problems calculating MAXSCALES
To: Tamas Szekeres <szekerest at gmail.com>


I was unable to reopen the ticket with comments - "TICKET_APPEND
privileges are required to perform this operation"

If someone else could reopen on my behalf, this is what I wrote for
the comments -

I've recently updated from 4.8.6 to 5.0.2 and fallen foul of this
defect, where layers are not visible when I would expect them to be.

I'm in OSGB Projection (epsg:27700) but I didn't include this
information in my sample mapfiles, in case it was a projection related
issue.  My implementation uses mapscript rather than the cgi mapserv
process, but I have been testing using shp2img.

4.8.3 Mapfile

{{{
MAP
 EXTENT 200000 200000 266145 266145
 IMAGECOLOR 255 255 255
 IMAGETYPE png
 RESOLUTION 96.000000
 SIZE 500 500
 STATUS ON
 TRANSPARENT TRUE
 UNITS METERS
 NAME "Base"
 IMAGEQUALITY 75

 LEGEND
   IMAGECOLOR 255 255 255
   KEYSIZE 20 10
   KEYSPACING 5 5
   LABEL
     SIZE MEDIUM
     TYPE BITMAP
     BUFFER 0
     COLOR 0 0 0
     FORCE FALSE
     MINDISTANCE -1
     MINFEATURESIZE -1
     OFFSET 0 0
     PARTIALS TRUE
   END
   POSITION LL
   STATUS OFF
 END
 WEB
   IMAGEPATH "c:\tmp\"
   IMAGEURL "/"
   QUERYFORMAT text/html
   LEGENDFORMAT text/html
   BROWSEFORMAT text/html
 END
 LAYER
   MAXSCALE 500000
   MINSCALE 0
   NAME "Land"
   STATUS ON
   TRANSPARENCY 100
   TYPE RASTER
   UNITS METERS
   DATA "C:\Documents and Settings\Administrator\Desktop\gb\gbpng.tif"
 END
END
}}}


5.0.2 Mapfile

{{{
MAP
 EXTENT 200000 200000 266145 266145
 IMAGECOLOR 255 255 255
 IMAGETYPE png
 RESOLUTION 96.000000
 SIZE 500 500
 STATUS ON
 TRANSPARENT TRUE
 UNITS METERS
 NAME "Base"
 OUTPUTFORMAT
   NAME "png"
   MIMETYPE "image/png"
   DRIVER "GD/PNG"
   EXTENSION "png"
   IMAGEMODE "PC256"
   TRANSPARENT TRUE
 END
 PROJECTION
   "init=epsg:27700"
 END
 LEGEND
   IMAGECOLOR 255 255 255
   KEYSIZE 20 10
   KEYSPACING 5 5
   LABEL
     SIZE MEDIUM
     TYPE BITMAP
     BUFFER 0
     COLOR 0 0 0
     FORCE FALSE
     MINDISTANCE -1
     MINFEATURESIZE -1
     OFFSET 0 0
     PARTIALS TRUE
   END
   POSITION LL
   STATUS OFF
 END
 WEB
   IMAGEPATH "c:\tmp\"
   IMAGEURL "/"
   QUERYFORMAT text/html
   LEGENDFORMAT text/html
   BROWSEFORMAT text/html
 END
 LAYER
   DEBUG 5
   MAXSCALEDENOM 500000
   MINSCALEDENOM 0
   NAME "Land"
   STATUS ON
   TRANSPARENCY 100
   TYPE RASTER
   UNITS METERS
   DATA "C:\Documents and Settings\Administrator\Desktop\gb\gbpng.tif"
 END
END
}}}

GBPNG.TFW

{{{
333.333333333
0.000
0.000
-333.333333333
166.66666666
649833.33333333
}}}

Any 1000x1000 image should work.

Running shp2img against 4.8.3 will produce a valid image.  Running
shp2img against 5.0.2 does not.

Code is currently


{{{
center_y = (extent.miny+extent.maxy)/2.0;
  md = (width-1)/(resolution*msInchesPerUnit(units, center_y)); /*
remember, we use a pixel-center to pixel-center extent, hence the
width-1 */
  gd = extent.maxx - extent.minx;
  *scale = gd/md;
}}}

For the extents in the mapfiles, this gives a scale of 500997

Previously, using (width) instead of (width-1), we would have had 499993

My desktop GIS product seems to agree with the calculation to result
in 499993, judging by the bbox it requests when zooming to 1:500,000

Full mapserver-users conversation is here -
http://www.nabble.com/Problems-calculating-MAXSCALES-td18926188.html


More information about the mapserver-users mailing list