Example #1
0
 def add_noise(self, sigma=0.02):
     for i,rd in enumerate(self.rds):
         lonlat = rd['gps_lonlat']
         angle = random.uniform(0,2 * math.pi)
         r = abs(random.gauss(0,sigma))
         dlat = cg.km2latgap(r * math.sin(angle))
         dlon = cg.km2longap(r * math.cos(angle), lonlat[1])
         self.rds[i]['gps_lonlat'] = (lonlat[0] + dlon, lonlat[1] + dlat)
def rect_of_nodes(nodes, r=1):
    latgap = cg.km2latgap(r)
    longap = cg.km2longap(r, 39.0)
    min_lon = INF
    min_lat = INF
    max_lon = -INF
    max_lat = -INF
    for v in nodes:
        (lon, lat) = gw.nodes_pos[v]
        min_lon = min(min_lon, lon)
        max_lon = max(max_lon, lon)
        min_lat = min(min_lat, lat)
        max_lat = max(max_lat, lat)
    return (min_lon - longap, min_lat - latgap, max_lon + longap, max_lat + latgap)
def rect_of_nodes(nodes, r=1):
    latgap = cg.km2latgap(r)
    longap = cg.km2longap(r, 39.0)
    min_lon = INF
    min_lat = INF
    max_lon = -INF
    max_lat = -INF
    for v in nodes:
        (lon, lat) = gw.nodes_pos[v]
        min_lon = min(min_lon, lon)
        max_lon = max(max_lon, lon)
        min_lat = min(min_lat, lat)
        max_lat = max(max_lat, lat)
    return (min_lon - longap, min_lat - latgap, max_lon + longap,
            max_lat + latgap)