Esempio n. 1
0
File: map.py Progetto: kthyng/GNOME2
    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)
Esempio n. 2
0
File: map.py Progetto: kthyng/GNOME2
    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
Esempio n. 3
0
    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
Esempio n. 4
0
    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
Esempio n. 5
0
File: map.py Progetto: kthyng/GNOME2
    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
Esempio n. 6
0
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)
Esempio n. 7
0
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, )))
Esempio n. 8
0
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