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

GpxMainObject class #12

Closed
HarelM opened this issue Aug 4, 2018 · 2 comments
Closed

GpxMainObject class #12

HarelM opened this issue Aug 4, 2018 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@HarelM
Copy link
Contributor

HarelM commented Aug 4, 2018

I'm missing a class to hold all the information that I can pass in memory from place to place.
Currently the writer is getting a metadata object and three list of features (among other stuff).
It would be nice to have a interface call to the writer that receives an object that hold all the information.
Some thing like:

public class GpxMainObject { 
    public GpxMetadata { get; }
    public GpxRoute[] {get;}
    ...

And the writer:

public void Write(..., GpxMainObject gpx, ...)
@airbreather airbreather added the enhancement New feature or request label Aug 4, 2018
@airbreather
Copy link
Member

It makes sense to give, e.g., GpxRoute[] to the consumer from Read, since we can always guarantee that it'll be an array, which gives the consumer maximum flexibility for what they can do with it right away, at no performance penalty. So yeah, it totally makes sense to have a Read kind of method that gives back a single object that encapsulates all the top-level gpx element content.

On the other hand, it doesn't make quite as much sense for Write to accept the same. The provider might want to pass in any number of different sequence types that implement IEnumerable<T>, and so if they have, e.g., IEnumerable<GpxRoute> that's being created by a LINQ query, then it would be wasteful to force it to go through a .ToArray() just to meet the demands of the API.

If you think it would help usability significantly, then I wouldn't mind doing something like this:

public static void Write(XmlWriter writer, GpxWriterSettings settings, GpxMainObject gpx)
{
    Write(writer, settings, gpx.Metadata, gpx.Waypoints, gpx.Routes, gpx.Tracks, gpx.Extensions);
}

@airbreather airbreather self-assigned this Aug 4, 2018
@HarelM
Copy link
Contributor Author

HarelM commented Aug 5, 2018

I never said anything about removing existing calls :-)
The above suggesting is great IMO.

airbreather added a commit that referenced this issue Aug 20, 2018
Also probably fix something that was making test failures not fail the build... derp.
@airbreather airbreather added this to the Alpha 0.2.0 milestone Aug 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants