Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testMultiPolygon(self):
# with holes
p0 = Polygon(
[(-1, -1), (2, -1), (2, 2), (-1, -1)],
[[(0, 0), (1, 0), (1, 1), (0, 0)]]
)
# without holes
p1 = Polygon([(3, 0), (4, 0), (4, 1), (3, 0)])
g = Geometry(geometry=MultiPolygon([p0, p1]))
self.assertTrue('MultiGeometry' in str(g.to_string()))
self.assertTrue('Polygon' in str(g.to_string()))
self.assertTrue('outerBoundaryIs' in str(g.to_string()))
self.assertTrue('innerBoundaryIs' in str(g.to_string()))
self.assertTrue('LinearRing' in str(g.to_string()))
self.assertTrue(
'coordinates>0.000000,0.000000 1.000000,0.000000 1.000000,1.000000 0.000000,0.000000-1.000000,-1.000000 2.000000,-1.000000 2.000000,2.000000 -1.000000,-1.0000003.000000,0.000000 4.000000,0.000000 4.000000,1.000000 3.000000,0.000000
def testPolygon(self):
# without holes
l = Polygon([(0, 0), (1, 0), (1, 1), (0, 0)])
g = Geometry(geometry=l)
self.assertEqual(g.geometry, l)
self.assertTrue('Polygon' in str(g.to_string()))
self.assertTrue('outerBoundaryIs' in str(g.to_string()))
self.assertFalse('innerBoundaryIs' in str(g.to_string()))
self.assertTrue('LinearRing' in str(g.to_string()))
self.assertTrue(
'coordinates>0.000000,0.000000 1.000000,0.000000 1.000000,1.000000 0.000000,0.000000
def testMultiLineString(self):
l0 = LineString([(0, 0), (1, 0)])
l1 = LineString([(0, 1), (1, 1)])
g = Geometry(geometry=MultiLineString([l0, l1]))
self.assertTrue('MultiGeometry' in str(g.to_string()))
self.assertTrue('LineString' in str(g.to_string()))
self.assertTrue('coordinates>0.000000,0.000000 1.000000,0.0000000.000000,1.000000 1.000000,1.000000
def testLineString(self):
doc = """
0.000000,0.000000 1.000000,1.000000
"""
g = Geometry()
g.from_string(doc)
self.assertEqual(
g.geometry.__geo_interface__,
{'type': 'LineString', 'coordinates': ((0.0, 0.0), (1.0, 1.0))}
)
def test_altitude_mode(self):
doc = """
0.000000,1.000000
clampToGround
"""
g = Geometry()
self.assertEqual(g.altitude_mode, None)
g.from_string(doc)
self.assertEqual(g.altitude_mode, 'clampToGround')
ns=ns,
icon_href=icon,
scale=scale)
flight_style = fastkml.styles.Style(
ns=ns,
styles=[flight_icon_style])
flight_placemark = fastkml.kml.Placemark(
ns=ns,
id=placemark_id,
name=name,
description="",
styles=[flight_style])
flight_placemark.geometry = fastkml.geometry.Geometry(
ns=ns,
geometry=Point(lon, lat, alt),
altitude_mode=_alt_mode)
return flight_placemark
where the ground elevation is 10 meters above sea level,
then the elevation of the coordinate is 19 meters.
A typical use of this mode is for placing telephone
poles or a ski lift.
absolute - Sets the altitude of the coordinate relative to
sea level, regardless of the actual elevation of the
terrain beneath the element. For example, if you set
the altitude of a coordinate to 10 meters with an
absolute altitude mode, the icon of a point placemark
will appear to be at ground level if the terrain beneath
is also 10 meters above sea level. If the terrain is
3 meters above sea level, the placemark will appear
elevated above the terrain by 7 meters. A typical use
of this mode is for aircraft placement.
"""
super(Geometry, self).__init__(ns, id)
self.extrude = extrude
self.tessellate = tessellate
self.altitude_mode = altitude_mode
if geometry:
if isinstance(
geometry,
(
Point, LineString, Polygon,
MultiPoint, MultiLineString, MultiPolygon,
LinearRing, GeometryCollection
)
):
self.geometry = geometry
else:
self.geometry = asShape(geometry)
ns=ns,
color=poly_color)
flight_track_style = fastkml.styles.Style(
ns=ns,
styles=[flight_track_line_style, flight_extrusion_style])
# Generate the Placemark which will contain the track data.
flight_line = fastkml.kml.Placemark(
ns=ns,
id=placemark_id,
name=name,
styles=[flight_track_style])
# Add the track data to the Placemark
flight_line.geometry = fastkml.geometry.Geometry(
ns=ns,
geometry=_flight_geom,
altitude_mode=_alt_mode,
extrude=extrude,
tessellate=tessellate)
return flight_line