def allowable_spill_position(self, coord): """ :param coord: location for test. :type coord: 3-tuple of floats: (long, lat, depth) :return: - True if the point is an allowable spill position - False if the point is not an allowable spill position .. note:: it could be either off the map, or in a location that spills aren't allowed """ return points_in_poly(self.spillable_area, coord)
def on_map(self, coords): """ :param coords: location for test. :type coords: 3-tuple of floats: (long, lat, depth) or a NX3 numpy array :return: bool array: True if the location is on the map, False otherwise Note: coord is 3-d, but the concept of "on the map" is 2-d in this context, so depth is ignored. """ coords = np.asarray(coords, dtype=world_point_type) on_map_mask = points_in_poly(self.map_bounds, coords) return on_map_mask
def allowable_spill_position(self, coord): """ :param coord: location for test. :type coord: 3-tuple of floats: (long, lat, depth) :return: - True if the point is an allowable spill position - False if the point is not an allowable spill position .. note:: it could be either off the map, or in a location that spills aren't allowed """ for poly in self.spillable_area: if points_in_poly(poly.points, coord): return True return False
def allowable_spill_position(self, coord): """ Returns true is the spill position is in the allowable spill area .. note:: This may not be the same as in_water! :param coord: (lon, lat, depth) coordinate """ if self.on_map(coord): if not self.on_land(coord): if self.spillable_area is None: return True else: return points_in_poly(self.spillable_area, coord) else: return False else: return False
def test_points_in_poly_array(): points = np.array(( (0.5, 0.5, 0.0), (1.5, 0.5, 0.0), (0.5, 0.5, 0.0), (0.5, 0.5, 0.0), (-0.5, 0.5, 0.0), (0.5, 0.5, 0.0), )) result = np.array(( True, False, True, True, False, True, )) assert np.array_equal(points_in_poly(poly1, points), result)
def test_points_in_poly_array_one_element(): assert np.array_equal(points_in_poly(poly1, ((0.5, 0.5, 0.0), )), np.array((True, ))) assert np.array_equal(points_in_poly(poly1, ((1.5, -0.5, 0.0), )), np.array((False, )))
def test_points_in_poly_scalar(): assert points_in_poly(poly1, (0.5, 0.5, 0.0)) is True assert points_in_poly(poly1, (1.5, 0.5, 0.0)) is False