Skip to content

Commit

Permalink
Merge pull request #424 from LACMTA:2023-api-optimization
Browse files Browse the repository at this point in the history
2023-api-optimization
  • Loading branch information
albertkun authored Nov 29, 2023
2 parents cc34b1a + bbfb97f commit 5c1aacb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fastapi/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,13 @@ async def validation_exception_handler(request, err):
def to_geojson(data):
features = []
for item in data:
# Check if trip_id is None before trying to access it
if item.trip_id is None:
continue # skip this item
# Create a Point from the 'geometry' coordinates
geometry = Point(item['geometry']['coordinates'])
geometry = Point((item.geometry.longitude, item.geometry.latitude))
# Exclude the 'geometry' key from the properties
properties = {key: item[key] for key in item if key != 'geometry'}
properties = {key: getattr(item, key) for key in dir(item) if not key.startswith('_') and key != 'geometry'}
feature = Feature(geometry=geometry, properties=properties)
features.append(feature)
feature_collection = FeatureCollection(features)
Expand Down

0 comments on commit 5c1aacb

Please sign in to comment.