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_point_feature(self):
itr = coords(geojson.Feature(geometry=geojson.Point((-115.81, 37.24))))
self.assertEqual(next(itr), (-115.81, 37.24))
def __init__(self, x, y):
self.x = x
self.y = y
@property
def __geo_interface__(self):
return {'type': 'Point',
'coordinates': (self.x, self.y)}
point_instance = MyPoint(52.235, -19.234)
geojson.dumps(point_instance, sort_keys=True)
###############################################################################
import geojson
my_line = geojson.LineString([(-152.62, 51.21),
(5.21, 10.69)])
my_feature = geojson.Feature(geometry=my_line)
list(geojson.utils.coords(my_feature))
###############################################################################
import geojson
new_point = geojson.utils.map_coords(lambda x: x/2,
geojson.Point((-115.81, 37.24)))
geojson.dumps(new_point, sort_keys=True)
###############################################################################
import geojson
geojson.utils.generate_random("LineString")
def test_featurecollection(self):
p1 = geojson.Feature(geometry=geojson.Point((-115.11, 37.11)))
p2 = geojson.Feature(geometry=geojson.Point((-115.22, 37.22)))
itr = coords(geojson.FeatureCollection([p1, p2]))
pairs = list(itr)
self.assertEqual(pairs[0], (-115.11, 37.11))
self.assertEqual(pairs[1], (-115.22, 37.22))
def test_point(self):
itr = coords(geojson.Point((-115.81, 37.24)))
self.assertEqual(next(itr), (-115.81, 37.24))
def bbox(self):
lats, lngs = zip(*geojson.utils.coords(self.geometry))
return [min(lats), min(lngs), max(lats), max(lngs)]
if len(d_man.label) < min_len:
min_len = len(d_man.label)
feature['properties']['trench-book'] = d_man.label
geometry_type = feature['geometry']['type']
coordinates = feature['geometry']['coordinates']
v_geojson = ValidateGeoJson()
c_ok = v_geojson.validate_all_geometry_coordinates(geometry_type,
coordinates)
if not c_ok:
coordinates = v_geojson.fix_geometry_rings_dir(geometry_type,
coordinates)
feature['geometry']['coordinates'] = coordinates
if geometry_type == 'Polygon':
poly = Polygon(coordinates)
act_feature = geojson.Feature(geometry=poly)
cors = geojson.utils.coords(act_feature)
for cor in cors:
if min_lon is None or min_lon > cor[0]:
min_lon = cor[0]
if max_lon is None or max_lon < cor[0]:
max_lon = cor[0]
if min_lat is None or min_lat > cor[1]:
min_lat = cor[1]
if max_lat is None or max_lat < cor[1]:
max_lat = cor[1]
if combine_json_obj:
feature['properties']['p-uris'] = ''
print('Limit to {}, {} :: {}, {}'.format(
min_lon, min_lat, max_lon, max_lat
))
near_contexts = []
near_uris = []
def get_coords(self):
return geojson.utils.coords(self.feature)