コード例 #1
0
def setup(cfg):
    tripkit = TripKit(config=cfg)
    tripkit.setup(force=False)
    return tripkit
コード例 #2
0
# run from parent directory
import os
import sys
import tripkit_config_itinerum as cfg

sys.path[0] = os.path.abspath(os.path.pardir)
os.chdir(os.path.pardir)
# begin
import logging
from tripkit import TripKit

logging.basicConfig(level=logging.INFO)
logging.getLogger('itinerum-tripkit').setLevel(level=logging.DEBUG)

# Edit ./tripkit_config.py first!
tripkit = TripKit(config=cfg)
tripkit.setup()

# -- Load user trip from database and write as GIS-compatible file
users = tripkit.load_users(load_trips=False)

parameters = {
    'subway_entrances': tripkit.database.load_subway_entrances(),
    'break_interval_seconds': cfg.TRIP_DETECTION_BREAK_INTERVAL_SECONDS,
    'subway_buffer_meters': cfg.TRIP_DETECTION_SUBWAY_BUFFER_METERS,
    'cold_start_distance': cfg.TRIP_DETECTION_COLD_START_DISTANCE_METERS,
    'accuracy_cutoff_meters': cfg.TRIP_DETECTION_ACCURACY_CUTOFF_METERS,
}
for user in users:
    user.trips = tripkit.process.trip_detection.triplab.v2.algorithm.run(
        user.coordinates, parameters)
コード例 #3
0
import os
import sys
import tripkit_config_itinerum as cfg

sys.path[0] = os.path.abspath(os.path.pardir)
os.chdir(os.path.pardir)
# begin
import logging
from datetime import datetime
from tripkit import TripKit

logging.basicConfig(level=logging.INFO)
logging.getLogger('itinerum-tripkit').setLevel(level=logging.DEBUG)

# Edit ./tripkit_config.py first!
tripkit = TripKit(config=cfg)

# -- Stage 1: load platform data to cache if surveys responses table does not exist
tripkit.setup(force=False)
users = tripkit.load_users(limit=10, load_trips=False)

# -- Stage 2: perform trip detection via library algorithms
parameters = {
    'subway_entrances': tripkit.database.load_subway_entrances(),
    'break_interval_seconds': cfg.TRIP_DETECTION_BREAK_INTERVAL_SECONDS,
    'subway_buffer_meters': cfg.TRIP_DETECTION_SUBWAY_BUFFER_METERS,
    'cold_start_distance': cfg.TRIP_DETECTION_COLD_START_DISTANCE_METERS,
    'accuracy_cutoff_meters': cfg.TRIP_DETECTION_ACCURACY_CUTOFF_METERS,
}
for idx, user in enumerate(users, start=1):
    print("Processing user ({}) trips: {}/{}...".format(
コード例 #4
0
import os
import sys
import tripkit_config_itinerum as cfg

sys.path[0] = os.path.abspath(os.path.pardir)
os.chdir(os.path.pardir)
### begin
from collections import namedtuple
import logging
from tripkit import TripKit, utils

logging.basicConfig(level=logging.INFO)
logging.getLogger('itinerum-tripkit').setLevel(level=logging.DEBUG)

# 1. load itinerum data to database
tripkit = TripKit(config=cfg)
tripkit.setup(force=False)

# 2. write GIS-compatible outputs of input data
user = tripkit.load_users(uuid='bcb6958f-7b86-43ce-b8f8-8794e4cb18b6')
tripkit.io.shapefile.write_inputs(
    fn_base=user.uuid,
    coordinates=user.coordinates,
    prompts=user.prompt_responses,
    cancelled_prompts=user.cancelled_prompt_responses,
)

# 3. detect trips on data and write a GIS-compatible output
parameters = {
    'subway_entrances': tripkit.database.load_subway_entrances(),
    'break_interval_seconds': cfg.TRIP_DETECTION_BREAK_INTERVAL_SECONDS,
コード例 #5
0
#!/usr/bin/env python
# Kyle Fitzsimmons, 2018-2019

# run from parent directory
import os
import sys
import tripkit_config_itinerum as cfg

sys.path[0] = os.path.abspath(os.path.pardir)
os.chdir(os.path.pardir)
# begin
import logging
from tripkit import TripKit

logging.basicConfig(level=logging.INFO)
logging.getLogger('itinerum-tripkit').setLevel(level=logging.DEBUG)


# Edit ./tripkit_config.py first!
tripkit = TripKit(config=cfg)
tripkit.setup()

# -- Load user trip from database and write as GIS file
print('Writing cached database trip to .gpkg file...')
user = tripkit.load_users(uuid='00807c5b-7542-4868-8462-14b79a9fcc9f')
tripkit.io.geopackage.write_trips(fn_base=user.uuid, trips=user.trips)
コード例 #6
0
# run from parent directory
import os
import sys
import tripkit_config_qstarz as cfg

sys.path[0] = os.path.abspath(os.path.pardir)
os.chdir(os.path.pardir)
# begin
import logging
from tripkit import TripKit

logging.basicConfig(level=logging.INFO)
logging.getLogger('itinerum-tripkit').setLevel(level=logging.DEBUG)

# 1. load itinerum data to database
tripkit = TripKit(config=cfg)
tripkit.setup(force=False)

# 2. write GIS-compatible outputs of input data
user = tripkit.load_user_by_orig_id(orig_id=1)
tripkit.io.shapefile.write_inputs(
    fn_base=user.uuid,
    coordinates=user.coordinates,
    prompts=user.prompt_responses,
    cancelled_prompts=user.cancelled_prompt_responses,
)

# 2.1. clean out junk input data
## about 90% of provided points seem to be junk, many with the exact
## same lat/lon 1-sec apart with 0-values for accelerations. Clean these
## to properly test point-to-point speed
コード例 #7
0
import os
import sys
import tripkit_config_itinerum as cfg

sys.path[0] = os.path.abspath(os.path.pardir)
os.chdir(os.path.pardir)
# begin
import logging
from tripkit import TripKit, utils
from tripkit.models import ActivityLocation

logging.basicConfig(level=logging.INFO)
logging.getLogger('itinerum-tripkit').setLevel(level=logging.DEBUG)

# -- main
tripkit = TripKit(config=cfg)
tripkit.setup()
users = tripkit.load_users(limit=1)

# perform activity detection on all user points
daily_activity_summaries = []
for idx, user in enumerate(users, start=1):
    # determine the locations to associate with coordinates as activities
    locations = utils.itinerum.create_activity_locations(user)
    tripkit.io.geojson.write_activity_locations(fn_base=user.uuid,
                                                locations=locations)

    complete_day_summaries = tripkit.process.complete_days.triplab.counter.run(
        user.trips, cfg.TIMEZONE)
    activity = tripkit.process.activities.triplab.detect.run(
        user, locations, cfg.ACTIVITY_LOCATION_PROXIMITY_METERS)
import os
import sys
import tripkit_config_itinerum as cfg

sys.path[0] = os.path.abspath(os.path.pardir)
os.chdir(os.path.pardir)
# begin
import logging
from datetime import datetime
from tripkit import TripKit

logging.basicConfig(level=logging.INFO)
logging.getLogger('itinerum-tripkit').setLevel(level=logging.DEBUG)

# Edit ./tripkit_config.py and populate trip detection coordinates in cache db first!
tripkit = TripKit(config=cfg)

# -- Stage 1: load platform data to cache
tripkit.setup()

# -- Stage 2: select user data and process points
# a manually selected trip to perform test map matching on
user = tripkit.load_users(uuid='00807c5b-7542-4868-8462-14b79a9fcc9f',
                          start=datetime(2017, 11, 29),
                          end=datetime(2017, 11, 30))
map_matcher = tripkit.process.map_match.osrm(cfg)
mapmatched_results = map_matcher.match(coordinates=user.coordinates,
                                       matcher='DRIVING')

# -- Stage 3: write input and output data to geojsons
# write user coordinates to geojson as points