-
Notifications
You must be signed in to change notification settings - Fork 19
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
functionality to update gpx traces from files #37
Conversation
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.
Thanks, looks fine! I have a few comments on that.
(There is also a bug in the code, but it will go away after doing the requested changes.)
libs/core/src/main/java/de/westnordost/osmapi/common/GpxInputStreamWriter.java
Outdated
Show resolved
Hide resolved
libs/core/src/main/java/de/westnordost/osmapi/common/GpxInputStreamWriter.java
Outdated
Show resolved
Hide resolved
libs/core/src/main/java/de/westnordost/osmapi/common/GpxInputStreamWriter.java
Outdated
Show resolved
Hide resolved
libs/traces/src/main/java/de/westnordost/osmapi/traces/GpsTracesApi.java
Outdated
Show resolved
Hide resolved
libs/traces/src/main/java/de/westnordost/osmapi/traces/GpsTracesApi.java
Show resolved
Hide resolved
Thanks for the review, i applied the improvements to the code. |
libs/traces/src/main/java/de/westnordost/osmapi/traces/GpxInputStreamWriter.java
Outdated
Show resolved
Hide resolved
libs/traces/src/main/java/de/westnordost/osmapi/traces/GpxInputStreamWriter.java
Outdated
Show resolved
Hide resolved
InputStream is = new FileInputStream(gpxFile); | ||
|
||
long id = privilegedApi.create("gpx file test case", Visibility.PRIVATE, "test case from gpx file desc", | ||
tags, is); |
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.
Oh, don't forget to close the file input stream after it is read, otherwise the file will stay open.
Also in your own OSMTracker code of course.
I read up whether it is good practice to close the input stream already in our case in TracesApi::create
but the general opinion is that an input stream should be closed at the level where it is created. In any case, it might be a good hint to explicitly state that in the javadoc, too.
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.
Thanks for the reminder to close the stream. Will add a line in the javadoc comment of the method.
Great, thank you! There is one thing left that is also relevant for your implementation in OSMTracker. You'll likely want to use try-with-resources so that the file handle is always closed also if an IO exception occurs: try (InputStream in = new FileInputStream(file)) {
// ...
} catch (IOException e) {
// ...
} |
Nice, thank you! Will release a new version today. |
implements Upload gpx from file #36