Skip to content

Commit ddf6b9b

Browse files
committed
Adjust KML color style models.
1 parent f7e9e01 commit ddf6b9b

File tree

17 files changed

+63
-29
lines changed

17 files changed

+63
-29
lines changed

worldwind/src/commonMain/kotlin/earth/worldwind/formats/kml/models/ColorStyle.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import nl.adaptivity.xmlutil.serialization.XmlSerialName
99
* It provides elements for specifying the color and color mode of extended style types.
1010
*/
1111
@Serializable
12-
internal abstract class ColorStyle(
12+
internal abstract class ColorStyle : Object() {
1313
/**
1414
* Color and opacity (alpha) values are expressed in hexadecimal notation.
1515
* The range of values for any one color is 0 to 255 (00 to ff). For alpha, 00 is fully transparent and ff is fully opaque.
@@ -18,7 +18,7 @@ internal abstract class ColorStyle(
1818
* <color>7fff0000</color>, where alpha=0x7f, blue=0xff, green=0x00, and red=0x00.
1919
*/
2020
@XmlElement
21-
val color: String = "ffffffff",
21+
abstract val color: String
2222

2323
/**
2424
* Values for [colorMode] are [ColorMode.normal] (no effect) and [ColorMode.random].
@@ -32,5 +32,5 @@ internal abstract class ColorStyle(
3232
*/
3333
@XmlSerialName("colorMode")
3434
@XmlElement
35-
val colorMode: ColorMode = ColorMode.normal
36-
) : Object()
35+
abstract val colorMode: ColorMode
36+
}

worldwind/src/commonMain/kotlin/earth/worldwind/formats/kml/models/Coordinates.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@ import nl.adaptivity.xmlutil.serialization.XmlValue
66
@Serializable
77
internal data class Coordinates(@XmlValue(true) val value: String) {
88
override fun toString() = value
9+
10+
companion object {
11+
fun fromCoordinates(list: List<Coordinate>) = Coordinates(value = toString(list))
12+
13+
private fun toString(list: List<Coordinate>) = list.joinToString(" ") { it.toString() }
14+
}
915
}

worldwind/src/commonMain/kotlin/earth/worldwind/formats/kml/models/Document.kt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package earth.worldwind.formats.kml.models
22

33
import kotlinx.serialization.Serializable
44
import nl.adaptivity.xmlutil.serialization.XmlElement
5-
import nl.adaptivity.xmlutil.serialization.XmlPolyChildren
65

76
/**
87
* A Document is a container for features and styles. This element is required if your KML file uses shared styles.
@@ -32,22 +31,9 @@ import nl.adaptivity.xmlutil.serialization.XmlPolyChildren
3231
internal data class Document(
3332
override val id: String? = null,
3433

35-
/**
36-
* Define all Styles in a Document. Assign a unique ID to each Style.
37-
*/
38-
@XmlElement
39-
val styles: List<Style> = emptyList(),
40-
41-
/**
42-
* Within a given Feature or StyleMap, reference the Style's ID using a [styleUrl] element.
43-
*/
44-
@XmlElement
45-
val styleMaps: List<StyleMap> = emptyList(),
46-
4734
/**
4835
* Specifies a custom KML schemas that is used to add custom data to KML Features.
4936
*/
5037
@XmlElement
5138
val schemas: List<Schema> = emptyList(),
52-
) : Container()
53-
39+
) : Container()

worldwind/src/commonMain/kotlin/earth/worldwind/formats/kml/models/Feature.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import earth.worldwind.formats.kml.serializer.FlexibleBooleanSerializer
44
import kotlinx.serialization.Serializable
55
import nl.adaptivity.xmlutil.serialization.XmlElement
66
import nl.adaptivity.xmlutil.serialization.XmlPolyChildren
7-
import nl.adaptivity.xmlutil.serialization.XmlSerialName
87

98
/**
109
* This is an abstract element and cannot be used directly in a KML file.
@@ -112,7 +111,7 @@ internal abstract class Feature(
112111
"earth.worldwind.formats.kml.models.StyleMap",
113112
]
114113
)
115-
val styleSelector: StyleSelector? = null,
114+
val styleSelector: List<StyleSelector> = emptyList(),
116115

117116
/**
118117
* Features and geometry associated with a Region are drawn only when the Region is active. See [Region].

worldwind/src/commonMain/kotlin/earth/worldwind/formats/kml/models/Folder.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package earth.worldwind.formats.kml.models
22

33
import kotlinx.serialization.Serializable
4-
import nl.adaptivity.xmlutil.serialization.XmlElement
5-
import nl.adaptivity.xmlutil.serialization.XmlPolyChildren
64

75
/**
86
* A Folder is used to arrange other Features hierarchically ([Folder]s, [Placemark]s, [NetworkLink]s, or [Overlay]s).

worldwind/src/commonMain/kotlin/earth/worldwind/formats/kml/models/HotSpot.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ internal data class HotSpot(
2727
* A value of pixels indicates the x value in pixels. A value of insetPixels indicates the indent from the right edge of the icon.
2828
*/
2929
@XmlSerialName("xunits")
30-
val xunits: HotSpotUnits,
30+
val xunits: HotSpotUnits = HotSpotUnits.fraction,
3131

3232
/**
3333
* Units in which the y value is specified. A value of fraction indicates the y value is a fraction of the icon.
3434
* A value of pixels indicates the y value in pixels. A value of insetPixels indicates the indent from the top edge of the icon.
3535
*/
3636
@XmlSerialName("yunits")
37-
val yunits: HotSpotUnits,
37+
val yunits: HotSpotUnits = HotSpotUnits.fraction,
3838
)

worldwind/src/commonMain/kotlin/earth/worldwind/formats/kml/models/Icon.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal data class Icon(
1818
* An HTTP address or a local file specification used to load an icon.
1919
*/
2020
@XmlElement
21-
val href: String? = null,
21+
val href: String,
2222

2323
/**
2424
* If the <href> specifies an icon palette, these elements identify the offsets, in pixels, from the lower-left

worldwind/src/commonMain/kotlin/earth/worldwind/formats/kml/models/IconStyle.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import nl.adaptivity.xmlutil.serialization.XmlSerialName
1313
internal data class IconStyle(
1414
override val id: String? = null,
1515

16+
@XmlElement
17+
override var color: String = "ffffffff",
18+
19+
@XmlElement
20+
override val colorMode: ColorMode = ColorMode.normal,
21+
1622
/**
1723
* Resizes the icon.
1824
*/

worldwind/src/commonMain/kotlin/earth/worldwind/formats/kml/models/LabelStyle.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import nl.adaptivity.xmlutil.serialization.XmlElement
1111
internal data class LabelStyle(
1212
override val id: String? = null,
1313

14+
@XmlElement
15+
override var color: String = "ffffffff",
16+
17+
@XmlElement
18+
override val colorMode: ColorMode = ColorMode.normal,
19+
1420
/**
1521
* Resizes the label.
1622
*/

worldwind/src/commonMain/kotlin/earth/worldwind/formats/kml/models/LineStyle.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import nl.adaptivity.xmlutil.serialization.XmlSerialName
1414
internal data class LineStyle(
1515
override val id: String? = null,
1616

17+
@XmlElement
18+
override var color: String = "ffffffff",
19+
20+
@XmlElement
21+
override val colorMode: ColorMode = ColorMode.normal,
22+
1723
/**
1824
* Width of the line, in pixels.
1925
*/

0 commit comments

Comments
 (0)