georuby 1.9.9 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/geo_ruby.rb +1 -15
- data/lib/geo_ruby/geojson.rb +2 -0
- data/lib/geo_ruby/georss.rb +1 -0
- data/lib/geo_ruby/kml.rb +1 -1
- data/lib/geo_ruby/simple_features.rb +25 -0
- data/lib/geo_ruby/version.rb +1 -1
- data/spec/geo_ruby/geojson_spec.rb +26 -26
- data/spec/geo_ruby/georss_spec.rb +215 -3
- data/spec/geo_ruby/gpx4r/gpx_spec.rb +19 -22
- data/spec/geo_ruby/kml_spec.rb +6 -6
- data/spec/geo_ruby/shp4r/shp_spec.rb +36 -38
- data/spec/geo_ruby/simple_features/circle_spec.rb +3 -5
- data/spec/geo_ruby/simple_features/envelope_spec.rb +8 -8
- data/spec/geo_ruby/simple_features/ewkb_parser_spec.rb +45 -45
- data/spec/geo_ruby/simple_features/ewkt_parser_spec.rb +49 -49
- data/spec/geo_ruby/simple_features/geometry_collection_spec.rb +20 -20
- data/spec/geo_ruby/simple_features/geometry_factory_spec.rb +2 -2
- data/spec/geo_ruby/simple_features/geometry_spec.rb +9 -12
- data/spec/geo_ruby/simple_features/line_string_spec.rb +53 -53
- data/spec/geo_ruby/simple_features/linear_ring_spec.rb +6 -6
- data/spec/geo_ruby/simple_features/multi_line_string_spec.rb +13 -13
- data/spec/geo_ruby/simple_features/multi_point_spec.rb +10 -10
- data/spec/geo_ruby/simple_features/multi_polygon_spec.rb +13 -13
- data/spec/geo_ruby/simple_features/point_spec.rb +52 -52
- data/spec/geo_ruby/simple_features/polygon_spec.rb +40 -40
- data/spec/geo_ruby_spec.rb +7 -12
- data/spec/spec_helper.rb +1 -9
- metadata +21 -5
- data/spec/geo_ruby/georss.rb +0 -218
@@ -1,26 +1,26 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe EWKTParser do
|
3
|
+
describe GeoRuby::SimpleFeatures::EWKTParser do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@factory = GeometryFactory::new
|
7
|
-
@ewkt_parser = EWKTParser::new(@factory)
|
6
|
+
@factory = GeoRuby::SimpleFeatures::GeometryFactory::new
|
7
|
+
@ewkt_parser = GeoRuby::SimpleFeatures::EWKTParser::new(@factory)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "test_point" do
|
11
11
|
ewkt="POINT( 3.456 0.123)"
|
12
12
|
@ewkt_parser.parse(ewkt)
|
13
13
|
point = @factory.geometry
|
14
|
-
point.should be_instance_of Point
|
15
|
-
point.should == Point.from_x_y(3.456,0.123)
|
14
|
+
point.should be_instance_of GeoRuby::SimpleFeatures::Point
|
15
|
+
point.should == GeoRuby::SimpleFeatures::Point.from_x_y(3.456,0.123)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "test_point_with_srid" do
|
19
19
|
ewkt="SRID=245;POINT(0.0 2.0)"
|
20
20
|
@ewkt_parser.parse(ewkt)
|
21
21
|
point = @factory.geometry
|
22
|
-
point.should be_instance_of Point
|
23
|
-
point.should == Point.from_x_y(0,2,245)
|
22
|
+
point.should be_instance_of GeoRuby::SimpleFeatures::Point
|
23
|
+
point.should == GeoRuby::SimpleFeatures::Point.from_x_y(0,2,245)
|
24
24
|
point.srid.should eql(245)
|
25
25
|
ewkt.should == point.as_ewkt(true,false)
|
26
26
|
end
|
@@ -29,8 +29,8 @@ describe EWKTParser do
|
|
29
29
|
ewkt="POINT(3.456 0.123 123.667)"
|
30
30
|
@ewkt_parser.parse(ewkt)
|
31
31
|
point = @factory.geometry
|
32
|
-
point.should be_instance_of Point
|
33
|
-
point.should == Point.from_x_y_z(3.456,0.123,123.667)
|
32
|
+
point.should be_instance_of GeoRuby::SimpleFeatures::Point
|
33
|
+
point.should == GeoRuby::SimpleFeatures::Point.from_x_y_z(3.456,0.123,123.667)
|
34
34
|
ewkt.should == point.as_ewkt(false)
|
35
35
|
end
|
36
36
|
|
@@ -38,8 +38,8 @@ describe EWKTParser do
|
|
38
38
|
ewkt="POINTM(3.456 0.123 123.667)"
|
39
39
|
@ewkt_parser.parse(ewkt)
|
40
40
|
point = @factory.geometry
|
41
|
-
point.should be_instance_of Point
|
42
|
-
point.should == Point.from_x_y_m(3.456,0.123,123.667)
|
41
|
+
point.should be_instance_of GeoRuby::SimpleFeatures::Point
|
42
|
+
point.should == GeoRuby::SimpleFeatures::Point.from_x_y_m(3.456,0.123,123.667)
|
43
43
|
ewkt.should == point.as_ewkt(false)
|
44
44
|
end
|
45
45
|
|
@@ -47,8 +47,8 @@ describe EWKTParser do
|
|
47
47
|
ewkt="POINT(3.456 0.123 123.667 15.0)"
|
48
48
|
@ewkt_parser.parse(ewkt)
|
49
49
|
point = @factory.geometry
|
50
|
-
point.should be_instance_of Point
|
51
|
-
point.should == Point.from_x_y_z_m(3.456,0.123,123.667,15.0)
|
50
|
+
point.should be_instance_of GeoRuby::SimpleFeatures::Point
|
51
|
+
point.should == GeoRuby::SimpleFeatures::Point.from_x_y_z_m(3.456,0.123,123.667,15.0)
|
52
52
|
ewkt.should == point.as_ewkt(false)
|
53
53
|
end
|
54
54
|
|
@@ -56,73 +56,73 @@ describe EWKTParser do
|
|
56
56
|
it "test_linestring" do
|
57
57
|
@ewkt_parser.parse("LINESTRING(3.456 0.123,123.44 123.56,54555.22 123.3)")
|
58
58
|
line_string = @factory.geometry
|
59
|
-
line_string.should be_instance_of LineString
|
60
|
-
line_string.should == LineString.from_coordinates([[3.456,0.123],[123.44,123.56],[54555.22,123.3]])
|
59
|
+
line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
|
60
|
+
line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[3.456,0.123],[123.44,123.56],[54555.22,123.3]])
|
61
61
|
|
62
62
|
@ewkt_parser.parse("SRID=256;LINESTRING(12.4 -45.3,45.4 41.6)")
|
63
63
|
line_string = @factory.geometry
|
64
|
-
line_string.should be_instance_of LineString
|
65
|
-
line_string.should == LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256)
|
64
|
+
line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
|
65
|
+
line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256)
|
66
66
|
|
67
67
|
@ewkt_parser.parse("SRID=256;LINESTRING(12.4 -45.3 35.3,45.4 41.6 12.3)")
|
68
68
|
line_string = @factory.geometry
|
69
|
-
line_string.should be_instance_of LineString
|
70
|
-
line_string.should == LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true)
|
69
|
+
line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
|
70
|
+
line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true)
|
71
71
|
|
72
72
|
@ewkt_parser.parse("SRID=256;LINESTRINGM(12.4 -45.3 35.3,45.4 41.6 12.3)")
|
73
73
|
line_string = @factory.geometry
|
74
|
-
line_string.should be_instance_of LineString
|
75
|
-
line_string.should == LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,false,true)
|
74
|
+
line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
|
75
|
+
line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,false,true)
|
76
76
|
|
77
77
|
@ewkt_parser.parse("SRID=256;LINESTRING(12.4 -45.3 35.3 25.2,45.4 41.6 12.3 13.75)")
|
78
78
|
line_string = @factory.geometry
|
79
|
-
line_string.should be_instance_of LineString
|
80
|
-
line_string.should == LineString.from_coordinates([[12.4,-45.3,35.3,25.2],[45.4,41.6,12.3,13.75]],256,true,true)
|
79
|
+
line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
|
80
|
+
line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3,25.2],[45.4,41.6,12.3,13.75]],256,true,true)
|
81
81
|
end
|
82
82
|
|
83
83
|
it "test_polygon" do
|
84
84
|
@ewkt_parser.parse("POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1,3 1,3 3,1 3,1 1))")
|
85
85
|
polygon = @factory.geometry
|
86
|
-
polygon.should be_instance_of Polygon
|
87
|
-
polygon.should == Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)
|
86
|
+
polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
|
87
|
+
polygon.should == GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)
|
88
88
|
|
89
89
|
@ewkt_parser.parse("SRID=256;POLYGON( ( 0 0 2,4 0 2,4 4 2,0 4 2,0 0 2),(1 1 2,3 1 2,3 3 2,1 3 2,1 1 2))")
|
90
90
|
polygon = @factory.geometry
|
91
|
-
polygon.should be_instance_of Polygon
|
92
|
-
polygon.should == Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,true)
|
91
|
+
polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
|
92
|
+
polygon.should == GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,true)
|
93
93
|
|
94
94
|
@ewkt_parser.parse("SRID=256;POLYGONM((0 0 2,4 0 2,4 4 2,0 4 2,0 0 2),(1 1 2,3 1 2,3 3 2,1 3 2,1 1 2))")
|
95
95
|
polygon = @factory.geometry
|
96
|
-
polygon.should be_instance_of Polygon
|
97
|
-
polygon.should == Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,false,true)
|
96
|
+
polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
|
97
|
+
polygon.should == GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,false,true)
|
98
98
|
|
99
99
|
@ewkt_parser.parse("SRID=256;POLYGON((0 0 2 -45.1,4 0 2 5,4 4 2 4.67,0 4 2 1.34,0 0 2 -45.1),(1 1 2 12.3,3 1 2 123,3 3 2 12.2,1 3 2 12,1 1 2 12.3))")
|
100
100
|
polygon = @factory.geometry
|
101
|
-
polygon.should be_instance_of Polygon
|
102
|
-
polygon.should == Polygon.from_coordinates([[[0,0,2,-45.1],[4,0,2,5],[4,4,2,4.67],[0,4,2,1.34],[0,0,2,-45.1]],[[1,1,2,12.3],[3,1,2,123],[3,3,2,12.2],[1,3,2,12],[1,1,2,12.3]]],256,true,true)
|
101
|
+
polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
|
102
|
+
polygon.should == GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,2,-45.1],[4,0,2,5],[4,4,2,4.67],[0,4,2,1.34],[0,0,2,-45.1]],[[1,1,2,12.3],[3,1,2,123],[3,3,2,12.2],[1,3,2,12],[1,1,2,12.3]]],256,true,true)
|
103
103
|
end
|
104
104
|
|
105
105
|
it "test_multi_point" do
|
106
106
|
#Form output by the current version of PostGIS. Future versions will output the one in the specification
|
107
107
|
@ewkt_parser.parse("SRID=444;MULTIPOINT(12.4 -123.3,-65.1 123.4,123.55555555 123)")
|
108
108
|
multi_point = @factory.geometry
|
109
|
-
multi_point.should be_instance_of MultiPoint
|
110
|
-
multi_point.should == MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
|
109
|
+
multi_point.should be_instance_of GeoRuby::SimpleFeatures::MultiPoint
|
110
|
+
multi_point.should == GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
|
111
111
|
multi_point.srid.should eql(444)
|
112
112
|
multi_point[0].srid.should eql(444)
|
113
113
|
|
114
114
|
@ewkt_parser.parse("SRID=444;MULTIPOINT(12.4 -123.3 4.5,-65.1 123.4 6.7,123.55555555 123 7.8)")
|
115
115
|
multi_point = @factory.geometry
|
116
|
-
multi_point.should be_instance_of MultiPoint
|
117
|
-
multi_point.should == MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,6.7],[123.55555555,123,7.8]],444,true)
|
116
|
+
multi_point.should be_instance_of GeoRuby::SimpleFeatures::MultiPoint
|
117
|
+
multi_point.should == GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,6.7],[123.55555555,123,7.8]],444,true)
|
118
118
|
multi_point.srid.should eql(444)
|
119
119
|
multi_point[0].srid.should eql(444)
|
120
120
|
|
121
121
|
#Form in the EWKT specification (from the OGC)
|
122
122
|
@ewkt_parser.parse("SRID=444;MULTIPOINT( ( 12.4 -123.3 4.5 ) , (-65.1 123.4 6.7),(123.55555555 123 7.8))")
|
123
123
|
multi_point = @factory.geometry
|
124
|
-
multi_point.should be_instance_of MultiPoint
|
125
|
-
multi_point.should == MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,6.7],[123.55555555,123,7.8]],444,true)
|
124
|
+
multi_point.should be_instance_of GeoRuby::SimpleFeatures::MultiPoint
|
125
|
+
multi_point.should == GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,6.7],[123.55555555,123,7.8]],444,true)
|
126
126
|
multi_point.srid.should eql(444)
|
127
127
|
multi_point[0].srid.should eql(444)
|
128
128
|
end
|
@@ -130,15 +130,15 @@ describe EWKTParser do
|
|
130
130
|
it "test_multi_line_string" do
|
131
131
|
@ewkt_parser.parse("SRID=256;MULTILINESTRING((1.5 45.2,-54.12312 -0.012),(1.5 45.2,-54.12312 -0.012,45.123 123.3))")
|
132
132
|
multi_line_string = @factory.geometry
|
133
|
-
multi_line_string.should be_instance_of MultiLineString
|
134
|
-
multi_line_string.should == MultiLineString.from_line_strings([LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012]],256),LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]],256)],256)
|
133
|
+
multi_line_string.should be_instance_of GeoRuby::SimpleFeatures::MultiLineString
|
134
|
+
multi_line_string.should == GeoRuby::SimpleFeatures::MultiLineString.from_line_strings([GeoRuby::SimpleFeatures::LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012]],256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]],256)],256)
|
135
135
|
multi_line_string.srid.should eql(256)
|
136
136
|
multi_line_string[0].srid.should eql(256)
|
137
137
|
|
138
138
|
@ewkt_parser.parse("SRID=256;MULTILINESTRING((1.5 45.2 1.3 1.2,-54.12312 -0.012 1.2 4.5),(1.5 45.2 5.1 -4.5,-54.12312 -0.012 -6.8 3.4,45.123 123.3 4.5 -5.3))")
|
139
139
|
multi_line_string = @factory.geometry
|
140
|
-
multi_line_string.should be_instance_of MultiLineString
|
141
|
-
multi_line_string.should == MultiLineString.from_line_strings([LineString.from_coordinates([[1.5,45.2,1.3,1.2],[-54.12312,-0.012,1.2,4.5]],256,true,true),LineString.from_coordinates([[1.5,45.2,5.1,-4.5],[-54.12312,-0.012,-6.8,3.4],[45.123,123.3,4.5,-5.3]],256,true,true)],256,true,true)
|
140
|
+
multi_line_string.should be_instance_of GeoRuby::SimpleFeatures::MultiLineString
|
141
|
+
multi_line_string.should == GeoRuby::SimpleFeatures::MultiLineString.from_line_strings([GeoRuby::SimpleFeatures::LineString.from_coordinates([[1.5,45.2,1.3,1.2],[-54.12312,-0.012,1.2,4.5]],256,true,true),GeoRuby::SimpleFeatures::LineString.from_coordinates([[1.5,45.2,5.1,-4.5],[-54.12312,-0.012,-6.8,3.4],[45.123,123.3,4.5,-5.3]],256,true,true)],256,true,true)
|
142
142
|
multi_line_string.srid.should eql(256)
|
143
143
|
multi_line_string[0].srid.should eql(256)
|
144
144
|
end
|
@@ -147,8 +147,8 @@ describe EWKTParser do
|
|
147
147
|
ewkt="SRID=256;MULTIPOLYGON(((12.4 -45.3,45.4 41.6,4.456 1.0698,12.4 -45.3),(2.4 5.3,5.4 1.4263,14.46 1.06,2.4 5.3)),((0.0 0.0,4.0 0.0,4.0 4.0,0.0 4.0,0.0 0.0),(1.0 1.0,3.0 1.0,3.0 3.0,1.0 3.0,1.0 1.0)))"
|
148
148
|
@ewkt_parser.parse(ewkt)
|
149
149
|
multi_polygon = @factory.geometry
|
150
|
-
multi_polygon.should be_instance_of MultiPolygon
|
151
|
-
multi_polygon.should == MultiPolygon.from_polygons([Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]],256),Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)],256)
|
150
|
+
multi_polygon.should be_instance_of GeoRuby::SimpleFeatures::MultiPolygon
|
151
|
+
multi_polygon.should == GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]],256),GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)],256)
|
152
152
|
multi_polygon.srid.should eql(256)
|
153
153
|
multi_polygon[0].srid.should eql(256)
|
154
154
|
ewkt.should == multi_polygon.as_ewkt
|
@@ -156,8 +156,8 @@ describe EWKTParser do
|
|
156
156
|
ewkt="MULTIPOLYGON(((12.4 -45.3 2,45.4 41.6 3,4.456 1.0698 4,12.4 -45.3 2),(2.4 5.3 1,5.4 1.4263 3.44,14.46 1.06 4.5,2.4 5.3 1)),((0 0 5.6,4 0 5.4,4 4 1,0 4 23,0 0 5.6),(1 1 2.3,3 1 4,3 3 5,1 3 6,1 1 2.3)))"
|
157
157
|
@ewkt_parser.parse(ewkt)
|
158
158
|
multi_polygon = @factory.geometry
|
159
|
-
multi_polygon.should be_instance_of MultiPolygon
|
160
|
-
multi_polygon.should == MultiPolygon.from_polygons([Polygon.from_coordinates([[[12.4,-45.3,2],[45.4,41.6,3],[4.456,1.0698,4],[12.4,-45.3,2]],[[2.4,5.3,1],[5.4,1.4263,3.44],[14.46,1.06,4.5],[2.4,5.3,1]]],4326,true),Polygon.from_coordinates([[[0,0,5.6],[4,0,5.4],[4,4,1],[0,4,23],[0,0,5.6]],[[1,1,2.3],[3,1,4],[3,3,5],[1,3,6],[1,1,2.3]]],4326,true)],4326,true)
|
159
|
+
multi_polygon.should be_instance_of GeoRuby::SimpleFeatures::MultiPolygon
|
160
|
+
multi_polygon.should == GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[12.4,-45.3,2],[45.4,41.6,3],[4.456,1.0698,4],[12.4,-45.3,2]],[[2.4,5.3,1],[5.4,1.4263,3.44],[14.46,1.06,4.5],[2.4,5.3,1]]],4326,true),GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,5.6],[4,0,5.4],[4,4,1],[0,4,23],[0,0,5.6]],[[1,1,2.3],[3,1,4],[3,3,5],[1,3,6],[1,1,2.3]]],4326,true)],4326,true)
|
161
161
|
multi_polygon.srid.should eql(4326)
|
162
162
|
multi_polygon[0].srid.should eql(4326)
|
163
163
|
end
|
@@ -165,14 +165,14 @@ describe EWKTParser do
|
|
165
165
|
it "test_geometry_collection" do
|
166
166
|
@ewkt_parser.parse("SRID=256;GEOMETRYCOLLECTION(POINT(4.67 45.4),LINESTRING(5.7 12.45,67.55 54),POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1,3 1,3 3,1 3,1 1)))")
|
167
167
|
geometry_collection = @factory.geometry
|
168
|
-
geometry_collection.should be_instance_of GeometryCollection
|
169
|
-
geometry_collection.should == GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_coordinates([[5.7,12.45],[67.55,54]],256),Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)],256)
|
168
|
+
geometry_collection.should be_instance_of GeoRuby::SimpleFeatures::GeometryCollection
|
169
|
+
geometry_collection.should == GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y(4.67,45.4,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256),GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)],256)
|
170
170
|
geometry_collection[0].srid.should eql(256)
|
171
171
|
|
172
172
|
@ewkt_parser.parse("SRID=256;GEOMETRYCOLLECTIONM(POINTM(4.67 45.4 45.6),LINESTRINGM(5.7 12.45 5.6,67.55 54 6.7))")
|
173
173
|
geometry_collection = @factory.geometry
|
174
|
-
geometry_collection.should be_instance_of GeometryCollection
|
175
|
-
geometry_collection.should == GeometryCollection.from_geometries([Point.from_x_y_m(4.67,45.4,45.6,256),LineString.from_coordinates([[5.7,12.45,5.6],[67.55,54,6.7]],256,false,true)],256,false,true)
|
174
|
+
geometry_collection.should be_instance_of GeoRuby::SimpleFeatures::GeometryCollection
|
175
|
+
geometry_collection.should == GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y_m(4.67,45.4,45.6,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45,5.6],[67.55,54,6.7]],256,false,true)],256,false,true)
|
176
176
|
geometry_collection[0].srid.should eql(256)
|
177
177
|
end
|
178
178
|
|
@@ -1,54 +1,54 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe GeometryCollection do
|
3
|
+
describe GeoRuby::SimpleFeatures::GeometryCollection do
|
4
4
|
|
5
5
|
it "should test_geometry_collection_creation" do
|
6
|
-
geometry_collection = GeometryCollection::new(256)
|
7
|
-
geometry_collection << Point.from_x_y(4.67,45.4,256)
|
6
|
+
geometry_collection = GeoRuby::SimpleFeatures::GeometryCollection::new(256)
|
7
|
+
geometry_collection << GeoRuby::SimpleFeatures::Point.from_x_y(4.67,45.4,256)
|
8
8
|
|
9
9
|
geometry_collection.length.should eql(1)
|
10
|
-
geometry_collection[0].should == Point.from_x_y(4.67,45.4,256)
|
10
|
+
geometry_collection[0].should == GeoRuby::SimpleFeatures::Point.from_x_y(4.67,45.4,256)
|
11
11
|
|
12
|
-
geometry_collection[0]=LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
|
13
|
-
geometry_collection << Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)
|
12
|
+
geometry_collection[0]=GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
|
13
|
+
geometry_collection << GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)
|
14
14
|
geometry_collection.length.should eql(2)
|
15
|
-
geometry_collection[0].should == LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
|
15
|
+
geometry_collection[0].should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
|
16
16
|
|
17
|
-
geometry_collection = GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
|
18
|
-
geometry_collection.class.should eql(GeometryCollection)
|
17
|
+
geometry_collection = GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y(4.67,45.4,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
|
18
|
+
geometry_collection.class.should eql(GeoRuby::SimpleFeatures::GeometryCollection)
|
19
19
|
geometry_collection.srid.should eql(256)
|
20
20
|
geometry_collection.length.should eql(2)
|
21
|
-
geometry_collection[1].should == LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
|
21
|
+
geometry_collection[1].should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
|
22
22
|
|
23
23
|
bbox = geometry_collection.bounding_box
|
24
24
|
bbox.length.should eql(2)
|
25
|
-
bbox[0].should == Point.from_x_y(4.67,12.45)
|
26
|
-
bbox[1].should == Point.from_x_y(67.55,54)
|
25
|
+
bbox[0].should == GeoRuby::SimpleFeatures::Point.from_x_y(4.67,12.45)
|
26
|
+
bbox[1].should == GeoRuby::SimpleFeatures::Point.from_x_y(67.55,54)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "test_geometry_collection_equal" do
|
30
|
-
geometry_collection1 = GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
|
31
|
-
geometry_collection2 = GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_coordinates([[5.7,12.45],[67.55,54]],256),Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256)],256,true)
|
32
|
-
line_string=LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
|
30
|
+
geometry_collection1 = GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y(4.67,45.4,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
|
31
|
+
geometry_collection2 = GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y(4.67,45.4,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256),GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256)],256,true)
|
32
|
+
line_string=GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
|
33
33
|
|
34
|
-
geometry_collection1.should == GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
|
34
|
+
geometry_collection1.should == GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y(4.67,45.4,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
|
35
35
|
geometry_collection2.should_not == geometry_collection1
|
36
36
|
line_string.should_not == geometry_collection1
|
37
37
|
end
|
38
38
|
|
39
39
|
it "test_geometry_collection_binary" do
|
40
|
-
geometry_collection = GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
|
40
|
+
geometry_collection = GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y(4.67,45.4,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
|
41
41
|
geometry_collection.as_hex_ewkb.should eql("010700002000010000020000000101000000AE47E17A14AE12403333333333B34640010200000002000000CDCCCCCCCCCC16406666666666E628403333333333E350400000000000004B40")
|
42
42
|
|
43
|
-
geometry_collection = GeometryCollection.from_geometries([Point.from_x_y_z_m(4.67,45.4,45.67,2.3,256),LineString.from_coordinates([[5.7,12.45,4.56,98.3],[67.55,54,12.2,3.4]],256,true, true)],256,true, true)
|
43
|
+
geometry_collection = GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y_z_m(4.67,45.4,45.67,2.3,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45,4.56,98.3],[67.55,54,12.2,3.4]],256,true, true)],256,true, true)
|
44
44
|
geometry_collection.as_hex_ewkb.should eql("01070000E0000100000200000001010000C0AE47E17A14AE12403333333333B34640F6285C8FC2D54640666666666666024001020000C002000000CDCCCCCCCCCC16406666666666E628403D0AD7A3703D124033333333339358403333333333E350400000000000004B4066666666666628403333333333330B40")
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should test_geometry_collection_text" do
|
48
|
-
geometry_collection = GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
|
48
|
+
geometry_collection = GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y(4.67,45.4,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
|
49
49
|
geometry_collection.as_ewkt.should eql("SRID=256;GEOMETRYCOLLECTION(POINT(4.67 45.4),LINESTRING(5.7 12.45,67.55 54))")
|
50
50
|
|
51
|
-
geometry_collection = GeometryCollection.from_geometries([Point.from_x_y_m(4.67,45.4,45.6,256),LineString.from_coordinates([[5.7,12.45,5.6],[67.55,54,6.7]],256,false,true)],256,false,true)
|
51
|
+
geometry_collection = GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y_m(4.67,45.4,45.6,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45,5.6],[67.55,54,6.7]],256,false,true)],256,false,true)
|
52
52
|
geometry_collection.as_ewkt.should eql("SRID=256;GEOMETRYCOLLECTIONM(POINTM(4.67 45.4 45.6),LINESTRINGM(5.7 12.45 5.6,67.55 54 6.7))")
|
53
53
|
end
|
54
54
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe GeometryFactory do
|
3
|
+
describe GeoRuby::SimpleFeatures::GeometryFactory do
|
4
4
|
# before(:each) do
|
5
|
-
# @po = MultiPolygon.new
|
5
|
+
# @po = GeoRuby::SimpleFeatures::MultiPolygon.new
|
6
6
|
# end
|
7
7
|
|
8
8
|
#it "should f" do
|
@@ -1,32 +1,29 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe Geometry do
|
4
|
-
before(:each) do
|
5
|
-
@geo = Geometry.new
|
6
|
-
end
|
3
|
+
describe GeoRuby::SimpleFeatures::Geometry do
|
7
4
|
|
8
5
|
it "should instantiate" do
|
9
|
-
violated unless
|
6
|
+
violated unless subject
|
10
7
|
end
|
11
8
|
|
12
9
|
it "should have a default srid" do
|
13
|
-
|
10
|
+
subject.srid.should eql(4326) #Geometry.default_srid)
|
14
11
|
end
|
15
12
|
|
16
13
|
it "should change srid" do
|
17
|
-
geo = Geometry.new(225)
|
14
|
+
geo = GeoRuby::SimpleFeatures::Geometry.new(225)
|
18
15
|
geo.srid.should eql(225)
|
19
16
|
end
|
20
17
|
|
21
18
|
it "should instantiate from hex ewkb" do
|
22
|
-
point = Geometry.from_hex_ewkb("01010000207B000000CDCCCCCCCCCC28406666666666A64640")
|
23
|
-
point.class.should == Point
|
19
|
+
point = GeoRuby::SimpleFeatures::Geometry.from_hex_ewkb("01010000207B000000CDCCCCCCCCCC28406666666666A64640")
|
20
|
+
point.class.should == GeoRuby::SimpleFeatures::Point
|
24
21
|
point.x.should be_within(0.1).of(12.4)
|
25
22
|
end
|
26
23
|
|
27
24
|
it "should output as_ewkb" do
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
subject.stub!(:binary_geometry_type).and_return(1)
|
26
|
+
subject.stub!(:binary_representation).and_return(1)
|
27
|
+
subject.as_ewkb.should eql("\001\001\000\000 \346\020\000\000\001")
|
31
28
|
end
|
32
29
|
end
|
@@ -2,22 +2,22 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
module LineSpecHelper
|
4
4
|
def mock_points(num)
|
5
|
-
# @point = mock(Point, :x => 1.0, :y => 2.0)
|
5
|
+
# @point = mock(GeoRuby::SimpleFeatures::Point, :x => 1.0, :y => 2.0)
|
6
6
|
Array.new(num) { |i| mock_point(i,i) }
|
7
7
|
end
|
8
8
|
|
9
9
|
def mock_point(x=1,y=2)
|
10
|
-
mock(Point, :x => x, :y => y, :text_representation => "#{x} #{y}")
|
10
|
+
mock(GeoRuby::SimpleFeatures::Point, :x => x, :y => y, :text_representation => "#{x} #{y}")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe LineString do
|
14
|
+
describe GeoRuby::SimpleFeatures::LineString do
|
15
15
|
|
16
16
|
include LineSpecHelper
|
17
17
|
|
18
18
|
describe "Instance Methods" do
|
19
19
|
|
20
|
-
let(:line) { LineString.from_points([mock(Point)]) }
|
20
|
+
let(:line) { GeoRuby::SimpleFeatures::LineString.from_points([mock(GeoRuby::SimpleFeatures::Point)]) }
|
21
21
|
|
22
22
|
it "should instantiate" do
|
23
23
|
violated unless line
|
@@ -37,16 +37,16 @@ describe LineString do
|
|
37
37
|
|
38
38
|
end
|
39
39
|
|
40
|
-
describe "Valid LineString" do
|
40
|
+
describe "Valid GeoRuby::SimpleFeatures::LineString" do
|
41
41
|
|
42
|
-
let(:line) { LineString.from_points([Point.xy(1,1), Point.xy(2,2), Point.xy(3,3)]) }
|
42
|
+
let(:line) { GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.xy(1,1), GeoRuby::SimpleFeatures::Point.xy(2,2), GeoRuby::SimpleFeatures::Point.xy(3,3)]) }
|
43
43
|
|
44
44
|
it "should check orientation" do
|
45
45
|
line.should_not be_clockwise
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should check orientation" do
|
49
|
-
l = LineString.from_points([Point.from_x_y(20,20), Point.from_x_y(10,10), Point.from_x_y(-10,10)])
|
49
|
+
l = GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.from_x_y(20,20), GeoRuby::SimpleFeatures::Point.from_x_y(10,10), GeoRuby::SimpleFeatures::Point.from_x_y(-10,10)])
|
50
50
|
l.should be_clockwise
|
51
51
|
end
|
52
52
|
|
@@ -55,107 +55,107 @@ describe LineString do
|
|
55
55
|
describe "tu converted" do
|
56
56
|
|
57
57
|
it "should concat points" do
|
58
|
-
line_string = LineString::new
|
59
|
-
line_string.concat([Point.from_x_y(12.4,45.3),Point.from_x_y(45.4,41.6)])
|
58
|
+
line_string = GeoRuby::SimpleFeatures::LineString::new
|
59
|
+
line_string.concat([GeoRuby::SimpleFeatures::Point.from_x_y(12.4,45.3),GeoRuby::SimpleFeatures::Point.from_x_y(45.4,41.6)])
|
60
60
|
|
61
61
|
line_string.length.should eql(2)
|
62
|
-
line_string[0].should == Point.from_x_y(12.4,45.3)
|
62
|
+
line_string[0].should == GeoRuby::SimpleFeatures::Point.from_x_y(12.4,45.3)
|
63
63
|
|
64
|
-
point=Point.from_x_y(123,45.8777)
|
64
|
+
point=GeoRuby::SimpleFeatures::Point.from_x_y(123,45.8777)
|
65
65
|
line_string[0]=point
|
66
66
|
line_string[0].should == point
|
67
67
|
|
68
|
-
points=[Point.from_x_y(123,45.8777),Point.from_x_y(45.4,41.6)]
|
68
|
+
points=[GeoRuby::SimpleFeatures::Point.from_x_y(123,45.8777),GeoRuby::SimpleFeatures::Point.from_x_y(45.4,41.6)]
|
69
69
|
line_string.each_index {|i| line_string[i].should == points[i] }
|
70
70
|
|
71
|
-
point=Point.from_x_y(22.4,13.56)
|
71
|
+
point=GeoRuby::SimpleFeatures::Point.from_x_y(22.4,13.56)
|
72
72
|
line_string << point
|
73
73
|
line_string.length.should eql(3)
|
74
74
|
line_string[2].should eql(point)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should create" do
|
78
|
-
line_string = LineString.from_points([Point.from_x_y(12.4,-45.3),Point.from_x_y(45.4,41.6)],123)
|
79
|
-
line_string.class.should eql(LineString)
|
78
|
+
line_string = GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.from_x_y(12.4,-45.3),GeoRuby::SimpleFeatures::Point.from_x_y(45.4,41.6)],123)
|
79
|
+
line_string.class.should eql(GeoRuby::SimpleFeatures::LineString)
|
80
80
|
line_string.length.should eql(2)
|
81
|
-
line_string[0].should == Point.from_x_y(12.4,-45.3)
|
82
|
-
line_string[1].should == Point.from_x_y(45.4,41.6)
|
81
|
+
line_string[0].should == GeoRuby::SimpleFeatures::Point.from_x_y(12.4,-45.3)
|
82
|
+
line_string[1].should == GeoRuby::SimpleFeatures::Point.from_x_y(45.4,41.6)
|
83
83
|
|
84
|
-
line_string = LineString.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698]],123)
|
85
|
-
line_string.class.should eql(LineString)
|
84
|
+
line_string = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698]],123)
|
85
|
+
line_string.class.should eql(GeoRuby::SimpleFeatures::LineString)
|
86
86
|
line_string.length.should eql(3)
|
87
|
-
line_string[0].should == Point.from_x_y(12.4,-45.3)
|
88
|
-
line_string[1].should == Point.from_x_y(45.4,41.6)
|
87
|
+
line_string[0].should == GeoRuby::SimpleFeatures::Point.from_x_y(12.4,-45.3)
|
88
|
+
line_string[1].should == GeoRuby::SimpleFeatures::Point.from_x_y(45.4,41.6)
|
89
89
|
|
90
|
-
line_string = LineString.from_coordinates([[12.4,-45.3,123],[45.4,41.6,333],[4.456,1.0698,987]],123,true)
|
91
|
-
line_string.class.should eql(LineString)
|
90
|
+
line_string = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,123],[45.4,41.6,333],[4.456,1.0698,987]],123,true)
|
91
|
+
line_string.class.should eql(GeoRuby::SimpleFeatures::LineString)
|
92
92
|
line_string.length.should eql(3)
|
93
|
-
line_string[0].should == Point.from_x_y_z(12.4,-45.3,123,123)
|
93
|
+
line_string[0].should == GeoRuby::SimpleFeatures::Point.from_x_y_z(12.4,-45.3,123,123)
|
94
94
|
|
95
|
-
line_string = LineString.from_coordinates([[12.4,-45.3,123],[45.4,41.6,333],[4.456,1.0698,987]],123,true)
|
96
|
-
line_string.class.should eql(LineString)
|
95
|
+
line_string = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,123],[45.4,41.6,333],[4.456,1.0698,987]],123,true)
|
96
|
+
line_string.class.should eql(GeoRuby::SimpleFeatures::LineString)
|
97
97
|
line_string.length.should eql(3)
|
98
|
-
line_string[0].should == Point.from_x_y_z(12.4,-45.3,123,123)
|
98
|
+
line_string[0].should == GeoRuby::SimpleFeatures::Point.from_x_y_z(12.4,-45.3,123,123)
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should bbox it" do
|
102
|
-
bbox = LineString.from_coordinates([[12.4,-45.3,123],[45.4,41.6,333],[4.456,1.0698,987]],123,true).bounding_box
|
102
|
+
bbox = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,123],[45.4,41.6,333],[4.456,1.0698,987]],123,true).bounding_box
|
103
103
|
bbox.length.should eql(2)
|
104
|
-
bbox[0].should == Point.from_x_y_z(4.456,-45.3,123)
|
105
|
-
bbox[1].should == Point.from_x_y_z(45.4,41.6,987)
|
104
|
+
bbox[0].should == GeoRuby::SimpleFeatures::Point.from_x_y_z(4.456,-45.3,123)
|
105
|
+
bbox[1].should == GeoRuby::SimpleFeatures::Point.from_x_y_z(45.4,41.6,987)
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should test_line_string_equal" do
|
109
|
-
line_string1 = LineString.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698]],123)
|
110
|
-
line_string2 = LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],123)
|
111
|
-
point = Point.from_x_y(12.4,-45.3,123)
|
109
|
+
line_string1 = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698]],123)
|
110
|
+
line_string2 = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],123)
|
111
|
+
point = GeoRuby::SimpleFeatures::Point.from_x_y(12.4,-45.3,123)
|
112
112
|
|
113
|
-
line_string1.should == LineString.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698]],123)
|
113
|
+
line_string1.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698]],123)
|
114
114
|
line_string1.should_not == line_string2
|
115
115
|
line_string1.should_not == point
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should test_line_string_binary" do
|
119
|
-
line_string = LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256)
|
119
|
+
line_string = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256)
|
120
120
|
line_string.as_hex_ewkb.should eql("01020000200001000002000000CDCCCCCCCCCC28406666666666A646C03333333333B34640CDCCCCCCCCCC4440")
|
121
121
|
|
122
|
-
line_string = LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true)
|
122
|
+
line_string = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true)
|
123
123
|
line_string.as_hex_ewkb.should eql("01020000A00001000002000000CDCCCCCCCCCC28406666666666A646C06666666666A641403333333333B34640CDCCCCCCCCCC44409A99999999992840")
|
124
124
|
|
125
|
-
line_string = LineString.from_coordinates([[12.4,-45.3,35.3,45.1],[45.4,41.6,12.3,40.23]],256,true,true)
|
125
|
+
line_string = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3,45.1],[45.4,41.6,12.3,40.23]],256,true,true)
|
126
126
|
line_string.as_hex_ewkb.should eql("01020000E00001000002000000CDCCCCCCCCCC28406666666666A646C06666666666A64140CDCCCCCCCC8C46403333333333B34640CDCCCCCCCCCC44409A999999999928403D0AD7A3701D4440")
|
127
127
|
end
|
128
128
|
|
129
129
|
it "test_line_string_text" do
|
130
|
-
line_string = LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256)
|
130
|
+
line_string = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256)
|
131
131
|
line_string.as_ewkt.should eql("SRID=256;LINESTRING(12.4 -45.3,45.4 41.6)")
|
132
132
|
|
133
|
-
line_string = LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true)
|
133
|
+
line_string = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true)
|
134
134
|
line_string.as_ewkt.should eql("SRID=256;LINESTRING(12.4 -45.3 35.3,45.4 41.6 12.3)")
|
135
135
|
|
136
|
-
line_string = LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,false,true)
|
136
|
+
line_string = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,false,true)
|
137
137
|
line_string.as_ewkt.should eql("SRID=256;LINESTRINGM(12.4 -45.3 35.3,45.4 41.6 12.3)")
|
138
138
|
|
139
|
-
line_string = LineString.from_coordinates([[12.4,-45.3,35.3,25.2],[45.4,41.6,12.3,13.75]],256,true,true)
|
139
|
+
line_string = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3,25.2],[45.4,41.6,12.3,13.75]],256,true,true)
|
140
140
|
line_string.as_ewkt.should eql("SRID=256;LINESTRING(12.4 -45.3 35.3 25.2,45.4 41.6 12.3 13.75)")
|
141
141
|
end
|
142
142
|
|
143
143
|
it "should test_linear_ring_creation" do
|
144
144
|
#testing just the constructor helpers since the rest is the same as for line_string
|
145
|
-
linear_ring = LinearRing.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],345)
|
146
|
-
linear_ring.class.should eql(LinearRing)
|
145
|
+
linear_ring = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],345)
|
146
|
+
linear_ring.class.should eql(GeoRuby::SimpleFeatures::LinearRing)
|
147
147
|
linear_ring.length.should eql(4)
|
148
148
|
linear_ring.should be_closed
|
149
|
-
linear_ring[1].should == Point.from_x_y(45.4,41.6,345)
|
149
|
+
linear_ring[1].should == GeoRuby::SimpleFeatures::Point.from_x_y(45.4,41.6,345)
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
153
|
describe "> Coordinates" do
|
154
154
|
|
155
155
|
before(:each) do
|
156
|
-
Point.should_receive(:from_coordinates).
|
156
|
+
GeoRuby::SimpleFeatures::Point.should_receive(:from_coordinates).
|
157
157
|
exactly(4).with(anything, 4326, false, false).and_return(mock_point)
|
158
|
-
@line = LineString.from_coordinates([1.2,2.5,2.2,4.5])
|
158
|
+
@line = GeoRuby::SimpleFeatures::LineString.from_coordinates([1.2,2.5,2.2,4.5])
|
159
159
|
end
|
160
160
|
|
161
161
|
it "should instantiate from coordinates" do
|
@@ -166,7 +166,7 @@ describe LineString do
|
|
166
166
|
|
167
167
|
describe "> Instantiated" do
|
168
168
|
|
169
|
-
let (:line) { LineString.from_points(mock_points(7)) }
|
169
|
+
let (:line) { GeoRuby::SimpleFeatures::LineString.from_points(mock_points(7)) }
|
170
170
|
|
171
171
|
it "should be closed if the last point equals the first" do
|
172
172
|
line.push(line.first)
|
@@ -203,10 +203,10 @@ describe LineString do
|
|
203
203
|
|
204
204
|
describe "> Distances..." do
|
205
205
|
before(:each) do
|
206
|
-
@p1 = mock(Point)
|
207
|
-
@p2 = mock(Point)
|
208
|
-
@p3 = mock(Point)
|
209
|
-
@line = LineString.from_points([@p1,@p2,@p3])
|
206
|
+
@p1 = mock(GeoRuby::SimpleFeatures::Point)
|
207
|
+
@p2 = mock(GeoRuby::SimpleFeatures::Point)
|
208
|
+
@p3 = mock(GeoRuby::SimpleFeatures::Point)
|
209
|
+
@line = GeoRuby::SimpleFeatures::LineString.from_points([@p1,@p2,@p3])
|
210
210
|
end
|
211
211
|
|
212
212
|
it "should print the length with haversine" do
|
@@ -224,10 +224,10 @@ describe LineString do
|
|
224
224
|
|
225
225
|
describe "Simplify" do
|
226
226
|
|
227
|
-
let(:line) { LineString.from_coordinates([[6,0],[4,1],[3,4],[4,6],[5,8],[5,9],[4,10],[6,15]], 4326) }
|
227
|
+
let(:line) { GeoRuby::SimpleFeatures::LineString.from_coordinates([[6,0],[4,1],[3,4],[4,6],[5,8],[5,9],[4,10],[6,15]], 4326) }
|
228
228
|
|
229
229
|
it "should simplify a simple linestring" do
|
230
|
-
line = LineString.from_coordinates([[12,15],[14,17],[17, 20]], 4326)
|
230
|
+
line = GeoRuby::SimpleFeatures::LineString.from_coordinates([[12,15],[14,17],[17, 20]], 4326)
|
231
231
|
line.simplify.should have(2).points
|
232
232
|
end
|
233
233
|
|