Skip to content

Commit

Permalink
Merge branch 'update_python_incidentally' into validate_geojson
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnelson-nist committed Aug 27, 2024
2 parents b0c2d57 + f151d0b commit 83dfd80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion python/CASE2GeoJSON.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import json
import sys
from os.path import exists, isdir, isfile
from pathlib import Path
from typing import List

from geotypes import GeoRecord
from geoutilities import records_to_geojson, remove_nulls
from rdflib import Graph
from rdflib.query import ResultRow

# Parse the arguments from the CLI to get the input and output filenames
if len(sys.argv) != 3:
Expand All @@ -21,7 +23,7 @@
sys.exit(1)

# Ensure the output directory exists
output_directory: str = output_filename[: output_filename.rfind("/")]
output_directory: str = str(Path(output_filename).parent.absolute())
if not exists(output_directory) and not isdir(output_directory):
print(f"Directory not found: {output_directory}")
sys.exit(1)
Expand Down Expand Up @@ -64,6 +66,7 @@

# Loop through the results and add them to the list of GeoRecords if the latitude and longitude are present
for row in results:
assert isinstance(row, ResultRow)
geo_record: GeoRecord = GeoRecord()
geo_record.Latitude = row.lLatitude
geo_record.Longitude = row.lLongitude
Expand Down
6 changes: 5 additions & 1 deletion python/geotypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ def reprJSON(self):
"""
return dict(
type=self.type,
properties=self.properties.reprJSON(),
properties=(
self.properties.reprJSON()
if hasattr(self, "properties") and self.properties is not None
else None
),
geometry=(
self.geometry.reprJSON()
if hasattr(self, "geometry") and self.geometry is not None
Expand Down

0 comments on commit 83dfd80

Please sign in to comment.