@@ -2,84 +2,82 @@ package org.geoscript
2
2
package geometry
3
3
4
4
import org .geoscript .io .{ Sink , Source }
5
- import org .specs ._
5
+ import org .scalatest . _ , matchers ._
6
6
7
- class SerializationSpec extends Specification {
8
- " JSON Serialization" should {
9
- " round-trip points" in {
10
- val p = Point (100 , 0 )
11
- val json = io.GeoJSON .write(p, Sink .string)
12
- json must_== """ {"type":"Point","coordinates":[100,0.0]}"""
13
- // io.GeoJSON.read(Source.string(json)) must_== p
14
- // TODO: Implement equality for geometries
15
- }
7
+ class SerializationSpec extends FunSuite with ShouldMatchers {
8
+ test(" round-trip points" ) {
9
+ val p = Point (100 , 0 )
10
+ val json = io.GeoJSON .write(p, Sink .string)
11
+ json should be(""" {"type":"Point","coordinates":[100,0.0]}""" )
12
+ // io.GeoJSON.read(Source.string(json)) should be p
13
+ // TODO: Implement equality for geometries
14
+ }
16
15
17
- " round-trip linestrings" in {
18
- val ls = LineString ((100 , 0 ), (101 , 1 ))
19
- io.GeoJSON .write(ls, Sink .string) must_ ==
20
- """ {"type":"LineString","coordinates":[[100,0.0],[101,1]]}"""
21
- }
16
+ test( " round-trip linestrings" ) {
17
+ val ls = LineString ((100 , 0 ), (101 , 1 ))
18
+ io.GeoJSON .write(ls, Sink .string) should be
19
+ ( """ {"type":"LineString","coordinates":[[100,0.0],[101,1]]}""" )
20
+ }
22
21
23
- " round-trip polygons" in {
24
- val solid = Polygon (
25
- LineString ((100 , 0 ), (101 , 0 ), (101 , 1 ), (100 , 1 ), (100 , 0 ))
26
- )
22
+ test( " round-trip polygons" ) {
23
+ val solid = Polygon (
24
+ LineString ((100 , 0 ), (101 , 0 ), (101 , 1 ), (100 , 1 ), (100 , 0 ))
25
+ )
27
26
28
- val withHoles = Polygon (
29
- LineString ((100 , 0 ), (101 , 0 ), (101 , 1 ), (100 , 1 ), (100 , 0 )),
30
- Seq (LineString (
31
- (100.2 , 0.2 ), (100.8 , 0.2 ), (100.8 , 0.8 ), (100.2 , 0.8 ), (100.2 , 0.2 )
32
- ))
33
- )
27
+ val withHoles = Polygon (
28
+ LineString ((100 , 0 ), (101 , 0 ), (101 , 1 ), (100 , 1 ), (100 , 0 )),
29
+ Seq (LineString (
30
+ (100.2 , 0.2 ), (100.8 , 0.2 ), (100.8 , 0.8 ), (100.2 , 0.8 ), (100.2 , 0.2 )
31
+ ))
32
+ )
34
33
35
- io.GeoJSON .write(solid, Sink .string) must_ ==
36
- """ {"type":"Polygon","coordinates":[[[100,0.0],[101,0.0],[101,1],[100,1],[100,0.0]]]}"""
37
- io.GeoJSON .write(withHoles, Sink .string) must_ ==
38
- """ {"type":"Polygon","coordinates":[[[100,0.0],[101,0.0],[101,1],[100,1],[100,0.0]],[[100.2,0.2],[100.8,0.2],[100.8,0.8],[100.2,0.8],[100.2,0.2]]]}"""
39
- }
34
+ io.GeoJSON .write(solid, Sink .string) should be(
35
+ """ {"type":"Polygon","coordinates":[[[100,0.0],[101,0.0],[101,1],[100,1],[100,0.0]]]}""" )
36
+ io.GeoJSON .write(withHoles, Sink .string) should be(
37
+ """ {"type":"Polygon","coordinates":[[[100,0.0],[101,0.0],[101,1],[100,1],[100,0.0]],[[100.2,0.2],[100.8,0.2],[100.8,0.8],[100.2,0.8],[100.2,0.2]]]}""" )
38
+ }
40
39
41
- " round-trip a multipoint" in {
42
- val mp = MultiPoint ((100.0 , 0.0 ), (101.0 , 1.0 ))
43
- io.GeoJSON .write(mp, Sink .string) must_ ==
44
- """ {"type":"MultiPoint","coordinates":[[100,0.0],[101,1]]}"""
45
- }
40
+ test( " round-trip a multipoint" ) {
41
+ val mp = MultiPoint ((100.0 , 0.0 ), (101.0 , 1.0 ))
42
+ io.GeoJSON .write(mp, Sink .string) should be(
43
+ """ {"type":"MultiPoint","coordinates":[[100,0.0],[101,1]]}""" )
44
+ }
46
45
47
- " round-trip a MultiLineString" in {
48
- val mls = MultiLineString (
49
- LineString ((100 , 0 ), Point (101 , 1 )),
50
- LineString ((102 , 2 ), Point (103 , 3 ))
51
- )
46
+ test( " round-trip a MultiLineString" ) {
47
+ val mls = MultiLineString (
48
+ LineString ((100 , 0 ), Point (101 , 1 )),
49
+ LineString ((102 , 2 ), Point (103 , 3 ))
50
+ )
52
51
53
- io.GeoJSON .write(mls, Sink .string) must_ ==
54
- """ {"type":"MultiLineString","coordinates":[[[100,0.0],[101,1]],[[102,2],[103,3]]]}"""
55
- }
52
+ io.GeoJSON .write(mls, Sink .string) should be(
53
+ """ {"type":"MultiLineString","coordinates":[[[100,0.0],[101,1]],[[102,2],[103,3]]]}""" )
54
+ }
56
55
57
- " round-trip a MultiPolygon" in {
58
- val mp = MultiPolygon (
59
- Polygon (LineString (
60
- (102 , 2 ), (103 , 2 ), (103 , 3 ), (102 , 3 ), (102 , 2 )
61
- )),
62
- Polygon (LineString (
63
- (100 , 0 ), (101 , 0 ), (101 , 1 ), (100 , 1 ), (100 , 0 )
64
- ),
65
- Seq (LineString (
66
- (100.2 , 0.2 ), (100.8 , 0.2 ), (100.8 , 0.8 ), (100.2 , 0.8 ), (100.2 , 0.2 )
67
- ))
68
- )
56
+ test(" round-trip a MultiPolygon" ) {
57
+ val mp = MultiPolygon (
58
+ Polygon (LineString (
59
+ (102 , 2 ), (103 , 2 ), (103 , 3 ), (102 , 3 ), (102 , 2 )
60
+ )),
61
+ Polygon (LineString (
62
+ (100 , 0 ), (101 , 0 ), (101 , 1 ), (100 , 1 ), (100 , 0 )
63
+ ),
64
+ Seq (LineString (
65
+ (100.2 , 0.2 ), (100.8 , 0.2 ), (100.8 , 0.8 ), (100.2 , 0.8 ), (100.2 , 0.2 )
66
+ ))
69
67
)
68
+ )
70
69
71
- io.GeoJSON .write(mp, Sink .string) must_ ==
72
- """ {"type":"MultiPolygon","coordinates":[[[[102,2],[103,2],[103,3],[102,3],[102,2]]],[[[100,0.0],[101,0.0],[101,1],[100,1],[100,0.0]],[[100.2,0.2],[100.8,0.2],[100.8,0.8],[100.2,0.8],[100.2,0.2]]]]}"""
73
- }
70
+ io.GeoJSON .write(mp, Sink .string) should be(
71
+ """ {"type":"MultiPolygon","coordinates":[[[[102,2],[103,2],[103,3],[102,3],[102,2]]],[[[100,0.0],[101,0.0],[101,1],[100,1],[100,0.0]],[[100.2,0.2],[100.8,0.2],[100.8,0.8],[100.2,0.8],[100.2,0.2]]]]}""" )
72
+ }
74
73
75
- " round-trip a GeometryCollection" in {
76
- val gc = GeometryCollection (
77
- Point (100.0 , 0.0 ),
78
- LineString ((101.0 , 0.0 ), (102.0 , 1.0 ))
79
- )
74
+ test( " round-trip a GeometryCollection" ) {
75
+ val gc = GeometryCollection (
76
+ Point (100.0 , 0.0 ),
77
+ LineString ((101.0 , 0.0 ), (102.0 , 1.0 ))
78
+ )
80
79
81
- io.GeoJSON .write(gc, Sink .string) must_==
82
- """ {"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[100,0.0]},{"type":"LineString","coordinates":[[101,0.0],[102,1]]}]}"""
83
- }
80
+ io.GeoJSON .write(gc, Sink .string) should be(
81
+ """ {"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[100,0.0]},{"type":"LineString","coordinates":[[101,0.0],[102,1]]}]}""" )
84
82
}
85
83
}
0 commit comments