Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_nested_constructors(self):
a = [5, 6]
b = [9, 10]
c = [-5, 12]
mp = geojson.MultiPoint([geojson.Point(a), b])
self.assertEquals(mp.coordinates, [a, b])
mls = geojson.MultiLineString([geojson.LineString([a, b]), [a, c]])
self.assertEquals(mls.coordinates, [[a, b], [a, c]])
outer = [a, b, c, a]
poly = geojson.Polygon(geojson.MultiPoint(outer))
other = [[1, 1], [1, 2], [2, 1], [1, 1]]
poly2 = geojson.Polygon([outer, other])
self.assertEquals(geojson.MultiPolygon([poly, poly2]).coordinates,
[[outer], [outer, other]])
def test_valid_multipoint(self):
mpoint = geojson.MultiPoint([(10, 20), (30, 40)])
self.assertEqual(mpoint.is_valid, True)
def test_nested_constructors(self):
a = [5, 6]
b = [9, 10]
c = [-5, 12]
mp = geojson.MultiPoint([geojson.Point(a), b])
self.assertEquals(mp.coordinates, [a, b])
mls = geojson.MultiLineString([geojson.LineString([a, b]), [a, c]])
self.assertEquals(mls.coordinates, [[a, b], [a, c]])
outer = [a, b, c, a]
poly = geojson.Polygon(geojson.MultiPoint(outer))
other = [[1, 1], [1, 2], [2, 1], [1, 1]]
poly2 = geojson.Polygon([outer, other])
self.assertEquals(geojson.MultiPolygon([poly, poly2]).coordinates,
[[outer], [outer, other]])
def __to_geojson_point(s_geo: icp_model.Geometry):
coordinates = []
for point in s_geo.points:
coordinates.append([point.x, point.y])
if len(coordinates) == 1:
geo = geojson.Point(coordinates=coordinates[0])
else:
geo = geojson.MultiPoint(coordinates=coordinates)
return geo
{valid: 'no', message:'explanation, why this object is not valid'}
Example:
>> point = Point((10,20), (30,40))
>> IsValid(point)
>> {valid: 'yes', message: ''}
"""
if not isinstance(obj, geojson.GeoJSON):
return output('this is not GeoJSON object')
if isinstance(obj, geojson.Point):
if len(obj['coordinates']) not in (2, 3):
return output('the "coordinates" member must be a single position')
if isinstance(obj, geojson.MultiPoint):
if checkListOfObjects(obj['coordinates'], lambda x: len(x) in (2, 3)):
return output(
'the "coordinates" member must be an array of positions'
)
if isinstance(obj, geojson.LineString):
if len(obj['coordinates']) < 2:
return output('the "coordinates" member must be an array '
'of two or more positions')
if isinstance(obj, geojson.MultiLineString):
coord = obj['coordinates']
if checkListOfObjects(coord, lambda x: len(x) >= 2):
return output('the "coordinates" member must be an array '
'of LineString coordinate arrays')
def __init__(self, list_of_tuples):
if not list_of_tuples:
raise ValueError("A MultiPoint cannot be empty")
for t in list_of_tuples:
assert_is_lon(t[0])
assert_is_lat(t[1])
self._geom = geojson.MultiPoint(list_of_tuples)
ret['x'], ret['y'] = coordinates
ret['type'] = 'esriGeometryPoint'
return self._cleanup(ret)
if isinstance(obj, geojson.geometry.LineString):
ret = dict(obj)
path = coordinates
ret['paths'] = [[xy for xy in path]]
ret['type'] = 'esriGeometryPolyline'
ret = self._hasZ(xy, ret)
return self._cleanup(ret)
if isinstance(obj, (geojson.MultiPoint)):
ret = dict(obj)
points = [xy for xy in coordinates]
ret['points'] = points
ret['type'] = 'esriGeometryMultipoint'
ret = self._hasZ(xy, ret)
return self._cleanup(ret)
if isinstance(obj, geojson.MultiLineString):
ret = dict(obj)
paths = coordinates
ret['paths'] = [[xy for xy in p] for p in paths]
ret['type'] = 'esriGeometryPolyline'
ret = self._hasZ(xy, ret)