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

Load Track from file and add as Route #312

Merged
merged 2 commits into from
Jun 19, 2020

Conversation

printpagestopdf
Copy link
Contributor

This pull request is related to #254 and #274. It adds a dropdown item and modal dialog to import a local trackfile and using parts of the linestring points to add it as route.
I haven't done yarn push-transifex, because in my understanding should be done after merge (otherwise please tell me).
Feel free to change or request changes from me.

@rkflx
Copy link
Contributor

rkflx commented Jun 16, 2020

Nice, great feature!

Make sure to run yarn prettier to automatically reformat the code and yarn test or yarn build to check whether everything builds in release mode (currently it stumbles on let, which does not seem supported here, among other things).

UI-wise, would it be possible to combine this with the regular track loading? Having two entries could be slightly confusing for users not knowing about the difference between routes and tracks. Also, there is currently no way to convert a track after is has already been added.

Here are some ideas:

  • Only provide a single menu entry: "Load tracks", which opens a file chooser in multi-file mode as before.
  • If only a single file was selected, open a dialog containing:
    • A big button which directly adds the file as a background layer after clicking on it.
    • An explanation for what the button does (so the user is aware the track cannot be modified).
    • Another big button to add the file as an editable route. A "More" button or a separate dialog could be used for the "Tuning", "POI" and (reworded) "Copy track to background layer" options.
    • An explanation for what the button does (so the user knows the current route will be extended).
    • Possibly a "Remember my choice for the future" checkbox.
  • If multiple files were selected: Assume the user wants to add all of them as tracks, no need to ask.
  • In the "Layers" sidebar tab, add a clickable icon after each track to open the conversion dialog.
  • Get rid of the "Format" chooser (it should always work automatically, instead of having the user to do the work), replace with a help button listing the formats available and an error message if things went wrong.

@printpagestopdf
Copy link
Contributor Author

Ups thank you for the yarn checking commands, wasn't aware that let is not allowed (all specifications I read prefer it). I like your suggestions, will try to implement it.
One question: haven't make changes on a existing pull request before. What is the best method to do? Is it enough to make the changes in my fork or do I have to make a new pull request ...?

@nrenner
Copy link
Owner

nrenner commented Jun 16, 2020

Prettier and Eslint should automatically be executed as pre-commit hook, don't know why that apparently didn't work:

brouter-web/package.json

Lines 17 to 20 in 8621c44

"husky": {
"hooks": {
"pre-commit": "pretty-quick --bail && yarn lint"
}

Ups thank you for the yarn checking commands, wasn't aware that let is not allowed (all specifications I read prefer it).

let and other ES6 features in your code are failing because we don't support ES6 yet (#249).

But no need to remove those - I intend to introduce Babel, just want to get a bugfix release out first, so probably will postpone merging after that.

@nrenner
Copy link
Owner

nrenner commented Jun 16, 2020

UI-wise, would it be possible to combine this with the regular track loading? Having two entries could be slightly confusing for users not knowing about the difference between routes and tracks.

I had thought about having a common dialog, but wasn't sure. For everyday use two separate menu entries might be more efficient and less bloated. On the other hand, it might be useful for common settings like choosing the color for the the track(s) to load.

I personally don't really mind either way for this PR, as we already got the users confused that the loaded tracks aren't editable.

Also, there is currently no way to convert a track after is has already been added.

I don't want to raise the bar for merging this PR. This should be an enhancement for later in a separate issue, as we currently have no general concept for interacting with tracks (changing color, removing) - neither on the map nor in the layer switcher, also see #297 (comment).

Copy link
Owner

@nrenner nrenner left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! Some minor comments inline.


if(isBusy === true)
$("#loadedittrackdlg #msg_busy").removeClass("invisible");
// $("#loadedittrackdlg #busy_img").addClass("d-block");
Copy link
Owner

Choose a reason for hiding this comment

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

Do you want to keep commented code (two more)?

turf.featureEach(this._currentGeoJSON,(feature,idx) => {
if(turf.getType(feature) == "Point")
{
console.log("POI",feature);
Copy link
Owner

Choose a reason for hiding this comment

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

Please remove the console.log

Comment on lines 255 to 261
if (toGeoJSON === undefined) {
if (typeof window !== 'undefined') {
toGeoJSON = require('togeojson');
} else {
toGeoJSON = require('togeojson')(root);
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

We don't need this? Could you move this to external code when using in other contexts?

@nrenner
Copy link
Owner

nrenner commented Jun 16, 2020

One question: haven't make changes on a existing pull request before. What is the best method to do? Is it enough to make the changes in my fork or do I have to make a new pull request ...?

You shold be able just to push more commits into your branch, see the GitHub hint at end of comments section below:

Add more commits by pushing to the loadtrackasroute branch on printpagestopdf/brouter-web.

@printpagestopdf
Copy link
Contributor Author

UI-wise, would it be possible to combine this with the regular track loading? Having two entries could be slightly confusing for users not knowing about the difference between routes and tracks.

I had thought about having a common dialog, but wasn't sure. For everyday use two separate menu entries might be more efficient and less bloated. On the other hand, it might be useful for common settings like choosing the color for the the track(s) to load.

I personally don't really mind either way for this PR, as we already got the users confused that the loaded tracks aren't editable.

Also, there is currently no way to convert a track after is has already been added.

I don't want to raise the bar for merging this PR. This should be an enhancement for later in a separate issue, as we currently have no general concept for interacting with tracks (changing color, removing) - neither on the map nor in the layer switcher, also see #297 (comment).

I am with you, that the best approach is, to move these UI suggestions in new feature requests. So I am not touching the UI for now

@printpagestopdf
Copy link
Contributor Author

Sorry my fault I believed to close only this discussion thread so I have ot reopen it.

Beneath the code changes you mentioned (I was too lazy to recheck it) I will although try to remove the ES6 features (understanding that Babel would sove this, but I will try to follow the current coding rules).

@printpagestopdf
Copy link
Contributor Author

Hopefully I found everything that has to be fixed. Removed the items mentioned by @nrenner including ES6 features. Following @rkflx suggestions removed the format selection select and ran yarn prettier.

@nrenner nrenner merged commit 0d6cd61 into nrenner:master Jun 19, 2020
@nrenner
Copy link
Owner

nrenner commented Jun 19, 2020

Thanks for your contribution!

@nrenner nrenner added this to the 0.13.0 milestone Jun 19, 2020
@nrenner
Copy link
Owner

nrenner commented Jun 19, 2020

I haven't done yarn push-transifex, because in my understanding should be done after merge

Only by the maintainers, so this is done by me.

@printpagestopdf printpagestopdf deleted the loadtrackasroute branch June 19, 2020 17:48
@printpagestopdf
Copy link
Contributor Author

Many thanks for maintaining this nice project.

nrenner added a commit that referenced this pull request Jun 25, 2020
- common track style
- TracksLoader now also adds points as POIs
- RouteLoaderConverter does not add route points as POI
nrenner added a commit that referenced this pull request Jul 1, 2020
Loading a track as route with lots of waypoints (simplify tolerance of 0) caused a long pause before even handling the first route request.

This seems to be caused by a repaint for every added marker/layer. Adding them all at once in FeatureGroup.addTo(map) helps (although still added in a loop).
nrenner added a commit that referenced this pull request Jul 14, 2020
to prevent code in GPX getting executed like this:
<name>&lt;img src="xyz" onerror="alert('script executed')"></name>
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.

3 participants