Skip to content

Commit

Permalink
Merge pull request #534 from LACMTA:dev
Browse files Browse the repository at this point in the history
Refactor get_route_details function to use JSON deserialization for geometries
  • Loading branch information
albertkun authored May 22, 2024
2 parents 1d7d4e7 + f4a9f0a commit 00a4473
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fastapi/app/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,15 @@ async def get_route_details(db: AsyncSession, route_code: str, direction_id: int
# Extract shape_ids from stop_times
shape_ids = {shape_id for stop in stop_times for shape_id in stop[1]['shape_ids']}


query = text("SELECT shape_id, ST_AsGeoJSON(geometry) FROM metro_api.trip_shapes WHERE shape_id IN :shape_ids")
result = db.execute(query, {'shape_ids': tuple(shape_ids)})

# Fetch all rows from the result
geometries_result = result.fetchall()

# Process the geometries
geometries = {shape_id: geometry for shape_id, geometry in geometries_result}
geometries = {shape_id: json.loads(geometry) for shape_id, geometry in geometries_result}

# Prepare the debugging information
debug_info = {
Expand Down

0 comments on commit 00a4473

Please sign in to comment.