Determine if point is within bounding box

This solution also takes in consideration a case in which the UI sends a box which crosses longitude 180/-180 (maps views on low zoom level where you can see the whole world, allow infinite cyclic horizontal scrolling, so it is possible for example that a box's bottomLeft.lng=170 while topRight.lng=-170(=190) and by that including a range of 20 degrees.

def inBoundingBox(bl/*bottom left*/: Coordinates, tr/*top right*/: Coordinates, p: Coordinates): Boolean = {
    // in case longitude 180 is inside the box
    val isLongInRange =
      if (tr.long < bl.long) {
        p.long >= bl.long || p.long <= tr.long
      } else
        p.long >= bl.long && p.long <= tr.long

    p.lat >= bl.lat  &&  p.lat <= tr.lat  &&  isLongInRange
}

Do just as usual:

if( bb.ix <= p.x && p.x <= bb.ax && bb.iy <= p.y && p.y <= bb.ay ) {
    // Point is in bounding box
}

bb is the bounding box, (ix,iy) are its top-left coordinates, and (ax,ay) its bottom-right coordinates. p is the point and (x,y) its coordinates.