Skip to content

Commit

Permalink
reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
sun-jiao committed Mar 9, 2024
1 parent 3bae1ff commit 5091f91
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 91 deletions.
19 changes: 9 additions & 10 deletions lib/src/kml_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,10 @@ class KmlReader {
polygon = Polygon();
break;
case KmlTag.extrude:
item.extrude =
(await _readInt(iterator, val.name))?.toBool();
item.extrude = (await _readInt(iterator, val.name))?.toBool();
break;
case KmlTag.tessellate:
tessellate =
(await _readInt(iterator, val.name))?.toBool();
tessellate = (await _readInt(iterator, val.name))?.toBool();
break;
case KmlTag.altitudeMode:
item.altitudeMode =
Expand All @@ -217,8 +215,9 @@ class KmlReader {
break;
case KmlTag.innerBoundaryIs:
polygon = polygon ?? Polygon();
polygon.innerBoundaryIs.addAll((await _readCoordinates(iterator,
val.name)).map((e) => Rte(rtepts: e)));
polygon.innerBoundaryIs.addAll(
(await _readCoordinates(iterator, val.name))
.map((e) => Rte(rtepts: e)));
break;
case KmlTag.style:
style = await _readStyle(iterator, val.name);
Expand Down Expand Up @@ -978,12 +977,12 @@ class KmlReader {
if (val is XmlStartElementEvent) {
switch (val.name) {
case KmlTag.bgColor:
balloonStyle.bgColor = await _readInt(iterator, val.name, 16)
?? balloonStyle.bgColor;
balloonStyle.bgColor = await _readInt(iterator, val.name, 16) ??
balloonStyle.bgColor;
break;
case KmlTag.textColor:
balloonStyle.textColor = await _readInt(iterator, val.name, 16)
?? balloonStyle.textColor;
balloonStyle.textColor = await _readInt(iterator, val.name, 16) ??
balloonStyle.textColor;
break;
case KmlTag.text:
balloonStyle.text = await _readString(iterator, val.name) ?? '';
Expand Down
36 changes: 18 additions & 18 deletions lib/src/kml_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ class KmlWriter {
_writeAtomLinks(builder, item.links);

if (item.style != null) {
if (item.style!.id != null && item.style!.id!.isNotEmpty
&& geoXml.styles.contains(item.style)) {
if (item.style!.id != null &&
item.style!.id!.isNotEmpty &&
geoXml.styles.contains(item.style)) {
_writeElement(builder, KmlTag.styleUrl, '#${item.style!.id}');
} else {
_writeStyle(builder, item.style!);
Expand Down Expand Up @@ -206,8 +207,9 @@ class KmlWriter {

// Style the polygon.
if (polygon.style != null) {
if (polygon.style!.id != null && polygon.style!.id!.isNotEmpty
&& geoXml.styles.contains(polygon.style)) {
if (polygon.style!.id != null &&
polygon.style!.id!.isNotEmpty &&
geoXml.styles.contains(polygon.style)) {
_writeElement(builder, KmlTag.styleUrl, '#${polygon.style!.id}');
} else {
_writeStyle(builder, polygon.style!);
Expand Down Expand Up @@ -251,8 +253,8 @@ class KmlWriter {
builder.element(KmlTag.polyStyle, nest: () {
_writeColorStyleElements(builder, style.polyStyle);
_writeElement(builder, KmlTag.fill, style.polyStyle?.fill?.toInt());
_writeElement(builder,
KmlTag.outline, style.polyStyle?.outline?.toInt());
_writeElement(
builder, KmlTag.outline, style.polyStyle?.outline?.toInt());
});
}

Expand All @@ -267,9 +269,9 @@ class KmlWriter {
_writeElement(builder, KmlTag.scale, style.iconStyle?.scale);
_writeElement(builder, KmlTag.heading, style.iconStyle?.heading);
if (style.iconStyle?.x != null &&
style.iconStyle?.y != null &&
style.iconStyle?.xunit != null &&
style.iconStyle?.yunit != null){
style.iconStyle?.y != null &&
style.iconStyle?.xunit != null &&
style.iconStyle?.yunit != null) {
builder.element(KmlTag.hotSpot, attributes: {
KmlTag.hotSpotX: style.iconStyle!.x!.toString(),
KmlTag.hotSpotY: style.iconStyle!.y!.toString(),
Expand All @@ -293,8 +295,7 @@ class KmlWriter {
style.balloonStyle!.bgColor.toRadixString(16));
_writeElement(builder, KmlTag.textColor,
style.balloonStyle!.textColor.toRadixString(16));
_writeElement(builder, KmlTag.text,
style.balloonStyle!.text);
_writeElement(builder, KmlTag.text, style.balloonStyle!.text);
_writeElement(builder, KmlTag.displayMode,
style.balloonStyle!.show ? 'default' : 'hide');
});
Expand All @@ -306,10 +307,8 @@ class KmlWriter {
if (colorStyle == null) {
return;
}
_writeElement(builder,
KmlTag.color, colorStyle.color?.toRadixString(16));
_writeElement(builder,
KmlTag.colorMode, colorStyle.colorMode?.name);
_writeElement(builder, KmlTag.color, colorStyle.color?.toRadixString(16));
_writeElement(builder, KmlTag.colorMode, colorStyle.colorMode?.name);
}

void _writePoint(XmlBuilder builder, Wpt wpt, GeoXml geoXml) {
Expand All @@ -320,10 +319,11 @@ class KmlWriter {
_writeElementWithTime(builder, wpt.time);

_writeAtomLinks(builder, wpt.links);

if (wpt.style != null) {
if (wpt.style!.id != null && wpt.style!.id!.isNotEmpty
&& geoXml.styles.contains(wpt.style)) {
if (wpt.style!.id != null &&
wpt.style!.id!.isNotEmpty &&
geoXml.styles.contains(wpt.style)) {
_writeElement(builder, KmlTag.styleUrl, '#${wpt.style!.id}');
} else {
_writeStyle(builder, wpt.style!);
Expand Down
3 changes: 1 addition & 2 deletions lib/src/model/geo_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ class GeoObject {
AltitudeMode? altitudeMode;
}


enum AltitudeMode {
clampToGround,
relativeToGround,
absolute,
relativeToSeaFloor,
clampToSeaFloor,
}
}
81 changes: 40 additions & 41 deletions lib/src/model/polygon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,21 @@ class Polygon implements GeoObject {
List<Rte> innerBoundaryIs;

/// Construct a new [Trk] object.
Polygon(
{this.name,
this.cmt,
this.desc,
this.src,
List<Link>? links,
this.number,
this.type,
Map<String, String>? extensions,
this.extrude,
this.tessellate,
this.altitudeMode,
Rte? outerBoundaryIs,
List<Rte>? innerBoundaryIs,
})
: links = links ?? [],
Polygon({
this.name,
this.cmt,
this.desc,
this.src,
List<Link>? links,
this.number,
this.type,
Map<String, String>? extensions,
this.extrude,
this.tessellate,
this.altitudeMode,
Rte? outerBoundaryIs,
List<Rte>? innerBoundaryIs,
}) : links = links ?? [],
extensions = extensions ?? <String, String>{},
outerBoundaryIs = outerBoundaryIs ?? Rte(),
innerBoundaryIs = innerBoundaryIs ?? [];
Expand Down Expand Up @@ -110,32 +109,32 @@ class Polygon implements GeoObject {

@override
String toString() => "Polygon[${[
name,
type,
extensions,
style,
extrude,
tessellate,
altitudeMode,
outerBoundaryIs,
innerBoundaryIs
].join(",")}]";
name,
type,
extensions,
style,
extrude,
tessellate,
altitudeMode,
outerBoundaryIs,
innerBoundaryIs
].join(",")}]";

@override
int get hashCode => hashObjects([
name,
cmt,
desc,
src,
number,
type,
extrude,
tessellate,
altitudeMode,
outerBoundaryIs,
...links,
...extensions.keys,
...extensions.values,
...innerBoundaryIs
]);
name,
cmt,
desc,
src,
number,
type,
extrude,
tessellate,
altitudeMode,
outerBoundaryIs,
...links,
...extensions.keys,
...extensions.values,
...innerBoundaryIs
]);
}
18 changes: 9 additions & 9 deletions lib/src/model/rte.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ class Rte implements GeoObject {

@override
String toString() => "Rte[${[
name,
type,
extensions,
style,
extrude,
tessellate,
altitudeMode,
rtepts,
].join(",")}]";
name,
type,
extensions,
style,
extrude,
tessellate,
altitudeMode,
rtepts,
].join(",")}]";

@override
int get hashCode => hashObjects([
Expand Down
18 changes: 9 additions & 9 deletions lib/src/model/trk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ class Trk implements GeoObject {

@override
String toString() => "Trk[${[
name,
type,
extensions,
style,
extrude,
tessellate,
altitudeMode,
trksegs,
].join(",")}]";
name,
type,
extensions,
style,
extrude,
tessellate,
altitudeMode,
trksegs,
].join(",")}]";

@override
int get hashCode => hashObjects([
Expand Down
3 changes: 1 addition & 2 deletions lib/src/model/wpt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ class Wpt implements GeoObject {
other.lat == lat && other.lon == lon && other.ele == ele;

@override
String toString() =>
"Wpt[${[
String toString() => "Wpt[${[
lat,
lon,
ele,
Expand Down

0 comments on commit 5091f91

Please sign in to comment.