Esempio n. 1
0
    def load_paths(self):
        for path in self.tc['results']:
            print(path)
            self.paths[path], _ = read_init_path(
                self.tc['results'][path]['gen-path'])
            self.params[path] = json.load(
                open(self.tc['results'][path]['params']))

            if 'flight_path' in self.tc['results'][path]:
                self.flights[path] = read_init_path(
                    test_dict['results'][path_name]['flight_path'])
Esempio n. 2
0
def load_test_case(case_file):
    test_dict = json.load(open(case_file))
    path, pro = read_init_path(test_dict['path'])
    tif, tif_proj = read_tif(test_dict['tif'])
    if "shapes" not in test_dict:
        test_dict['shapes'] = "gen/shapes/{0}.shapes".format(
            splitext(case_file)[0])
        test_dict['alts'] = "gen/shapes/{0}.alt.json".format(
            splitext(case_file)[0])
        save_test_case(case_file, test_dict)

        vecs = vectorize_raster(test_dict['tif'])
        shapes, alt = shapelify_vector(vecs, test_dict['proj'])
        binary = dumps(MultiPolygon(shapes))

        with open(test_dict['shapes'], "wb") as wkb_file:
            wkb_file.write(binary)

        with open(test_dict['alts'], "w") as alt_dict_file:
            json.dump(alt, alt_dict_file)
    else:
        shapes = load_shapefile(test_dict['shapes'])
        alt = load_altfile(test_dict['alts'])

    return path, alt, shapes, tif, pro, tif_proj, test_dict
Esempio n. 3
0
def plot_2d_one(case_name, *plots):
    paths = []
    path, alt, shapes, tif, proj, test_dict = load_test_case(case_name)
    lines = json.load(open(test_dict['lines']))
    print(lines)
    for path_name in plots:
        print(path_name)
        path, _ = read_init_path(test_dict['results'][path_name]['gen-path'])
        path = (path_name, path)
        paths.append(path)
    plot2d(('surface', lines), False, *paths)
Esempio n. 4
0
def plot_3d_one(case_name, *path_names):
    path, alt, shapes, tif, proj, test_dict = load_test_case(case_name)

    raster = rasterio.open('tests/' + test_dict['tif'])
    paths = []

    for path_name in path_names:
        path, _ = read_init_path(test_dict['results'][path_name]['gen-path'])
        paths.append((path_name, path))

    plot3d(tif, raster, proj, *paths)
Esempio n. 5
0
def perform_comparisons(test_case, base, *paths):
    base, base_name = base
    for path_name in paths:
        path, _ = read_init_path(test_case['results'][path_name]['gen-path'])
        print_comparison_info(base, path, base_name, path_name)
Esempio n. 6
0
def compare_to_base(case_name, base, *paths):
    path, alt, shapes, tif, proj, test_dict = load_test_case(case_name)
    base_name = base
    base, _ = read_init_path(base)

    perform_comparisons(test_dict, (base, base_name), *paths)
Esempio n. 7
0
def compare_to_flight(case_name, path_name):
    path, alt, shapes, tif, proj, test_dict = load_test_case(case_name)
    flight, _ = read_init_path(test_dict['results'][path_name]['flight_path'])

    perform_comparisons(test_dict, (flight, "flight"), path_name)
Esempio n. 8
0
        "buffer",
        metavar="buffer",
        type=float,
        help="amount of space to leave between surface and path in meters")
    parser.add_argument("--bare-earth-geotiff",
                        type=str,
                        help="Contains the geotiff to generate the files from",
                        required=False)
    parser.add_argument("--canopy-geotiff",
                        type=str,
                        help="Contains the geotiff to generate the files from",
                        required=False)

    args = parser.parse_args()

    miss_waypoints, proj = read_init_path(args.path_file)

    if args.bare_earth_geotiff:

        vectors = get_vector_from_raster(args.geotif)
        be_shapes, be_alt_dict = get_shapes_from_vector(vectors)

        binary = dumps(MultiPolygon(shapes))

        with open("gen/" + args.bare_earth_geotiff + ".shapes",
                  "wb") as wkb_file:
            wkb_file.write(binary)

        with open("gen/" + args.bare_earth_geotiff + ".alt.json",
                  "w") as alt_dict_file:
            json.dump(alt_dict, alt_dict_file)