Package org.openstreetmap.josm.io
Class GpxWriter
- java.lang.Object
-
- org.openstreetmap.josm.io.XmlWriter
-
- org.openstreetmap.josm.io.GpxWriter
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,GpxConstants
- Direct Known Subclasses:
MarkerSessionExporter.MarkerWriter
public class GpxWriter extends XmlWriter implements GpxConstants
Writes GPX files from GPX data or OSM data.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.data.gpx.GpxConstants
GpxConstants.ColorFormat
-
-
Field Summary
Fields Modifier and Type Field Description private GpxData
data
private String
indent
private Instant
metaTime
private static int
ROUTE_POINT
private static int
TRACK_POINT
private List<String>
validprefixes
private static int
WAY_POINT
-
Fields inherited from interface org.openstreetmap.josm.data.gpx.GpxConstants
EXTENSION_ABBREVIATIONS, FIX_VALUES, GARMIN_COLORS, GPX_CMT, GPX_DESC, GPX_NAME, GPX_PREFIX, GPX_SRC, JOSM_CREATOR_NAME, META_AUTHOR_EMAIL, META_AUTHOR_LINK, META_AUTHOR_NAME, META_BOUNDS, META_COPYRIGHT_AUTHOR, META_COPYRIGHT_LICENSE, META_COPYRIGHT_YEAR, META_DESC, META_KEYWORDS, META_LINKS, META_NAME, META_PREFIX, META_TIME, PT_AGEOFDGPSDATA, PT_DGPSID, PT_ELE, PT_FIX, PT_GEOIDHEIGHT, PT_HDOP, PT_MAGVAR, PT_PDOP, PT_SAT, PT_SYM, PT_TIME, PT_TYPE, PT_VDOP, RTE_TRK_KEYS, RTKLIB_AGE, RTKLIB_Q, RTKLIB_RATIO, RTKLIB_SDE, RTKLIB_SDEU, RTKLIB_SDN, RTKLIB_SDNE, RTKLIB_SDU, RTKLIB_SDUN, WPT_KEYS, XML_URI_EXTENSIONS_DRAWING, XML_URI_EXTENSIONS_GARMIN, XML_URI_EXTENSIONS_JOSM, XML_URI_XSD, XML_XSD_EXTENSIONS_DRAWING, XML_XSD_EXTENSIONS_GARMIN, XML_XSD_EXTENSIONS_JOSM
-
-
Constructor Summary
Constructors Constructor Description GpxWriter(OutputStream out)
Constructs a newGpxWriter
.GpxWriter(PrintWriter out)
Constructs a newGpxWriter
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
close(String tag)
private void
closeln(String tag)
Instant
getMetaTime()
Returns the forced metadata time information, if any.private void
gpxExtensions(GpxExtensionCollection allExtensions)
private void
gpxLink(GpxLink link)
output linkprivate void
inline(String tag, String attributes)
private void
open(String tag)
private void
open(String tag, String attributes)
private void
openln(String tag)
private void
openln(String tag, String attributes)
void
setMetaTime(Instant metaTime)
Sets the forced metadata time information.private void
simpleTag(String tag, String content)
if content not null, open tag, write encoded content, and close tag else do nothing.private void
simpleTag(String tag, String content, String attributes)
private void
wayPoint(WayPoint pnt, int mode)
output a pointvoid
write(GpxData data)
Writes the given GPX data.void
write(GpxData data, GpxConstants.ColorFormat colorFormat, boolean savePrefs)
Writes the given GPX data.private void
writeAttr(IWithAttributes obj, List<String> keys)
private void
writeExtension(List<GpxExtension> extensions)
private void
writeMetaData()
private void
writeRoutes()
private void
writeTracks()
private void
writeWayPoints()
-
-
-
Field Detail
-
validprefixes
private List<String> validprefixes
-
WAY_POINT
private static final int WAY_POINT
- See Also:
- Constant Field Values
-
ROUTE_POINT
private static final int ROUTE_POINT
- See Also:
- Constant Field Values
-
TRACK_POINT
private static final int TRACK_POINT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GpxWriter
public GpxWriter(PrintWriter out)
Constructs a newGpxWriter
.- Parameters:
out
- The output writer
-
GpxWriter
public GpxWriter(OutputStream out)
Constructs a newGpxWriter
.- Parameters:
out
- The output stream
-
-
Method Detail
-
getMetaTime
public Instant getMetaTime()
Returns the forced metadata time information, if any.- Returns:
- the forced metadata time information, or
null
- Since:
- 18219
-
setMetaTime
public void setMetaTime(Instant metaTime)
Sets the forced metadata time information.- Parameters:
metaTime
- the forced metadata time information, ornull
to use the current time- Since:
- 18219
-
write
public void write(GpxData data)
Writes the given GPX data.- Parameters:
data
- The data to write
-
write
public void write(GpxData data, GpxConstants.ColorFormat colorFormat, boolean savePrefs)
Writes the given GPX data.- Parameters:
data
- The data to writecolorFormat
- determines if colors are saved and which extension is to be usedsavePrefs
- whether layer specific preferences are saved
-
writeAttr
private void writeAttr(IWithAttributes obj, List<String> keys)
-
writeMetaData
private void writeMetaData()
-
writeWayPoints
private void writeWayPoints()
-
writeRoutes
private void writeRoutes()
-
writeTracks
private void writeTracks()
-
simpleTag
private void simpleTag(String tag, String content)
if content not null, open tag, write encoded content, and close tag else do nothing.- Parameters:
tag
- GPX tagcontent
- content
-
wayPoint
private void wayPoint(WayPoint pnt, int mode)
output a point- Parameters:
pnt
- waypointmode
-WAY_POINT
forwpt
,ROUTE_POINT
forrtept
,TRACK_POINT
fortrkpt
-
gpxExtensions
private void gpxExtensions(GpxExtensionCollection allExtensions)
-
writeExtension
private void writeExtension(List<GpxExtension> extensions)
-
-