def __init__(self, config=None): if config is not None and isinstance(config, Config): self._config = config else: self._config = Config() self._traffic = TrafficClient() self._setup_logging()
def __init__(self, trace): self._config = Config() if isinstance(trace, pd.DataFrame): self._trace = trace.to_dict('records') self._matches = None self._trace = self._trace matches_dict = self._request(use_waypoints=False) if matches_dict['code'] == 'Ok': # todo assert response complies with assumptions matches = MatchResult(**matches_dict) self._matches = self._match_sub_routes(matches) self.trace_index = self._stitch_route_legs(matches) else: self._matches = MatchResult( **{ 'code': 'Ok', 'tracepoints': [None] * len(self._trace), 'matchings': [], 'confidence': 1.0 }) self.trace_index = pd.DataFrame(columns=[ 'route', 'leg', 'edge', 'source', 'target', 'distance_steps', 'distance_annotation', 'duration_steps', 'duration_annotation' ], index=range( 0, len(self._trace))) self.trace_index.route = -1 else: # todo raise type error if not dataframe self._trace = None self._matches = None self.trace_index = None
def __init__(self, bbid=None, mode: str = 'fastest', backend: str = 'here', network=None, traffic: bool = True, terrain: bool = True, weather: bool = True): self._config = Config() # todo enable bbid from postgres if network is None and isinstance(bbid, str): self._network = Network(bbid=bbid) elif isinstance(network, Network): self._network = network else: raise Exception("either network or bbid must be valid") if mode in ['fastest', 'shortest']: self._mode = mode elif mode is None: self._mode = 'fastest' else: raise ValueError("Invalid value " + mode + " for argument mode") if backend in ['here', 'ws', 'osrm', 'mapbox']: self._backend = backend elif backend is None: self._backend = 'here' else: raise ValueError("Invalid value " + backend + " for argument backend") assert isinstance(traffic, bool) self._traffic = traffic assert isinstance(terrain, bool) self._terrain = terrain assert isinstance(weather, bool) self._weather = weather
def __init__(self): self._config = Config() self._base_url = "http://{}:{}/api/v1/lookup".format( self._config.open_elevation["host"], self._config.open_elevation["port"]) self._max_get_size = 90 self._max_post_size = 500
def __init__(self, bucket_name=None): self._config = Config() self._s3 = boto3.resource('s3') self._client = boto3.client('s3') if not bucket_name: self._bucket_name = self._config.s3_bucket else: self._bucket_name = bucket_name
def __init__(self, json=None): self._config = Config() self._json = None self._df = None self._gdf = None if json is not None: self._json = json self._df = TrafficFlow.json_to_df(json) self._gdf = TrafficFlow.json_to_gdf(json)
def __init__(self, latitude: float = None, longitude: float = None, id=None, address: str = None, date_time=None): self._config = Config() assert ((latitude is not None) & (longitude is not None)) ^ (id is not None) ^ (address is not None) if latitude is not None: self._latitude = latitude self._longitude = longitude if id is not None: self._latitude, self._longitude = self._lookup_id(id) if address is not None: self._latitude, self._longitude = self._lookup_address(address) self._datetime = date_time
def __init__(self, config=None): if config is not None: self._config = config else: self._config = Config()
from ws_maps.config import Config import pandas as pd import json import functools import requests import warnings from itertools import groupby import plotly.graph_objects as go import plotly.io as pio import polyline import numpy as np import copy pio.renderers.default = "browser" mapbox_access_token = Config().mapbox class Result(object): """Wrapper for result objects off the OSRM HTTP API Deserialize JSON responses into objects rather than dictionaries, simplifying results validation and manipulation. """ _fields = [] @staticmethod def _init_arg(expected_type, islist, value): if islist and isinstance(value, list): vlist = [] for v in value:
def __init__(self): # start_time = time.time() self._config = Config() self._prefix = "traffic_" self._s3_blobs = Blob()
from ws_maps.tmc import Tmc from ws_maps.network import BBID from ws_maps.s3 import Blob import sys import daemon import logging import datetime import dateutil import time import json import pandas as pd from sqlalchemy import Column, DateTime, String, Integer from sqlalchemy.ext.declarative import declarative_base import time config = Config() r = config.redis Base = declarative_base() class TrafficClient: """This class provides methods to get traffic data for a route or a network, at given times """ def __init__(self): # start_time = time.time() self._config = Config() self._prefix = "traffic_" self._s3_blobs = Blob() # print("traffic client init took {} seconds ---".format((time .time()- start_time)))
from ws_maps.config import Config # from ws_maps.network import Network # import ws_maps.traffic as traffic import datetime import dateutil import pytz from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, Float, BigInteger, create_engine from sqlalchemy.orm import relationship, backref from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker, scoped_session import subprocess import os config = Config() r = config.redis Base = declarative_base() def db_init(): """ """ my_env = os.environ.copy() my_env['TESTING'] = 'true' subprocess.call(['alembic', 'downgrade', 'base'], env=my_env) subprocess.call(['alembic', 'upgrade', 'head'], env=my_env) def init_engine(config):