georuby 2.3.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -9
  3. data/Rakefile +13 -14
  4. data/lib/geo_ruby/ewk.rb +2 -0
  5. data/lib/geo_ruby/{simple_features → ewk}/ewkb_parser.rb +206 -218
  6. data/lib/geo_ruby/ewk/ewkt_parser.rb +321 -0
  7. data/lib/geo_ruby/geojson.rb +27 -32
  8. data/lib/geo_ruby/georss.rb +88 -66
  9. data/lib/geo_ruby/gpx.rb +113 -1
  10. data/lib/geo_ruby/kml.rb +43 -31
  11. data/lib/geo_ruby/shp.rb +1 -0
  12. data/lib/geo_ruby/shp4r/dbf.rb +7 -3
  13. data/lib/geo_ruby/shp4r/shp.rb +297 -284
  14. data/lib/geo_ruby/simple_features.rb +2 -6
  15. data/lib/geo_ruby/simple_features/circle.rb +15 -13
  16. data/lib/geo_ruby/simple_features/envelope.rb +84 -77
  17. data/lib/geo_ruby/simple_features/geometry.rb +89 -69
  18. data/lib/geo_ruby/simple_features/geometry_collection.rb +46 -43
  19. data/lib/geo_ruby/simple_features/geometry_factory.rb +50 -47
  20. data/lib/geo_ruby/simple_features/helper.rb +14 -14
  21. data/lib/geo_ruby/simple_features/line_string.rb +94 -97
  22. data/lib/geo_ruby/simple_features/linear_ring.rb +4 -9
  23. data/lib/geo_ruby/simple_features/multi_line_string.rb +18 -21
  24. data/lib/geo_ruby/simple_features/multi_point.rb +18 -20
  25. data/lib/geo_ruby/simple_features/multi_polygon.rb +19 -25
  26. data/lib/geo_ruby/simple_features/point.rb +134 -128
  27. data/lib/geo_ruby/simple_features/polygon.rb +60 -59
  28. data/lib/geo_ruby/version.rb +1 -1
  29. data/spec/data/geojson/feature.json +9 -0
  30. data/spec/data/geojson/feature_collection.json +3 -4
  31. data/spec/geo_ruby/{simple_features → ewk}/ewkb_parser_spec.rb +56 -57
  32. data/spec/geo_ruby/{simple_features → ewk}/ewkt_parser_spec.rb +62 -63
  33. data/spec/geo_ruby/geojson_spec.rb +34 -17
  34. data/spec/geo_ruby/georss_spec.rb +76 -64
  35. data/spec/geo_ruby/{gpx4r/gpx_spec.rb → gpx_spec.rb} +25 -25
  36. data/spec/geo_ruby/kml_spec.rb +40 -36
  37. data/spec/geo_ruby/shp4r/shp_spec.rb +51 -51
  38. data/spec/geo_ruby/simple_features/circle_spec.rb +2 -2
  39. data/spec/geo_ruby/simple_features/envelope_spec.rb +8 -8
  40. data/spec/geo_ruby/simple_features/geometry_collection_spec.rb +26 -26
  41. data/spec/geo_ruby/simple_features/geometry_factory_spec.rb +5 -5
  42. data/spec/geo_ruby/simple_features/geometry_spec.rb +8 -8
  43. data/spec/geo_ruby/simple_features/line_string_spec.rb +102 -102
  44. data/spec/geo_ruby/simple_features/linear_ring_spec.rb +7 -7
  45. data/spec/geo_ruby/simple_features/multi_line_string_spec.rb +20 -20
  46. data/spec/geo_ruby/simple_features/multi_point_spec.rb +16 -16
  47. data/spec/geo_ruby/simple_features/multi_polygon_spec.rb +19 -19
  48. data/spec/geo_ruby/simple_features/point_spec.rb +180 -174
  49. data/spec/geo_ruby/simple_features/polygon_spec.rb +55 -56
  50. data/spec/geo_ruby_spec.rb +4 -4
  51. data/spec/spec_helper.rb +19 -13
  52. metadata +10 -9
  53. data/lib/geo_ruby/gpx4r/gpx.rb +0 -118
  54. data/lib/geo_ruby/simple_features/ewkt_parser.rb +0 -336
@@ -3,176 +3,175 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
3
3
  describe GeoRuby::SimpleFeatures::EWKTParser do
4
4
 
5
5
  before(:each) do
6
- @factory = GeoRuby::SimpleFeatures::GeometryFactory::new
7
- @ewkt_parser = GeoRuby::SimpleFeatures::EWKTParser::new(@factory)
6
+ @factory = GeoRuby::SimpleFeatures::GeometryFactory.new
7
+ @ewkt_parser = GeoRuby::SimpleFeatures::EWKTParser.new(@factory)
8
8
  end
9
9
 
10
- it "test_point" do
11
- ewkt="POINT( 3.456 0.123)"
10
+ it 'test_point' do
11
+ ewkt = 'POINT( 3.456 0.123)'
12
12
  @ewkt_parser.parse(ewkt)
13
13
  point = @factory.geometry
14
14
  expect(point).to be_instance_of GeoRuby::SimpleFeatures::Point
15
- expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y(3.456,0.123))
15
+ expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y(3.456, 0.123))
16
16
  end
17
17
 
18
- it "test_point_with_srid" do
19
- ewkt="SRID=245;POINT(0.0 2.0)"
18
+ it 'test_point_with_srid' do
19
+ ewkt = 'SRID=245;POINT(0.0 2.0)'
20
20
  @ewkt_parser.parse(ewkt)
21
21
  point = @factory.geometry
22
22
  expect(point).to be_instance_of GeoRuby::SimpleFeatures::Point
23
- expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y(0,2,245))
23
+ expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y(0, 2, 245))
24
24
  expect(point.srid).to eql(245)
25
- expect(ewkt).to eq(point.as_ewkt(true,false))
25
+ expect(ewkt).to eq(point.as_ewkt(true, false))
26
26
  end
27
27
 
28
- it "test_point3dz" do
29
- ewkt="POINT(3.456 0.123 123.667)"
28
+ it 'test_point3dz' do
29
+ ewkt = 'POINT(3.456 0.123 123.667)'
30
30
  @ewkt_parser.parse(ewkt)
31
31
  point = @factory.geometry
32
32
  expect(point).to be_instance_of GeoRuby::SimpleFeatures::Point
33
- expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y_z(3.456,0.123,123.667))
33
+ expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y_z(3.456, 0.123, 123.667))
34
34
  expect(ewkt).to eq(point.as_ewkt(false))
35
35
  end
36
36
 
37
- it "test_point3dm" do
38
- ewkt="POINTM(3.456 0.123 123.667)"
37
+ it 'test_point3dm' do
38
+ ewkt = 'POINTM(3.456 0.123 123.667)'
39
39
  @ewkt_parser.parse(ewkt)
40
40
  point = @factory.geometry
41
41
  expect(point).to be_instance_of GeoRuby::SimpleFeatures::Point
42
- expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y_m(3.456,0.123,123.667))
42
+ expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y_m(3.456, 0.123, 123.667))
43
43
  expect(ewkt).to eq(point.as_ewkt(false))
44
44
  end
45
45
 
46
- it "test_point4d" do
47
- ewkt="POINT(3.456 0.123 123.667 15.0)"
46
+ it 'test_point4d' do
47
+ ewkt = 'POINT(3.456 0.123 123.667 15.0)'
48
48
  @ewkt_parser.parse(ewkt)
49
49
  point = @factory.geometry
50
50
  expect(point).to be_instance_of GeoRuby::SimpleFeatures::Point
51
- expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y_z_m(3.456,0.123,123.667,15.0))
51
+ expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y_z_m(3.456, 0.123, 123.667, 15.0))
52
52
  expect(ewkt).to eq(point.as_ewkt(false))
53
53
  end
54
54
 
55
-
56
- it "test_linestring" do
57
- @ewkt_parser.parse("LINESTRING(3.456 0.123,123.44 123.56,54555.22 123.3)")
55
+ it 'test_linestring' do
56
+ @ewkt_parser.parse('LINESTRING(3.456 0.123,123.44 123.56,54555.22 123.3)')
58
57
  line_string = @factory.geometry
59
58
  expect(line_string).to be_instance_of GeoRuby::SimpleFeatures::LineString
60
- expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[3.456,0.123],[123.44,123.56],[54555.22,123.3]]))
59
+ expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[3.456, 0.123], [123.44, 123.56], [54_555.22, 123.3]]))
61
60
 
62
- @ewkt_parser.parse("SRID=256;LINESTRING(12.4 -45.3,45.4 41.6)")
61
+ @ewkt_parser.parse('SRID=256;LINESTRING(12.4 -45.3,45.4 41.6)')
63
62
  line_string = @factory.geometry
64
63
  expect(line_string).to be_instance_of GeoRuby::SimpleFeatures::LineString
65
- expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256))
64
+ expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4, -45.3], [45.4, 41.6]], 256))
66
65
 
67
- @ewkt_parser.parse("SRID=256;LINESTRING(12.4 -45.3 35.3,45.4 41.6 12.3)")
66
+ @ewkt_parser.parse('SRID=256;LINESTRING(12.4 -45.3 35.3,45.4 41.6 12.3)')
68
67
  line_string = @factory.geometry
69
68
  expect(line_string).to be_instance_of GeoRuby::SimpleFeatures::LineString
70
- expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true))
69
+ expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4, -45.3, 35.3], [45.4, 41.6, 12.3]], 256, true))
71
70
 
72
- @ewkt_parser.parse("SRID=256;LINESTRINGM(12.4 -45.3 35.3,45.4 41.6 12.3)")
71
+ @ewkt_parser.parse('SRID=256;LINESTRINGM(12.4 -45.3 35.3,45.4 41.6 12.3)')
73
72
  line_string = @factory.geometry
74
73
  expect(line_string).to be_instance_of GeoRuby::SimpleFeatures::LineString
75
- expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,false,true))
74
+ expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4, -45.3, 35.3], [45.4, 41.6, 12.3]], 256, false, true))
76
75
 
77
- @ewkt_parser.parse("SRID=256;LINESTRING(12.4 -45.3 35.3 25.2,45.4 41.6 12.3 13.75)")
76
+ @ewkt_parser.parse('SRID=256;LINESTRING(12.4 -45.3 35.3 25.2,45.4 41.6 12.3 13.75)')
78
77
  line_string = @factory.geometry
79
78
  expect(line_string).to be_instance_of GeoRuby::SimpleFeatures::LineString
80
- expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3,25.2],[45.4,41.6,12.3,13.75]],256,true,true))
79
+ expect(line_string).to eq(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
80
  end
82
81
 
83
- it "test_polygon" do
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))")
82
+ it 'test_polygon' do
83
+ @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
84
  polygon = @factory.geometry
86
85
  expect(polygon).to be_instance_of GeoRuby::SimpleFeatures::Polygon
87
- expect(polygon).to eq(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))
86
+ expect(polygon).to eq(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
87
 
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))")
88
+ @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
89
  polygon = @factory.geometry
91
90
  expect(polygon).to be_instance_of GeoRuby::SimpleFeatures::Polygon
92
- expect(polygon).to eq(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))
91
+ expect(polygon).to eq(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
92
 
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))")
93
+ @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
94
  polygon = @factory.geometry
96
95
  expect(polygon).to be_instance_of GeoRuby::SimpleFeatures::Polygon
97
- expect(polygon).to eq(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))
96
+ expect(polygon).to eq(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
97
 
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))")
98
+ @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
99
  polygon = @factory.geometry
101
100
  expect(polygon).to be_instance_of GeoRuby::SimpleFeatures::Polygon
102
- expect(polygon).to eq(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))
101
+ expect(polygon).to eq(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
102
  end
104
103
 
105
- it "test_multi_point" do
106
- #Form output by the current version of PostGIS. Future versions will output the one in the specification
107
- @ewkt_parser.parse("SRID=444;MULTIPOINT(12.4 -123.3,-65.1 123.4,123.55555555 123)")
104
+ it 'test_multi_point' do
105
+ # Form output by the current version of PostGIS. Future versions will output the one in the specification
106
+ @ewkt_parser.parse('SRID=444;MULTIPOINT(12.4 -123.3,-65.1 123.4,123.55555555 123)')
108
107
  multi_point = @factory.geometry
109
108
  expect(multi_point).to be_instance_of GeoRuby::SimpleFeatures::MultiPoint
110
- expect(multi_point).to eq(GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444))
109
+ expect(multi_point).to eq(GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4, -123.3], [-65.1, 123.4], [123.55555555, 123]], 444))
111
110
  expect(multi_point.srid).to eql(444)
112
111
  expect(multi_point[0].srid).to eql(444)
113
112
 
114
- @ewkt_parser.parse("SRID=444;MULTIPOINT(12.4 -123.3 4.5,-65.1 123.4 6.7,123.55555555 123 7.8)")
113
+ @ewkt_parser.parse('SRID=444;MULTIPOINT(12.4 -123.3 4.5,-65.1 123.4 6.7,123.55555555 123 7.8)')
115
114
  multi_point = @factory.geometry
116
115
  expect(multi_point).to be_instance_of GeoRuby::SimpleFeatures::MultiPoint
117
- expect(multi_point).to eq(GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,6.7],[123.55555555,123,7.8]],444,true))
116
+ expect(multi_point).to eq(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
117
  expect(multi_point.srid).to eql(444)
119
118
  expect(multi_point[0].srid).to eql(444)
120
119
 
121
- #Form in the EWKT specification (from the OGC)
122
- @ewkt_parser.parse("SRID=444;MULTIPOINT( ( 12.4 -123.3 4.5 ) , (-65.1 123.4 6.7),(123.55555555 123 7.8))")
120
+ # Form in the EWKT specification (from the OGC)
121
+ @ewkt_parser.parse('SRID=444;MULTIPOINT( ( 12.4 -123.3 4.5 ) , (-65.1 123.4 6.7),(123.55555555 123 7.8))')
123
122
  multi_point = @factory.geometry
124
123
  expect(multi_point).to be_instance_of GeoRuby::SimpleFeatures::MultiPoint
125
- expect(multi_point).to eq(GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,6.7],[123.55555555,123,7.8]],444,true))
124
+ expect(multi_point).to eq(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
125
  expect(multi_point.srid).to eql(444)
127
126
  expect(multi_point[0].srid).to eql(444)
128
127
  end
129
128
 
130
- it "test_multi_line_string" do
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))")
129
+ it 'test_multi_line_string' do
130
+ @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
131
  multi_line_string = @factory.geometry
133
132
  expect(multi_line_string).to be_instance_of GeoRuby::SimpleFeatures::MultiLineString
134
- expect(multi_line_string).to eq(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))
133
+ expect(multi_line_string).to eq(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
134
  expect(multi_line_string.srid).to eql(256)
136
135
  expect(multi_line_string[0].srid).to eql(256)
137
136
 
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))")
137
+ @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
138
  multi_line_string = @factory.geometry
140
139
  expect(multi_line_string).to be_instance_of GeoRuby::SimpleFeatures::MultiLineString
141
- expect(multi_line_string).to eq(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))
140
+ expect(multi_line_string).to eq(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
141
  expect(multi_line_string.srid).to eql(256)
143
142
  expect(multi_line_string[0].srid).to eql(256)
144
143
  end
145
144
 
146
- it "test_multi_polygon" do
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)))"
145
+ it 'test_multi_polygon' do
146
+ 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
147
  @ewkt_parser.parse(ewkt)
149
148
  multi_polygon = @factory.geometry
150
149
  expect(multi_polygon).to be_instance_of GeoRuby::SimpleFeatures::MultiPolygon
151
- expect(multi_polygon).to eq(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))
150
+ expect(multi_polygon).to eq(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
151
  expect(multi_polygon.srid).to eql(256)
153
152
  expect(multi_polygon[0].srid).to eql(256)
154
153
  expect(ewkt).to eq(multi_polygon.as_ewkt)
155
154
 
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)))"
155
+ 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
156
  @ewkt_parser.parse(ewkt)
158
157
  multi_polygon = @factory.geometry
159
158
  expect(multi_polygon).to be_instance_of GeoRuby::SimpleFeatures::MultiPolygon
160
- expect(multi_polygon).to eq(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))
159
+ expect(multi_polygon).to eq(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
160
  expect(multi_polygon.srid).to eql(4326)
162
161
  expect(multi_polygon[0].srid).to eql(4326)
163
162
  end
164
163
 
165
- it "test_geometry_collection" do
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)))")
164
+ it 'test_geometry_collection' do
165
+ @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
166
  geometry_collection = @factory.geometry
168
167
  expect(geometry_collection).to be_instance_of GeoRuby::SimpleFeatures::GeometryCollection
169
- expect(geometry_collection).to eq(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))
168
+ expect(geometry_collection).to eq(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
169
  expect(geometry_collection[0].srid).to eql(256)
171
170
 
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))")
171
+ @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
172
  geometry_collection = @factory.geometry
174
173
  expect(geometry_collection).to be_instance_of GeoRuby::SimpleFeatures::GeometryCollection
175
- expect(geometry_collection).to eq(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))
174
+ expect(geometry_collection).to eq(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
175
  expect(geometry_collection[0].srid).to eql(256)
177
176
  end
178
177
 
@@ -7,25 +7,25 @@ DATA_DIR = File.dirname(__FILE__) + '/../data/geojson/'
7
7
  #
8
8
  # TODO Refactor comon test approaches into methods
9
9
  # TODO Add use of contexts?
10
- describe GeoRuby::GeojsonParser do
10
+ describe GeoRuby::GeoJSONParser do
11
11
 
12
- it "should create a specified GeoRuby::SimpleFeatures::Point" do
13
- point_json = %{ { "type": "Point", "coordinates": [100.0, 0.0] } }
12
+ it 'should create a specified GeoRuby::SimpleFeatures::Point' do
13
+ point_json = %( { "type": "Point", "coordinates": [100.0, 0.0] } )
14
14
  point = GeoRuby::SimpleFeatures::Geometry.from_geojson(point_json)
15
15
  expect(point.class).to eql(GeoRuby::SimpleFeatures::Point)
16
16
  point_hash = JSON.parse(point_json)
17
17
  expect(point.to_coordinates).to eql(point_hash['coordinates'])
18
18
  end
19
19
 
20
- it "should create a specified GeoRuby::SimpleFeatures::LineString" do
21
- ls_json = %{ { "type": "LineString", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ]} }
20
+ it 'should create a specified GeoRuby::SimpleFeatures::LineString' do
21
+ ls_json = %( { "type": "LineString", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ]} )
22
22
  line_string = GeoRuby::SimpleFeatures::Geometry.from_geojson(ls_json)
23
23
  expect(line_string.class).to eql(GeoRuby::SimpleFeatures::LineString)
24
24
  ls_hash = JSON.parse(ls_json)
25
25
  expect(line_string.to_coordinates).to eql(ls_hash['coordinates'])
26
26
  end
27
27
 
28
- it "should create a specified GeoRuby::SimpleFeatures::Polygon" do
28
+ it 'should create a specified GeoRuby::SimpleFeatures::Polygon' do
29
29
  poly_json = <<-EOJ
30
30
  { "type": "Polygon",
31
31
  "coordinates": [
@@ -41,7 +41,7 @@ describe GeoRuby::GeojsonParser do
41
41
  expect(polygon.to_coordinates).to eql(poly_hash['coordinates'])
42
42
  end
43
43
 
44
- it "should create a specified GeoRuby::SimpleFeatures::MultiPoint" do
44
+ it 'should create a specified GeoRuby::SimpleFeatures::MultiPoint' do
45
45
  mp_json = <<-EOJ
46
46
  { "type": "MultiPoint",
47
47
  "coordinates": [ [100.0, 0.0], [101.0, 1.0] ]
@@ -53,7 +53,7 @@ describe GeoRuby::GeojsonParser do
53
53
  expect(multi_point.to_coordinates).to eql(mp_hash['coordinates'])
54
54
  end
55
55
 
56
- it "should create a specified GeoRuby::SimpleFeatures::MultiLineString" do
56
+ it 'should create a specified GeoRuby::SimpleFeatures::MultiLineString' do
57
57
  mls_json = <<-EOJ
58
58
  { "type": "MultiLineString",
59
59
  "coordinates": [
@@ -68,7 +68,7 @@ describe GeoRuby::GeojsonParser do
68
68
  expect(multi_ls.to_coordinates).to eql(mls_hash['coordinates'])
69
69
  end
70
70
 
71
- it "should create a specifiead GeoRuby::SimpleFeatures::MultiPolygon" do
71
+ it 'should create a specifiead GeoRuby::SimpleFeatures::MultiPolygon' do
72
72
  mpoly_json = <<-EOJ
73
73
  { "type": "MultiPolygon",
74
74
  "coordinates": [
@@ -84,7 +84,7 @@ describe GeoRuby::GeojsonParser do
84
84
  expect(mpoly.to_coordinates).to eql(mpoly_hash['coordinates'])
85
85
  end
86
86
 
87
- it "should create a specified GeoRuby::SimpleFeatures::GeometryCollection" do
87
+ it 'should create a specified GeoRuby::SimpleFeatures::GeometryCollection' do
88
88
  gcol_json = <<-EOJ
89
89
  { "type": "GeometryCollection",
90
90
  "geometries": [
@@ -100,7 +100,7 @@ describe GeoRuby::GeojsonParser do
100
100
  gcol = GeoRuby::SimpleFeatures::Geometry.from_geojson(gcol_json)
101
101
  expect(gcol.class).to eql(GeoRuby::SimpleFeatures::GeometryCollection)
102
102
  gcol_hash = JSON.parse(gcol_json)
103
- gcol.geometries.each_with_index do |g,i|
103
+ gcol.geometries.each_with_index do |g, i|
104
104
  gh = gcol_hash['geometries'][i]
105
105
  expect(g.class).to eql(GeoRuby::SimpleFeatures.const_get(gh['type']))
106
106
  expect(g.to_coordinates).to eql(gh['coordinates'])
@@ -108,7 +108,7 @@ describe GeoRuby::GeojsonParser do
108
108
  end
109
109
 
110
110
  # Feature GeoJSON test example from wikipedia entry
111
- it "should create a specified Feature" do
111
+ it 'should create a specified Feature' do
112
112
  feature_json = <<-EOJ
113
113
  {
114
114
  "type":"Feature",
@@ -121,7 +121,7 @@ describe GeoRuby::GeojsonParser do
121
121
  }
122
122
  EOJ
123
123
  f = GeoRuby::SimpleFeatures::Geometry.from_geojson(feature_json)
124
- expect(f.class).to eql(GeoRuby::GeojsonFeature)
124
+ expect(f.class).to eql(GeoRuby::GeoJSONFeature)
125
125
  feature_hash = JSON.parse(feature_json)
126
126
  expect(f.id).to eql(feature_hash['id'])
127
127
  expect(f.properties).to eql(feature_hash['properties'])
@@ -129,12 +129,12 @@ describe GeoRuby::GeojsonParser do
129
129
  expect(f.geometry.to_coordinates).to eql(feature_hash['geometry']['coordinates'])
130
130
  end
131
131
 
132
- it "should create a specified FeatureCollection" do
132
+ it 'should create a specified FeatureCollection' do
133
133
  fcol_json = File.read(DATA_DIR + 'feature_collection.json')
134
134
  fcol = GeoRuby::SimpleFeatures::Geometry.from_geojson(fcol_json)
135
- expect(fcol.class).to eql(GeoRuby::GeojsonFeatureCollection)
135
+ expect(fcol.class).to eql(GeoRuby::GeoJSONFeatureCollection)
136
136
  fcol_hash = JSON.parse(fcol_json)
137
- fcol.features.each_with_index do |f,i|
137
+ fcol.features.each_with_index do |f, i|
138
138
  fgh = fcol_hash['features'][i]['geometry']
139
139
  fg = f.geometry
140
140
  expect(f.properties).to eql(fcol_hash['features'][i]['properties'])
@@ -143,5 +143,22 @@ describe GeoRuby::GeojsonParser do
143
143
  end
144
144
  end
145
145
 
146
- end
146
+ it 'should export a feature as JSON' do
147
+ fcol_json = File.read(DATA_DIR + 'feature.json')
148
+ geojson = GeoRuby::SimpleFeatures::Geometry.from_geojson(fcol_json)
149
+ expect(geojson).to be_a(GeoRuby::GeoJSONFeature)
150
+
151
+ export = GeoRuby::SimpleFeatures::Geometry.from_geojson(geojson.to_json)
152
+ expect(geojson).to eq(export)
153
+ end
154
+
155
+ it 'should export a feature collection as JSON' do
156
+ fcol_json = File.read(DATA_DIR + 'feature_collection.json')
157
+ geojson = GeoRuby::SimpleFeatures::Geometry.from_geojson(fcol_json)
158
+ expect(geojson).to be_a(GeoRuby::GeoJSONFeatureCollection)
159
+
160
+ export = GeoRuby::SimpleFeatures::Geometry.from_geojson(geojson.to_json)
161
+ expect(geojson).to eq(export)
162
+ end
147
163
 
164
+ end
@@ -4,71 +4,71 @@ RSS_DATA_DIR = File.dirname(__FILE__) + '/../data/georss/'
4
4
 
5
5
  describe GeoRuby::GeorssParser do
6
6
 
7
- it "should parse an rss file" do
8
- geo = subject.parse(File.read(RSS_DATA_DIR + "/w3c.xml"))
7
+ it 'should parse an rss file' do
8
+ geo = subject.parse(File.read(RSS_DATA_DIR + '/w3c.xml'))
9
9
  expect(geo).to be_a GeoRuby::SimpleFeatures::Point
10
10
  end
11
11
 
12
- it "test_point_creation" do
13
- point = GeoRuby::SimpleFeatures::Point.from_x_y(3,4)
12
+ it 'test_point_creation' do
13
+ point = GeoRuby::SimpleFeatures::Point.from_x_y(3, 4)
14
14
 
15
- expect(point.as_georss(:dialect => :simple, :elev => 45.7, :featuretypetag => "hoyoyo").gsub("\n","")).to eql("<georss:point featuretypetag=\"hoyoyo\" elev=\"45.7\">4 3</georss:point>")
16
- expect(point.as_georss(:dialect => :w3cgeo).gsub("\n","")).to eql("<geo:lat>4</geo:lat><geo:long>3</geo:long>")
17
- expect(point.as_georss(:dialect => :gml).gsub("\n","")).to eql("<georss:where><gml:Point><gml:pos>4 3</gml:pos></gml:Point></georss:where>")
15
+ expect(point.as_georss(dialect: :simple, elev: 45.7, featuretypetag: 'hoyoyo').gsub("\n", '')).to eql("<georss:point featuretypetag=\"hoyoyo\" elev=\"45.7\">4 3</georss:point>")
16
+ expect(point.as_georss(dialect: :w3cgeo).gsub("\n", '')).to eql('<geo:lat>4</geo:lat><geo:long>3</geo:long>')
17
+ expect(point.as_georss(dialect: :gml).gsub("\n", '')).to eql('<georss:where><gml:Point><gml:pos>4 3</gml:pos></gml:Point></georss:where>')
18
18
 
19
- expect(point.as_kml(:id => "HOYOYO-42").gsub("\n","")).to eql("<Point id=\"HOYOYO-42\"><coordinates>3,4</coordinates></Point>")
19
+ expect(point.as_kml(id: 'HOYOYO-42').gsub("\n", '')).to eql("<Point id=\"HOYOYO-42\"><coordinates>3,4</coordinates></Point>")
20
20
  end
21
21
 
22
- it "test_line_string" do
23
- ls = GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.from_lon_lat_z(12.4,-45.3,56),GeoRuby::SimpleFeatures::Point.from_lon_lat_z(45.4,41.6,45)],123,true)
22
+ it 'test_line_string' do
23
+ ls = GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.from_lon_lat_z(12.4, -45.3, 56), GeoRuby::SimpleFeatures::Point.from_lon_lat_z(45.4, 41.6, 45)], 123, true)
24
24
 
25
- expect(ls.as_georss.gsub("\n","")).to eql("<georss:line>-45.3 12.4 41.6 45.4</georss:line>")
26
- expect(ls.as_georss(:dialect => :w3cgeo).gsub("\n","")).to eql("<geo:lat>-45.3</geo:lat><geo:long>12.4</geo:long>")
27
- expect(ls.as_georss(:dialect => :gml).gsub("\n","")).to eql("<georss:where><gml:LineString><gml:posList>-45.3 12.4 41.6 45.4</gml:posList></gml:LineString></georss:where>")
25
+ expect(ls.as_georss.gsub("\n", '')).to eql('<georss:line>-45.3 12.4 41.6 45.4</georss:line>')
26
+ expect(ls.as_georss(dialect: :w3cgeo).gsub("\n", '')).to eql('<geo:lat>-45.3</geo:lat><geo:long>12.4</geo:long>')
27
+ expect(ls.as_georss(dialect: :gml).gsub("\n", '')).to eql('<georss:where><gml:LineString><gml:posList>-45.3 12.4 41.6 45.4</gml:posList></gml:LineString></georss:where>')
28
28
 
29
- expect(ls.as_kml(:extrude => 1, :altitude_mode => "absolute").gsub("\n","")).to eql("<LineString><extrude>1</extrude><altitudeMode>absolute</altitudeMode><coordinates>12.4,-45.3,56 45.4,41.6,45</coordinates></LineString>")
29
+ expect(ls.as_kml(extrude: 1, altitude_mode: 'absolute').gsub("\n", '')).to eql('<LineString><extrude>1</extrude><altitudeMode>absolute</altitudeMode><coordinates>12.4,-45.3,56 45.4,41.6,45</coordinates></LineString>')
30
30
  end
31
31
 
32
- it "test_polygon" do
33
- linear_ring1 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],256)
34
- linear_ring2 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]],256)
35
- polygon = GeoRuby::SimpleFeatures::Polygon.from_linear_rings([linear_ring1,linear_ring2],256)
32
+ it 'test_polygon' do
33
+ linear_ring1 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[12.4, -45.3], [45.4, 41.6], [4.456, 1.0698], [12.4, -45.3]], 256)
34
+ linear_ring2 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[2.4, 5.3], [5.4, 1.4263], [14.46, 1.06], [2.4, 5.3]], 256)
35
+ polygon = GeoRuby::SimpleFeatures::Polygon.from_linear_rings([linear_ring1, linear_ring2], 256)
36
36
 
37
- expect(polygon.as_georss(:georss_ns => "hoyoyo").gsub("\n","")).to eql("<hoyoyo:polygon>-45.3 12.4 41.6 45.4 1.0698 4.456 -45.3 12.4</hoyoyo:polygon>")
38
- expect(polygon.as_georss(:dialect => :w3cgeo, :w3cgeo_ns => "bouyoul").gsub("\n","")).to eql("<bouyoul:lat>-45.3</bouyoul:lat><bouyoul:long>12.4</bouyoul:long>")
39
- expect(polygon.as_georss(:dialect => :gml).gsub("\n","")).to eql("<georss:where><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList>-45.3 12.4 41.6 45.4 1.0698 4.456 -45.3 12.4</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></georss:where>")
37
+ expect(polygon.as_georss(georss_ns: 'hoyoyo').gsub("\n", '')).to eql('<hoyoyo:polygon>-45.3 12.4 41.6 45.4 1.0698 4.456 -45.3 12.4</hoyoyo:polygon>')
38
+ expect(polygon.as_georss(dialect: :w3cgeo, w3cgeo_ns: 'bouyoul').gsub("\n", '')).to eql('<bouyoul:lat>-45.3</bouyoul:lat><bouyoul:long>12.4</bouyoul:long>')
39
+ expect(polygon.as_georss(dialect: :gml).gsub("\n", '')).to eql('<georss:where><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList>-45.3 12.4 41.6 45.4 1.0698 4.456 -45.3 12.4</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></georss:where>')
40
40
 
41
- expect(polygon.as_kml.gsub("\n","")).to eql("<Polygon><outerBoundaryIs><LinearRing><coordinates>12.4,-45.3 45.4,41.6 4.456,1.0698 12.4,-45.3</coordinates></LinearRing></outerBoundaryIs><innerBoundaryIs><LinearRing><coordinates>2.4,5.3 5.4,1.4263 14.46,1.06 2.4,5.3</coordinates></LinearRing></innerBoundaryIs></Polygon>")
41
+ expect(polygon.as_kml.gsub("\n", '')).to eql('<Polygon><outerBoundaryIs><LinearRing><coordinates>12.4,-45.3 45.4,41.6 4.456,1.0698 12.4,-45.3</coordinates></LinearRing></outerBoundaryIs><innerBoundaryIs><LinearRing><coordinates>2.4,5.3 5.4,1.4263 14.46,1.06 2.4,5.3</coordinates></LinearRing></innerBoundaryIs></Polygon>')
42
42
  end
43
43
 
44
- it "test_geometry_collection" do
45
- gc = 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)
44
+ it 'test_geometry_collection' do
45
+ gc = 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)
46
46
 
47
- #only the first geometry is output
48
- expect(gc.as_georss(:dialect => :simple,:floor => 4).gsub("\n","")).to eql("<georss:point floor=\"4\">45.4 4.67</georss:point>")
49
- expect(gc.as_georss(:dialect => :w3cgeo).gsub("\n","")).to eql("<geo:lat>45.4</geo:lat><geo:long>4.67</geo:long>")
50
- expect(gc.as_georss(:dialect => :gml).gsub("\n","")).to eql("<georss:where><gml:Point><gml:pos>45.4 4.67</gml:pos></gml:Point></georss:where>")
47
+ # only the first geometry is output
48
+ expect(gc.as_georss(dialect: :simple, floor: 4).gsub("\n", '')).to eql("<georss:point floor=\"4\">45.4 4.67</georss:point>")
49
+ expect(gc.as_georss(dialect: :w3cgeo).gsub("\n", '')).to eql('<geo:lat>45.4</geo:lat><geo:long>4.67</geo:long>')
50
+ expect(gc.as_georss(dialect: :gml).gsub("\n", '')).to eql('<georss:where><gml:Point><gml:pos>45.4 4.67</gml:pos></gml:Point></georss:where>')
51
51
 
52
- expect(gc.as_kml(:id => "HOYOYO-42").gsub("\n","")).to eql("<MultiGeometry id=\"HOYOYO-42\"><Point><coordinates>4.67,45.4</coordinates></Point><LineString><coordinates>5.7,12.45 67.55,54</coordinates></LineString></MultiGeometry>")
52
+ expect(gc.as_kml(id: 'HOYOYO-42').gsub("\n", '')).to eql("<MultiGeometry id=\"HOYOYO-42\"><Point><coordinates>4.67,45.4</coordinates></Point><LineString><coordinates>5.7,12.45 67.55,54</coordinates></LineString></MultiGeometry>")
53
53
  end
54
54
 
55
- it "test_envelope" do
56
- linear_ring1 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[12,-45,5],[45,41,6],[4,1,8],[12.4,-45,3]],256,true)
57
- linear_ring2 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[2,5,9],[5.4,1,-5.4],[14,1,34],[2,5,3]],256,true)
58
- polygon = GeoRuby::SimpleFeatures::Polygon.from_linear_rings([linear_ring1,linear_ring2],256,true)
55
+ it 'test_envelope' do
56
+ linear_ring1 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[12, -45, 5], [45, 41, 6], [4, 1, 8], [12.4, -45, 3]], 256, true)
57
+ linear_ring2 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[2, 5, 9], [5.4, 1, -5.4], [14, 1, 34], [2, 5, 3]], 256, true)
58
+ polygon = GeoRuby::SimpleFeatures::Polygon.from_linear_rings([linear_ring1, linear_ring2], 256, true)
59
59
 
60
60
  e = polygon.envelope
61
61
 
62
- expect(e.as_georss(:dialect => :simple).gsub("\n","")).to eql("<georss:box>-45 4 41 45</georss:box>")
63
- #center
64
- expect(e.as_georss(:dialect => :w3cgeo).gsub("\n","")).to eql("<geo:lat>-2</geo:lat><geo:long>24</geo:long>")
65
- expect(e.as_georss(:dialect => :gml).gsub("\n","")).to eql("<georss:where><gml:Envelope><gml:LowerCorner>-45 4</gml:LowerCorner><gml:UpperCorner>41 45</gml:UpperCorner></gml:Envelope></georss:where>")
62
+ expect(e.as_georss(dialect: :simple).gsub("\n", '')).to eql('<georss:box>-45 4 41 45</georss:box>')
63
+ # center
64
+ expect(e.as_georss(dialect: :w3cgeo).gsub("\n", '')).to eql('<geo:lat>-2</geo:lat><geo:long>24</geo:long>')
65
+ expect(e.as_georss(dialect: :gml).gsub("\n", '')).to eql('<georss:where><gml:Envelope><gml:LowerCorner>-45 4</gml:LowerCorner><gml:UpperCorner>41 45</gml:UpperCorner></gml:Envelope></georss:where>')
66
66
 
67
- expect(e.as_kml.gsub("\n","")).to eql("<LatLonAltBox><north>41</north><south>-45</south><east>45</east><west>4</west><minAltitude>-5.4</minAltitude><maxAltitude>34</maxAltitude></LatLonAltBox>")
67
+ expect(e.as_kml.gsub("\n", '')).to eql('<LatLonAltBox><north>41</north><south>-45</south><east>45</east><west>4</west><minAltitude>-5.4</minAltitude><maxAltitude>34</maxAltitude></LatLonAltBox>')
68
68
  end
69
69
 
70
- it "test_point_georss_read" do
71
- #W3CGeo
70
+ it 'test_point_georss_read' do
71
+ # W3CGeo
72
72
  str = " <geo:lat >12.3</geo:lat >\n\t <geo:long> 4.56</geo:long> "
73
73
  geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
74
74
  expect(geom.class).to eql(GeoRuby::SimpleFeatures::Point)
@@ -81,49 +81,51 @@ describe GeoRuby::GeorssParser do
81
81
  expect(geom.lat).to eql(12.3)
82
82
  expect(geom.lon).to eql(4.56)
83
83
 
84
- #gml
84
+ # gml
85
85
  str = " <georss:where> \t\r <gml:Point > \t <gml:pos> 4 \t 3 </gml:pos> </gml:Point> </georss:where>"
86
86
  geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
87
87
  expect(geom.class).to eql(GeoRuby::SimpleFeatures::Point)
88
88
  expect(geom.lat).to eql(4.0)
89
89
  expect(geom.lon).to eql(3.0)
90
90
 
91
- #simple
91
+ # simple
92
92
  str = "<georss:point > 4 \r\t 3 \t</georss:point >"
93
93
  geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
94
94
  expect(geom.class).to eql(GeoRuby::SimpleFeatures::Point)
95
95
  expect(geom.lat).to eql(4.0)
96
96
  expect(geom.lon).to eql(3.0)
97
97
 
98
- #simple with tags
99
- str = "<georss:point featuretypetag=\"hoyoyo\" elev=\"45.7\" \n floor=\"2\" relationshiptag=\"puyopuyo\" radius=\"42\" > 4 \n 3 \t</georss:point >"
100
- geom,tags = GeoRuby::SimpleFeatures::Geometry.from_georss_with_tags(str)
98
+ # simple with tags
99
+ str = "<georss:point featuretypetag=\"hoyoyo\" elev=\"45.7\" \n" \
100
+ "floor=\"2\" relationshiptag=\"puyopuyo\" radius=\"42\" > 4" \
101
+ "\n 3 \t</georss:point >"
102
+ geom, tags = GeoRuby::SimpleFeatures::Geometry.from_georss_with_tags(str)
101
103
  expect(geom.class).to eql(GeoRuby::SimpleFeatures::Point)
102
104
  expect(geom.lat).to eql(4.0)
103
105
  expect(geom.lon).to eql(3.0)
104
- expect(tags.featuretypetag).to eql("hoyoyo")
106
+ expect(tags.featuretypetag).to eql('hoyoyo')
105
107
  expect(tags.elev).to eql(45.7)
106
- expect(tags.relationshiptag).to eql("puyopuyo")
108
+ expect(tags.relationshiptag).to eql('puyopuyo')
107
109
  expect(tags.floor).to eql(2)
108
110
  expect(tags.radius).to eql(42.0)
109
111
  end
110
112
 
111
- it "test_line_string_georss_read" do
112
- ls = GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.from_lon_lat(12.4,-45.3),GeoRuby::SimpleFeatures::Point.from_lon_lat(45.4,41.6)])
113
+ it 'test_line_string_georss_read' do
114
+ ls = GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.from_lon_lat(12.4, -45.3), GeoRuby::SimpleFeatures::Point.from_lon_lat(45.4, 41.6)])
113
115
 
114
116
  str = "<georss:line > -45.3 12.4 \n \r41.6\t 45.4</georss:line>"
115
117
  geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
116
118
  expect(geom.class).to eql(GeoRuby::SimpleFeatures::LineString)
117
119
  expect(ls).to eq(geom)
118
120
 
119
- str = "<georss:where><gml:LineString><gml:posList>-45.3 12.4 41.6 45.4</gml:posList></gml:LineString></georss:where>"
121
+ str = '<georss:where><gml:LineString><gml:posList>-45.3 12.4 41.6 45.4</gml:posList></gml:LineString></georss:where>'
120
122
  geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
121
123
  expect(geom.class).to eql(GeoRuby::SimpleFeatures::LineString)
122
124
  expect(ls).to eq(geom)
123
125
  end
124
126
 
125
- it "test_polygon_georss_read" do
126
- linear_ring = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]])
127
+ it 'test_polygon_georss_read' do
128
+ linear_ring = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[12.4, -45.3], [45.4, 41.6], [4.456, 1.0698], [12.4, -45.3]])
127
129
  polygon = GeoRuby::SimpleFeatures::Polygon.from_linear_rings([linear_ring])
128
130
 
129
131
  str = "<hoyoyo:polygon featuretypetag=\"42\" > -45.3 12.4 41.6 \n\r 45.4 1.0698 \r 4.456 -45.3 12.4 </hoyoyo:polygon>"
@@ -137,8 +139,8 @@ describe GeoRuby::GeorssParser do
137
139
  expect(polygon).to eq(geom)
138
140
  end
139
141
 
140
- it "test_envelope_georss_read" do
141
- e = GeoRuby::SimpleFeatures::Envelope.from_coordinates([[4.456,-45.3],[45.4,41.6]])
142
+ it 'test_envelope_georss_read' do
143
+ e = GeoRuby::SimpleFeatures::Envelope.from_coordinates([[4.456, -45.3], [45.4, 41.6]])
142
144
 
143
145
  str = "<georss:box >-45.3 4.456 \n41.6 45.4</georss:box>"
144
146
  geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
@@ -151,10 +153,10 @@ describe GeoRuby::GeorssParser do
151
153
  expect(geom).to eq(e)
152
154
  end
153
155
 
154
- it "reads KML" do
155
- g = GeoRuby::SimpleFeatures::Geometry.from_kml("<Point><coordinates>45,12,25</coordinates></Point>")
156
+ it 'reads KML' do
157
+ g = GeoRuby::SimpleFeatures::Geometry.from_kml('<Point><coordinates>45,12,25</coordinates></Point>')
156
158
  expect(g).to be_a GeoRuby::SimpleFeatures::Point
157
- expect(g).to eq(GeoRuby::SimpleFeatures::Point.from_x_y_z('45','12','25'))
159
+ expect(g).to eq(GeoRuby::SimpleFeatures::Point.from_x_y_z('45', '12', '25'))
158
160
 
159
161
  g = GeoRuby::SimpleFeatures::Geometry.from_kml("<LineString>
160
162
  <extrude>1</extrude>
@@ -165,7 +167,7 @@ describe GeoRuby::GeorssParser do
165
167
  </LineString>")
166
168
  expect(g).to be_a GeoRuby::SimpleFeatures::LineString
167
169
  expect(g.length).to eql(2)
168
- expect(g).to eq(GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.from_x_y_z('-122.364383','37.824664','0'),GeoRuby::SimpleFeatures::Point.from_x_y_z('-122.364152','37.824322','0')],4326,true))
170
+ expect(g).to eq(GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.from_x_y_z('-122.364383', '37.824664', '0'), GeoRuby::SimpleFeatures::Point.from_x_y_z('-122.364152', '37.824322', '0')], 4326, true))
169
171
 
170
172
  g = GeoRuby::SimpleFeatures::Geometry.from_kml("<Polygon>
171
173
  <extrude>1</extrude>
@@ -208,18 +210,28 @@ describe GeoRuby::GeorssParser do
208
210
  expect(g.length).to eql(3)
209
211
  end
210
212
 
211
- it "does not raise type error if point geom data not provided" do
212
- point = GeoRuby::SimpleFeatures::Point.from_coordinates([1.6,2.8],123)
213
+ it 'does not raise type error if point geom data not provided' do
214
+ point = GeoRuby::SimpleFeatures::Point.from_coordinates([1.6, 2.8], 123)
213
215
  expect { point.kml_representation }.not_to raise_error
214
216
  end
215
217
 
216
- it "does not raise type error if polygon geom data not provided" do
217
- polygon = 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)
218
+ it 'does not raise type error if polygon geom data not provided' do
219
+ polygon = GeoRuby::SimpleFeatures::Polygon
220
+ .from_coordinates([[
221
+ [12.4, -45.3], [45.4, 41.6],
222
+ [4.456, 1.0698], [12.4, -45.3]
223
+ ],
224
+ [
225
+ [2.4, 5.3], [5.4, 1.4263],
226
+ [14.46, 1.06], [2.4, 5.3]
227
+ ]
228
+ ], 256)
218
229
  expect { polygon.kml_representation }.not_to raise_error
219
230
  end
220
231
 
221
- it "does not raise type error if linestring geom data not provided" do
222
- ls = GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
232
+ it 'does not raise type error if linestring geom data not provided' do
233
+ ls = GeoRuby::SimpleFeatures::LineString
234
+ .from_coordinates([[5.7, 12.45], [67.55, 54]], 256)
223
235
  expect { ls.kml_representation }.not_to raise_error
224
236
  end
225
237