def test_geojson_with_key(self): """Test for reading GeoJSON files with a key""" for filepath in self.filepaths: records = io.read_geojson(filepath) f = cv.records2geojson(records, key="id") geojson = loads(f.read()) nt.assert_equal("FeatureCollection", geojson["type"]) nt.assert_true("crs" in geojson) nt.assert_equal(self.bbox, geojson["bbox"]) nt.assert_true(geojson["features"]) for feature in geojson["features"]: nt.assert_equal("Feature", feature["type"]) nt.assert_true("id" in feature) nt.assert_less_equal(2, len(feature["properties"])) geometry = feature["geometry"] if geometry["type"] == "Point": nt.assert_equal(2, len(geometry["coordinates"])) elif geometry["type"] == "LineString": nt.assert_equal(2, len(geometry["coordinates"][0])) elif geometry["type"] == "Polygon": nt.assert_equal(2, len(geometry["coordinates"][0][0]))
def test_geojson_with_key(self): """Test for reading GeoJSON files with a key""" for filepath in self.filepaths: records = io.read_geojson(filepath) f = cv.records2geojson(records, key='id') geojson = loads(f.read()) nt.assert_equal('FeatureCollection', geojson['type']) nt.assert_true('crs' in geojson) nt.assert_equal(self.bbox, geojson['bbox']) nt.assert_true(geojson['features']) for feature in geojson['features']: nt.assert_equal('Feature', feature['type']) nt.assert_true('id' in feature) nt.assert_less_equal(2, len(feature['properties'])) geometry = feature['geometry'] if geometry['type'] == 'Point': nt.assert_equal(2, len(geometry['coordinates'])) elif geometry['type'] == 'LineString': nt.assert_equal(2, len(geometry['coordinates'][0])) elif geometry['type'] == 'Polygon': nt.assert_equal(2, len(geometry['coordinates'][0][0]))
def test_geojson_with_crs(self): records = io.read_geojson(self.filepath) f = cv.records2geojson(records, crs='EPSG:4269') geojson = loads(f.read()) nt.assert_true('crs' in geojson) nt.assert_equal('name', geojson['crs']['type']) nt.assert_equal('EPSG:4269', geojson['crs']['properties']['name'])
def test_geojson_with_crs(self): """Test for reading GeoJSON files with CRS""" records = io.read_geojson(self.filepath) f = cv.records2geojson(records, crs="EPSG:4269") geojson = loads(f.read()) nt.assert_true("crs" in geojson) nt.assert_equal("name", geojson["crs"]["type"]) nt.assert_equal("EPSG:4269", geojson["crs"]["properties"]["name"])
def test_geojson(self): expected = { 'id': 6635402, 'iso3': 'ABW', 'bed_prv_pr': Decimal('0.003'), 'ic_mhg_cr': Decimal('0.0246'), 'bed_prv_cr': 0, 'type': 'Point', 'lon': Decimal('-70.0624999987871'), 'lat': Decimal('12.637499976568533')} records = io.read_geojson(self.filepath) record = next(records) nt.assert_equal(expected, record) for record in records: nt.assert_true('id' in record) nt.assert_equal(record['lon'], record['lon']) nt.assert_equal(record['lat'], record['lat'])
def test_geojson(self): expected = { 'id': 6635402, 'iso3': 'ABW', 'bed_prv_pr': Decimal('0.003'), 'ic_mhg_cr': Decimal('0.0246'), 'bed_prv_cr': 0, 'type': 'Point', 'lon': Decimal('-70.0624999987871'), 'lat': Decimal('12.637499976568533') } records = io.read_geojson(self.filepath) record = next(records) nt.assert_equal(expected, record) for record in records: nt.assert_true('id' in record) nt.assert_equal(record['lon'], record['lon']) nt.assert_equal(record['lat'], record['lat'])
def test_geojson(self): """Test for reading GeoJSON files""" expected = { "id": 6635402, "iso3": "ABW", "bed_prv_pr": Decimal("0.003"), "ic_mhg_cr": Decimal("0.0246"), "bed_prv_cr": 0, "type": "Point", "lon": Decimal("-70.0624999987871"), "lat": Decimal("12.637499976568533"), } records = io.read_geojson(self.filepath) record = next(records) nt.assert_equal(expected, record) for record in records: nt.assert_true("id" in record) nt.assert_equal(record["lon"], record["lon"]) nt.assert_equal(record["lat"], record["lat"])