Skip to content

Commit

Permalink
fix(Segment): Fixed speed data from Segment.to_geojson()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrtn-fa committed Nov 18, 2024
1 parent 85473d5 commit c347fcf
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions backend/rest_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,25 @@ def to_geojson(self):
date, day_type, temporal_segment = get_last_temporal_segment_data()
speed = Speed.objects.filter(segment=self, timestamp__date=date, temporal_segment=temporal_segment).first()

if speed is not None:
if speed:
alert = Alert.objects.filter(segment=self, temporal_segment=speed.temporal_segment).first()
if alert is not None:
if alert:
properties['alert_id'] = alert.pk
speed_info = speed.check_value()
properties.update(speed_info)
properties.update(speed.check_value())
else:
historic_speed = (HistoricSpeed.objects.filter(segment=self, day_type=day_type,
temporal_segment=temporal_segment)
.order_by("-timestamp").first())
if historic_speed is not None:
properties["historic_speed"] = historic_speed.speed
else:
properties["historic_speed"] = "Sin registro"
properties["speed"] = "Sin registro"
properties["color"] = "#DDDDDD"

historic_speed = (HistoricSpeed.objects.filter(segment=self, day_type=day_type,
temporal_segment=temporal_segment)
.order_by('-timestamp').first())
if historic_speed:
properties['historic_speed'] = historic_speed.speed
else:
properties['historic_speed'] = 'Sin registro'

services = Services.objects.filter(segment=self).first()
if services is not None:
if services:
properties["services"] = services.services
line = shp_LineString(coordinates=self.geometry)
line = line.simplify(tolerance=0.00001)
Expand Down

0 comments on commit c347fcf

Please sign in to comment.