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

Don't write empty objects to GPX file #17

Closed
jenetics opened this issue Jan 8, 2017 · 1 comment
Closed

Don't write empty objects to GPX file #17

jenetics opened this issue Jan 8, 2017 · 1 comment
Assignees
Milestone

Comments

@jenetics
Copy link
Owner

jenetics commented Jan 8, 2017

The GPX definition allows to create empty objects like

final GPX gpx = GPX.builder()
    .metadata(md -> {})
    .addTrack(track -> {})
    .addTrack(track -> track
        .addSegment(segment -> {})
        .addSegment(segment -> segment
            .addPoint(wp -> wp.ele(12).lat(21).lon(23))))
    .build();

GPX.write(gpx, System.out, "    ");

This leads to empty elements in the serialized GPX file.

<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="JPX - https://jenetics.github.io/jpx" xmlns="http://www.topografix.com/GPX/1/1">
    <metadata></metadata>
    <trk></trk>
    <trk>
        <trkseg></trkseg>
        <trkseg>
            <trkpt lat="21.0" lon="23.0">
                <ele>12.0</ele>
            </trkpt>
        </trkseg>
    </trk>
</gpx>

The files are valid, but empty elements doesn't add additional information. The library should omit empty objects when writing them into a file.

@jenetics jenetics added this to the v1.1.0 milestone Jan 8, 2017
@jenetics jenetics self-assigned this Jan 8, 2017
jenetics added a commit that referenced this issue Feb 22, 2017
#17: Implement filter for removing empty GPX elements
@jenetics
Copy link
Owner Author

Merged into r1.1.0 branch.

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

No branches or pull requests

1 participant