def test_get_color_rgba(): expected_color = Color(rgba=RgbaValue(values=[255, 204, 0, 255])) assert get_color("#ffcc00") == expected_color assert get_color(0xFFCC00) == expected_color assert get_color("#ffcc00ff") == expected_color assert get_color(0xFFCC00FF) == expected_color assert get_color([255, 204, 0]) == expected_color assert get_color([255, 204, 0, 255]) == expected_color
def packet_from_point(feat, id_=None): name = feat.get("name", "point_{}".format(id_) if id_ is not None else "point_0") description = feat.get("description", name) color = get_color(feat.get("color", 0xff0000)) point = feat.get_shape(WGS84_CRS) return Packet( id=id_, name=name, description=description, point=Point(color=color, pixelSize=5), position=Position( # this assumes 0 elevation for all points cartographicDegrees=[point.x, point.y, 0]), )
def packet_from_polygon(feat, id_=None): name = feat.get( "name", "polygon_{}".format(id_) if id_ is not None else "polygon_0") description = feat.get("description", name) color = get_color(feat.get("color", 0xff0000)) polygon = feat.get_shape(WGS84_CRS) return Packet( id=id_, name=name, description=description, polygon=Polygon( positions=PositionList(cartographicDegrees=list( flatten_line(fill_height(polygon.exterior.coords)))), material=Material(solidColor=SolidColorMaterial(color=color)), ), )
def test_get_color_invalid_input_raises_error(input): with pytest.raises(ValueError): get_color(input)
def test_get_color_rgbaf(): expected_color = Color(rgbaf=RgbafValue(values=[1.0, 0.8, 0.0, 1.0])) # TODO: Simplify after https://github.com/poliastro/czml3/issues/36 assert get_color([1.0, 0.8, 0.0]) == expected_color assert get_color([1.0, 0.8, 0.0, 1.0]) == expected_color