[Mapserver-dev] FYI: Bug 673 - layer->project flag not being reset properly

Frank Warmerdam warmerdam at pobox.com
Fri May 21 18:19:42 EDT 2004


Folks,

From:
   http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=673

Currently the layer->project flag is MS_TRUE if a layer needs (or potentially
needs) reprojection and if MS_FALSE we know we don't have to look at the
projection object at all.

In various places, such as mapdraw.c:msDrawShape() we have code constructs
like this:

#ifdef USE_PROJ
     if(layer->project && msProjectionsDiffer(&(layer->projection),
&(map->projection)))
       msProjectPoint(&layer->projection, &map->projection, &center);
     else
       layer->project = MS_FALSE;
#endif

If it finds that the map and layer projections are identical then it
sets the "project" flag to false so we don't have to do any more checking.

However, in a MapScript or other long lived session operating on a map it is
possible to thereafter reset the map projection (such that it would differ
from a layer projection) but not have the layer->project flag reset to
MS_TRUE.  This can basically result in layers not being reprojected
when they should under some esoteric situations.

The problem is slightly worse with map rotation in the picture as the
msProjectionsDiffer() also has to check if there is a rotation in effect
and if so, returns TRUE even if the projections don't differ since there is
a transformation to be applied.

I think the solution is to review all code that uses the layer->project
flag and ensure that it is recomputed carefully on each pass.  Thus
msDrawLayer() might reset the flag to MS_TRUE each time it is called. But
the flag is also used in various query code and possibly other places, so
I think other places also need to be updated.

I propose to implement a msLayerSetProjectFlag(layerObj*) that would just
set the layer->project flag appropriate at that point depend on whether
projections exist, USE_PROJ is set, and the projections differ.  This could
be inserted at strategic points.

Technically this issue exists in 4.2 and earlier versions but I think the
situations in which it can cause problems are sufficiently esoteric that
we can just address it in 4.3.

... followup in bugzilla if you have any issues with regard to this bug.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the mapserver-dev mailing list