Skip to content

Commit

Permalink
Tweaking geotab processing
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob6838 committed Nov 8, 2024
1 parent 288e770 commit 411c48d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10,043 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pathlib
from setuptools import setup, find_packages

VERSION = "1.3.0"
VERSION = "1.3.1"
DESCRIPTION = "CDOT Work Zone WZDx Translators"
HERE = pathlib.Path(__file__).parent
README = (HERE / "README.md").read_text()
Expand Down
20 changes: 14 additions & 6 deletions wzdx/experimental_combination/attenuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def main():
geotab_avl = [json.loads(open(geotabFile, "r").read())]
outputPath = output_dir + "/wzdx_attenuator_combined.geojson"
if updateDates == "true":
geotab_avl[0]["avl_location"]["source"]["collection_timestamp"] = (
date_tools.get_current_ts_millis() / 1000
)
geotab_avl[0]["avl_location"]["source"]["collection_timestamp"] = datetime.now()
wzdx[0]["features"][0]["properties"]["start_date"] = (
date_tools.get_iso_string_from_datetime(datetime.now() - timedelta(days=2))
)
Expand Down Expand Up @@ -107,9 +105,19 @@ def validate_dates(geotab: dict, wzdx: dict) -> bool:
Returns:
bool: Whether the Geotab date falls within the WZDx date range
"""
geotab_date = date_tools.get_unix_from_iso_string(
geotab["avl_location"]["source"]["collection_timestamp"]
)
if type(geotab["avl_location"]["source"]["collection_timestamp"]) == datetime:
geotab_date = date_tools.date_to_unix(
geotab["avl_location"]["source"]["collection_timestamp"]
)
elif type(geotab["avl_location"]["source"]["collection_timestamp"]) == str:
geotab_date = date_tools.get_unix_from_iso_string(
geotab["avl_location"]["source"]["collection_timestamp"]
)
else:
logging.error(
f"Invalid Geotab date format: avl_location.source.collection_timestamp is type {type(geotab['avl_location']['source']['collection_timestamp'])}"
)
return False
logging.debug(f"Geotab: {json.dumps(geotab)}")
if not geotab_date:
geotab_date = (
Expand Down
18 changes: 18 additions & 0 deletions wzdx/sample_files/raw/geotab_avl/attenuator_msg_2024_11_08.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"avl_location": {
"vehicle": {
"id": "bFB",
"id2": "G90N60BYJT18",
"fleet": "Heavy",
"type": "Attenuator",
"sub_type": "Attenuator (ATMA)"
},
"position": { "latitude": 37.4596863, "longitude": -105.877327, "bearing": null, "speed": 0.0, "odometer": null },
"confidence": null,
"current_status": { "state": "Active", "info": "Parked" },
"additional_info": [{ "name": "displayName", "value": null }],
"source": { "name": "Geotab", "collection_timestamp": "2024-11-08 23:14:03.063000+00:00" }
},
"rtdh_message_id": "4a3541e4-8319-4cf8-bbc0-36c7a4d0b694",
"rtdh_timestamp": "2024-11-08T23:14:08Z"
}
Loading

0 comments on commit 411c48d

Please sign in to comment.