Package slash.navigation.kml
Class KmlFormat
java.lang.Object
slash.navigation.base.BaseNavigationFormat<KmlRoute>
slash.navigation.base.XmlNavigationFormat<KmlRoute>
slash.navigation.kml.BaseKmlFormat
slash.navigation.kml.KmlFormat
- All Implemented Interfaces:
MultipleRoutesFormat<KmlRoute>,NavigationFormat<KmlRoute>
- Direct Known Subclasses:
Kml20Format,Kml21Format,Kml22BetaFormat,Kml22Format
The base of all Google Earth formats.
- Author:
- Christian Pesch
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class slash.navigation.base.BaseNavigationFormat
GENERATED_BY, UNLIMITED_MAXIMUM_POSITION_COUNT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendPlacemarkAsWaypointOrTrack(String name, String description, String placemarkName, boolean characteristicsFromRouteName, String placemarkDescription, String styleUrl, CompactCalendar time, List<KmlPosition> positions, List<KmlPosition> waypoints, ParserContext<KmlRoute> context) Appends a placemark's positions as a single waypoint (one position) or a track (more).protected KmlPositionasKmlPosition(NavigationPosition position) protected List<KmlPosition> asKmlPositions(List<String> strings) protected StringconcatPath(String path, String fragment) protected StringcreateCoordinates(KmlPosition position, boolean separateWithSpace) protected StringcreateDocumentName(KmlRoute route) protected StringcreateFolderName(String prefix, KmlRoute route) createLineStringCoordinates(KmlRoute route, int startIndex, int endIndex) Renders route.getPositions()[startIndex, endIndex) as KML coordinate strings for a LineString.<P extends NavigationPosition>
KmlRoutecreateRoute(RouteCharacteristics characteristics, String name, List<P> positions) protected voidenrichPosition(KmlPosition position, CompactCalendar time, String name, String description, CompactCalendar startDate) protected List<KmlPosition> extractPositionsByElementName(jakarta.xml.bind.JAXBElement<?> geometryElement, Function<Object, List<? extends jakarta.xml.bind.JAXBElement<?>>> multiGeometryChildrenOf, Function<jakarta.xml.bind.JAXBElement<?>, List<KmlPosition>> recurse) Extracts positions from a Point/LineString/MultiGeometry element by dispatching on the element's local name rather than its JAXB-bound Java type.protected <T> voidextractTracksFromContainers(List<jakarta.xml.bind.JAXBElement<T>> containers, Function<T, String> nameOf, KmlFormat.FeatureRecursor<T> recurseInto) Recurses into each child container (KML Folder or Document), invoking recurseInto with the container's resolved name and its raw (version-specific) value. nameOf may return null to skip a container without recursing into it -- KML 2.2 uses this to ignore its internal "speed" and "marks" folders, a behaviour the other versions don't have and don't trigger (their nameOf never returns null).protected <T> List<jakarta.xml.bind.JAXBElement<T>> Filters a list of feature elements down to those whose element local name matches, regardless of the JAXB-bound feature supertype (KML 2.1 binds against FeatureType, KML 2.2-beta/2.2 against AbstractFeatureType) -- the lookup only needs the element's QName, which JAXBElement exposes independent of its type parameter.protected floatprotected byte[]protected byte[]booleanprotected booleanprotected booleanbooleanprotected RouteCharacteristicsparseCharacteristics(String nameToParse, String styleUrl, RouteCharacteristics fallback) protected StringparseFolderName(String folderName) protected CompactCalendarprotected voidprependWaypointsRoute(String name, String description, List<KmlPosition> waypoints, ParserContext<KmlRoute> context) Prepends the accumulated single-position placemarks as one combined waypoint route.Methods inherited from class slash.navigation.base.XmlNavigationFormat
asDescription, getMaximumPositionCountMethods inherited from class slash.navigation.base.BaseNavigationFormat
asDesc, asDesc, asDescription, asDescription, asName, asName, asRouteName, equals, getCreator, getMaximumFileNameLength, getMaximumRouteNameLength, hashCode, isSupportsReading, isSupportsWritingMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface slash.navigation.base.MultipleRoutesFormat
writeMethods inherited from interface slash.navigation.base.NavigationFormat
getMaximumFileNameLength, getMaximumPositionCount, getMaximumRouteNameLength, getName, isSupportsReading, isSupportsWriting, read, write
-
Constructor Details
-
KmlFormat
public KmlFormat()
-
-
Method Details
-
getExtension
-
isSupportsMultipleRoutes
public boolean isSupportsMultipleRoutes() -
isWritingRouteCharacteristics
public boolean isWritingRouteCharacteristics() -
asKmlPositions
-
parseFolderName
-
parseTime
-
find
protected <T> List<jakarta.xml.bind.JAXBElement<T>> find(List<? extends jakarta.xml.bind.JAXBElement<?>> elements, String name, Class<T> resultClass) Filters a list of feature elements down to those whose element local name matches, regardless of the JAXB-bound feature supertype (KML 2.1 binds against FeatureType, KML 2.2-beta/2.2 against AbstractFeatureType) -- the lookup only needs the element's QName, which JAXBElement exposes independent of its type parameter. Identical across all three modern KML versions; previously duplicated verbatim in each. -
extractPositionsByElementName
protected List<KmlPosition> extractPositionsByElementName(jakarta.xml.bind.JAXBElement<?> geometryElement, Function<Object, List<? extends jakarta.xml.bind.JAXBElement<?>>> multiGeometryChildrenOf, Function<jakarta.xml.bind.JAXBElement<?>, List<KmlPosition>> recurse) Extracts positions from a Point/LineString/MultiGeometry element by dispatching on the element's local name rather than its JAXB-bound Java type. KML 2.1/2.2-beta/2.2 each generate separate, unrelated PointType/LineStringType/MultiGeometryType classes with no shared supertype, but all three expose an identical getCoordinates() shape on Point/ LineString -- read here via reflection so one method serves all three instead of each duplicating the same instanceof chain. Geometry kinds other than Point/LineString/ MultiGeometry (e.g. KML 2.2's gx:Track) are left to the caller, matching the original per-version code, which also silently ignored anything it didn't explicitly check for. multiGeometryChildrenOf supplies the version-specific MultiGeometry child accessor (getGeometry() in KML 2.1, getAbstractGeometryGroup() in 2.2-beta/2.2); recurse must be the caller's own full extraction method (not this one), so that version-specific geometry kinds nested inside a MultiGeometry are still recognised by the caller on the way back in. Operates on raw JAXBElementinvalid input: '<'?>/Object rather than a shared bound type -- the per-version binding classes don't have one -- so each caller's lambdas carry a single unchecked cast at the type-erasure boundary; that cast is always safe since the value really is whatever binding type the caller's own JAXB unmarshalling produced. -
concatPath
-
getLineWidth
protected float getLineWidth() -
getRouteLineColor
protected byte[] getRouteLineColor() -
getTrackLineColor
protected byte[] getTrackLineColor() -
isWriteName
protected boolean isWriteName() -
isWriteDesc
protected boolean isWriteDesc()
-