1

I tried running this code to get duartion and disatnce for each method. But I got same duration and distance. Is there something wrong?

# -*- coding: utf-8 -*-
"""
Created on Fri Jul 23 14:49:45 2021
@author: ukjo
"""
import datetime
import requests
import numpy as np
import pandas as pd
from util import get_src_engine, get_api_engine
import folium

src_engine = get_src_engine()

def get_public_transformation_info_from_osrm(sx, sy, dx, dy, method):
    ii32 = np.iinfo(np.int32)
    min_total_time = ii32.max

    if method == 'foot':
        url = f"http://localhost:5000/route/v1/foot/{sx},{sy};{dx},{dy}?steps=true&geometries=geojson"
    elif method == 'driving':
        url = f"http://localhost:5000/route/v1/car/{sx},{sy};{dx},{dy}"

    resp = requests.get(url)

    resp_dic = resp.json()

    duration = resp_dic['routes'][0]['duration']
    distance  = resp_dic['routes'][0]['distance']

    return duration, distance


if __name__ == '__main__':
    """
    126.9485743, 37.4794274
    127.0121342, 37.4875451
    """
    sx = 126.9485743
    sy = 37.4794274
    dx = 127.0121342
    dy = 37.4875451

    print(f"walk time : {get_public_transformation_info_from_osrm(sx, sy, dx, dy, 'foot')}")
    print(f"driving time : {get_public_transformation_info_from_osrm(sx, sy, dx, dy, 'driving')}")
verystrongjoe
  • 3,831
  • 9
  • 35
  • 66

0 Answers0