This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RA, 2019-01-15 | |
# Download an OpenStreetMap file based on a lat-lon bounding box | |
# License: CC0 -- "No rights reserved" | |
# IMPORTS: | |
import os | |
import json | |
import inspect |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RA, 2019-01-16 | |
# Download a rendered map from Mapbox based on a bounding box | |
# License: CC0 -- no rights reserved | |
import io | |
import urllib.request | |
from PIL import Image | |
from math import pi, log, tan, exp, atan, log2, floor | |
# Convert geographical coordinates to pixels |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"PlateNumb": "698-FP", | |
"SubRouteUID": "KHH122", | |
"Direction": 1, | |
"Speed": [ | |
0.0, | |
0.0, | |
16.0, | |
0.0, |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"PlateNumb": "551-FP", | |
"SubRouteUID": "KHH82", | |
"Direction": 1, | |
"Speed": [ | |
27.0, | |
0.0, | |
35.0, | |
0.0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zlib, json, base64 | |
ZIPJSON_KEY = 'base64(zip(o))' | |
def json_zip(j): | |
j = { | |
ZIPJSON_KEY: base64.b64encode( | |
zlib.compress( | |
json.dumps(j).encode('utf-8') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zlib, json, base64 | |
ZIPJSON_KEY = 'base64(zip(o))' | |
def json_unzip(j, insist=True): | |
try: | |
assert (j[ZIPJSON_KEY]) | |
assert (set(j.keys()) == {ZIPJSON_KEY}) | |
except: | |
if insist: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RA, 2019-01-22 | |
# Compress and decompress a JSON object | |
# License: CC0 -- "No rights reserved" | |
# For zlib license, see https://docs.python.org/3/license.html | |
import zlib | |
import json, base64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"PlateNumb": "001-FQ", | |
"OperatorID": "100", | |
"RouteUID": "TPE10181", | |
"RouteID": "10181", | |
"RouteName": { | |
"Zh_tw": "205", | |
"En": "205" | |
}, | |
"SubRouteUID": "TPE101810", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RA, 2019-01-15 | |
# Download an OpenStreetMap file based on a lat-lon bounding box | |
# License: CC0 -- "No rights reserved" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# IMPORTS: | |
import os | |
import json | |
import inspect | |
import logging | |
import datetime as dt | |
import urllib.request, urllib.error |
OlderNewer