Opened 20 years ago

Closed 20 years ago

#794 closed defect (fixed)

msQueryByPoint() fails when doing a reprojection with tolerance=0

Reported by: dmorissette Owned by: warmerdam
Priority: high Milestone:
Component: MapServer C Library Version: 4.3
Severity: normal Keywords:
Cc: bartvde@…, blow@…

Description

Frank, Steve,

We ran into a problem doing GetFeatureInfo with some WMS service when the SRS of
the request was different from the native projection of the data and the
TOLERANCE is 0 in the layer definition (i.e. not set). I could send you a
testcase to reproduce if needed, but I can't attach it to this bug, and you
probably won't need it anyway once you read the description below.

It turns out that when tolerance is sero, msQueryByPoint() creates a zero-size
searchrect:

(gdb) p rect
$6 = {minx = -123.56434997895762, miny = 48.452835466316486, 
  maxx = -123.56434997895762, maxy = 48.452835466316486}

... and then passes it to msProjectRect().

Inside msProjectRect(), we calculate dx and dy, which happen to be zero, and
because of that all tests in the function fail and the original rect is never
reprojected.

If msQueryByPoint() had tested the return value of msProjectRect() then it would
have seen the MS_FAILURE, but that still wouldn't help the user get meaningful
results.

We could possibly modify msQueryByPoint() to use a pointObj to reproject if
tolerance is zero, but that would just make the code more complicated and the
same situation could still fail elsewhere.  I think the best would be to modify
msProjectRect() to properly handle the case where dx==0 && dy==0.

What do you think?

Change History (5)

comment:1 by blow@…, 20 years ago

Cc: blow@… added

comment:2 by fwarmerdam, 20 years ago

Status: newassigned
Brian,

I have modified msProjectRect() so that it *should* work for a degenerate
(point) rectangle.  I have not tested it, other than to run my test stream
and verify that it still passes as far as it tests. 

Are you working with 4.3?  If so, can you run again from CVS? 

The change was adding the following near the beginning of msProjectRect():

  /* first ensure the top left corner is processed, even if the rect
     turns out to be degenerate. */

  prj_point.x = rect->minx;
  prj_point.y = rect->miny;

  msProjectGrowRect(in,out,&prj_rect,&rect_initialized,&prj_point,
                    &failure);

Basically, it ensures that at least a single point gets included in the output
rect even if stepping along sides does not make sense. I have also looked at
MapServer 4.2, and msProjectRect() is the same there, so it might make sense
to apply the same change in 4.2. 

comment:3 by dmorissette, 20 years ago

Cc: bartvde@… added

comment:4 by dmorissette, 20 years ago

*** Bug 707 has been marked as a duplicate of this bug. ***

comment:5 by dmorissette, 20 years ago

Resolution: fixed
Status: assignedclosed
Tested the fix in 4.3, works great. Thanks Frank.

I have also backported the fix to the 4.2 branch, to be eventually released in
4.2.3.

Note: See TracTickets for help on using tickets.