@@ -322,15 +322,17 @@ Bbox::contains(const Py::Tuple &args) {
322322}
323323
324324Py::Object
325- Bbox::overlaps (const Py::Tuple &args) {
325+ Bbox::overlaps (const Py::Tuple &args, const Py::Dict &kwargs ) {
326326 _VERBOSE (" Bbox::overlaps" );
327327 args.verify_length (1 );
328328
329329 if (! check (args[0 ]))
330330 throw Py::TypeError (" Expected a bbox" );
331331
332- int x = Py::Int ( overlapsx (args) );
333- int y = Py::Int ( overlapsy (args) );
332+
333+
334+ int x = Py::Int ( overlapsx (args, kwargs) );
335+ int y = Py::Int ( overlapsy (args, kwargs) );
334336 return Py::Int (x&&y);
335337}
336338
@@ -343,13 +345,18 @@ Bbox::ignore(const Py::Tuple &args) {
343345}
344346
345347Py::Object
346- Bbox::overlapsx (const Py::Tuple &args) {
348+ Bbox::overlapsx (const Py::Tuple &args, const Py::Dict &kwargs ) {
347349 _VERBOSE (" Bbox::overlapsx" );
348350 args.verify_length (1 );
349351
350352 if (! check (args[0 ]))
351353 throw Py::TypeError (" Expected a bbox" );
352354
355+ int ignoreend = false ;
356+ if (kwargs.hasKey (" ignoreend" )) {
357+ ignoreend = Py::Int (kwargs[" ignoreend" ]);
358+ }
359+
353360 Bbox* other = static_cast <Bbox*>(args[0 ].ptr ());
354361
355362 double minx = _ll->xval ();
@@ -358,20 +365,34 @@ Bbox::overlapsx(const Py::Tuple &args) {
358365 double ominx = other->_ll ->xval ();
359366 double omaxx = other->_ur ->xval ();
360367
361- int b = ( ( (ominx>=minx) && (ominx<=maxx)) ||
362- ( (minx>=ominx) && (minx<=omaxx)) );
368+ int b=0 ;
369+ if (ignoreend) {
370+ b = ( ( (ominx>minx) && (ominx<maxx)) ||
371+ ( (minx>ominx) && (minx<omaxx)) );
372+ }
373+ else {
374+ b = ( ( (ominx>=minx) && (ominx<=maxx)) ||
375+ ( (minx>=ominx) && (minx<=omaxx)) );
376+
377+ }
363378 return Py::Int (b);
364379
365380}
366381
367382Py::Object
368- Bbox::overlapsy (const Py::Tuple &args) {
383+ Bbox::overlapsy (const Py::Tuple &args, const Py::Dict &kwargs ) {
369384 _VERBOSE (" Bbox::overlapsy" );
370385 args.verify_length (1 );
371386
372387 if (! check (args[0 ]))
373388 throw Py::TypeError (" Expected a bbox" );
374389
390+
391+ int ignoreend = false ;
392+ if (kwargs.hasKey (" ignoreend" )) {
393+ ignoreend = Py::Int (kwargs[" ignoreend" ]);
394+ }
395+
375396 Bbox* other = static_cast <Bbox*>(args[0 ].ptr ());
376397
377398 double miny = _ll->yval ();
@@ -381,9 +402,16 @@ Bbox::overlapsy(const Py::Tuple &args) {
381402 double omaxy = other->_ur ->yval ();
382403
383404
405+ int b=0 ;
406+ if (ignoreend) {
407+ b = ( ( (ominy>miny) && (ominy<maxy)) ||
408+ ( (miny>ominy) && (miny<omaxy)) );
409+ }
410+ else {
411+ b = ( ( (ominy>=miny) && (ominy<=maxy)) ||
412+ ( (miny>=ominy) && (miny<=omaxy)) );
384413
385- int b = ( ( (ominy>=miny) && (ominy<=maxy)) ||
386- ( (miny>=ominy) && (miny<=omaxy)) );
414+ }
387415 return Py::Int (b);
388416
389417}
@@ -2203,9 +2231,9 @@ Bbox::init_type()
22032231 add_varargs_method (" ur" , &Bbox::ur, " ur()\n " );
22042232 add_varargs_method (" contains" , &Bbox::contains, " contains(x,y)\n " );
22052233 add_varargs_method (" count_contains" , &Bbox::count_contains, " count_contains(xys)\n " );
2206- add_varargs_method (" overlaps" , &Bbox::overlaps, " overlaps(bbox)\n " );
2207- add_varargs_method (" overlapsx" , &Bbox::overlapsx, " overlapsx(bbox)\n " );
2208- add_varargs_method (" overlapsy" , &Bbox::overlapsy, " overlapsy(bbox)\n " );
2234+ add_keyword_method (" overlaps" , &Bbox::overlaps, " overlaps(bbox)\n " );
2235+ add_keyword_method (" overlapsx" , &Bbox::overlapsx, " overlapsx(bbox)\n " );
2236+ add_keyword_method (" overlapsy" , &Bbox::overlapsy, " overlapsy(bbox)\n " );
22092237 add_varargs_method (" intervalx" , &Bbox::intervalx, " intervalx()\n " );
22102238 add_varargs_method (" intervaly" , &Bbox::intervaly, " intervaly()\n " );
22112239
0 commit comments