예제 #1
0
def test_line_locate_point_invalid_geometry(normalized):
    with pytest.raises(shapely.GEOSException):
        shapely.line_locate_point(line_string,
                                  line_string,
                                  normalized=normalized)

    with pytest.raises(shapely.GEOSException):
        shapely.line_locate_point(polygon, point, normalized=normalized)
예제 #2
0
def test_line_locate_point_empty(normalized):
    assert np.isnan(
        shapely.line_locate_point(line_string,
                                  empty_point,
                                  normalized=normalized))
    assert np.isnan(
        shapely.line_locate_point(empty_line_string,
                                  point,
                                  normalized=normalized))
예제 #3
0
    def project(self, other, normalized=False):
        """Returns the distance along this geometry to a point nearest the
        specified point

        If the normalized arg is True, return the distance normalized to the
        length of the linear geometry.
        """
        return shapely.line_locate_point(self, other, normalized=normalized)
예제 #4
0
def test_line_locate_point_geom_array():
    point = shapely.points(0, 1)
    actual = shapely.line_locate_point([line_string, linear_ring], point)
    np.testing.assert_allclose(actual, [0.0, 3.0])
예제 #5
0
def test_line_locate_point_none(normalized):
    assert np.isnan(
        shapely.line_locate_point(line_string, None, normalized=normalized))
    assert np.isnan(
        shapely.line_locate_point(None, point, normalized=normalized))
예제 #6
0
def test_line_locate_point_geom_array2():
    points = shapely.points([[0, 0], [1, 0]])
    actual = shapely.line_locate_point(line_string, points)
    np.testing.assert_allclose(actual, [0.0, 1.0])