Ejemplo n.º 1
0
def whentogo():
    gmaps = directions.Directions()

    d = datetime.today()
    l = gmaps.directions(d)

    old_stdout = sys.stdout
    sys.stdout = mystdout = StringIO()

    print "<pre>"
    print gmaps.distance_text, 'normally', gmaps.duration_text
    print 'LEAVE ARRIVE NOTES'
    tz = d.replace(tzinfo=pytz.timezone("UTC")).astimezone(
        pytz.timezone("US/Pacific"))
    print '[now]', (
        tz + timedelta(minutes=gmaps.duration_in_traffic / 60)
    ).strftime("%H:%M"), gmaps.duration_in_traffic_text, gmaps.diffstr
    d = d.replace(d.year, d.month, d.day, d.hour,
                  int(d.minute / 10) * 10, 0, 0) + timedelta(minutes=10)
    for f in range(24):
        td = d + timedelta(minutes=10 * f)
        l = gmaps.directions(td)
        tz = td.replace(tzinfo=pytz.timezone("UTC")).astimezone(
            pytz.timezone("US/Pacific"))
        try:
            print tz.strftime("%H:%M"), (
                tz + timedelta(minutes=gmaps.duration_in_traffic / 60)
            ).strftime("%H:%M"), gmaps.duration_in_traffic_text, gmaps.diffstr
        except Exception, e:
            print "error", repr(e)
Ejemplo n.º 2
0
def hello():

    gmaps = directions.Directions()
    # to make the most useful cached data, we want to make the time rounded but app engine cron can run
    # the script anytime.  So, zero out the end of the time to make it nice.
    dt = datetime.now()
    dt = dt.replace(dt.year, dt.month, dt.day, dt.hour,
                    int(dt.minute / 10) * 10, 0, 0) + timedelta(minutes=10)
    r = gmaps.directions(dt)
    return json.dumps(r)
Ejemplo n.º 3
0
def drawday(td, reverse=False, cache=True):
    memkey = str(td)
    if reverse:
        memkey = memkey + ":reverse"
    d = memcache.get(memkey)
    if d and cache:
        return d

    gmaps = directions.Directions(
        origin=request.cookies.get('origin'),
        destination=request.cookies.get('destination'))

    mapdata = [['Time', 'Expected', 'Delay']]
    if reverse:
        #mapdata = [['Time', 'AM Delay', 'PM Delay']]
        mapdata = [['Time', 'Delay']]

    data = []
    tdata = []
    mindata = []
    prev = None
    td = td.replace(tzinfo=pytz.timezone("UTC")).astimezone(
        pytz.timezone('US/Pacific'))
    td = td.replace(hour=0, minute=0, second=0)
    for f in range(24):
        tdstr = td.strftime("%H:%M")
        directions_result = gmaps.directions(td)
        dur = gmaps.duration / 60
        traffic = gmaps.duration_in_traffic / 60
        pmdelay = traffic - dur
        if pmdelay < 0 and not reverse:
            dur = dur + pmdelay
            pmdelay = pmdelay * -1

        directions_result = gmaps.directions(td, reverse=True)
        dur = gmaps.duration / 60
        traffic = gmaps.duration_in_traffic / 60
        amdelay = traffic - dur
        if amdelay < 0 and not reverse:
            dur = dur + amdelay
            amdelay = amdelay * -1
        delay = max(amdelay, pmdelay)

        if reverse:
            mapdata.append([tdstr, delay])
        else:
            mapdata.append([tdstr, dur, delay])

        td = td + timedelta(hours=1)
    memcache.set(memkey, mapdata)
    return mapdata
Ejemplo n.º 4
0
def hello():
    if request.cookies.get('origin') is None:
        origin = "1200 Crittenden Lane, Mountain View CA"
        destination = "114 El Camino Del Mar, Aptos CA"
    else:
        origin = request.cookies.get('origin')
        destination = request.cookies.get('destination')
    gmaps = directions.Directions(origin=origin, destination=destination)
    l = gmaps.directions(None)
    print "steps", gmaps.leg['steps']
    resp = make_response(render_template('index.html', directions=gmaps))
    # check on the cookies
    if request.cookies.get('origin') is None:
        resp.set_cookie('origin', "1200 Crittenden Lane, Mountain View CA")
        resp.set_cookie('destination', "114 El Camino Del Mar, Aptos CA")

    return resp
Ejemplo n.º 5
0
#    dirs.vykresli(T, window)

"""
edges_of_cell = np.array([300.0, 1.0, 1.0])

graph = draw_arrows.DrawArrows(probabilities.Directions(27, [4, [1.0, 1.0], [86400.0, 604800.0]], '../data/two_weeks_days_nights_weekends_with_dirs.txt'),
                               frequencies.Frequencies(9, edges_of_cell, [2, [1.0, 1.0], [86400.0, 604800.0]], '../data/two_weeks_days_nights_weekends_without_dirs.txt'),
                               edges_of_cell)

for counter, time in enumerate(xrange(0, 86401, int(edges_of_cell[0]))):
    start = clock()
    graph.make_png(time, counter)
    finish = clock()
    print('png created in [seconds]: ' + str(finish - start))
"""


edges_of_cell = np.array([60.0, 1.0, 1.0])
structure1 = [2, [1.0, 1.0, 1.0, 1.0], [21600.0, 43200.0, 86400.0, 604800.0]]
structure2 = [2, [1.0, 1.0], [86400.0, 604800.0]]
graph = draw_arrows.DrawArrows(directions.Directions(9, structure1, '../data/two_weeks_days_nights_weekends_with_angles_plus_reversed.txt'),
                               frequencies.Frequencies(9, edges_of_cell, structure2, '../data/two_weeks_days_nights_weekends_without_dirs.txt'),
                               edges_of_cell)

for counter, time in enumerate(xrange(32100, 68201, int(edges_of_cell[0]))):
    start = clock()
    graph.make_png(time, counter)
    finish = clock()
    print('png created in [seconds]: ' + str(finish - start))

Ejemplo n.º 6
0
Archivo: fetch.py Proyecto: ropeck/map
#!/usr/bin/env python
import googlemaps
from datetime import datetime
from datetime import timedelta
import directions

gmaps = directions.Directions()


def val(d,key='duration_in_traffic'): 
  print d[key]['text']
  return int(d[key]['value'],)

def time_diff(str,dst):
  returning = gmaps.directions(datetime.today())

  return (val(returning) - val(returning,key='duration'))/60


print time_diff("1200 Crittenden Lane, Mountain View CA",
                "114 El Camino Del Mar, Aptos CA")
Ejemplo n.º 7
0
def process(binary_folder_direction, input_folder_direction, output_folder_direction,
            quality_choice, output_type_choice, nb_of_images, **kwargs):
    """ Entry point of the wrapper. Runs the process.

    Arguments
    ----------
    - binary_folder_direction: path to the folder that contains Meshroom binary files
    - input_folder_direction: path to the folder which contains the input images
    - output_folder_direction: path to the folder where the output will be stacked (must exist)
    - quality_choice: quality desired. Must be one of DRAFT, MEDIUM, HIGH
    - output_type_choice: type of output desired. Must be one of POINT_CLOUD, MESH, FILTERED_MESH, TEXTURED_MESH
    - nb_of_images: number of input images
    - kwargs:
        + path_to_results_json_file: path to the results.json file (optional)
        + path_to_metadata_json_file_directory: path to the folder where the metadata.json file will be written (optional)
        + path_to_status_json_file_directory: path to the folder where the status.json file will be written
    """
    # Set setups
    set_setups = setups.Setups(
        quality_choice,
        output_type_choice,
        nb_of_images
        )
    # Set directions
    set_directions = directions.Directions(
        binary_folder_direction,
        input_folder_direction,
        output_folder_direction,
        utils.concat_and_normalize_paths(output_folder_direction, 'log'),
        results_dir=kwargs["path_to_results_json_file"],
        metadata_dir=kwargs["path_to_metadata_json_file_directory"],
        status_dir=kwargs["path_to_status_json_file_directory"]
        )
    # Set pipeline structure
    structure = pipeline_structure.get_the_pipeline_structure(
        set_setups.quality,
        set_setups.output_type
        )

    # Create the log folder to stack the log files
    utils.create_folder(set_directions.log_dir)

    # Initialise the status.json file
    status_dict = {}
    utils.update_json_file(set_directions.status_file, status_dict)

    # Initialize the metadata.json file
    metadata_dict = {
        "global_report": {},
        "step_by_step_report": {}
        }
    utils.update_json_file(set_directions.metadata_file, metadata_dict)

    # Build the pipeline
    pipeline = build_the_pipeline(set_setups, set_directions, structure, status_dict)

    # Run the process
    global_starting_time = time.time()
    for node in pipeline:
        # Run the step
        step_starting_time = time.time()
        node.run_the_node(set_directions.status_file, status_dict)
        step_ending_time = time.time()
        # Stack metadata
        report = node.report()
        metadata_dict["step_by_step_report"][node.name] = {
            "time_taken": step_ending_time - step_starting_time,
            "report": report
            }
        utils.update_json_file(set_directions.metadata_file, metadata_dict)
    global_ending_time = time.time()
    metadata_dict["global_report"]["time_taken"] = global_ending_time - global_starting_time
    utils.update_json_file(set_directions.metadata_file, metadata_dict)

    # Renaming and moving files to fit the given results.json file
    try:
        metadata_dict["global_report"]["results.json_file"] = True
        metadata_dict["global_report"]["output_file_report"] = utils.fitting_the_json_results_file(set_directions)
    except:
        metadata_dict["global_report"]["results.json_file"] = False
        metadata_dict["global_report"]["output_file_report"] = utils.output_file_report(set_directions.get_the_process_directions())

    utils.update_json_file(set_directions.metadata_file, metadata_dict)

    return 0
Ejemplo n.º 8
0
def inject_apikey():
    gmap = directions.Directions()
    return dict(apikey=gmap.key)
Ejemplo n.º 9
0
def main():

    # integrate nunchuk movement here
    # wait for confirmation from Arduino that procedure complete

    objectPickedUp = False

    t1.start()

    while (not cameraEvent.isSet()):
        pass

    while (cameraEvent.isSet()):

        while (cameraEvent.isSet() and not controlsEvent.isSet()):
            pass

        if (controlsEvent.isSet()):

            global toMove

            if (toMove == None):
                break

            else:

                # horizontal movement using the drivetrain
                horizontalDirection = ""
                rotateDirection = ""
                if (toMove[0] < 0):
                    horizontalDirection = "LEFT"
                    rotateDirection = "LEFT"
                else:
                    horizontalDirection = "RIGHT"
                    rotateDirection = "RIGHT"

                pixelsHorizontal = abs(toMove[0])

                rotateAmt = 0
                direction1 = directions.Directions(horizontalDirection,
                                                   rotateDirection,
                                                   pixelsHorizontal, rotateAmt)

                drivetrain_controls.driveToLocation(wp1, wp2, direction1)
                """
				# integrate movements together through concurrency
				# manipulate arm
				verticalDirection = ""
				if (toMove[1] < 0):
					verticalDirection = "UP"
				else:
					verticalDirection = "DOWN"
				
				pixelsVertical = abs(toMove[1])
				
				directions2 = directions(verticalDirection, rotate, pixelsVertical)
				
				arm_controls.levelClaw()
				arm_controls.moveToCenter(directions2)
				"""

                objectPickedUp = False

            controlsEvent.clear()
            cameraEvent.set()

    t1.join()