-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update carbon calculations for GIS server (richer modes) #576
Update carbon calculations for GIS server (richer modes) #576
Conversation
Can one of the admins verify this patch? |
e-mission/e-mission-docs#288 is resolved (you need to modify the CSP in |
Yes, the server supports both When the mode inference step is run successfully, both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First round of obvious changes. Will do a more careful review of the real functionality changes in a bit.
www/index.html
Outdated
@@ -106,6 +106,8 @@ | |||
<script src="lib/angular-nvd3/dist/angular-nvd3.min.js"></script> | |||
<script src="lib/nz-tour/dist/nz-tour.min.js"></script> | |||
<link rel="stylesheet" href="lib/nvd3/build/nv.d3.css"> | |||
<!-- TIAGO: allow debug with weinre --> | |||
<script src="http://192.168.1.238:8090/target/target-script-min.js#anonymous"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove? Seems to be hardcoded to your IP.
www/js/metrics-factory.js
Outdated
return result; | ||
} | ||
fh.getLowestFootprintForDistance = function(distance) { | ||
var lowestFootprint = 9999; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 9999
instead of Number.MAX_VALUE
?
www/js/metrics.js
Outdated
@@ -410,6 +410,9 @@ angular.module('emission.main.metrics',['nvd3', 'emission.services', 'ionic-date | |||
delete clonedData.metric; | |||
clonedData.metric_list = [DURATION, MEDIAN_SPEED, COUNT, DISTANCE]; | |||
clonedData.is_return_aggregate = true; | |||
// TIAGO we should use our own server here, but for now it will return empty metrics, see: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I responded to this.
www/js/metrics.js
Outdated
lastWeekCarbonInt = FootprintHelper.getFootprintForMetrics(userCarbonData); | ||
} | ||
else { | ||
// TIAGO: ------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove these and similar before the final PR (they have my name on them so I can find them quickly).
So I realized that we would need to handle both So it looks like we convert all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few more fit and finish issues but rest looks good.
Functionality is fine, and if you file an issue for the NaN
with more details on how to reproduce, I am happy to take a look.
www/js/metrics.js
Outdated
} | ||
} | ||
|
||
$scope.carbonData.aggrVehicleRange = FootprintHelper.getFootprintForMetrics(aggrCarbonData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not your change, but I don't see this variable being used anywhere.
So you could remove it, since aggrCarbon
seems to represent the same value anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not should probably rename to indicate that it is not a range any more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed :)
Does this mean that in the app I will always use |
…e IN_VEHICLE restored
@shankari need your input on this, I think it's the only outstanding issue in the PR - besides removing all my test code (e.g. |
www/index.html
Outdated
@@ -3,7 +3,7 @@ | |||
<head> | |||
<meta charset="utf-8"> | |||
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> | |||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com http://nominatim.openstreetmap.org https://e-mission.eecs.berkeley.edu https://api.ionic.io/push/tokens emission: 'unsafe-eval'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data: http://*.tile.openstreetmap.org http://tile.stamen.com https://*.tile.stamen.com http://*.tile.stamen.com 'unsafe-inline'"> | |||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com http://nominatim.openstreetmap.org http://192.168.1.238 https://api.ionic.io/push/tokens emission: 'unsafe-eval'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data: http://*.tile.openstreetmap.org http://tile.stamen.com https://*.tile.stamen.com http://*.tile.stamen.com 'unsafe-inline'"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also remove from PR :)
@tms-martins
We already do this conversion in the app, but in the reverse direction. Sorry about the lack of consistency :( I can fix that or you can fix it as part of the PR. LMK what you prefer. |
Making the change myself since it is a comment-only change
i18n e-mission-phone
When using the GIS-based server, it seems that It also begs the question: should I ever expect the mode Nevertheless, should I always check server data for old modes (i.e. |
…e IN_VEHICLE restored
…artins/e-mission-phone into update_carbon_calc_for_GIS
if (aggrCarbonData[i].key === "IN_VEHICLE") { | ||
$scope.carbonData.aggrVehicleRange = FootprintHelper.getFootprintRaw(aggrCarbonData[i].values, aggrCarbonData[i].key); | ||
$scope.carbonData.aggrCarbon = FootprintHelper.getFootprint(aggrCarbonData[i].values, aggrCarbonData[i].key); | ||
if (isNaN(aggrCarbonData[i].values)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been investigated a bit more using the master phone branch and turned into an issue.
e-mission/e-mission-docs#422
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although both master and your branch now have the changes in #584, the github file changes list still shows the changes in that PR mixed with your changes.
So I'm using a new compare
master...tms-martins:update_carbon_calc_for_GIS for this review.
Looks good barring the hardcoded IP addresses and TIAGO
messages. Happy to merge once you have resolved those. Can you also add some testing screenshots or a testing video?
I am now investigating e-mission/e-mission-docs#422
www/js/metrics.js
Outdated
fieldPhone = "ON_FOOT"; | ||
} else { | ||
// if (field === "WALKING" || field === "RUNNING") { | ||
// fieldPhone = "ON_FOOT"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you are using WALKING
everywhere, you should probably have the reverse of this, right? e.g. if returned as ON_FOOT
, convert to WALKING
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or I guess you are handing this in the footprint calculations (e.g. getFootprintForMetrics
). Any reason for the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I knew I didn't want to convert WALKINg to ON_FOOT; but removing/commenting that code was also lazy, because then I can have RUNNING labels which aren't handled in getFootprintForMetrics
. I think a separate branch should address the mode consistency (i.e. check for and convert certain modes) at some point.
I will restore this line and avoid addressing the issue piecemeal before I break something :)
I'm tidying up now, including removing the |
Yes. I rebased my branch, and when I looked at the GitHub diff last time all looked well. I don't know exactly why this happens, although I've seen it before. I'm afraid that if I try to fix it now I end up making matters worse. |
Tidied up. @shankari what is the best way to add testing videos? Something like G Drive or is there a Git Repo for those? |
I've read up that the PR-diff is made "against the common ancestor of the source branch and the target branch". Also that a quick fix is to use the |
No worries. I can just review off the compare since I don't expect to have a lot of review comments. |
G Drive is fine. I typically make the video short and gzip it so that I can upload it to github directly (.gz extensions are supported). |
This should not be an issue. I also use the devapp for my development and it has been pretty reliable in translating to real devices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise all looks good. Will merge as soon as I see testing video.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anything else obviously wrong. Will merge as soon as I see testing video :)
Video looks good. |
Update the carbon calculations so that they use the richer modes in the GIS-based server (ground_truth_matching branch).
fillFootprintAggVals
it can happen that that the modeON_FOOT
has a NaN value; a workaround was provided for that, but the source of the problem should be investigated (perhaps it is due to different modes in app VS server?)