Пример #1
0
    if args.debug:
        _log.setLevel(logging.DEBUG)
        logging.getLogger('geotiler.tilenet').setLevel(logging.DEBUG)

    gpx = gpxpy.parse(args.gpx_file)

    # Join all the points from all segments for the track into a single list
    gpx_points = [p for s in gpx.tracks[0].segments for p in s.points]

    # Calculate map bounding box with padding
    padding_pct = 10
    bounds = gpx.get_bounds()
    bbox = gfx.add_padding((bounds.min_longitude, bounds.min_latitude,
                            bounds.max_longitude, bounds.max_latitude), 10)

    # Draw the original track
    gpx_surface = gfx.draw_track(gpx_points, bbox)
    gpx_img_filename = "original.png"
    _log.info("Saving original track to '{}'".format(gpx_img_filename))
    gpx_surface.write_to_png(gpx_img_filename)

    # Evenly distribute the points
    gpx_points = geo.interpolate_distance(gpx_points, args.even)

    # Draw the distributed track
    gpx_surface = gfx.draw_track(gpx_points, bbox)
    gpx_img_filename = "even.png"
    _log.info("Saving original track to '{}'".format(gpx_img_filename))
    gpx_surface.write_to_png(gpx_img_filename)
Пример #2
0
    a1, a2 = align_tracks(gpx1_points, gpx2_points, gap_penalty)

    # Calculate map bounding box with padding
    padding_pct = 10
    bounds1 = gpx1.get_bounds()
    bounds2 = gpx2.get_bounds()
    bbox1 = gfx.add_padding((bounds1.min_longitude, bounds1.min_latitude,
                             bounds1.max_longitude, bounds1.max_latitude), 10)
    bbox2 = gfx.add_padding((bounds2.min_longitude, bounds2.min_latitude,
                             bounds2.max_longitude, bounds2.max_latitude), 10)
    bbox = (min(bbox1[0], bbox2[0]), min(bbox1[1], bbox2[1]),
            max(bbox1[2], bbox2[2]), max(bbox1[3], bbox2[3]))

    # Draw tracks and alignment
    if args.separate_tracks:
        gpx1_surface = gfx.draw_track(gpx1_points, bbox1)
        gpx1_img_filename = "{}.png".format(
            os.path.basename(os.path.splitext(args.gpx_file1.name)[0]))
        _log.info("Saving original track to '{}'".format(gpx1_img_filename))
        gpx1_surface.write_to_png(gpx1_img_filename)

        gpx2_surface = gfx.draw_track(gpx2_points, bbox2)
        gpx2_img_filename = "{}.png".format(
            os.path.basename(os.path.splitext(args.gpx_file2.name)[0]))
        _log.info("Saving original track to '{}'".format(gpx2_img_filename))
        gpx2_surface.write_to_png(gpx2_img_filename)

    surface = draw_alignment(a1, a2, bbox)
    _log.info("Saving alignment to '{}'".format(args.output_file))
    surface.write_to_png(args.output_file)
Пример #3
0
    a1, a2 = align_tracks(gpx1_points, gpx2_points, gap_penalty)

    # Calculate map bounding box with padding
    padding_pct = 10
    bounds1 = gpx1.get_bounds()
    bounds2 = gpx2.get_bounds()
    bbox1 = gfx.add_padding((bounds1.min_longitude, bounds1.min_latitude,
                             bounds1.max_longitude, bounds1.max_latitude), 10)
    bbox2 = gfx.add_padding((bounds2.min_longitude, bounds2.min_latitude,
                             bounds2.max_longitude, bounds2.max_latitude), 10)
    bbox = (min(bbox1[0], bbox2[0]), min(bbox1[1], bbox2[1]),
            max(bbox1[2], bbox2[2]), max(bbox1[3], bbox2[3]))

    # Draw tracks and alignment
    if args.separate_tracks:
        gpx1_surface = gfx.draw_track(gpx1_points, bbox1)
        gpx1_img_filename = "{}.png".format(
            os.path.basename(os.path.splitext(args.gpx_file1.name)[0]))
        _log.info("Saving original track to '{}'".format(gpx1_img_filename))
        gpx1_surface.write_to_png(gpx1_img_filename)

        gpx2_surface = gfx.draw_track(gpx2_points, bbox2)
        gpx2_img_filename = "{}.png".format(
            os.path.basename(os.path.splitext(args.gpx_file2.name)[0]))
        _log.info("Saving original track to '{}'".format(gpx2_img_filename))
        gpx2_surface.write_to_png(gpx2_img_filename)

    surface = draw_alignment(a1, a2, bbox)
    _log.info("Saving alignment to '{}'".format(args.output_file))
    surface.write_to_png(args.output_file)