-
Notifications
You must be signed in to change notification settings - Fork 186
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
Modularize Data Download #654
Conversation
* export as `dataHelper` instead of `L`
* all functions that were part of wv global are now exported * export reuseable constants `export const examples ='something'`
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.
Looks good. Tested locally and didn't find any errors. I do agree that the L
naming is not named well / intuitive when looking at the code.
var L = {};
edsc.L = L;
Actually, I am seeing the following error: |
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.
Great job modularizing a very complex section of code! I left a few comments about variable names that I think are confusing. My main point is that we should be choosing variable names that are consistent and clearly communicate what the code is doing with minimal mental overhead. I'm not asking for any changes, unless you agree with my comments or see an easy way to make things clearer.
@@ -0,0 +1,15 @@ | |||
export function dataParser(state, errors, config) { |
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.
What do you think about naming this file parser.js
?
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.
A number of the 'parser' files in other features have other methods in them.
import {dataHelper} from '../edsc'; | ||
import { | ||
CRS_WGS_84, | ||
mapIsPolygonValid, |
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.
What's the difference between prefixing all of these with map
and prefixing all of the Worldview JavaScript files with wv.
? Does the extra prefix provide some value? Or are we being more verbose than we need to be?
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'd say we essentially got rid of thewv
in wv.map.something
and are left with the map.something
as camel case. The prefix stands for the folder in which something is in. We can't just call a method parser
, we need dataParser
if we want to export unique names across the board. mapIsPolygonValid
would be fine as isPolygonValid
but I'm just trying to stick with a convention.
web/js/data/results.js
Outdated
import loEach from 'lodash/each'; | ||
import {dataCmrRoundTime, dataCmrGeometry} from './cmr'; | ||
import util from '../util/util'; | ||
import {dataHelper} from '../edsc'; |
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 not rename the whole edsc
directory to web/data/helpers
or something and eliminate the edsc name completely?
@@ -1,9 +1,14 @@ | |||
import edscArc from './edsc/arc'; |
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.
What's the value of the edsc
prefix? Didn't we agree that edsc
isn't really relevant to this code anymore?
@@ -269,7 +283,7 @@ wv.data.results.dateTimeLabel = function (time) { | |||
return self; | |||
}; | |||
|
|||
wv.data.results.densify = function () { | |||
export function dataResultsDensify() { |
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.
What's the difference between prefixing all of the data functions with data
and prefixing all of the Worldview JavaScript files with wv.
? Does the extra prefix provide some value? Or are we being more verbose than we need to be?
web/js/data/cmr.js
Outdated
wv.data.cmr.client = wv.data.cmr.client || function (spec) { | ||
import $ from 'jquery'; | ||
import util from '../util/util'; | ||
import OlPolygon from 'ol/geom/polygon'; |
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.
Should this be OlGeomPolygon
for consistency with the other places you imported it?
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.
Good catch!
web/js/data/ui.js
Outdated
'No results received yet. This may be due to a ' + | ||
'connectivity issue. Please try again later.' | ||
); | ||
}; | ||
|
||
var updateSelection = function () { | ||
var $button = $('#wv-data-download-button'); | ||
var selected = _.size(model.selectedGranules); | ||
var selected = loSize(model.selectedGranules); |
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 think loSize
is a very confusing function name to find in a context like this. Wouldn't someone's first intuition here be to think that we're selecting the granule with the lowest size from the model? I think @ZachTRice and I are in favor of spelling out the whole prefix for lodash functions; lodashSize
, since lo
can be kind of ambiguous.
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 am seeing problems when trying to use data download in any projection other than Geographic. If I go to this link https://localhost:3000/?p=antarctic&l=VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,MODIS_Terra_Brightness_Temp_Band31_Night,MODIS_Aqua_Ice_Surface_Temp_Night,MODIS_Terra_Ice_Surface_Temp_Night,MODIS_Terra_Snow_Cover,Coastlines&t=2018-01-08&z=3&v=-6881280,-3952640,6881280,3952640&ab=off&as=2018-01-01&ae=2018-01-08&av=3&al=true&download=MOD10_L2
It doesn't work, but the same link works fine on production.
return granule; | ||
}; | ||
|
||
return self; | ||
}; | ||
|
||
wv.data.results.extentFilter = function (projection, extent) { | ||
export function dataResultsExtentFilter(projection, extent) { | ||
var self = {}; |
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.
When a non-geographic projection is selected, it looks like this function gets called with extent
being undefined.
@@ -4,6 +4,10 @@ import loIsUndefined from 'lodash/isUndefined'; | |||
import loFind from 'lodash/find'; | |||
import OlGeomPolygon from 'ol/geom/polygon'; | |||
|
|||
export const CRS_WGS_84 = 'EPSG:4326'; |
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.
Where was this constant defined before? I suspect that maybe the bug we're seeing is related to this constant.
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.
@localjo @ZachTRice |
Looks good! Let's merge! |
Changes in this pull request: