Ejemplo n.º 1
0
def test_geometry_coords_rounding():

    # test the rounding of geometry coordinates
    from shapely.geometry import Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon

    precision = 3

    shape1 = Point(1.123456, 2.123456)
    shape2 = ox.round_shape_coords(shape1, precision)

    shape1 = MultiPoint([(1.123456, 2.123456), (3.123456, 4.123456)])
    shape2 = ox.round_shape_coords(shape1, precision)

    shape1 = LineString([(1.123456, 2.123456), (3.123456, 4.123456)])
    shape2 = ox.round_shape_coords(shape1, precision)

    shape1 = MultiLineString([[(1.123456, 2.123456), (3.123456, 4.123456)],
                              [(11.123456, 12.123456), (13.123456, 14.123456)]])
    shape2 = ox.round_shape_coords(shape1, precision)

    shape1 = Polygon([(1.123456, 2.123456), (3.123456, 4.123456), (6.123456, 5.123456)])
    shape2 = ox.round_shape_coords(shape1, precision)

    shape1 = MultiPolygon([Polygon([(1.123456, 2.123456), (3.123456, 4.123456), (6.123456, 5.123456)]),
                           Polygon([(16.123456, 15.123456), (13.123456, 14.123456), (12.123456, 11.123456)])])
    shape2 = ox.round_shape_coords(shape1, precision)
Ejemplo n.º 2
0
def test_geometry_coords_rounding():

    # test the rounding of geometry coordinates
    from shapely.geometry import Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon

    precision = 3

    shape1 = Point(1.123456, 2.123456)
    shape2 = ox.round_shape_coords(shape1, precision)

    shape1 = MultiPoint([(1.123456, 2.123456), (3.123456, 4.123456)])
    shape2 = ox.round_shape_coords(shape1, precision)

    shape1 = LineString([(1.123456, 2.123456), (3.123456, 4.123456)])
    shape2 = ox.round_shape_coords(shape1, precision)

    shape1 = MultiLineString([[(1.123456, 2.123456), (3.123456, 4.123456)],
                              [(11.123456, 12.123456), (13.123456, 14.123456)]])
    shape2 = ox.round_shape_coords(shape1, precision)

    shape1 = Polygon([(1.123456, 2.123456), (3.123456, 4.123456), (6.123456, 5.123456)])
    shape2 = ox.round_shape_coords(shape1, precision)

    shape1 = MultiPolygon([Polygon([(1.123456, 2.123456), (3.123456, 4.123456), (6.123456, 5.123456)]),
                           Polygon([(16.123456, 15.123456), (13.123456, 14.123456), (12.123456, 11.123456)])])
    shape2 = ox.round_shape_coords(shape1, precision)