-
Notifications
You must be signed in to change notification settings - Fork 17
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
Allow customisation by transformers #11
base: master
Are you sure you want to change the base?
Conversation
}); | ||
break; | ||
default: | ||
console.log("warning: unsupported geometry type: "+f.geometry.type); | ||
} | ||
}; |
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.
the ;
is superfluous here, right? (as it's the end of the mapFeature
function definition)
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.
Yes, you are right.
This looks like great improvements, thank you very much! But can you please complete a few more things before I can merge it (and make it into a v0.6 release):
|
Yes, I'll do that. Some comments: |
For a small library such as this one, I usually try to keep external dependencies to an absolute minimum. |
Just wondering if this pull request is going to be merged. I was about to try and add the ability to save routes to your code when I noticed @JarnoLeConte PR which includes this. Must admit I haven't done a PR before either so unsure why it stalled? |
Use togpx fork for now (outdated), see PR: tyrasd/togpx#11
Use togpx fork for now (outdated), see PR: tyrasd/togpx#11
Use togpx fork for now (outdated), see PR: tyrasd/togpx#11
- Remove superfluous `;` (and another) - Reverse `default` logic to match Object.assign and options init - Rename `default` to `assign` - Replace default options overrride on init
See #16 for a merge of this PR for current master, with improvements applied, but still lacking documentation. |
Code is now more generalised and has explicit build functions for the elements:
<wpt>
,<trkpt>
,<rtept>
,<trk>
,<rte>
,<gpx>
Additionally, developers could define
options.transform
to attach transform functions to each of these build functions. These transformers will post process the data and give the flexibility to set all fields defined in the GPX v1.1 specification.This way developers could easily define their own helpers to fit their needs. The functions
get_feature_title()
,get_feature_description()
andget_feature_coord_times()
could have been implemented this way. Moreover this solves my initial problem whereproperties.coordTimes
was defined on my features instead ofproperties.times
.EXAMPLES
get_feature_title()
implemented by a transformer to set the name of a waypoint<wpt>
.<trkpt>
.<extensions>
(see GPX v1.1 specification)API
available transformers