Exemplo n.º 1
0
def _equals_exact_with_ndim(x, y, tolerance):
    dimension_equals = shapely.get_coordinate_dimension(
        x) == shapely.get_coordinate_dimension(y)
    with np.errstate(invalid="ignore"):
        # Suppress 'invalid value encountered in equals_exact' with nan coordinates
        geometry_equals = shapely.equals_exact(x, y, tolerance=tolerance)
    return dimension_equals & geometry_equals
Exemplo n.º 2
0
def test_from_wkb_point_empty(wkb, expected_type, expected_dim):
    geom = shapely.from_wkb(wkb)
    # POINT (nan nan) transforms to an empty point
    assert shapely.is_empty(geom)
    assert shapely.get_type_id(geom) == expected_type
    # The dimensionality (2D/3D) is only read correctly for GEOS >= 3.9.0
    if shapely.geos_version >= (3, 9, 0):
        assert shapely.get_coordinate_dimension(geom) == expected_dim
Exemplo n.º 3
0
def test_get_coordinate_dimension():
    actual = shapely.get_coordinate_dimension([point, point_z, None]).tolist()
    assert actual == [2, 3, -1]
Exemplo n.º 4
0
def test_force_3d(geom, expected):
    actual = shapely.force_3d(geom, z=4)
    assert shapely.get_coordinate_dimension(actual) == 3
    assert_geometries_equal(actual, expected)
Exemplo n.º 5
0
 def _ndim(self):
     return shapely.get_coordinate_dimension(self)
Exemplo n.º 6
0
def test_apply_remove_z(geom):
    assert shapely.get_coordinate_dimension(geom) == 3
    new_geom = apply(geom, lambda x: x + 1, include_z=False)
    assert shapely.get_coordinate_dimension(new_geom) == 2
Exemplo n.º 7
0
def test_apply_empty_preserve_z(geom):
    assert shapely.get_coordinate_dimension(geom) == 3
    new_geom = apply(geom, lambda x: x + 1, include_z=True)
    assert shapely.get_coordinate_dimension(new_geom) == 3
Exemplo n.º 8
0
def test_apply_correct_coordinate_dimension():
    # ensure that new geometry is 2D with include_z=False
    geom = line_string_z
    assert shapely.get_coordinate_dimension(geom) == 3
    new_geom = apply(geom, lambda x: x + 1, include_z=False)
    assert shapely.get_coordinate_dimension(new_geom) == 2
Exemplo n.º 9
0
def test_transform_remove_z(geom):
    assert shapely.get_coordinate_dimension(geom) == 3
    new_geom = transform(geom, lambda x: x + 1, include_z=False)
    assert shapely.get_coordinate_dimension(new_geom) == 2