[Mapserver-dev] msProjectRect for degenerate rectangles?
Ed McNierney
ed at topozone.com
Fri Mar 21 10:39:36 EST 2003
Actually, the fix is slightly different than that. It's probably a bit of overkill, but if dx == 0 and dy == 0 (i.e. both blocks of code are skipped) then I passed both the minx, miny and maxx, maxy points to msProjectGrowRect. They should be exactly the same point, but I always worry about comparing floating-point numbers to 0. msProjectGrowRect will take care of setting both corners of the rectangle.
// If both deltas are zero, the rectangle is small but we need to do something
if ((dx == 0) && (dy == 0))
{
prj_point.x = rect->minx;
prj_point.y = rect->miny;
msProjectGrowRect (in, out, &prj_rect, &rect_initialized, &prj_point, &failure);
prj_point.x = rect->maxx;
prj_point.y = rect->maxy;
msProjectGrowRect (in, out, &prj_rect, &rect_initialized, &prj_point, &failure);
}
- Ed
Ed McNierney
President and Chief Mapmaker
TopoZone.com / Maps a la carte, Inc.
73 Princeton Street, Suite 305
North Chelmsford, MA 01863
ed at topozone.com
(978) 251-4242
-----Original Message-----
From: Ed McNierney
Sent: Thursday, March 20, 2003 2:20 PM
To: mapserver-dev at lists.gis.umn.edu
Subject: [Mapserver-dev] msProjectRect for degenerate rectangles?
Folks -
Now that I can actually run queries on 3.7, they don't work <g>. It appears that doing a simple single-layer point query (i.e. what object is this point in) for a data layer that's not in the MAP file's native projection doesn't work. The query point is used to initialize a rectangle with no TOLERANCE values, so msQueryByPoint creates a degenerate rectangle object (minx == maxx, miny == maxy) and passes it to msProjectRect. It *appears* that msProjectRect does the wrong thing - it looks to see if dx (deltax) is greater than 0, and calls msProjectGrowRect, then looks to see if dy (deltay) is greater than 0 and calls msProjectGrowRect again.
If dx == 0 and dy == 0 then the output rectangle's values are copied from prj_rect, which was never initialized. So I get goofy results and the query doesn't work.
I'm really asking about what msProjectRect should do when passed a degenerate rectangle. It seems to me that there's nothing really wrong with such a rectangle, and it ought to handle it just fine (i.e. the fix should be in msProjectRect). But I don't know enough about its usage to be sure.
It seems like modifying the two tests (if (dx > 0), if (dy > 0)) to simply be >= tests would be fine. Thoughts would be appreciated - thanks.
- Ed
Ed McNierney
President and Chief Mapmaker
TopoZone.com / Maps a la carte, Inc.
73 Princeton Street, Suite 305
North Chelmsford, MA 01863
ed at topozone.com
(978) 251-4242
_______________________________________________
Mapserver-dev mailing list
Mapserver-dev at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-dev
More information about the mapserver-dev
mailing list