Skip to content

Commit

Permalink
Merge pull request #14 from mapup/refactor-scripts
Browse files Browse the repository at this point in the history
minor changes
  • Loading branch information
ajay-padwal-mapup authored Mar 12, 2024
2 parents 8d536b0 + a6b31fa commit 81f4474
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 18 deletions.
3 changes: 1 addition & 2 deletions javascript/flex_poly.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function encodeUnsignedNumber(val) {

function encodeScaledValue(value) {
// Transform a integer `value` into a variable length sequence of characters.
// `appender` is a callable where the produced chars will land to
// `appender` is a callable where the produced chars will land to
let numVal = Num(value);
const negative = numVal < 0;
numVal <<= Num(1);
Expand All @@ -195,7 +195,6 @@ function encodeScaledValue(value) {
module.exports = {
encode,
decode,

ABSENT,
LEVEL,
ALTITUDE,
Expand Down
3 changes: 0 additions & 3 deletions javascript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ const getPoints = body => body.routes

const getPolyline = body => polyline.encode(getPoints(JSON.parse(body)));


const getRoute = (cb) => request.get(url, cb);

const handleRoute = (e, r, body) => {
console.log(body)

const _polyline = getPolyline(body);
console.log(_polyline);

Expand Down
8 changes: 2 additions & 6 deletions python/Here_Maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
TOLLGURU_API_URL = "https://apis.tollguru.com/toll/v2"
POLYLINE_ENDPOINT = "complete-polyline-from-mapping-service"

# From and To locations
source = "Philadelphia, PA"
destination = "New York, NY"

Expand All @@ -25,7 +26,6 @@
"departure_time": "2021-01-05T09:46:08Z",
}


def get_geocodes_from_here_maps(address):
"""Fetching geocodes form Here maps"""
params = {"searchtext": address, "apiKey": HERE_API_KEY}
Expand All @@ -35,7 +35,6 @@ def get_geocodes_from_here_maps(address):
]["DisplayPosition"].values()
return (latitude, longitude)


def get_polyline_from_here_maps(
source_latitude, source_longitude, destination_latitude, destination_longitude
):
Expand All @@ -60,10 +59,7 @@ def get_polyline_from_here_maps(
) # we converted that to encoded(google) polyline
return polyline_from_heremaps


"""Calling Tollguru API"""


# Calling Tollguru API
def get_rates_from_tollguru(polyline):
# Tollguru resquest parameters
headers = {"Content-type": "application/json", "x-api-key": TOLLGURU_API_KEY}
Expand Down
6 changes: 0 additions & 6 deletions python/Testing/Test_Here_Maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"departure_time": "2021-01-05T09:46:08Z",
}


def get_geocodes_from_here_maps(address):
"""Fetching geocodes form here maps"""
url = "https://geocoder.ls.hereapi.com/6.2/geocode.json"
Expand All @@ -32,7 +31,6 @@ def get_geocodes_from_here_maps(address):
]["DisplayPosition"].values()
return (latitude, longitude)


def get_polyline_from_here_maps(
source_latitude, source_longitude, destination_latitude, destination_longitude
):
Expand All @@ -57,10 +55,7 @@ def get_polyline_from_here_maps(
) # we converted that to encoded(google) polyline
return polyline_from_heremaps


"""Calling Tollguru API"""


def get_rates_from_tollguru(polyline):
# Tollguru resquest parameters
headers = {"Content-type": "application/json", "x-api-key": TOLLGURU_API_KEY}
Expand All @@ -83,7 +78,6 @@ def get_rates_from_tollguru(polyline):
else:
raise Exception(response_tollguru["message"])


"""Testing"""
# Importing Functions
from csv import reader, writer
Expand Down
2 changes: 1 addition & 1 deletion ruby/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
TOLLGURU_API_URL = "https://apis.tollguru.com/toll/v2"
POLYLINE_ENDPOINT = "complete-polyline-from-mapping-service"

# From and To locations
source = 'Philadelphia, PA'
destination = 'New York, NY'

Expand All @@ -36,7 +37,6 @@ def get_coord_hash(loc)
destination = get_coord_hash(destination)

# GET Request to HERE Maps for Polyline

HERE_URL = "#{HERE_API_URL}?transportMode=car&origin=#{source["lat"]},#{source["lng"]}&destination=#{destination["lat"]},#{destination["lng"]}&apiKey=#{HERE_API_KEY}&return=polyline"
RESPONSE = HTTParty.get(HERE_URL).body
json_parsed = JSON.parse(RESPONSE)
Expand Down

0 comments on commit 81f4474

Please sign in to comment.