Skip to content

Commit 0512cae

Browse files
author
David Winslow
committed
Merge branch 'scala-2.10' into raster-styling
Conflicts: geocss/src/main/scala/org/geoscript/geocss/Translator.scala
2 parents 9ff23dc + a30d020 commit 0512cae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+388
-585
lines changed

examples/src/main/scala/example/AllValid.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.geoscript._
55
object AllValid extends App {
66
val shp = layer.Shapefile(args.head)
77

8-
val invalid = shp.features filter { f => !f.geometry.isValid } toSeq
8+
val invalid = shp.features.filterNot(_.geometry.isValid).toSeq
99

1010
println("Found %s invalid features.".format(invalid.size))
1111
for (f <- invalid) println(f.id)

examples/src/main/scala/example/ColorRamp.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.geoscript.example
22

33
import org.geoscript._
4+
import filter._
45
import style.combinators._
56
import org.geotools.filter.text.ecql.ECQL.{ toFilter => cql }
67

@@ -19,8 +20,9 @@ object ColorRamp extends org.geoscript.feature.GeoCrunch {
1920
sldStream.close()
2021
}
2122

22-
def hex(c: java.awt.Color) =
23-
"#%02x02x02x".format(c.getRed, c.getGreen, c.getBlue)
23+
def hex(c: java.awt.Color): Paint =
24+
Color(literal(
25+
"#%02x02x02x".format(c.getRed, c.getGreen, c.getBlue)))
2426

2527
def colorRamp(data: layer.Layer, propertyName: String): style.Style = {
2628
val propertyView = data.features.view.map(f => f.get[Double](propertyName))
@@ -37,6 +39,6 @@ object ColorRamp extends org.geoscript.feature.GeoCrunch {
3739
filter = "%s BETWEEN %f AND %f".format(propertyName, min, max)
3840
} yield
3941
Fill(hex(color)) where cql(filter)
40-
rules reduce (_ and _)
42+
rules.reduce(_ and _).build
4143
}
4244
}

examples/src/main/scala/example/Postgis.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.geoscript.example
33
import com.vividsolutions.jts.geom.Geometry
44
import org.geoscript._
55
import feature.{ Feature, Field }
6+
import projection.lookupEPSG
67

78
object PostgisTest extends App {
89
val conflict = workspace.Postgis("database" -> "conflict")
@@ -13,7 +14,7 @@ object PostgisTest extends App {
1314

1415
val test = workSpaceTest.create("test",
1516
Field("name", classOf[String]),
16-
Field("geom", classOf[Geometry], "EPSG:4326")
17+
Field("geom", classOf[Geometry], lookupEPSG("EPSG:4326").get)
1718
)
1819

1920
test += Feature(

examples/src/main/scala/example/Render.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package org.geoscript.example
22

33
import org.geoscript.layer.Shapefile,
44
org.geoscript.style.CSS,
5-
org.geoscript.render.{ render, PNG, Viewport },
6-
org.geoscript.projection.Projection
5+
org.geoscript.render.{ render, MapLayer, PNG, Viewport },
6+
org.geoscript.projection.Projection,
7+
org.geoscript.io.Sink
78

89
object Render {
910
def reference(e: org.geoscript.geometry.Envelope, p: Projection) =
@@ -16,7 +17,7 @@ object Render {
1617
val viewport = Viewport.pad(reference(states.envelope, Projection("EPSG:4326")), frame)
1718
render(
1819
viewport,
19-
Seq(states -> theme)
20-
) on PNG("states.png", frame)
20+
Seq(MapLayer(states, theme))
21+
) on PNG(Sink.file("states.png"), frame)
2122
}
2223
}

examples/src/main/scala/example/Shp2Shp.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Shp2Shp extends App {
88
val source = layer.Shapefile(sourcefile)
99
val destSchema = Schema(destname,
1010
source.schema.fields map {
11-
case (g: GeoField) => g.copy(projection = proj)
11+
case (g: GeoField) => g.copy(projection = projection.lookupEPSG(proj).get)
1212
case (f: Field) => f
1313
}
1414
)

examples/src/main/scala/example/kmlrip/DocumentReader.scala

Lines changed: 0 additions & 72 deletions
This file was deleted.

examples/src/main/scala/example/kmlrip/QueueManager.scala

Lines changed: 0 additions & 51 deletions
This file was deleted.

examples/src/main/scala/example/kmlrip/Rip.scala

Lines changed: 0 additions & 23 deletions
This file was deleted.

examples/src/main/scala/example/kmlrip/messages.scala

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/src/main/scala/feature/GeoCrunch.scala

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,14 @@ trait GeoCrunch {
2323
shp.createNewDataStore(map)
2424
}
2525

26-
def create(params: Map[String, Serializable]): DataStore = {
27-
var map = new java.util.HashMap[String, Object]
28-
for ((key, value) <- params) map.put(key, value)
29-
shp.createNewDataStore(map)
30-
}
26+
def create(params: Map[String, Serializable]): DataStore =
27+
shp.createNewDataStore(params: Map[_, _]);
3128

32-
def connect(params: (String, Object)*): DataStore = {
33-
var map = new java.util.HashMap[String,Object]
34-
for ((key, value) <- params) map.put(key, value)
35-
DataStoreFinder.getDataStore(map)
36-
}
29+
def connect(params: (String, Serializable)*): DataStore =
30+
DataStoreFinder.getDataStore(params.toMap: Map[_, _])
3731

38-
def connect(params: Map[String,Serializable]): DataStore = {
39-
var map = new java.util.HashMap[String,Object]
40-
for ((key, value) <- params) map.put(key, value)
41-
DataStoreFinder.getDataStore(map)
42-
}
32+
def connect(params: Map[String,Serializable]): DataStore =
33+
DataStoreFinder.getDataStore(params: Map[_, _])
4334

4435
def foreach[T <: ogc.feature.`type`.FeatureType, F <: ogc.feature.Feature](
4536
fc: gt.FeatureCollection[T,F]

geocss/build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ libraryDependencies <++= gtVersion { v =>
88
}
99

1010
libraryDependencies ++= Seq(
11-
"org.scala-tools.testing" %% "scalacheck" % "1.9" % "test",
12-
"org.scalatest" %% "scalatest" % "1.8" % "test")
11+
"org.scalacheck" % "scalacheck_2.10" % "1.10.0" % "test",
12+
"org.scalatest" % "scalatest_2.10" % "1.9.1" % "test")
1313

1414
initialCommands += """
1515
import org.{ geotools => gt }

geocss/src/main/scala/org/geoscript/geocss/Converter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ object Converter {
6565
filenames.foreach { x =>
6666
val in = new File(x)
6767
val url = in.toURI.toURL
68-
if (in exists) {
68+
if (in.exists) {
6969
val styleSheet = CssParser.parse(new FileInputStream(in))
7070
val out = target(in, suffix)
7171
styleSheet match {

geocss/src/main/scala/org/geoscript/geocss/CssOps.scala

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ object CssOps {
251251
def apply(x: Selector): Specificity = x match {
252252
case (_: Typename) => Specificity(0, 0, 1)
253253
case (_: PseudoSelector) => Specificity(0, 1, 0)
254-
case (_: ParameterizedPseudoClass) => Specificity(0, 0, 2)
255-
case (_: PseudoClass) => Specificity(0, 0, 1)
256254
case (_: Id) => Specificity(1, 0, 0)
257255
case And(children) => (children map apply).fold(Zero) { _ + _ }
258256
case Or(children) => children.map(apply).max
@@ -295,15 +293,27 @@ object CssOps {
295293
val ShortHex = """#?([a-fA-F0-9]{3})""".r
296294
val LongHex = """#?([a-fA-F0-9]{6})""".r
297295

296+
import scala.util.control.Exception.catching
297+
298298
def unapply(value: Value): Option[ogc.expression.Expression] = value match {
299299
case Function("rgb", Seq(Literal(r), Literal(g), Literal(b))) =>
300300
val channels = Seq(r, g, b)
301301
val hex = "#%02x%02x%02x"
302302
def validInt(x: String) =
303-
try { x.toInt; true } catch { case _ => false }
303+
try {
304+
x.toInt
305+
true
306+
} catch {
307+
case (_: NumberFormatException) => false
308+
}
304309

305310
def validDouble(x: String) =
306-
try { x.toDouble; true } catch { case _ => false }
311+
try {
312+
x.toDouble
313+
true
314+
} catch {
315+
case (_: NumberFormatException) => false
316+
}
307317

308318
def dbl(x: String) = round(x.toFloat * 255f)
309319

0 commit comments

Comments
 (0)