Take the zone from road, not event as suggested by opatut.

This commit is contained in:
gluap 2022-05-05 23:16:38 +02:00
parent 66dd84982c
commit 8ba5d8e3ad
5 changed files with 4 additions and 33 deletions

View file

@ -1,25 +0,0 @@
"""add event zone
Revision ID: b22108ab2ffb
Revises: a9627f63fbed
Create Date: 2022-04-30 19:06:11.472579
"""
from alembic import op
import sqlalchemy as sa
from migrations.utils import dbtype
# revision identifiers, used by Alembic.
revision = 'b22108ab2ffb'
down_revision = 'a9627f63fbed'
branch_labels = None
depends_on = None
def upgrade():
op.add_column("overtaking_event", sa.Column("zone", dbtype("zone_type")), )
def downgrade():
op.drop_column("overtaking_event", "zone")

View file

@ -124,7 +124,6 @@ class OvertakingEvent(Base):
distance_stationary = Column(Float)
course = Column(Float)
speed = Column(Float)
zone = Column(ZoneType)
def __repr__(self):
return f"<OvertakingEvent {self.id}>"

View file

@ -27,7 +27,7 @@ from obs.face.filter import (
from obs.face.osm import DataSource, DatabaseTileSource, OverpassTileSource
from obs.api.db import OvertakingEvent, RoadUsage, Track, make_session, ZoneType
from obs.api.db import OvertakingEvent, RoadUsage, Track, make_session
from obs.api.app import app
log = logging.getLogger(__name__)
@ -293,7 +293,6 @@ async def import_overtaking_events(session, track, overtaking_events):
distance_stationary=m["distance_stationary"],
course=m["course"],
speed=m["speed"],
zone=m["OSM_zone"] if ('OSM_zone' in m and m['OSM_zone'] is not None) else "urban"
)
session.add_all(event_models.values())

View file

@ -77,7 +77,6 @@ async def export_events(req):
writer.field("direction", "N", decimal=0)
writer.field("course", "N", decimal=4)
writer.field("speed", "N", decimal=4)
writer.field("zone", "N", decimal=4)
async for event in events:
writer.point(event.longitude, event.latitude)
@ -88,7 +87,6 @@ async def export_events(req):
way_id=event.way_id,
course=event.course,
speed=event.speed,
zone=event.zone
# "time"=event.time,
)
@ -109,7 +107,6 @@ async def export_events(req):
"course": event.course,
"speed": event.speed,
"time": event.time,
"zone": event.zone
},
}
)

View file

@ -9,9 +9,10 @@ RETURNS TABLE(event_id bigint, geometry geometry, distance_overtaker float, dist
(case when direction_reversed then -1 else 1 end)::int as direction,
course,
speed,
zone,
way_id::bigint as way_id
CASE WHEN road.zone IS NULL THEN 'urban' else road.zone END as zone,
overtaking_event.way_id::bigint as way_id
FROM overtaking_event
FULL OUTER JOIN road ON (road.way_id = overtaking_event.way_id)
WHERE ST_Transform(overtaking_event.geometry, 3857) && bbox;
$$ LANGUAGE SQL IMMUTABLE;