[mapserver-commits] r10535 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Wed Sep 29 14:18:31 EDT 2010
Author: warmerdam
Date: 2010-09-29 18:18:31 +0000 (Wed, 29 Sep 2010)
New Revision: 10535
Modified:
trunk/mapserver/mapsearch.c
trunk/mapserver/mapserver.h
Log:
Added msRectIntersect()
Modified: trunk/mapserver/mapsearch.c
===================================================================
--- trunk/mapserver/mapsearch.c 2010-09-29 18:15:26 UTC (rev 10534)
+++ trunk/mapserver/mapsearch.c 2010-09-29 18:18:31 UTC (rev 10535)
@@ -8,7 +8,7 @@
* Notes: For information on point in polygon function please see:
*
* http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
- *
+ *
* The appropriate copyright notice accompanies the funtion definition.
*
******************************************************************************
@@ -53,6 +53,28 @@
}
/*
+** Computes the intersection of two rectangles, updating the first
+** to be only the intersection of the two. Returns MS_FALSE if
+** the intersection is empty.
+*/
+int msRectIntersect( rectObj *a, const rectObj *b )
+{
+ if( a->maxx > b->maxx )
+ a->maxx = b->maxx;
+ if( a->minx < b->minx )
+ a->minx = b->minx;
+ if( a->maxy > b->maxy )
+ a->maxy = b->maxy;
+ if( a->miny < b->miny )
+ a->miny = b->miny;
+
+ if( a->maxx < a->minx || b->maxx < b->minx )
+ return MS_FALSE;
+ else
+ return MS_TRUE;
+}
+
+/*
** Returns MS_TRUE if rectangle a is contained in rectangle b
*/
int msRectContained(rectObj *a, rectObj *b)
Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h 2010-09-29 18:15:26 UTC (rev 10534)
+++ trunk/mapserver/mapserver.h 2010-09-29 18:18:31 UTC (rev 10535)
@@ -1739,6 +1739,7 @@
MS_DLL_EXPORT int msPointInRect(pointObj *p, rectObj *rect); /* in mapsearch.c */
MS_DLL_EXPORT int msRectOverlap(rectObj *a, rectObj *b);
MS_DLL_EXPORT int msRectContained(rectObj *a, rectObj *b);
+MS_DLL_EXPORT int msRectIntersect(rectObj *a, const rectObj *b);
MS_DLL_EXPORT void msRectToFormattedString(rectObj *rect, char *format,
char *buffer, int buffer_length);
More information about the mapserver-commits
mailing list