java.lang.Object
io.jenetics.jpx.GPX.Writer
- Enclosing class:
- GPX
Class for writing GPX files. A writer instance can be created by the
GPX.writer factory methods.- Since:
- 1.3
- Version:
- 3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents the indentation value, the writer is using. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final GPX.WriterThe default GPX writer, with no indention and fraction digits ofDEFAULT_FRACTION_DIGITS.static final intThe default value for the maximum fraction digits. -
Method Summary
Modifier and TypeMethodDescriptionindent()Return the indentation string this GPX writer is using.intReturn the maximum number of digits allowed in the fraction portion of the written numbers like latitude and longitude.static GPX.Writerof(GPX.Writer.Indent indent) Return a new GPX writer with the givenindentand with maximum fraction digits ofDEFAULT_FRACTION_DIGITS.static GPX.Writerof(GPX.Writer.Indent indent, int maximumFractionDigits) Return a new GPX writer with the givenindentand number formatter, which is used for formattingWayPoint.getLatitude(),WayPoint.getLongitude(), ...Create an XML string representation of the givengpxobject.voidWrites the givengpxobject (in GPX XML format) to the givenfile.voidwrite(GPX gpx, OutputStream output) Writes the givengpxobject (in GPX XML format) to the givenoutputstream.voidWrites the givengpxobject (in GPX XML format) to the givenpath.voidWrites the givengpxobject (in GPX XML format) to the givenpath.voidWrites the givengpxobject to the givenresult.
-
Field Details
-
DEFAULT_FRACTION_DIGITS
The default value for the maximum fraction digits.- See Also:
-
DEFAULT
The default GPX writer, with no indention and fraction digits ofDEFAULT_FRACTION_DIGITS.- Since:
- 3.0
- See Also:
-
-
Method Details
-
indent
Return the indentation string this GPX writer is using.- Returns:
- the indentation string
- Since:
- 3.0
-
maximumFractionDigits
Return the maximum number of digits allowed in the fraction portion of the written numbers like latitude and longitude.- Returns:
- the maximum number of digits allowed in the fraction portion of the written numbers
-
write
Writes the givengpxobject to the givenresult. This is the most general way for writingGPXobjects.The following example shows how to create an XML-Document from a given
GPXobject.final GPX gpx = ...; final Document doc = XMLProvider.provider() .documentBuilderFactory() .newDocumentBuilder() .newDocument(); // The GPX data are written to the empty `doc` object. GPX.Writer.DEFAULT.write(gpx, new DOMResult(doc));- Parameters:
gpx- the GPX object to write to the outputresult- the output document- Throws:
IOException- if the writing of the GPX object failsNullPointerException- if one of the given arguments isnull- Since:
- 3.0
-
write
Writes the givengpxobject (in GPX XML format) to the givenoutputstream. The caller of this method is responsible for closing the givenoutputstream.- Parameters:
gpx- the GPX object to write to the outputoutput- the output stream where the GPX object is written to- Throws:
IOException- if the writing of the GPX object failsNullPointerException- if one of the given arguments isnull
-
write
Writes the givengpxobject (in GPX XML format) to the givenpath.- Parameters:
gpx- the GPX object to write to the outputpath- the output path where the GPX object is written to- Throws:
IOException- if the writing of the GPX object failsNullPointerException- if one of the given arguments isnull
-
write
Writes the givengpxobject (in GPX XML format) to the givenfile.- Parameters:
gpx- the GPX object to write to the outputfile- the output file where the GPX object is written to- Throws:
IOException- if the writing of the GPX object failsNullPointerException- if one of the given arguments isnull
-
write
Writes the givengpxobject (in GPX XML format) to the givenpath.- Parameters:
gpx- the GPX object to write to the outputpath- the output path where the GPX object is written to- Throws:
IOException- if the writing of the GPX object failsNullPointerException- if one of the given arguments isnull
-
toString
Create an XML string representation of the givengpxobject.- Parameters:
gpx- the GPX object to convert to a string- Returns:
- the XML string representation of the given
gpxobject - Throws:
NullPointerException- if the given GPX object isnull- See Also:
-
of
Return a new GPX writer with the givenindentand number formatter, which is used for formattingWayPoint.getLatitude(),WayPoint.getLongitude(), ...The example below shows the lat and lon values with maximal 5 fractional digits.
The following table should give you a feeling about the accuracy of a given fraction digits count, at the equator.<trkpt lat="45.78068" lon="12.55368"> <ele>1.2</ele> <time>2009-08-30T07:08:21Z</time> </trkpt>Maximum fraction digits accuracy Fraction digits Degree Distance 0 1 111.31 km 1 0.1 11.13 km 2 0,01 1.1 km 3 0.001 111.3 m 4 0.0001 11.1 m 5 0.00001 1.11 m 6 0.000001 0.1 m 7 0.0000001 11.1 mm 8 0.00000001 1.1 mm 9 0.000000001 0.11 mm - Parameters:
indent- the element indentationmaximumFractionDigits- the maximum number of digits allowed in the fraction portion of a number- Returns:
- a new GPX writer
- Since:
- 3.0
- See Also:
-
of
Return a new GPX writer with the givenindentand with maximum fraction digits ofDEFAULT_FRACTION_DIGITS.- Parameters:
indent- the element indentation- Returns:
- a new GPX writer
- Since:
- 3.0
- See Also:
-