diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml index 3572571..e7bedf3 100644 --- a/.idea/copyright/profiles_settings.xml +++ b/.idea/copyright/profiles_settings.xml @@ -1,5 +1,3 @@ - - - + \ No newline at end of file diff --git a/.idea/libraries/scala_2_10_3.xml b/.idea/libraries/scala_2_10_3.xml deleted file mode 100644 index 27fe7a8..0000000 --- a/.idea/libraries/scala_2_10_3.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bin/scalakml.jar b/bin/scalakml.jar index daa05e1..ef96ca5 100644 Binary files a/bin/scalakml.jar and b/bin/scalakml.jar differ diff --git a/build.sbt b/build.sbt index 602df47..0dfa6fb 100755 --- a/build.sbt +++ b/build.sbt @@ -6,4 +6,4 @@ organization := "com.kodekutters" version := "1.0" -scalaVersion := "2.10.3" +scalaVersion := "2.10.4" diff --git a/scalakml.iml b/scalakml.iml index 389a5ae..547555c 100644 --- a/scalakml.iml +++ b/scalakml.iml @@ -1,5 +1,13 @@ + + + + + + @@ -7,8 +15,8 @@ - + diff --git a/src/main/scala/com/scalakml/example/WriteExample1.scala b/src/main/scala/com/scalakml/example/WriteExample1.scala index cbb5abd..71a8899 100755 --- a/src/main/scala/com/scalakml/example/WriteExample1.scala +++ b/src/main/scala/com/scalakml/example/WriteExample1.scala @@ -1,12 +1,12 @@ package com.scalakml.example -import com.scalakml.io.{KmlPrintWriter, KmlFileReader} +import com.scalakml.io.{KmlPrintWriter} import xml.PrettyPrinter import com.scalakml.kml._ import com.scalakml.kml.FeaturePart import com.scalakml.kml.Point import com.scalakml.kml.Placemark -import scala.Some + /** * Author: Ringo Wathelet @@ -17,6 +17,7 @@ import scala.Some object WriteExample1 { def main(args: Array[String]) { println("....WriteExample1 start...\n") + // create a Point at a location val point = Point(coordinates = Option(Seq.empty :+ new Location(151.21037, -33.8526))) // create a Placemark with the point, and a name @@ -25,6 +26,7 @@ object WriteExample1 { val kml = Kml(feature = Option(placemark)) // write the kml to the output file new KmlPrintWriter("./kml-files/Sydney-oz.kml").write(Option(kml), new PrettyPrinter(80, 3)) + println("\n....WriteExample1 done...") } } diff --git a/src/main/scala/com/scalakml/example/WriteExample4.scala b/src/main/scala/com/scalakml/example/WriteExample4.scala index f4ce698..9c53a4e 100755 --- a/src/main/scala/com/scalakml/example/WriteExample4.scala +++ b/src/main/scala/com/scalakml/example/WriteExample4.scala @@ -16,6 +16,6 @@ object WriteExample4 { // create a scala Kml object with a Placemark that contains a Point val kml = new Kml(new Placemark("Sydney", new Point(RelativeToGround, 151.21037, -33.8526, 12345.0))) // write the kml object to System.out as xml - new KmlPrintWriter().write(Option(kml), new PrettyPrinter(80, 3)) + new KmlPrintWriter().write(kml, new PrettyPrinter(80, 3)) } } \ No newline at end of file diff --git a/src/main/scala/com/scalakml/io/KmlFromXml.scala b/src/main/scala/com/scalakml/io/KmlFromXml.scala index 04ceff3..b656b95 100755 --- a/src/main/scala/com/scalakml/io/KmlFromXml.scala +++ b/src/main/scala/com/scalakml/io/KmlFromXml.scala @@ -36,6 +36,7 @@ import scala.xml._ import com.scalaxal.io.XalFromXml._ import scala.language.postfixOps import scala.language.implicitConversions +import scala.collection.mutable /** * @author Ringo Wathelet diff --git a/src/main/scala/com/scalakml/io/KmlPrintWriter.scala b/src/main/scala/com/scalakml/io/KmlPrintWriter.scala index a76edf2..8a36c23 100755 --- a/src/main/scala/com/scalakml/io/KmlPrintWriter.scala +++ b/src/main/scala/com/scalakml/io/KmlPrintWriter.scala @@ -33,6 +33,7 @@ package com.scalakml.io import java.io._ import xml.{dtd, XML, PrettyPrinter} import scala.Some +import com.scalakml.kml.Kml /** * @author Ringo Wathelet @@ -82,6 +83,22 @@ class KmlPrintWriter(writer: Option[PrintWriter] = Some(new PrintWriter(System.o } } + /** + * convenience method + * @param value the Kml element + * @param pretty the pretty printer to use + */ + def write(value: Kml, pretty: PrettyPrinter) = write[Option[Kml]](Option(value), pretty) + + /** + * convenience method + * @param value the Kml element + */ + def write(value: Kml) = write[Option[Kml]](Option(value)) + + /** + * close the writer + */ def close() = if (writer.isDefined) writer.get.close() } diff --git a/src/main/scala/com/scalakml/kml/Kml.scala b/src/main/scala/com/scalakml/kml/Kml.scala index 0daa98f..062c9fe 100755 --- a/src/main/scala/com/scalakml/kml/Kml.scala +++ b/src/main/scala/com/scalakml/kml/Kml.scala @@ -33,6 +33,7 @@ package com.scalakml.kml import com.scalakml.atom._ import com.scalaxal.xAL.AddressDetails import com.scalakml.gx.LatLonQuad +import scala.collection.mutable /** * package of classes and constructs for the Google KML Version 2.2 model @@ -1006,8 +1007,8 @@ case class FeaturePart( /** * returns a new object with value added to the sequence - * @param value to add - * @return a new object with value added to the sequence + * @param value to add to styleSelector + * @return a new FeaturePart with value added to the sequence of styleSelector */ def addToStyleSelector(value: StyleSelector) = { this.copy(styleSelector = if (styleSelector == Nil) (Seq.empty :+ value) else (styleSelector :+ value)) @@ -1063,6 +1064,9 @@ case class Placemark( objectSimpleExtensionGroup: Seq[Any] = Nil) extends Feature { def this(geom: Geometry) = this(Option(geom)) + def this(geom: Geometry, featurePart: FeaturePart) = this(Option(geom), featurePart) + def this(geom: Geometry, featurePart: FeaturePart, id: String) = this(Option(geom), featurePart, Option(id)) + def this(geom: Geometry, featurePart: FeaturePart, id: String, targetId: String) = this(Option(geom), featurePart, Option(id), Option(targetId)) def this(name: String) = this(None, new FeaturePart(name = Option(name))) def this(name: String, geom: Geometry) = this(Option(geom), new FeaturePart(name = Option(name))) def this(name: String, geom: Geometry, id: String) = this(Option(geom), new FeaturePart(name = Option(name)), Option(id)) @@ -1460,7 +1464,8 @@ case class Document(featurePart: FeaturePart = new FeaturePart(), def this(feature: Feature) = this(new FeaturePart(), Nil, (Seq.empty :+ feature)) def this(name: String, feature: Feature) = this(new FeaturePart(name = Option(name)), Nil, (Seq.empty :+ feature)) - def this(name: String, feature: Feature, schema: Schema) = + def this(name: String, schema: Schema) = this(new FeaturePart(name = Option(name)), (Seq.empty :+ schema), Nil) + def this(name: String, schema: Schema, feature: Feature) = this(new FeaturePart(name = Option(name)), (Seq.empty :+ schema), (Seq.empty :+ feature)) /**