-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new src directory: it; KML:Mergeable:merge method now has a mergeNames parameter; println statements replaced by log messages;
- Loading branch information
1 parent
6464c37
commit 692cc60
Showing
7 changed files
with
122 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ sampleOutput.kml | |
/KML_Samples_output.kml | ||
|
||
*_out.kml | ||
|
||
work |
74 changes: 74 additions & 0 deletions
74
src/it/scala/com/phasmidsoftware/kmldoc/KMLEditorFuncSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.phasmidsoftware.kmldoc | ||
|
||
import cats.effect.IO | ||
import cats.effect.unsafe.implicits.global | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should | ||
import scala.util._ | ||
|
||
class KMLEditorFuncSpec extends AnyFlatSpec with should.Matchers { | ||
|
||
behavior of "KMLEditor" | ||
|
||
val placemark = "Placemark" | ||
private val triedFilename: Success[String] = Success("src/main/resources/com/phasmidsoftware/kmldoc/placemarks.kml") | ||
|
||
it should "processKMLs join" in { | ||
val editor = KMLEditor(Seq(KmlEdit(KmlEdit.JOIN, 2, Element(placemark, "Salem & Lowell RR (#1)"), Some(Element(placemark, "Salem & Lowell RR (#2)"))), KmlEdit(KmlEdit.DELETE, 1, Element(placemark, "Salem & Lowell RR (#2)"), None))) | ||
val ksi: IO[Seq[KML]] = for { | ||
ks <- KMLCompanion.loadKML(triedFilename) | ||
ks2 = editor.processKMLs(ks) | ||
} yield ks2 | ||
val result = ksi.unsafeRunSync() | ||
val feature: Feature = result.head.features.head | ||
feature match { | ||
case Document(fs) => | ||
val folder = fs.head | ||
folder match { | ||
case Folder(features) => | ||
features.size shouldBe 1 | ||
val p1 = features.head | ||
p1 match { | ||
case p@Placemark(g) => | ||
p.featureData.name.$.toString shouldBe "Salem & Lowell RR (#1)Salem & Lowell RR (#2)" | ||
p.featureData.name.matches("Salem & Lowell RR (#1)Salem & Lowell RR (#2)") shouldBe true | ||
val lineString = g.head | ||
lineString match { | ||
case LineString(_, cs) => | ||
cs.head.coordinates.size shouldBe 163 | ||
// TODO check the ordering of the Coordinate values. | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
it should "processKMLs joinX" in { | ||
val editor = KMLEditor(Seq(KmlEdit(KmlEdit.JOINX, 2, Element(placemark, "Salem & Lowell RR (#1)"), Some(Element(placemark, "Salem & Lowell RR (#2)"))), KmlEdit(KmlEdit.DELETE, 1, Element(placemark, "Salem & Lowell RR (#2)"), None))) | ||
val ksi: IO[Seq[KML]] = for { | ||
ks <- KMLCompanion.loadKML(triedFilename) | ||
ks2 = editor.processKMLs(ks) | ||
} yield ks2 | ||
val result = ksi.unsafeRunSync() | ||
val feature: Feature = result.head.features.head | ||
feature match { | ||
case Document(fs) => | ||
val folder = fs.head | ||
folder match { | ||
case Folder(features) => | ||
features.size shouldBe 1 | ||
val p1 = features.head | ||
p1 match { | ||
case p@Placemark(g) => | ||
p.featureData.name.matches("Salem & Lowell RR (#1)") shouldBe true | ||
val lineString = g.head | ||
lineString match { | ||
case LineString(_, cs) => | ||
cs.head.coordinates.size shouldBe 163 | ||
// TODO check the ordering of the Coordinate values. | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters