[mapserver-users] Problems with non-square pixels

Steve Lime Steve.Lime at dnr.state.mn.us
Thu Jul 16 15:21:00 PDT 2009


The nonsquare_enabled check is occurring *before* the WMS bbox (in map->extent) is converted
to the MapServer extent model so I believe the code is correct. I'd lean towards option 2 below.

Steve

>>> On 7/16/2009 at 2:40 PM, in message <4A5F8230.2080704 at pobox.com>, Frank
Warmerdam <warmerdam at pobox.com> wrote:
> Michael Pfeiffer wrote:
>> Try this wms request
>> 
>> 
> http://www.sogis1.so.ch/cgi-bin/sogis/sogis_print_test.wms?SERVICE=WMS&VERSION= 
> 1.1.1&REQUEST=GetMap&FORMAT=image/jpeg&LAYERS=Orthofoto&STYLES=&TRANSPARENT=true&BB
> OX=605035.8790650383,224864.94050038885,609110.4623983715,230528.7877226111&WI
> DTH=6417&HEIGHT=8921&SRS=EPSG:21781
>> A0 portrait 
>> 
>> This request needs over 1 minute.
> 
> Michael,
> 
> There seems to be a modest difference in the aspect ratio of the BBOX
> and the SIZE in the given request. The logic in mapwms.c that tests whether
> non-square mode needs to be used looks like this:
> 
>    /* Check whether requested BBOX and width/height result in non-square 
> pixels
>     */
>    nonsquare_enabled = msTestConfigOption( map, "MS_NONSQUARE", MS_FALSE );
>    if (!nonsquare_enabled)
>    {
>        double dx, dy, reqy;
>        dx = MS_ABS(map->extent.maxx - map->extent.minx);
>        dy = MS_ABS(map->extent.maxy - map->extent.miny);
> 
>        reqy = ((double)map->width) * dy / dx;
> 
>        /* Allow up to 1 pixel of error on the width/height ratios. */
>        /* If more than 1 pixel then enable non-square pixels */
>        if ( MS_ABS((reqy - (double)map->height)) > 1.0 )
>        {
>            if (map->debug)
>                msDebug("msWMSLoadGetMapParams(): enabling non-square 
> pixels.\n");
>            msSetConfigOption(map, "MS_NONSQUARE", "YES");
>            nonsquare_enabled = MS_TRUE;
>        }
>    }
> 
> I suspect the asymmetry is just enough to amount more than one pixel at
> this size.  I didn't run all the numbers but I suspect at smaller paper
> sizes (smaller SIZE values) the assymmetry amounts to less than one pixel.
> I'm not sure why it would affect portrait and not landscape.  I only ran
> the ratios on the case you mentioned was slow.
> 
> So there are a couple of possibilities here.
> 
>   1) It is possible the above computation is wrong.  I vaguely recall there
>      is an issue with map->extent actually being from the center of edge
>      pixel to the center of edge pixel, not the outer edges, in which case
>      the calculation should perhaps be:
>        reqy = MS_ABS(((map->width - 1) * dy / dx) + 1);
>      which might or might not make a difference in this case.
> 
>   2) Perhaps you just need to generate your WMS requests with more precise
>      BBOXes corresponding to the aspect ratio of the SIZE requested.
> 
> Well, I'm sure there could be other possibilities too.
> 
> Best regards,




More information about the MapServer-users mailing list