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
@@ -1,31 +1,30 @@
1
1
  require 'geo_ruby/simple_features/geometry'
2
2
 
3
3
  module GeoRuby
4
-
5
4
  module SimpleFeatures
6
-
7
5
  # Represents a polygon as an array of linear rings (see LinearRing).
8
- # No check is performed regarding the validity of the geometries forming the polygon.
6
+ # No check is performed regarding the validity of the geometries
7
+ # forming the polygon.
9
8
  class Polygon < Geometry
10
- #the list of rings forming the polygon
9
+ # the list of rings forming the polygon
11
10
  attr_reader :rings
12
11
 
13
- def initialize(srid = DEFAULT_SRID,with_z=false,with_m=false)
14
- super(srid,with_z,with_m)
12
+ def initialize(srid = DEFAULT_SRID, with_z = false, with_m = false)
13
+ super(srid, with_z, with_m)
15
14
  @rings = []
16
15
  end
17
16
 
18
- #Delegate the unknown methods to the rings array
19
- def method_missing(method_name,*args,&b)
20
- @rings.send(method_name,*args,&b)
17
+ # Delegate the unknown methods to the rings array
18
+ def method_missing(method_name, *args, &b)
19
+ @rings.send(method_name, *args, &b)
21
20
  end
22
21
 
23
- #Bounding box in 2D/3D. Returns an array of 2 points
22
+ # Bounding box in 2D/3D. Returns an array of 2 points
24
23
  def bounding_box
25
- unless with_z
24
+ if !with_z
26
25
  @rings[0].bounding_box
27
26
  else
28
- result = @rings[0].bounding_box #valid for x and y
27
+ result = @rings[0].bounding_box # valid for x and y
29
28
  max_z, min_z = result[1].z, result[0].z
30
29
  1.upto(size - 1) do |index|
31
30
  bbox = @rings[index].bounding_box
@@ -47,47 +46,50 @@ module GeoRuby
47
46
  max_m = lrmr[1] if lrmr[1] > max_m
48
47
  min_m = lrmr[0] if lrmr[0] < min_m
49
48
  end
50
- [min_m,max_m]
49
+ [min_m, max_m]
51
50
  else
52
- [0,0]
51
+ [0, 0]
53
52
  end
54
53
  end
55
54
 
56
- #tests for other equality. The SRID is not taken into account.
55
+ # tests for other equality. The SRID is not taken into account.
57
56
  def ==(other_polygon)
58
- if other_polygon.class != self.class or
59
- length != other_polygon.length
57
+ if other_polygon.class != self.class ||
58
+ length != other_polygon.length
60
59
  false
61
60
  else
62
- index=0
63
- while index<length
61
+ index = 0
62
+ while index < length
64
63
  return false if self[index] != other_polygon[index]
65
- index+=1
64
+ index += 1
66
65
  end
67
66
  true
68
67
  end
69
68
  end
70
69
 
71
- #binary representation of a polygon, without the headers neccessary for a valid WKB string
72
- def binary_representation(allow_z=true,allow_m=true)
73
- rep = [length].pack("V")
74
- each {|linear_ring| rep << linear_ring.binary_representation(allow_z,allow_m)}
70
+ # Binary representation of a polygon.
71
+ # Without the headers neccessary for a valid WKB string
72
+ def binary_representation(allow_z = true, allow_m = true)
73
+ rep = [length].pack('V')
74
+ each { |linear_ring| rep << linear_ring.binary_representation(allow_z, allow_m) }
75
75
  rep
76
76
  end
77
77
 
78
- #WKB geometry type
78
+ # WKB geometry type
79
79
  def binary_geometry_type
80
80
  3
81
81
  end
82
82
 
83
- #Text representation of a polygon
84
- def text_representation(allow_z=true,allow_m=true)
85
- @rings.collect{|line_string| "(" + line_string.text_representation(allow_z,allow_m) + ")" }.join(",")
83
+ # Text representation of a polygon
84
+ def text_representation(allow_z = true, allow_m = true)
85
+ @rings.map do |line_string|
86
+ '(' + line_string.text_representation(allow_z, allow_m) + ')'
87
+ end.join(',')
86
88
  end
87
89
 
88
- #WKT geometry type
90
+ # WKT geometry type
89
91
  def text_geometry_type
90
- "POLYGON"
92
+ 'POLYGON'
91
93
  end
92
94
 
93
95
  # Contains a point?
@@ -95,38 +97,39 @@ module GeoRuby
95
97
  !@rings.select { |lr| lr.contains_point? point }.empty?
96
98
  end
97
99
 
98
- #georss simple representation : outputs only the outer ring
100
+ # georss simple representation : outputs only the outer ring
99
101
  def georss_simple_representation(options)
100
- georss_ns = options[:georss_ns] || "georss"
102
+ georss_ns = options[:georss_ns] || 'georss'
101
103
  geom_attr = options[:geom_attr]
102
104
  "<#{georss_ns}:polygon#{geom_attr}>" + self[0].georss_poslist + "</#{georss_ns}:polygon>\n"
103
105
  end
104
106
 
105
- #georss w3c representation : outputs the first point of the outer ring
107
+ # georss w3c representation : outputs the first point of the outer ring
106
108
  def georss_w3cgeo_representation(options)
107
- w3cgeo_ns = options[:w3cgeo_ns] || "geo"
109
+ w3cgeo_ns = options[:w3cgeo_ns] || 'geo'
108
110
 
109
111
  "<#{w3cgeo_ns}:lat>#{self[0][0].y}</#{w3cgeo_ns}:lat>\n<#{w3cgeo_ns}:long>#{self[0][0].x}</#{w3cgeo_ns}:long>\n"
110
112
  end
111
- #georss gml representation
113
+
114
+ # georss gml representation
112
115
  def georss_gml_representation(options)
113
- georss_ns = options[:georss_ns] || "georss"
114
- gml_ns = options[:gml_ns] || "gml"
116
+ georss_ns = options[:georss_ns] || 'georss'
117
+ gml_ns = options[:gml_ns] || 'gml'
115
118
 
116
119
  result = "<#{georss_ns}:where>\n<#{gml_ns}:Polygon>\n<#{gml_ns}:exterior>\n<#{gml_ns}:LinearRing>\n<#{gml_ns}:posList>\n" + self[0].georss_poslist + "\n</#{gml_ns}:posList>\n</#{gml_ns}:LinearRing>\n</#{gml_ns}:exterior>\n</#{gml_ns}:Polygon>\n</#{georss_ns}:where>\n"
117
120
  end
118
121
 
119
- #outputs the geometry in kml format : options are <tt>:id</tt>, <tt>:tesselate</tt>, <tt>:extrude</tt>,
120
- #<tt>:altitude_mode</tt>. If the altitude_mode option is not present, the Z (if present) will not be output (since
121
- #it won't be used by GE anyway: clampToGround is the default)
122
+ # outputs the geometry in kml format : options are <tt>:id</tt>, <tt>:tesselate</tt>, <tt>:extrude</tt>,
123
+ # <tt>:altitude_mode</tt>. If the altitude_mode option is not present, the Z (if present) will not be output (since
124
+ # it won't be used by GE anyway: clampToGround is the default)
122
125
  def kml_representation(options = {})
123
126
  result = "<Polygon#{options[:id_attr]}>\n"
124
127
  result += options[:geom_data] if options[:geom_data]
125
128
  rings.each_with_index do |ring, i|
126
129
  if i == 0
127
- boundary = "outerBoundaryIs"
130
+ boundary = 'outerBoundaryIs'
128
131
  else
129
- boundary = "innerBoundaryIs"
132
+ boundary = 'innerBoundaryIs'
130
133
  end
131
134
  result += "<#{boundary}><LinearRing><coordinates>\n"
132
135
  result += ring.kml_poslist(options)
@@ -136,36 +139,34 @@ module GeoRuby
136
139
  end
137
140
 
138
141
  def to_coordinates
139
- rings.map{|lr| lr.to_coordinates}
142
+ rings.map(&:to_coordinates)
140
143
  end
141
144
 
142
- def as_json(options = {})
143
- {:type => 'Polygon', :coordinates => self.to_coordinates }
145
+ def as_json(_options = {})
146
+ { type: 'Polygon', coordinates: to_coordinates }
144
147
  end
145
148
 
146
- #creates a new polygon. Accepts an array of linear strings as argument
147
- def self.from_linear_rings(linear_rings,srid = DEFAULT_SRID,with_z=false,with_m=false)
148
- polygon = new(srid,with_z,with_m)
149
+ # creates a new polygon. Accepts an array of linear strings as argument
150
+ def self.from_linear_rings(linear_rings, srid = DEFAULT_SRID, with_z = false, with_m = false)
151
+ polygon = new(srid, with_z, with_m)
149
152
  polygon.concat(linear_rings)
150
153
  polygon
151
154
  end
152
155
 
153
- #creates a new polygon. Accepts a sequence of points as argument : ((x,y)....(x,y)),((x,y).....(x,y))
154
- def self.from_coordinates(point_sequences,srid=DEFAULT_SRID,with_z=false,with_m=false)
155
- polygon = new(srid,with_z,with_m)
156
- polygon.concat( point_sequences.map {|points| LinearRing.from_coordinates(points,srid,with_z,with_m) } )
156
+ # creates a new polygon. Accepts a sequence of points as argument:
157
+ # ((x,y)....(x,y)),((x,y).....(x,y))
158
+ def self.from_coordinates(point_sequences, srid = DEFAULT_SRID, z = false, m = false)
159
+ polygon = new(srid, z, m)
160
+ polygon.concat(point_sequences.map { |points| LinearRing.from_coordinates(points, srid, z, m) })
157
161
  polygon
158
162
  end
159
163
 
160
- #creates a new polygon from a list of Points (pt1....ptn),(pti....ptj)
161
- def self.from_points(point_sequences, srid=DEFAULT_SRID,with_z=false,with_m=false)
162
- polygon = new(srid,with_z,with_m)
163
- polygon.concat( point_sequences.map {|points| LinearRing.from_points(points,srid,with_z,with_m) } )
164
+ # creates a new polygon from a list of Points (pt1....ptn),(pti....ptj)
165
+ def self.from_points(point_sequences, srid = DEFAULT_SRID, z = false, m = false)
166
+ polygon = new(srid, z, m)
167
+ polygon.concat(point_sequences.map { |points| LinearRing.from_points(points, srid, z, m) })
164
168
  polygon
165
169
  end
166
-
167
170
  end
168
-
169
171
  end
170
-
171
172
  end
@@ -1,3 +1,3 @@
1
1
  module GeoRuby
2
- VERSION = '2.3.0'
2
+ VERSION = '2.5.1'
3
3
  end
@@ -0,0 +1,9 @@
1
+ {
2
+ "type":"Feature",
3
+ "id":"Some.Nice.Id_777",
4
+ "properties":{"color": "red"},
5
+ "geometry":{
6
+ "type":"Point",
7
+ "coordinates":[97.03125, 39.7265625]
8
+ }
9
+ }
@@ -27,8 +27,7 @@
27
27
  "properties": {
28
28
  "prop0": "value0",
29
29
  "prop1": {"this": "that"}
30
- }
31
30
  }
32
- ]
33
- }
34
-
31
+ }
32
+ ]
33
+ }
@@ -1,158 +1,157 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
2
+ # rubocop:disable Metrics/LineLength
3
3
  describe GeoRuby::SimpleFeatures::EWKBParser do
4
4
 
5
5
  before(:each) do
6
- @factory = GeoRuby::SimpleFeatures::GeometryFactory::new
7
- @hex_ewkb_parser = GeoRuby::SimpleFeatures::HexEWKBParser::new(@factory)
6
+ @factory = GeoRuby::SimpleFeatures::GeometryFactory.new
7
+ @hex_ewkb_parser = GeoRuby::SimpleFeatures::HexEWKBParser.new(@factory)
8
8
  end
9
9
 
10
- it "test_point2d" do
11
- @hex_ewkb_parser.parse("01010000207B000000CDCCCCCCCCCC28406666666666A64640")
10
+ it 'test_point2d' do
11
+ @hex_ewkb_parser.parse('01010000207B000000CDCCCCCCCCCC28406666666666A64640')
12
12
  point = @factory.geometry
13
13
  expect(point).to be_instance_of GeoRuby::SimpleFeatures::Point
14
14
  expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y(12.4, 45.3, 123))
15
15
  end
16
16
 
17
- it "test_point2d_BigEndian" do
18
- @hex_ewkb_parser.parse("00000000014013A035BD512EC7404A3060C38F3669")
17
+ it 'test_point2d_BigEndian' do
18
+ @hex_ewkb_parser.parse('00000000014013A035BD512EC7404A3060C38F3669')
19
19
  point = @factory.geometry
20
20
  expect(point).to be_instance_of GeoRuby::SimpleFeatures::Point
21
21
  expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y(4.906455, 52.377953))
22
22
  end
23
23
 
24
- it "test_point3dz" do
25
- @hex_ewkb_parser.parse("01010000A07B000000CDCCCCCCCCCC28406666666666A646400000000000000CC0")
24
+ it 'test_point3dz' do
25
+ @hex_ewkb_parser.parse('01010000A07B000000CDCCCCCCCCCC28406666666666A646400000000000000CC0')
26
26
  point = @factory.geometry
27
27
  expect(point).to be_instance_of GeoRuby::SimpleFeatures::Point
28
28
  expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y_z(12.4, 45.3, -3.5, 123))
29
29
  end
30
30
 
31
- it "test_point4d" do
32
- @hex_ewkb_parser.parse("01010000E07B000000CDCCCCCCCCCC28406666666666A646400000000000000CC00000000000002E40")
31
+ it 'test_point4d' do
32
+ @hex_ewkb_parser.parse('01010000E07B000000CDCCCCCCCCCC28406666666666A646400000000000000CC00000000000002E40')
33
33
  point = @factory.geometry
34
34
  expect(point).to be_instance_of GeoRuby::SimpleFeatures::Point
35
35
  expect(point).to eq(GeoRuby::SimpleFeatures::Point.from_x_y_z_m(12.4, 45.3, -3.5, 15, 123))
36
36
  end
37
37
 
38
- it "test_line_string" do
39
- @hex_ewkb_parser.parse("01020000200001000002000000CDCCCCCCCCCC28406666666666A646C03333333333B34640CDCCCCCCCCCC4440")
38
+ it 'test_line_string' do
39
+ @hex_ewkb_parser.parse('01020000200001000002000000CDCCCCCCCCCC28406666666666A646C03333333333B34640CDCCCCCCCCCC4440')
40
40
  line_string = @factory.geometry
41
41
  expect(line_string).to be_instance_of GeoRuby::SimpleFeatures::LineString
42
- expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256))
42
+ expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4, -45.3], [45.4, 41.6]], 256))
43
43
 
44
- @hex_ewkb_parser.parse("01020000A00001000002000000CDCCCCCCCCCC28406666666666A646C06666666666A641403333333333B34640CDCCCCCCCCCC44409A99999999992840")
44
+ @hex_ewkb_parser.parse('01020000A00001000002000000CDCCCCCCCCCC28406666666666A646C06666666666A641403333333333B34640CDCCCCCCCCCC44409A99999999992840')
45
45
  line_string = @factory.geometry
46
46
  expect(line_string).to be_instance_of GeoRuby::SimpleFeatures::LineString
47
- expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true))
47
+ expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4, -45.3, 35.3], [45.4, 41.6, 12.3]], 256, true))
48
48
 
49
- @hex_ewkb_parser.parse("01020000E00001000002000000CDCCCCCCCCCC28406666666666A646C06666666666A64140CDCCCCCCCC8C46403333333333B34640CDCCCCCCCCCC44409A999999999928403D0AD7A3701D4440")
49
+ @hex_ewkb_parser.parse('01020000E00001000002000000CDCCCCCCCCCC28406666666666A646C06666666666A64140CDCCCCCCCC8C46403333333333B34640CDCCCCCCCCCC44409A999999999928403D0AD7A3701D4440')
50
50
  line_string = @factory.geometry
51
51
  expect(line_string).to be_instance_of GeoRuby::SimpleFeatures::LineString
52
- expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3,45.1],[45.4,41.6,12.3,40.23]],256,true,true))
52
+ expect(line_string).to eq(GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4, -45.3, 35.3, 45.1], [45.4, 41.6, 12.3, 40.23]], 256, true, true))
53
53
  end
54
54
 
55
- it "test_polygon" do
56
- @hex_ewkb_parser.parse("0103000020000100000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000F03F000000000000F03F0000000000000840000000000000F03F00000000000008400000000000000840000000000000F03F0000000000000840000000000000F03F000000000000F03F")
55
+ it 'test_polygon' do
56
+ @hex_ewkb_parser.parse('0103000020000100000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000F03F000000000000F03F0000000000000840000000000000F03F00000000000008400000000000000840000000000000F03F0000000000000840000000000000F03F000000000000F03F')
57
57
  polygon = @factory.geometry
58
58
  expect(polygon).to be_instance_of GeoRuby::SimpleFeatures::Polygon
59
- 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))
59
+ 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))
60
60
 
61
- @hex_ewkb_parser.parse("01030000A000010000020000000500000000000000000000000000000000000000000000000000004000000000000010400000000000000000000000000000004000000000000010400000000000001040000000000000004000000000000000000000000000001040000000000000004000000000000000000000000000000000000000000000004005000000000000000000F03F000000000000F03F00000000000000400000000000000840000000000000F03F0000000000000040000000000000084000000000000008400000000000000040000000000000F03F00000000000008400000000000000040000000000000F03F000000000000F03F0000000000000040")
61
+ @hex_ewkb_parser.parse('01030000A000010000020000000500000000000000000000000000000000000000000000000000004000000000000010400000000000000000000000000000004000000000000010400000000000001040000000000000004000000000000000000000000000001040000000000000004000000000000000000000000000000000000000000000004005000000000000000000F03F000000000000F03F00000000000000400000000000000840000000000000F03F0000000000000040000000000000084000000000000008400000000000000040000000000000F03F00000000000008400000000000000040000000000000F03F000000000000F03F0000000000000040')
62
62
  polygon = @factory.geometry
63
63
  expect(polygon).to be_instance_of GeoRuby::SimpleFeatures::Polygon
64
- 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))
64
+ 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))
65
65
 
66
- @hex_ewkb_parser.parse("010300006000010000020000000500000000000000000000000000000000000000000000000000004000000000000010400000000000000000000000000000004000000000000010400000000000001040000000000000004000000000000000000000000000001040000000000000004000000000000000000000000000000000000000000000004005000000000000000000F03F000000000000F03F00000000000000400000000000000840000000000000F03F0000000000000040000000000000084000000000000008400000000000000040000000000000F03F00000000000008400000000000000040000000000000F03F000000000000F03F0000000000000040")
66
+ @hex_ewkb_parser.parse('010300006000010000020000000500000000000000000000000000000000000000000000000000004000000000000010400000000000000000000000000000004000000000000010400000000000001040000000000000004000000000000000000000000000001040000000000000004000000000000000000000000000000000000000000000004005000000000000000000F03F000000000000F03F00000000000000400000000000000840000000000000F03F0000000000000040000000000000084000000000000008400000000000000040000000000000F03F00000000000008400000000000000040000000000000F03F000000000000F03F0000000000000040')
67
67
  polygon = @factory.geometry
68
68
  expect(polygon).to be_instance_of GeoRuby::SimpleFeatures::Polygon
69
- 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))
69
+ 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))
70
70
 
71
- @hex_ewkb_parser.parse("01030000E0000100000200000005000000000000000000000000000000000000000000000000000040CDCCCCCCCC8C46C00000000000001040000000000000000000000000000000400000000000001440000000000000104000000000000010400000000000000040AE47E17A14AE1240000000000000000000000000000010400000000000000040713D0AD7A370F53F000000000000000000000000000000000000000000000040CDCCCCCCCC8C46C005000000000000000000F03F000000000000F03F00000000000000409A999999999928400000000000000840000000000000F03F00000000000000400000000000C05E400000000000000840000000000000084000000000000000406666666666662840000000000000F03F000000000000084000000000000000400000000000002840000000000000F03F000000000000F03F00000000000000409A99999999992840")
71
+ @hex_ewkb_parser.parse('01030000E0000100000200000005000000000000000000000000000000000000000000000000000040CDCCCCCCCC8C46C00000000000001040000000000000000000000000000000400000000000001440000000000000104000000000000010400000000000000040AE47E17A14AE1240000000000000000000000000000010400000000000000040713D0AD7A370F53F000000000000000000000000000000000000000000000040CDCCCCCCCC8C46C005000000000000000000F03F000000000000F03F00000000000000409A999999999928400000000000000840000000000000F03F00000000000000400000000000C05E400000000000000840000000000000084000000000000000406666666666662840000000000000F03F000000000000084000000000000000400000000000002840000000000000F03F000000000000F03F00000000000000409A99999999992840')
72
72
  polygon = @factory.geometry
73
73
  expect(polygon).to be_instance_of GeoRuby::SimpleFeatures::Polygon
74
- 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))
74
+ 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))
75
75
  end
76
76
 
77
- it "test_geometry_collection" do
78
- @hex_ewkb_parser.parse("010700002000010000020000000101000000AE47E17A14AE12403333333333B34640010200000002000000CDCCCCCCCCCC16406666666666E628403333333333E350400000000000004B40")
77
+ it 'test_geometry_collection' do
78
+ @hex_ewkb_parser.parse('010700002000010000020000000101000000AE47E17A14AE12403333333333B34640010200000002000000CDCCCCCCCCCC16406666666666E628403333333333E350400000000000004B40')
79
79
  geometry_collection = @factory.geometry
80
80
  expect(geometry_collection).to be_instance_of GeoRuby::SimpleFeatures::GeometryCollection
81
81
 
82
- 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)],256))
82
+ 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)], 256))
83
83
  expect(geometry_collection[0].srid).to eql(256)
84
84
 
85
- @hex_ewkb_parser.parse("01070000E0000100000200000001010000C0AE47E17A14AE12403333333333B34640F6285C8FC2D54640666666666666024001020000C002000000CDCCCCCCCCCC16406666666666E628403D0AD7A3703D124033333333339358403333333333E350400000000000004B4066666666666628403333333333330B40")
85
+ @hex_ewkb_parser.parse('01070000E0000100000200000001010000C0AE47E17A14AE12403333333333B34640F6285C8FC2D54640666666666666024001020000C002000000CDCCCCCCCCCC16406666666666E628403D0AD7A3703D124033333333339358403333333333E350400000000000004B4066666666666628403333333333330B40')
86
86
  geometry_collection = @factory.geometry
87
87
  expect(geometry_collection).to be_instance_of GeoRuby::SimpleFeatures::GeometryCollection
88
- expect(geometry_collection).to eq(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))
88
+ expect(geometry_collection).to eq(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))
89
89
  expect(geometry_collection[0].srid).to eql(256)
90
90
  end
91
91
 
92
- it "test_multi_point" do
93
- @hex_ewkb_parser.parse("0104000020BC010000030000000101000000CDCCCCCCCCCC28403333333333D35EC0010100000066666666664650C09A99999999D95E4001010000001F97DD388EE35E400000000000C05E40")
92
+ it 'test_multi_point' do
93
+ @hex_ewkb_parser.parse('0104000020BC010000030000000101000000CDCCCCCCCCCC28403333333333D35EC0010100000066666666664650C09A99999999D95E4001010000001F97DD388EE35E400000000000C05E40')
94
94
  multi_point = @factory.geometry
95
95
  expect(multi_point).to be_instance_of GeoRuby::SimpleFeatures::MultiPoint
96
- expect(multi_point).to eq(GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444))
96
+ expect(multi_point).to eq(GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4, -123.3], [-65.1, 123.4], [123.55555555, 123]], 444))
97
97
  expect(multi_point.srid).to eql(444)
98
98
  expect(multi_point[0].srid).to eql(444)
99
99
 
100
- @hex_ewkb_parser.parse("01040000A0BC010000030000000101000080CDCCCCCCCCCC28403333333333D35EC00000000000001240010100008066666666664650C09A99999999D95E40333333333333F33F01010000801F97DD388EE35E400000000000C05E406666666666660240")
100
+ @hex_ewkb_parser.parse('01040000A0BC010000030000000101000080CDCCCCCCCCCC28403333333333D35EC00000000000001240010100008066666666664650C09A99999999D95E40333333333333F33F01010000801F97DD388EE35E400000000000C05E406666666666660240')
101
101
  multi_point = @factory.geometry
102
102
  expect(multi_point).to be_instance_of GeoRuby::SimpleFeatures::MultiPoint
103
- expect(multi_point).to eq(GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,1.2],[123.55555555,123,2.3]],444,true))
103
+ expect(multi_point).to eq(GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4, -123.3, 4.5], [-65.1, 123.4, 1.2], [123.55555555, 123, 2.3]], 444, true))
104
104
  expect(multi_point.srid).to eql(444)
105
105
  expect(multi_point[0].srid).to eql(444)
106
106
  end
107
107
 
108
- it "test_multi_line_string" do
109
- @hex_ewkb_parser.parse("01050000200001000002000000010200000002000000000000000000F83F9A99999999994640E4BD6A65C20F4BC0FA7E6ABC749388BF010200000003000000000000000000F83F9A99999999994640E4BD6A65C20F4BC0FA7E6ABC749388BF39B4C876BE8F46403333333333D35E40")
108
+ it 'test_multi_line_string' do
109
+ @hex_ewkb_parser.parse('01050000200001000002000000010200000002000000000000000000F83F9A99999999994640E4BD6A65C20F4BC0FA7E6ABC749388BF010200000003000000000000000000F83F9A99999999994640E4BD6A65C20F4BC0FA7E6ABC749388BF39B4C876BE8F46403333333333D35E40')
110
110
  multi_line_string = @factory.geometry
111
111
  expect(multi_line_string).to be_instance_of GeoRuby::SimpleFeatures::MultiLineString
112
- 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))
112
+ 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))
113
113
  expect(multi_line_string.srid).to eql(256)
114
114
  expect(multi_line_string[0].srid).to eql(256)
115
115
 
116
- @hex_ewkb_parser.parse("0105000020000100000200000001020000C002000000000000000000F83F9A99999999994640CDCCCCCCCCCCF43F333333333333F33FE4BD6A65C20F4BC0FA7E6ABC749388BF333333333333F33F000000000000124001020000C003000000000000000000F83F9A99999999994640666666666666144000000000000012C0E4BD6A65C20F4BC0FA7E6ABC749388BF3333333333331BC03333333333330B4039B4C876BE8F46403333333333D35E40000000000000124033333333333315C0")
116
+ @hex_ewkb_parser.parse('0105000020000100000200000001020000C002000000000000000000F83F9A99999999994640CDCCCCCCCCCCF43F333333333333F33FE4BD6A65C20F4BC0FA7E6ABC749388BF333333333333F33F000000000000124001020000C003000000000000000000F83F9A99999999994640666666666666144000000000000012C0E4BD6A65C20F4BC0FA7E6ABC749388BF3333333333331BC03333333333330B4039B4C876BE8F46403333333333D35E40000000000000124033333333333315C0')
117
117
  multi_line_string = @factory.geometry
118
118
  expect(multi_line_string).to be_instance_of GeoRuby::SimpleFeatures::MultiLineString
119
- 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))
119
+ 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))
120
120
  expect(multi_line_string.srid).to eql(256)
121
121
  expect(multi_line_string[0].srid).to eql(256)
122
122
  end
123
123
 
124
- it "test_multi_polygon" do
125
- @hex_ewkb_parser.parse("0106000020000100000200000001030000000200000004000000CDCCCCCCCCCC28406666666666A646C03333333333B34640CDCCCCCCCCCC44406DE7FBA9F1D211403D2CD49AE61DF13FCDCCCCCCCCCC28406666666666A646C004000000333333333333034033333333333315409A999999999915408A8EE4F21FD2F63FEC51B81E85EB2C40F6285C8FC2F5F03F3333333333330340333333333333154001030000000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000F03F000000000000F03F0000000000000840000000000000F03F00000000000008400000000000000840000000000000F03F0000000000000840000000000000F03F000000000000F03F")
124
+ it 'test_multi_polygon' do
125
+ @hex_ewkb_parser.parse('0106000020000100000200000001030000000200000004000000CDCCCCCCCCCC28406666666666A646C03333333333B34640CDCCCCCCCCCC44406DE7FBA9F1D211403D2CD49AE61DF13FCDCCCCCCCCCC28406666666666A646C004000000333333333333034033333333333315409A999999999915408A8EE4F21FD2F63FEC51B81E85EB2C40F6285C8FC2F5F03F3333333333330340333333333333154001030000000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000F03F000000000000F03F0000000000000840000000000000F03F00000000000008400000000000000840000000000000F03F0000000000000840000000000000F03F000000000000F03F')
126
126
  multi_polygon = @factory.geometry
127
127
  expect(multi_polygon).to be_instance_of GeoRuby::SimpleFeatures::MultiPolygon
128
- 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))
128
+ 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))
129
129
  expect(multi_polygon.srid).to eql(256)
130
130
  expect(multi_polygon[0].srid).to eql(256)
131
131
 
132
- @hex_ewkb_parser.parse("0106000020000100000200000001030000400200000004000000CDCCCCCCCCCC28406666666666A646C0333333333333F33F3333333333B34640CDCCCCCCCCCC4440333333333333F33F6DE7FBA9F1D211403D2CD49AE61DF13F333333333333F33FCDCCCCCCCCCC28406666666666A646C0333333333333F33F0400000033333333333303403333333333331540333333333333F33F9A999999999915408A8EE4F21FD2F63F333333333333F33FEC51B81E85EB2C40F6285C8FC2F5F03F333333333333F33F33333333333303403333333333331540333333333333F33F0103000040020000000500000000000000000000000000000000000000333333333333F33F00000000000010400000000000000000333333333333F33F00000000000010400000000000001040666666666666024000000000000000000000000000001040333333333333F33F00000000000000000000000000000000333333333333F33F05000000000000000000F03F000000000000F03F9A999999999901400000000000000840000000000000F03F6666666666660A40000000000000084000000000000008409A9999999999F13F000000000000F03F00000000000008403333333333330340000000000000F03F000000000000F03F9A99999999990140")
132
+ @hex_ewkb_parser.parse('0106000020000100000200000001030000400200000004000000CDCCCCCCCCCC28406666666666A646C0333333333333F33F3333333333B34640CDCCCCCCCCCC4440333333333333F33F6DE7FBA9F1D211403D2CD49AE61DF13F333333333333F33FCDCCCCCCCCCC28406666666666A646C0333333333333F33F0400000033333333333303403333333333331540333333333333F33F9A999999999915408A8EE4F21FD2F63F333333333333F33FEC51B81E85EB2C40F6285C8FC2F5F03F333333333333F33F33333333333303403333333333331540333333333333F33F0103000040020000000500000000000000000000000000000000000000333333333333F33F00000000000010400000000000000000333333333333F33F00000000000010400000000000001040666666666666024000000000000000000000000000001040333333333333F33F00000000000000000000000000000000333333333333F33F05000000000000000000F03F000000000000F03F9A999999999901400000000000000840000000000000F03F6666666666660A40000000000000084000000000000008409A9999999999F13F000000000000F03F00000000000008403333333333330340000000000000F03F000000000000F03F9A99999999990140')
133
133
  multi_polygon = @factory.geometry
134
134
  expect(multi_polygon).to be_instance_of GeoRuby::SimpleFeatures::MultiPolygon
135
- expect(multi_polygon).to eq(GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[12.4,-45.3,1.2],[45.4,41.6,1.2],[4.456,1.0698,1.2],[12.4,-45.3,1.2]],[[2.4,5.3,1.2],[5.4,1.4263,1.2],[14.46,1.06,1.2],[2.4,5.3,1.2]]],256,false,true),GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,1.2],[4,0,1.2],[4,4,2.3],[0,4,1.2],[0,0,1.2]],[[1,1,2.2],[3,1,3.3],[3,3,1.1],[1,3,2.4],[1,1,2.2]]],256,false,true)],256,false,true))
135
+ expect(multi_polygon).to eq(GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[12.4, -45.3, 1.2], [45.4, 41.6, 1.2], [4.456, 1.0698, 1.2], [12.4, -45.3, 1.2]], [[2.4, 5.3, 1.2], [5.4, 1.4263, 1.2], [14.46, 1.06, 1.2], [2.4, 5.3, 1.2]]], 256, false, true), GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0, 0, 1.2], [4, 0, 1.2], [4, 4, 2.3], [0, 4, 1.2], [0, 0, 1.2]], [[1, 1, 2.2], [3, 1, 3.3], [3, 3, 1.1], [1, 3, 2.4], [1, 1, 2.2]]], 256, false, true)], 256, false, true))
136
136
  expect(multi_polygon.srid).to eql(256)
137
137
  expect(multi_polygon[0].srid).to eql(256)
138
138
  end
139
139
 
140
-
141
- it "test_failure_trailing_data" do
142
- #added A345 at the end
143
- expect {@hex_ewkb_parser.parse("01010000207B000000CDCCCCCCCCCC28406666666666A64640A345")}.to raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
140
+ it 'test_failure_trailing_data' do
141
+ # added A345 at the end
142
+ expect { @hex_ewkb_parser.parse('01010000207B000000CDCCCCCCCCCC28406666666666A64640A345') }.to raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
144
143
  end
145
144
 
146
- it "test_failure_unknown_geometry_type" do
147
- expect {@hex_ewkb_parser.parse("01090000207B000000CDCCCCCCCCCC28406666666666A64640")}.to raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
145
+ it 'test_failure_unknown_geometry_type' do
146
+ expect { @hex_ewkb_parser.parse('01090000207B000000CDCCCCCCCCCC28406666666666A64640') }.to raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
148
147
  end
149
148
 
150
- it "test_failure_m" do
151
- expect {@hex_ewkb_parser.parse("01010000607B000000CDCCCCCCCCCC28406666666666A64640")}.to raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
149
+ it 'test_failure_m' do
150
+ expect { @hex_ewkb_parser.parse('01010000607B000000CDCCCCCCCCCC28406666666666A64640') }.to raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
152
151
  end
153
152
 
154
- it "test_failure_truncated_data" do
155
- expect {@hex_ewkb_parser.parse("01010000207B000000CDCCCCCCCCCC2840666666")}.to raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
153
+ it 'test_failure_truncated_data' do
154
+ expect { @hex_ewkb_parser.parse('01010000207B000000CDCCCCCCCCCC2840666666') }.to raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
156
155
  end
157
156
 
158
157
  end