Пример #1
0
    def _process_lat_lon(self, lat, lon):
        """
        Get the lat, lon, and waypoint corresponding to the lat and lon values
        passed in.  If lat contains a point id, then the corresponding point is
        found.  Otherwise, the point closest to (lat, lon) is found.

        @raises: L{BadPointError}

        @param lat: latitude or point to search for
        @type lat: C{string}
        @param lon: longitude to search for
        @type lon: C{string}
        """
        waypoint = None
        if lat.find('.') == -1:
            for pt in self.template_data['seg_dict'][self.options.id].waypoints:
                if pt.id == lat:
                    waypoint = pt
                    lat = pt.lat
                    lon = pt.lon
                    break
            else:
                raise BadPointError(
                    "Matching point for '%s' not found!" % lat)
        else:
            dist = 100000.0
            check_pt = Point(lat, lon)
            for pt in self.template_data['seg_dict'][self.options.id].waypoints:
                t_dist = check_pt.calculate_distance(pt)
                if t_dist < dist:
                    waypoint = pt
                    dist = t_dist

        return lat, lon, waypoint
Пример #2
0
    def __init__(self, lat, lon): 
        """
        The bounding box starts out as just a single point.

        @param lat: latitude of starting point
        @type lat: C{float}
        @param lon: longitude of starting point
        @type lon: C{float}
        """
        Bounds.__init__(self, lat, lon, lat, lon)
        Point.__init__(self, lat, lon)
        self.point_count = 1
        self.index = 0
Пример #3
0
def search_seg(sabx, seg_id, lat, lon):
    """
    Search the indicated segment and find which waypoint is closest to the
    given (lat,lon) point.  Print the result.
    """
    search_pt = Point(lat, lon)
    shortest = 10000.0
    for pt in sabx["seg_dict"][seg_id].waypoints:
        dist = search_pt.calculate_distance(pt)
        if dist < shortest:
            shortest = dist
            id = pt.id

    print "id= %s   distant = %s" % (id, shortest)