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"
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'
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)] }
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)], }
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
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
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
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)] }
def test_map_dxf_point(): point = factory.new('POINT', dxfattribs={'location': (0, 0)}) assert geo.mapping(point) == { 'type': 'Point', 'coordinates': (0, 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)], }
def test_map_dxf_point(): point = factory.new("POINT", dxfattribs={"location": (0, 0)}) assert geo.mapping(point) == {"type": "Point", "coordinates": (0, 0)}