示例#1
0
def test_map_circle():
    circle = factory.new("CIRCLE")
    m = geo.mapping(circle)
    assert m["type"] == "Polygon"
    assert len(m["coordinates"][0]) == 8
    m = geo.mapping(circle, force_line_string=True)
    assert m["type"] == "LineString"
示例#2
0
def test_map_circle():
    circle = factory.new('CIRCLE')
    m = geo.mapping(circle)
    assert m['type'] == 'Polygon'
    assert len(m['coordinates'][0]) == 8
    m = geo.mapping(circle, force_line_string=True)
    assert m['type'] == 'LineString'
示例#3
0
def test_map_polyline():
    pline = cast('Polyline', factory.new('POLYLINE'))
    pline.append_vertices([(0, 0), (1, 0), (1, 1)])
    pline.close()
    assert geo.mapping(pline) == {
        'type': 'Polygon',
        'coordinates': ([(0, 0), (1, 0), (1, 1), (0, 0)], [])
    }
    assert geo.mapping(pline, force_line_string=True) == {
        'type': 'LineString',
        'coordinates': [(0, 0), (1, 0), (1, 1), (0, 0)]
    }
示例#4
0
def test_map_polyline():
    pline = cast("Polyline", factory.new("POLYLINE"))
    pline.append_vertices([(0, 0), (1, 0), (1, 1)])
    pline.close()
    assert geo.mapping(pline) == {
        "type": "Polygon",
        "coordinates": ([(0, 0), (1, 0), (1, 1), (0, 0)], []),
    }
    assert geo.mapping(pline, force_line_string=True) == {
        "type": "LineString",
        "coordinates": [(0, 0), (1, 0), (1, 1), (0, 0)],
    }
示例#5
0
def test_map_arc():
    arc = factory.new(
        "ARC",
        dxfattribs={
            "start_angle": 0,
            "end_angle": 90,
        },
    )
    m = geo.mapping(arc)
    assert m["type"] == "LineString"
    assert len(m["coordinates"][0]) > 1
示例#6
0
def test_map_hatch():
    hatch = cast(Hatch, factory.new('HATCH', dxfattribs={
        'hatch_style': 0,
    }))
    hatch.paths.add_polyline_path(EXTERIOR, flags=1)  # EXTERNAL
    hatch.paths.add_polyline_path(HOLE1, flags=0)  # DEFAULT
    hatch.paths.add_polyline_path(HOLE2, flags=0)  # DEFAULT
    m = geo.mapping(hatch)
    assert m['type'] == 'Polygon'
    exterior, holes = m['coordinates']
    assert len(exterior) == 5  # vertices
    assert len(holes) == 2
    assert len(holes[0]) == 5  # vertices
    assert len(holes[1]) == 5  # vertices
示例#7
0
def test_map_dxf_polygon(dxftype: str):
    hatch = cast(
        Hatch,
        factory.new(
            dxftype,
            dxfattribs={
                "hatch_style": 0,
            },
        ),
    )
    hatch.paths.add_polyline_path(EXTERIOR, flags=1)  # EXTERNAL
    hatch.paths.add_polyline_path(HOLE1, flags=0)  # DEFAULT
    hatch.paths.add_polyline_path(HOLE2, flags=0)  # DEFAULT
    m = geo.mapping(hatch)
    assert m["type"] == "Polygon"
    exterior, holes = m["coordinates"]
    assert len(exterior) == 5  # vertices
    assert len(holes) == 2
    assert len(holes[0]) == 5  # vertices
    assert len(holes[1]) == 5  # vertices
示例#8
0
def test_map_dxf_line():
    point = factory.new('LINE', dxfattribs={'start': (0, 0), 'end': (1, 0)})
    assert geo.mapping(point) == {
        'type': 'LineString',
        'coordinates': [(0, 0), (1, 0)]
    }
示例#9
0
def test_map_dxf_point():
    point = factory.new('POINT', dxfattribs={'location': (0, 0)})
    assert geo.mapping(point) == {
        'type': 'Point',
        'coordinates': (0, 0)
    }
示例#10
0
def test_map_dxf_line():
    point = factory.new("LINE", dxfattribs={"start": (0, 0), "end": (1, 0)})
    assert geo.mapping(point) == {
        "type": "LineString",
        "coordinates": [(0, 0), (1, 0)],
    }
示例#11
0
def test_map_dxf_point():
    point = factory.new("POINT", dxfattribs={"location": (0, 0)})
    assert geo.mapping(point) == {"type": "Point", "coordinates": (0, 0)}