Changeset 5673
- Timestamp:
- 01/07/08 14:54:44 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Geometry/LinearRing.js
r5614 r5673 213 213 */ 214 214 containsPoint: function(point) { 215 var px = point.x; 216 var py = point.y; 215 var approx = OpenLayers.Number.limitSigDigs; 216 var digs = 14; 217 var px = approx(point.x, digs); 218 var py = approx(point.y, digs); 217 219 function getX(y, x1, y1, x2, y2) { 218 220 return (((x1 - x2) * y) + ((x2 * y1) - (x1 * y2))) / (y1 - y2); … … 223 225 for(var i=0; i<numSeg; ++i) { 224 226 start = this.components[i]; 225 x1 = start.x;226 y1 = start.y;227 x1 = approx(start.x, digs); 228 y1 = approx(start.y, digs); 227 229 end = this.components[i + 1]; 228 x2 = end.x;229 y2 = end.y;230 x2 = approx(end.x, digs); 231 y2 = approx(end.y, digs); 230 232 231 233 /** … … 254 256 continue; 255 257 } 256 cx = getX(py, x1, y1, x2, y2);258 cx = approx(getX(py, x1, y1, x2, y2), digs); 257 259 if(cx == px) { 258 260 // point on line … … 268 270 continue; 269 271 } 270 if( cx < Math.min(x1, x2) || cx > Math.max(x1, x2)) {272 if(x1 != x2 && (cx < Math.min(x1, x2) || cx > Math.max(x1, x2))) { 271 273 // no crossing 272 274 continue; trunk/openlayers/tests/data/geos_wkt_intersects.js
r5458 r5673 489 489 {'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (140 120,80 70)', result:true}, 490 490 {'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (80 170,140 120,200 80)', result:true}, 491 {'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (80 170,140 120,200 80,80 70)', result:true} 491 {'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (80 170,140 120,200 80,80 70)', result:true}, 492 {'wkt1':'POLYGON((-8239529.462853361 4980952.065110421,-8224242.057199065 4980952.065110421,-8224242.057199064 4988844.188279452,-8239529.462853361 4988844.188279452,-8239529.462853361 4980952.065110421))', 'wkt2':'POINT(-8225445.94039435 4982695.78481786)', result:true}, 493 {'wkt1':'POLYGON((-8239529.462853361 4980952.065110421,-8224242.057199065 4980952.065110421,-8224242.057199064 4988844.188279452,-8239529.462853361 4988844.188279452,-8239529.462853361 4980952.065110421))', 'wkt2':'POINT(-8224242.0571985 4982695.78481786)', result:false}, 494 {'wkt1':'POLYGON((-8239529.462853361 4980952.065110421,-8224242.057199065 4980952.065110421,-8224242.057199064 4988844.188279452,-8239529.462853361 4988844.188279452,-8239529.462853361 4980952.065110421))', 'wkt2':'POINT(-8224242.0571995 4982695.78481786)', result:true} 492 495 ];
