예제 #1
0
 def test_from_gca_point(self):
     # Valid Point
     pt = GCA(*gca_vars.gca_pt_components)
     self.assertEqual(geo_json.from_gca(pt), gca_vars.pt_as_json)
     # Valid Linestring
     ls = GCA(*gca_vars.gca_ls_components)
     self.assertEqual(geo_json.from_gca(ls), gca_vars.ls_as_json)
     # Valid Polygon
     poly = GCA(*gca_vars.gca_poly_components)
     self.assertEqual(geo_json.from_gca(poly), gca_vars.poly_as_json)
예제 #2
0
def to_gca(json_str):
    json_str = from_geo_json_validate(json_str)
    json_dict = json.loads(json_str)

    json_type = json_dict['features'][0]['geometry']['type']

    if json_type == "Point":
        return GCA(*to_gca_point_components(json_str))
    elif json_type == "LineString":
        return GCA(*to_gca_linestring_components(json_str))
    elif json_type == "Polygon":
        return GCA(*to_gca_polygon_components(json_str))
    else:
        raise ValueError(
            f"'{json_type}' is not a recognized GeoJSON geometry type")
예제 #3
0
파일: test_csv.py 프로젝트: HFM3/strix
 def test_from_gca_point(self):
     # Valid Point
     pt = GCA(gca_vars.pt_geom, gca_vars.pt_coords, gca_vars.pt_attrs)
     self.assertEqual(csv.from_gca_point(pt), gca_vars.pt_as_csv)
     self.assertEqual(csv.from_gca_point(pt, True),
                      gca_vars.pt_as_csv_xyz_and_geometry_true)
     self.assertEqual(csv.from_gca_point(pt, False, False),
                      gca_vars.pt_as_csv_xyz_and_geometry_false)
예제 #4
0
파일: test_csv.py 프로젝트: HFM3/strix
 def test_from_gca_polygon(self):
     # Valid Linestring
     poly = GCA(gca_vars.poly_geom, gca_vars.poly_coords,
                gca_vars.poly_attrs)
     self.assertEqual(csv.from_gca_polygon(poly), gca_vars.poly_as_csv)
예제 #5
0
파일: test_csv.py 프로젝트: HFM3/strix
 def test_from_gca_linestring(self):
     # Valid Linestring
     ls = GCA(gca_vars.ls_geom, gca_vars.ls_coords, gca_vars.ls_attrs)
     self.assertEqual(csv.from_gca_linestring(ls), gca_vars.ls_as_csv)
예제 #6
0
 def test_from_gca_point(self):
     # Valid Point
     pt = GCA(*gca_vars.gca_pt_components)
     self.assertEqual(egf.from_gca_point(pt), gca_vars.pt_as_egf)
예제 #7
0
 def test_from_gca_polygon(self):
     # Valid Polygon
     poly = GCA(gca_vars.poly_geom, gca_vars.poly_coords,
                gca_vars.poly_attrs)
     self.assertEqual(egf.from_gca_polygon(poly), gca_vars.poly_as_egf)