Skip to content
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

Added abitlity to load from an already loaded file content (e.g. loaded from URL) #34

Merged
merged 2 commits into from
Sep 22, 2016

Conversation

opoto
Copy link
Contributor

@opoto opoto commented Sep 17, 2016

Added:

  • FileLoader.loadData(data, name, ext) where:
    • data is the input data to load (a GeoJson, GPX or KML)
    • name is the name of the data (file name, URL, etc)
    • ext is an optional parameter to set data type in order to force parser type
  • fire 'data:error' if load/loadData mandatory parameters are missing
  • trick to allow testing of load file (set file.testing to true to skip reader load)
  • tests for loadData

Sample usage (with JQuery):

  $.get('https://my.server.com/?id=89798747&type=3', function(data){
    fileloader.loadData(data, '89798747', 'gpx');
  });

  - FileLoader.loadData(data, name, ext)
    where:
       data is the input data to load (a GeoJson, GPX or KML)
       name is the name of the data (file name, URL, etc)
       ext is an optional parameter to set data type in order to force parser type
  - fire 'data:error' if load/loadData mandatory parameters are missing
  - trick to allow testing of load file (set file.testing to true to skip reader load)
  - tests for loadData
@opoto opoto changed the title Added abitlity to load from an already loaded file content (e.g. loaded from URL Added abitlity to load from an already loaded file content (e.g. loaded from URL) Sep 17, 2016
Copy link
Contributor

@SBats SBats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @opoto ! Thank you a lot for this contribution ! We really appreciate it.

If you don't mind I've put some review on few syntax things. The overall is really good, those are more to keep following our .eslintrc file. If you want you can enable eslint in your IDE for this project, rules are already in dev dependencies. Anyway, I just put the matching information on the pull request code.

Don't worry about the tests respecting the linter as I need to clean them anyway.

If you have any question or doubt, please let me know, I will be glad to help or exchange about it.

@@ -63,46 +63,117 @@
var ext;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ext var is not used anymore. It should be deleted

this.fire('data:loaded', { layer: layer, filename: file.name, format: ext });
this.fire('data:loading', { filename: file.name, format: parser.ext });
layer = parser.processor.call(this, e.target.result, parser.ext);
this.fire('data:loaded', { layer: layer, filename: file.name, format: parser.ext });
Copy link
Contributor

@SBats SBats Sep 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line 90 exceeds the 100 char, please pass the options object on multiple lines

} catch (err) {
this.fire('data:error', { error: err });
}
}, this);
reader.readAsText(file);

// Testing trick: tests don't pass a real file, but an object with file.testing set to true.
Copy link
Contributor

@SBats SBats Sep 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A trailing space to remove at the end of the line 95 :)

var parser;

// Check required parameters
if ((this._isParameterMissing(data, "data"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use single quotes for string


// Check required parameters
if ((this._isParameterMissing(data, "data"))
|| (this._isParameterMissing(name, "name"))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use single quotes for string

} catch (err) {
this.fire('data:error', { error: err });
}

Copy link
Contributor

@SBats SBats Sep 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove line 133 - block should not be padded with blank lines


},

_isParameterMissing: function (v, vname, vtype) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vtype should be deleted - vtype is defined but never used

},

_isParameterMissing: function (v, vname, vtype) {
if (typeof v === "undefined") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use single quotes for string

return undefined;
}
return {
"processor": parser,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use single quotes for string

}
return {
"processor": parser,
"ext": ext
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use single quotes for string

@opoto
Copy link
Contributor Author

opoto commented Sep 21, 2016

Hi. Thanks for the review. I fixed eslint errors you listed, plus no-unneeded-ternary and consistent-return errors that were also reported. I ignored warnings (which anyway are not related to my changes), and left the no-undef and global-require errors which are not related to my changes neither.

@SBats SBats merged commit bb81a24 into makinacorpus:master Sep 22, 2016
@SBats
Copy link
Contributor

SBats commented Sep 22, 2016

Wonderfull ! Thank you again for this great contribution !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants