Skip to content
Permalink
Browse files

Actually fix the geojson plotter to return the correct values

The first set of changes (in 232628c) switch
cleaned -> inferred. But that was actually in code where we get the locations
for the section.

The actual sections are retrieved as part of the cleaned timeline.

So the potential fixes are:
- we can create a new inferred timeline that combines inferred sections with
  cleaned stops. This is not strictly hard to do; see
  `emission.storage.decorations.timeline.get_timeline` but then we need to
  think about whether we should also have the stops be inferred stops...

- just replace the mode (which is the only thing different between the
  sections) with the mode from the corresponding inferred section. This is easy
  and it works.
  • Loading branch information...
shankari committed Feb 23, 2018
1 parent 2cd8328 commit a4f623e7e15e53c4366e8f7c3bb70f039dd9cbdc
Showing with 13 additions and 2 deletions.
  1. +13 −2 emission/analysis/plotting/geojson/geojson_feature_converter.py
@@ -19,6 +19,7 @@

import emission.storage.decorations.trip_queries as esdt
import emission.storage.decorations.analysis_timeseries_queries as esda
import emission.storage.decorations.section_queries as esds
import emission.storage.decorations.timeline as esdtl

import emission.core.wrapper.location as ecwl
@@ -114,7 +115,7 @@ def section_to_geojson(section, tl):
ts = esta.TimeSeries.get_time_series(section.user_id)
entry_it = ts.find_entries(["analysis/recreated_location"],
esda.get_time_query_for_trip_like(
eac.get_section_key_for_analysis_results(),
"analysis/cleaned_section",
section.get_id()))

# TODO: Decide whether we want to use Rewrite to use dataframes throughout instead of python arrays.
@@ -147,9 +148,19 @@ def section_to_geojson(section, tl):
# Update works on dicts, convert back to a section object to make the modes
# work properly
points_line_feature.properties = ecwcs.Cleanedsection(points_line_feature.properties)

points_line_feature.properties["feature_type"] = "section"
points_line_feature.properties["sensed_mode"] = str(points_line_feature.properties.sensed_mode)

if eac.get_section_key_for_analysis_results() == esda.INFERRED_SECTION_KEY:
ise = esds.cleaned2inferred_section(section.user_id, section.get_id())
logging.debug("mapped cleaned section %s -> inferred section %s" %
(section.get_id(), ise.get_id()))
logging.debug("changing mode from %s -> %s" %
(points_line_feature.properties.sensed_mode, ise.data.sensed_mode))
points_line_feature.properties["sensed_mode"] = str(ise.data.sensed_mode)
else:
points_line_feature.properties["sensed_mode"] = str(points_line_feature.properties.sensed_mode)

_del_non_derializable(points_line_feature.properties, ["start_loc", "end_loc"])

# feature_array.append(gj.FeatureCollection(points_feature_array))

0 comments on commit a4f623e

Please sign in to comment.
You can’t perform that action at this time.