示例#1
0
def get_fake_points(origin, destination):
    all_points.append(origin)
    params = {  'origin': "%s,%s" % (origin[LAT], origin[LON]),
                'destination': "%s,%s" % (destination[LAT], destination[LON]),
                'mode': "driving",
                # 'avoid': "highways",
                'sensor': "false"
                }
    params = net.urlencode(params)
    url = "http://maps.googleapis.com/maps/api/directions/json?" + params
    response = net.read(url)
    directions = json.loads(response)
    try:
        steps = directions['routes'][0]['legs'][0]['steps']  
    except Exception as e:
        print(response)
        exit()    
    points = []
    for i, step in enumerate(steps):
        instruction = step['html_instructions']
        instructions.append(instruction)
        if i != 0:
            point = [step['start_location']['lng'], step['start_location']['lat'], None, None, None]
            points.append(point)
        if i != len(steps) - 1:    
            point = [step['end_location']['lng'], step['end_location']['lat'], None, None, None]
            points.append(point)
    for point in points:
        point[X] = util.scale(point[LON], min_lon, max_lon)
        point[Y] = util.scale(point[LAT], min_lat, max_lat) 
        all_points.append(point)
    all_points.append(destination)               
    return points
示例#2
0
def get_map(city, bounds):

    CLOUDMADE_KEY = "9e44428bdd434d7697b10be5f975b849"
    STYLE_ID = 63595
    ZOOM = 12

    params = {  #'center': "%s,%s" % (city.centroid.lat, city.centroid.lon),
                #'zoom': ZOOM,    
                'bbox': "%s,%s,%s,%s" % (bounds[0].lat, bounds[0].lon, bounds[1].lat, bounds[1].lon),
                'size': "%sx%s" % (SIZE[0], SIZE[1]),
                'format': "png",
                'styleid': STYLE_ID,
                'marker': "size:big|url:%s|opacity:1.0|%s,%s|%s,%s" % ("http://brianhouse.net/download/quotidio_marker.png", bounds[0].lat, bounds[0].lon, bounds[1].lat, bounds[1].lon),
                }
    urlstring = "http://staticmaps.cloudmade.com/%s/staticmap" % CLOUDMADE_KEY
        
    print
    urlstring = "%s?%s" % (urlstring, net.urlencode(params))
    print urlstring
    
    try:    
        net.grab(urlstring, "screenshots/%s_geograph_%s,%s_map.png" % (int(time.time()), city.centroid.lat, city.centroid.lon))
    except Exception as e:
        log.error(log.exc(e))
示例#3
0
            ]


            
total_venues = 0

for anchor in anchors:

    log.info("checking for %s" % anchor)

    # params = {'intent': "browse", 'll': anchor, 'radius': 8000, 'limit': 50, 'client_id': config['foursquare']['key'], 'client_secret': config['foursquare']['secret'], 'v': "20130704"}
    # params = net.urlencode(params)
    # request_string = "https://api.foursquare.com/v2/venues/search?%s" % params

    params = {'ll': anchor, 'radius': 8000, 'limit': 50, 'time': "any", 'day': "any", 'client_id': config['foursquare']['key'], 'client_secret': config['foursquare']['secret'], 'v': "20130704"}
    params = net.urlencode(params)
    request_string = "https://api.foursquare.com/v2/venues/explore?%s" % params

    try:
        response = net.read(request_string)
    except Exception as e:
        log.error(log.exc(e))
        continue
    data = json.loads(response)    
    # print(json.dumps(data, indent=4))
    try:
        venues = data['response']['groups'][0]['items']
        for venue in venues:
            venue = venue['venue']
            checkins = venue['stats']['checkinsCount']
            if checkins == 0:
示例#4
0
STYLE_ID = 63595
WIDTH = 640
HEIGHT = 480
ZOOM = 12

cities = [  (39.7119386606,-104.950620722),
            (40.7241002316,-73.9162034413),
            (41.7252473831,-74.0063800812),
            (44.9335235581,-93.219538549),
            (38.9482655525,-77.0590810776)
            ]


for city in cities:
        
    params = {  'center': "%s,%s" % (city[0], city[1]),
                'zoom': ZOOM,    
                'size': "%sx%s" % (WIDTH, HEIGHT),
                'format': "png",
                'styleid': STYLE_ID
                # 'marker': "size:big|url:%s|opacity:1.0|%s, %s" % ("http://brianhouse.net/download/marker.png", city[0], city[1]),
                }
    urlstring = "http://staticmaps.cloudmade.com/%s/staticmap" % CLOUDMADE_KEY
        
    urlstring = "%s?%s" % (urlstring, net.urlencode(params))
    print urlstring
        
    net.grab(urlstring, "screenshots/maps/map_%s,%s.png" % (city[0], city[1]))
    print "%s,%s" % (city[0], city[1])

示例#5
0
#!/usr/bin/env python3

from housepy import net

d = {'test': 2, 'gain': "high"}

result = net.urlencode(d)

print(result)

result = net.urldecode(result)

print(result)