def test_featurecollection2geometry(self): path = os.path.join(TESTDATA, "geojson_input/featurecollection.json") features = vector.read_geojson(path) ans0 = Point((102.0, 0.5), properties={"prop0": "value0"}, crs=self.default_crs) self.assertEqual(features[0], ans0) ans1 = Line([(102.0, 0.0), (103.0, 1.0), (104.0, 0.0), (105.0, 1.0)], properties={ "prop0": "value0", "prop1": 0.0 }, crs=self.default_crs) self.assertEqual(features[1], ans1) ans2 = Polygon([(100.0, 0.0), (101.0, 0.0), (101.0, 1.0), (100.0, 1.0), (100.0, 0.0)], properties={ "prop0": "value0", "prop1": { "this": "that" } }, crs=self.default_crs) self.assertEqual(features[2], ans2) return
def test_geometrycollection2geometry(self): path = os.path.join(TESTDATA, "geojson_input/geometrycollection.json") geoms = vector.read_geojson(path) self.assertEqual(len(geoms), 2) self.assertTrue(isinstance(geoms[0], vector.Point)) self.assertTrue(isinstance(geoms[1], vector.Line)) return
def test_read_capitols(self): path = os.path.join(TESTDATA, "geojson_input/us-capitols.json") features = vector.read_geojson(path) names = [ 'Phoenix, Arizona, United States', 'Sacramento, California, United States', 'Atlanta, Georgia, United States', 'Indianapolis, Indiana, United States', 'Helena, Montana, United States', 'Columbus, Ohio, United States', 'Richmond, Virginia, United States', 'Topeka, Kansas, United States', 'Boston, Massachusetts, United States', 'Lincoln, Nebraska, United States', 'Oklahoma City, Oklahoma, United States', 'Juneau, Alaska, United States', 'Pierre, South Dakota, United States', 'Honolulu, Hawaii, United States', 'Montgomery, Alabama, United States', 'Little Rock, Arkansas, United States', 'Denver, Colorado, United States', 'Hartford, Connecticut, United States', 'Dover, Delaware, United States', 'Washington, District of Columbia, United States', 'Tallahassee, Florida, United States', 'Boise, Idaho, United States', 'Springfield, Illinois, United States', 'Des Moines, Iowa, United States', 'Frankfort, Kentucky, United States', 'Baton Rouge, Louisiana, United States', 'Augusta, Maine, United States', 'Annapolis, Maryland, United States', 'Lansing, Michigan, United States', 'Saint Paul, Minnesota, United States', 'Jackson, Mississippi, United States', 'Jefferson City, Missouri, United States', 'Carson City, Nevada, United States', 'Concord, New Hampshire, United States', 'Trenton, New Jersey, United States', 'Santa Fe, New Mexico, United States', 'Albany, New York, United States', 'Raleigh, North Carolina, United States', 'Bismarck, North Dakota, United States', 'Salem, Oregon, United States', 'Harrisburg, Pennsylvania, United States', 'Providence, Rhode Island, United States', 'Columbia, South Carolina, United States', 'Nashville, Tennessee, United States', 'Austin, Texas, United States', 'Salt Lake City, Utah, United States', 'Montpelier, Vermont, United States', 'Olympia, Washington, United States', 'Charleston, West Virginia, United States', 'Madison, Wisconsin, United States', 'Cheyenne, Wyoming, United States' ] self.assertEqual(names, features[0].data.getfield("n")) return
def test_featurecollection2geometry(self): path = os.path.join(TESTDATA, "geojson_input/featurecollection.json") features = vector.read_geojson(path) ans0 = Point((102.0, 0.5), properties={"prop0":"value0"}, crs=self.crs4326) self.assertEqual(features[0], ans0) ans1 = Line([(102.0, 0.0), (103.0, 1.0), (104.0, 0.0), (105.0, 1.0)], properties={"prop0":"value0", "prop1":0.0}, crs=self.crs4326) self.assertEqual(features[1], ans1) ans2 = Polygon([(100.0, 0.0), (101.0, 0.0), (101.0, 1.0), (100.0, 1.0), (100.0, 0.0)], properties={"prop0":"value0", "prop1":{"this":"that"}}, crs=self.crs4326) self.assertEqual(features[2], ans2) return
def test_read_capitols(self): path = os.path.join(TESTDATA, "geojson_input/us-capitols.json") features = vector.read_geojson(path) names = ['Phoenix, Arizona, United States', 'Sacramento, California, United States', 'Atlanta, Georgia, United States', 'Indianapolis, Indiana, United States', 'Helena, Montana, United States', 'Columbus, Ohio, United States', 'Richmond, Virginia, United States', 'Topeka, Kansas, United States', 'Boston, Massachusetts, United States', 'Lincoln, Nebraska, United States', 'Oklahoma City, Oklahoma, United States', 'Juneau, Alaska, United States', 'Pierre, South Dakota, United States', 'Honolulu, Hawaii, United States', 'Montgomery, Alabama, United States', 'Little Rock, Arkansas, United States', 'Denver, Colorado, United States', 'Hartford, Connecticut, United States', 'Dover, Delaware, United States', 'Washington, District of Columbia, United States', 'Tallahassee, Florida, United States', 'Boise, Idaho, United States', 'Springfield, Illinois, United States', 'Des Moines, Iowa, United States', 'Frankfort, Kentucky, United States', 'Baton Rouge, Louisiana, United States', 'Augusta, Maine, United States', 'Annapolis, Maryland, United States', 'Lansing, Michigan, United States', 'Saint Paul, Minnesota, United States', 'Jackson, Mississippi, United States', 'Jefferson City, Missouri, United States', 'Carson City, Nevada, United States', 'Concord, New Hampshire, United States', 'Trenton, New Jersey, United States', 'Santa Fe, New Mexico, United States', 'Albany, New York, United States', 'Raleigh, North Carolina, United States', 'Bismarck, North Dakota, United States', 'Salem, Oregon, United States', 'Harrisburg, Pennsylvania, United States', 'Providence, Rhode Island, United States', 'Columbia, South Carolina, United States', 'Nashville, Tennessee, United States', 'Austin, Texas, United States', 'Salt Lake City, Utah, United States', 'Montpelier, Vermont, United States', 'Olympia, Washington, United States', 'Charleston, West Virginia, United States', 'Madison, Wisconsin, United States', 'Cheyenne, Wyoming, United States'] self.assertEqual(names, features[0].data.getfield("n")) return
def test_read_with_crs(self): path = os.path.join(TESTDATA, "geojson_input/us-capitols.json") features = vector.read_geojson(path, crs=LonLatWGS84) for f in features: self.assertEqual(f.crs, LonLatWGS84) return
def test_read_scalar_properties(self): path = os.path.join(TESTDATA, "geojson_input/california.geojson") geoms = vector.read_geojson(path) self.assertEqual(geoms[0].properties, {'featurecla': 'Land', 'scalerank': 0}) return