示例#1
0
 def viewshed():
     IMAGE_DATA = load_image_data(get_filename())
     viewshed_complete = generate_viewshed(IMAGE_DATA)
     if viewshed_complete:
         return ("", 204)
     else:
         return "<h4>Could Not Create Viewshed</h4>"
示例#2
0
 def rendering():
     IMAGE_DATA = load_image_data(get_filename())
     render_complete = render_height(IMAGE_DATA)
     if render_complete:
         return ("", 204)
     else:
         return "<h4>Render Failed</h4>"
示例#3
0
 def mtn_lookup(pano_filename, gpx_path, interactive):
     im_data = load_image_data(pano_filename)
     if im_data is not None:
         mountains_3d, images_3d, visible_hikes = mountain_lookup(
             im_data, gpx_path, interactive)
         gpx = gpx_path.split("/")[-1].split(".")[0]
         hs = create_hotspots(mountains_3d, images_3d, visible_hikes)
         im_data.add_hotspots(gpx, hs)
         save_image_data(im_data)
示例#4
0
 def gpsc():
     IMAGE_DATA = load_image_data(get_filename())
     if request.method == "POST":
         pano_coords = request.form.get("pano-coords")
         pano_coords = strip_array(pano_coords)
         return redirect(
             url_for(
                 "srcoords",
                 render_path=IMAGE_DATA.render_path,
                 pano_coords=str(pano_coords),
             ))
     return ("", 404)
示例#5
0
def create_hotspots(mountains_3d, images_3d, visible_hikes):
    hotspots = {}
    mountain_hotpots = {}
    for mountain in mountains_3d:
        mountain_hotpots.update({
            str(mountain.name): {
                "yaw": float(mountain.location_in_3d.yaw),
                "pitch": mountain.location_in_3d.pitch,
                "distance": mountain.location_in_3d.distance,
                "elevation": mountain.location.elevation,
                "url": mountain.link,
            }
        })
    image_hotpots = {}
    for image in images_3d:
        im_data = load_image_data(image.name)
        if im_data is not None:
            image_hotpots.update({
                str(image.name): {
                    "text": image.name[0:-9],
                    "imageTooltip":
                    f"<div class='panorama-image-div'><img class='panorama-image' src='{im_data.thumbnail_path}'></div>",
                    "sceneId": image.name,
                    "yaw": float(image.location_in_3d.yaw),
                    "pitch": image.location_in_3d.pitch,
                    "distance": image.location_in_3d.distance,
                }
            })
    hike_hotspots = {}
    for hike, waypoints in visible_hikes.items():
        hike_waypoints = []
        for wp in waypoints:
            hike_waypoints.append({
                "id": wp.id,
                "yaw": float(wp.location_in_3d.yaw),
                "pitch": wp.location_in_3d.pitch,
                "distance": wp.location_in_3d.distance,
                "elevation": wp.location.elevation,
            })
        hike_hotspots.update({hike: hike_waypoints})
    hotspots.update({
        "mountains": mountain_hotpots,
        "images": image_hotpots,
        "hikes": hike_hotspots,
    })
    return hotspots
示例#6
0
def verify_image_data(im):
    im_data = load_image_data(im)
    if im_data is None:
        return False
    if im_data.render_path is None:
        return False
    if im_data.view_direction is None:
        return False
    if im_data.ultrawide_path is None:
        return False
    if im_data.overlay_path is None:
        return False
    if im_data.hotspots is None:
        return False
    if im_data.warped_panorama_path is None:
        return False
    return True
示例#7
0
 def srcoords():
     IMAGE_DATA = load_image_data(get_filename())
     pano_coords = request.args.get("pano_coords")
     with Image.open(IMAGE_DATA.render_path) as img:
         width, height = img.size
         img.close()
     horizontal_fov = 360
     vertical_fov = 180
     return render_template(
         "render_select_coords.html",
         render_path=IMAGE_DATA.render_path,
         rwidth=width,
         rheight=height,
         horizontal_fov=horizontal_fov,
         vertical_fov=vertical_fov,
         pano_coords=pano_coords,
     )
示例#8
0
    def spcoords():
        IMAGE_DATA = load_image_data(get_filename())

        with Image.open(IMAGE_DATA.path) as img:
            width, height = img.size
            img.close()
        horizontal_fov = 450 * (height / width)
        vertical_fov = 150 * (height / width)
        return render_template(
            "pano_select_coords.html",
            pano_path=IMAGE_DATA.path,
            render_path=IMAGE_DATA.render_path,
            pwidth=width,
            pheight=height,
            horizontal_fov=horizontal_fov,
            vertical_fov=vertical_fov,
        )
示例#9
0
def make_scenes(gpx_filename, images=None):
    scenes = {}
    for filename in images:
        im_data = load_image_data(filename)
        hs_name = f"{im_data.filename}-{gpx_filename}"
        im_hs = im_data.hotspots.get(hs_name, None)

        if im_hs is not None:
            scenes[filename] = {
                "hotspots": im_hs,
                "render_path": im_data.render_path,
                "view_direction": im_data.view_direction,
                "cropped_render_path": im_data.ultrawide_path,
                "cropped_overlay_path": im_data.overlay_path,
                "warped_panorama_path": im_data.warped_panorama_path,
                "place_name": im_data.place_name,
                "elevation": str(im_data.place_elevation),
            }
    return scenes
示例#10
0
    def homepage():
        ims = get_seen_items()
        i = []
        for im in ims:
            im_data = load_image_data(im)
            if im_data:
                i.append([im_data.filename, im_data.thumbnail_path])
        gpx = session.get("gpx_path", "None selected")
        if gpx != "None selected":
            gpx = gpx.split("/")[-1]
        interactive = session.get("interactive", False)
        uploaded_hikes = [
            f"{x.split('/')[-1].split('.')[0]}" for x in get_files(SEEN_HIKES)
        ]

        return render_template("home.html",
                               ims=i,
                               gpx=gpx,
                               hikes=uploaded_hikes,
                               folium=interactive)
示例#11
0
    def transform():
        IMAGE_DATA = load_image_data(get_filename())
        session["filename"] = IMAGE_DATA.filename

        pano_coords = strip_array(request.args.get("pano_coords"), True)
        render_coords = strip_array(request.args.get("render_coords"), True)

        IMAGE_DATA = transform_panorama(IMAGE_DATA, pano_coords, render_coords)
        if not IMAGE_DATA:
            return "<h4>Transform failed because of an unequal amount of sample points in the panorama and render ...</h4>"

        save_image_data(IMAGE_DATA)
        session["filename"] = IMAGE_DATA.filename

        mark_image_seen(IMAGE_DATA)
        return render_template(
            "preview_warped.html",
            warped=IMAGE_DATA.overlay_path,
            render=IMAGE_DATA.ultrawide_path,
            pano_id=IMAGE_DATA.filename,
        )
示例#12
0
 def mountains():
     ims = get_seen_items()
     i = []
     for im in ims:
         if verify_image_data(im):
             i.append(im)
         else:
             remove_image_as_seen(im)
     if len(i) == 0:
         return "<h4>No images found</h4>"
     IMAGE_DATA = load_image_data(i[-1])
     gpx_filename = session.get("gpx_path",
                                None).split("/")[-1].split(".")[0]
     scenes = make_scenes(gpx_filename, i)
     interactive = session.get("interactive", False)
     return render_template(
         "view_mountains.html",
         scenes=scenes,
         defaultScene=IMAGE_DATA.filename,
         gpx=gpx_filename,
         interactive=interactive,
     )
示例#13
0
    def upload():

        if request.method == "POST":
            f = request.files["file"]
            filename = secure_filename(f.filename)
            f_hash = hashlib.md5(filename.encode("utf-8")).hexdigest()[-8:]
            fn, ft = filename.split(".")
            filename_h = f"{fn}-{f_hash}.{ft}"
            fp = f"{UPLOAD_FOLDER}images/"
            make_folder(fp)
            IMG_UPLOAD_FOLDER = f"{fp}{filename_h.split('.')[0]}/"
            session["img_folder"] = IMG_UPLOAD_FOLDER
            pano_path = f"{IMG_UPLOAD_FOLDER}{filename_h}"

            make_folder(UPLOAD_FOLDER)
            make_folder(IMG_UPLOAD_FOLDER)

            IMAGE_DATA = load_image_data(filename_h.split(".")[0])
            if IMAGE_DATA is None:
                IMAGE_DATA = ImageData(pano_path)
                save_image_data(IMAGE_DATA)

            session["filename"] = IMAGE_DATA.filename
            mark_image_seen(IMAGE_DATA)

            if not os.path.exists(IMAGE_DATA.path):
                f.save(IMAGE_DATA.path)
                reduce_filesize(IMAGE_DATA.path)

            im_view_direction = get_exif_gsp_img_direction(IMAGE_DATA.path)

            if im_view_direction is not None:
                IMAGE_DATA.view_direction = im_view_direction
                save_image_data(IMAGE_DATA)

                if os.path.exists(IMAGE_DATA.render_path):
                    return redirect(url_for("homepage"))
            return redirect(url_for("spcoords"))