nofxx-georuby 1.7.3 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ describe Geometry do
21
21
  it "should instantiate from hex ewkb" do
22
22
  point = Geometry.from_hex_ewkb("01010000207B000000CDCCCCCCCCCC28406666666666A64640")
23
23
  point.class.should == Point
24
- point.x.should be_close(12.4, 0.1)
24
+ point.x.should be_within(0.1).of(12.4)
25
25
  end
26
26
 
27
27
  it "should output as_ewkb" do
@@ -112,8 +112,8 @@ describe Point do
112
112
 
113
113
  it "should instantiate a point from polar coordinates" do
114
114
  point = Point.from_r_t(1.4142,45)
115
- point.y.should be_close(1, 0.00001)
116
- point.x.should be_close(1, 0.00001)
115
+ point.y.should be_within(0.1).of(1)
116
+ point.x.should be_within(0.1).of(1)
117
117
  end
118
118
 
119
119
  it "should instantiate from coordinates x,y" do
@@ -153,30 +153,30 @@ describe Point do
153
153
  end
154
154
 
155
155
  it "should parse lat long" do
156
- Point.from_latlong("-20° 47' 26.37","-20° 47' 26.37").x.should be_close(-20.790658, 0.00001)
157
- Point.from_latlong("20° 47' 26.378","20° 47' 26.378").y.should be_close(20.790658, 0.00001)
156
+ Point.from_latlong("-20° 47' 26.37","-20° 47' 26.37").x.should be_within(0.00001).of(-20.790658)
157
+ Point.from_latlong("20° 47' 26.378","20° 47' 26.378").y.should be_within(0.00001).of(20.790658)
158
158
  end
159
159
 
160
160
  it "should parse lat long w/o sec" do
161
- Point.from_latlong("-20°47′26″","-20°47′26″").x.should be_close(-20.790555, 0.00001)
162
- Point.from_latlong("20°47′26″","20°47′26″").y.should be_close(20.790555, 0.00001)
161
+ Point.from_latlong("-20°47′26″","-20°47′26″").x.should be_within(0.00001).of(-20.790555)
162
+ Point.from_latlong("20°47′26″","20°47′26″").y.should be_within(0.00001).of(20.790555)
163
163
  end
164
164
 
165
165
  it "should accept with W or S notation" do
166
- Point.from_latlong("20° 47' 26.37 W","20° 47' 26.37 S").x.should be_close(-20.790658, 0.00001)
167
- Point.from_latlong("20° 47' 26.37 W","20° 47' 26.37 S").y.should be_close(-20.790658, 0.00001)
166
+ Point.from_latlong("20° 47' 26.37 W","20° 47' 26.37 S").x.should be_within(0.00001).of(-20.790658)
167
+ Point.from_latlong("20° 47' 26.37 W","20° 47' 26.37 S").y.should be_within(0.00001).of(-20.790658)
168
168
  end
169
169
 
170
170
  it "should instantiate a point from positive degrees" do
171
171
  point = Point.from_latlong('47`20 06.09E','22`50 77.35N')
172
- point.y.should be_close(22.8548194, 0.000001)
173
- point.x.should be_close(47.335025, 0.000001)
172
+ point.y.should be_within(0.000001).of(22.8548194)
173
+ point.x.should be_within(0.000001).of(47.335025)
174
174
  end
175
175
 
176
176
  it "should instantiate a point from negative degrees" do
177
177
  point = Point.from_latlong('47`20 06.09W','22`50 77.35S')
178
- point.y.should be_close(-22.8548194, 0.000001)
179
- point.x.should be_close(-47.335025, 0.000001)
178
+ point.y.should be_within(0.000001).of(-22.8548194)
179
+ point.x.should be_within(0.000001).of(-47.335025)
180
180
  end
181
181
 
182
182
  it "should print out nicely" do
@@ -210,17 +210,17 @@ describe Point do
210
210
 
211
211
  it "and a 3th grade child should calculate euclidian distance" do
212
212
  @p1.euclidian_distance(@p2).
213
- should be_close(1.4142135623731, 0.00000001)
213
+ should be_within(0.00000001).of(1.4142135623731)
214
214
  end
215
215
 
216
216
  it "should calculate spherical distance" do
217
217
  @p1.spherical_distance(@p2).
218
- should be_close(157225.358003181,0.00000001)
218
+ should be_within(0.00000001).of(157225.358003181)
219
219
  end
220
220
 
221
221
  it "should calculate ellipsoidal distance" do
222
222
  @p1.ellipsoidal_distance(@p2).
223
- should be_close(156876.149400742, 0.00000001)
223
+ should be_within(0.00000001).of(156876.149400742)
224
224
  end
225
225
 
226
226
  describe "Orthogonal Distance" do
@@ -230,7 +230,7 @@ describe Point do
230
230
  end
231
231
 
232
232
  it "should calcula orthogonal distance from a line (90 deg)" do
233
- @p1.orthogonal_distance(@line).should be_close(1.414, 0.001)
233
+ @p1.orthogonal_distance(@line).should be_within(0.001).of(1.414)
234
234
  end
235
235
 
236
236
  it "should calcula orthogonal distance very close..." do
@@ -238,41 +238,41 @@ describe Point do
238
238
  end
239
239
 
240
240
  it "should calcula orthogonal distance from a line (90 deg)" do
241
- @p2.orthogonal_distance(@line).should be_close(2.828, 0.001)
241
+ @p2.orthogonal_distance(@line).should be_within(0.001).of(2.828)
242
242
  end
243
243
 
244
244
  it "should calcula orthogonal distance from a line (0 deg)" do
245
- @p2.orthogonal_distance(@line2).should be_close(1.0, 0.1)
245
+ @p2.orthogonal_distance(@line2).should be_within(0.1).of(1.0)
246
246
  end
247
247
 
248
248
  it "should calcula orthogonal distance from a line (0 deg)" do
249
- @p2.orthogonal_distance(@line2).should be_close(1.0, 0.1)
249
+ @p2.orthogonal_distance(@line2).should be_within(0.1).of(1.0)
250
250
  end
251
251
 
252
252
  end
253
253
 
254
254
  it "should calculate the bearing from apoint to another in degrees" do
255
- @p1.bearing_to(@p2).should be_close(45.0, 0.01)
255
+ @p1.bearing_to(@p2).should be_within(0.01).of(45.0)
256
256
  end
257
257
 
258
258
  it "should calculate the bearing from apoint to another in degrees" do
259
259
  p3 = Point.from_x_y(1,-1)
260
- @p1.bearing_to(p3).should be_close(180.0, 0.01)
260
+ @p1.bearing_to(p3).should be_within(0.01).of(180.0)
261
261
  end
262
262
 
263
263
  it "should calculate the bearing from apoint to another in degrees" do
264
264
  p3 = Point.from_x_y(-1,-1)
265
- @p1.bearing_to(p3).should be_close(225.0, 0.01)
265
+ @p1.bearing_to(p3).should be_within(0.01).of(225.0)
266
266
  end
267
267
 
268
268
  it "should calculate the bearing from apoint to another in degrees" do
269
269
  p3 = Point.from_x_y(-1,1)
270
- @p1.bearing_to(p3).should be_close(270.0, 0.01)
270
+ @p1.bearing_to(p3).should be_within(0.01).of(270.0)
271
271
  end
272
272
 
273
273
  it "should calculate the bearing from apoint to another in degrees" do
274
274
  p3 = Point.from_x_y(2,-1)
275
- @p1.bearing_to(p3).should be_close(153.4349488, 0.0001)
275
+ @p1.bearing_to(p3).should be_within(0.0001).of(153.4349488)
276
276
  end
277
277
 
278
278
  it "should calculate a clone point bearing to 0" do
@@ -335,15 +335,15 @@ describe Point do
335
335
  end
336
336
 
337
337
  it "should print r (polar coords)" do
338
- @point.r.should be_close(34.214154, 0.00001)
338
+ @point.r.should be_within(0.000001).of(34.214154)
339
339
  end
340
340
 
341
341
  it "should print theta as degrees" do
342
- @point.theta_deg.should be_close(289.184406352127, 0.0001)
342
+ @point.theta_deg.should be_within(0.0001).of(289.184406352127)
343
343
  end
344
344
 
345
345
  it "should print theta as radians" do
346
- @point.theta_rad.should be_close(5.04722003626982, 0.0001)
346
+ @point.theta_rad.should be_within(0.0001).of(5.04722003626982)
347
347
  end
348
348
 
349
349
  it "should output as polar" do
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,16 @@
1
- begin
2
- require 'rubygems'
3
- require 'spec'
4
- rescue LoadError
1
+ require 'rubygems'
2
+
3
+ # Must require active_spport/core_ext/object and then json/pure
4
+ # or the json module gets clobbered and geojson output
5
+ # becomes invalid... ie. it never calls class specific to_json
6
+ #require 'active_support/core_ext/object'
7
+ #require 'json/pure'
8
+
9
+ # begin
10
+ # require 'spec'
11
+ # rescue LoadError
5
12
  require 'rspec'
6
- end
13
+ #end
7
14
 
8
15
  $:.unshift(File.dirname(__FILE__) + '/../lib')
9
16
  require 'geo_ruby'
@@ -36,7 +43,7 @@ module GeorubyMatchers
36
43
  [:x, :y, :z, :m].each_with_index do |c, i|
37
44
  next unless val = @expect[i]
38
45
  if val.kind_of? Numeric
39
- actual.send(c).should be_close(val, 0.1)
46
+ actual.send(c).should be_within(0.1).of(val)
40
47
  else
41
48
  actual.send(c).should eql(val)
42
49
  end
metadata CHANGED
@@ -4,22 +4,24 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 7
8
- - 3
9
- version: 1.7.3
7
+ - 9
8
+ - 0
9
+ version: 1.9.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Guilhem Vellut
13
13
  - Marcos Piccinini
14
+ - Marcus Mateus
15
+ - Doug Cole
14
16
  autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2010-09-20 00:00:00 -03:00
20
+ date: 2011-01-14 00:00:00 -02:00
19
21
  default_executable:
20
22
  dependencies:
21
23
  - !ruby/object:Gem::Dependency
22
- name: rspec
24
+ name: json_pure
23
25
  prerelease: false
24
26
  requirement: &id001 !ruby/object:Gem::Requirement
25
27
  none: false
@@ -28,40 +30,54 @@ dependencies:
28
30
  - !ruby/object:Gem::Version
29
31
  segments:
30
32
  - 1
33
+ - 4
34
+ - 6
35
+ version: 1.4.6
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ segments:
31
47
  - 2
32
- - 9
33
- version: 1.2.9
48
+ - 0
49
+ - 0
50
+ version: 2.0.0
34
51
  type: :development
35
- version_requirements: *id001
52
+ version_requirements: *id002
36
53
  - !ruby/object:Gem::Dependency
37
54
  name: dbf
38
55
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
56
+ requirement: &id003 !ruby/object:Gem::Requirement
40
57
  none: false
41
58
  requirements:
42
59
  - - ">="
43
60
  - !ruby/object:Gem::Version
44
61
  segments:
45
62
  - 1
46
- - 1
47
63
  - 2
48
- version: 1.1.2
64
+ - 9
65
+ version: 1.2.9
49
66
  type: :development
50
- version_requirements: *id002
67
+ version_requirements: *id003
51
68
  description: GeoRuby provides geometric data types from the OGC 'Simple Features' specification.
52
- email: x@nofxx.com
69
+ email: georuby@simplitex.com
53
70
  executables: []
54
71
 
55
72
  extensions: []
56
73
 
57
74
  extra_rdoc_files:
58
75
  - LICENSE
59
- - README.txt
76
+ - README.rdoc
60
77
  files:
61
- - .gitignore
62
78
  - History.txt
63
79
  - LICENSE
64
- - README.txt
80
+ - README.rdoc
65
81
  - Rakefile
66
82
  - VERSION
67
83
  - lib/geo_ruby.rb
@@ -73,6 +89,7 @@ files:
73
89
  - lib/geo_ruby/simple_features/envelope.rb
74
90
  - lib/geo_ruby/simple_features/ewkb_parser.rb
75
91
  - lib/geo_ruby/simple_features/ewkt_parser.rb
92
+ - lib/geo_ruby/simple_features/geojson_parser.rb
76
93
  - lib/geo_ruby/simple_features/geometry.rb
77
94
  - lib/geo_ruby/simple_features/geometry_collection.rb
78
95
  - lib/geo_ruby/simple_features/geometry_factory.rb
@@ -85,11 +102,12 @@ files:
85
102
  - lib/geo_ruby/simple_features/multi_polygon.rb
86
103
  - lib/geo_ruby/simple_features/point.rb
87
104
  - lib/geo_ruby/simple_features/polygon.rb
88
- - nofxx-georuby.gemspec
105
+ - marcusmateus-georuby.gemspec
89
106
  - script/console
90
107
  - script/destroy
91
108
  - script/generate
92
109
  - script/txt2html
110
+ - spec/data/geojson/feature_collection.json
93
111
  - spec/data/gpx/fells_loop.gpx
94
112
  - spec/data/gpx/long.gpx
95
113
  - spec/data/gpx/long.kml
@@ -114,6 +132,7 @@ files:
114
132
  - spec/geo_ruby/simple_features/envelope_spec.rb
115
133
  - spec/geo_ruby/simple_features/ewkb_parser_spec.rb
116
134
  - spec/geo_ruby/simple_features/ewkt_parser_spec.rb
135
+ - spec/geo_ruby/simple_features/geojson_parser_spec.rb
117
136
  - spec/geo_ruby/simple_features/geometry_collection_spec.rb
118
137
  - spec/geo_ruby/simple_features/geometry_factory_spec.rb
119
138
  - spec/geo_ruby/simple_features/geometry_spec.rb
@@ -132,8 +151,8 @@ homepage: http://github.com/nofxx/georuby
132
151
  licenses: []
133
152
 
134
153
  post_install_message:
135
- rdoc_options:
136
- - --charset=UTF-8
154
+ rdoc_options: []
155
+
137
156
  require_paths:
138
157
  - lib
139
158
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -160,21 +179,22 @@ signing_key:
160
179
  specification_version: 3
161
180
  summary: Ruby data holder for OGC Simple Features
162
181
  test_files:
163
- - spec/geo_ruby_spec.rb
164
- - spec/spec_helper.rb
165
182
  - spec/geo_ruby/gpx4r/gpx_spec.rb
166
183
  - spec/geo_ruby/shp4r/shp_spec.rb
167
- - spec/geo_ruby/simple_features/point_spec.rb
168
- - spec/geo_ruby/simple_features/geometry_factory_spec.rb
169
184
  - spec/geo_ruby/simple_features/envelope_spec.rb
170
- - spec/geo_ruby/simple_features/polygon_spec.rb
171
- - spec/geo_ruby/simple_features/line_string_spec.rb
172
- - spec/geo_ruby/simple_features/multi_line_string_spec.rb
173
- - spec/geo_ruby/simple_features/ewkt_parser_spec.rb
174
185
  - spec/geo_ruby/simple_features/ewkb_parser_spec.rb
175
- - spec/geo_ruby/simple_features/linear_ring_spec.rb
186
+ - spec/geo_ruby/simple_features/ewkt_parser_spec.rb
187
+ - spec/geo_ruby/simple_features/geojson_parser_spec.rb
176
188
  - spec/geo_ruby/simple_features/geometry_collection_spec.rb
177
- - spec/geo_ruby/simple_features/multi_polygon_spec.rb
178
- - spec/geo_ruby/simple_features/multi_point_spec.rb
179
- - spec/geo_ruby/simple_features/georss_parser_spec.rb
189
+ - spec/geo_ruby/simple_features/geometry_factory_spec.rb
180
190
  - spec/geo_ruby/simple_features/geometry_spec.rb
191
+ - spec/geo_ruby/simple_features/georss_parser_spec.rb
192
+ - spec/geo_ruby/simple_features/line_string_spec.rb
193
+ - spec/geo_ruby/simple_features/linear_ring_spec.rb
194
+ - spec/geo_ruby/simple_features/multi_line_string_spec.rb
195
+ - spec/geo_ruby/simple_features/multi_point_spec.rb
196
+ - spec/geo_ruby/simple_features/multi_polygon_spec.rb
197
+ - spec/geo_ruby/simple_features/point_spec.rb
198
+ - spec/geo_ruby/simple_features/polygon_spec.rb
199
+ - spec/geo_ruby_spec.rb
200
+ - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- .DS_Store
2
- pkg/*.gem
3
- pkg/*.tgz
4
- pkg/**/*
5
- coverage/*
6
- doc/*
data/README.txt DELETED
@@ -1,118 +0,0 @@
1
- = GeoRuby
2
-
3
- This is a fork of GeoRuby. It is intended as a holder for data returned from PostGIS and the Spatial Extensions of MySql. The data model roughly follows the OGC "Simple Features for SQL" specification (see http://www.opengis.org/docs/99-049.pdf), although without any kind of advanced functionalities (such as geometric operators or reprojections). It also supports various output and input formats (GeoRSS, KML, Shapefile).
4
-
5
-
6
- === Available data types
7
-
8
- The following geometric data types are provided :
9
- - Point
10
- - Line string
11
- - Linear ring
12
- - Polygon
13
- - Multi point
14
- - Multi line string
15
- - Multi polygon
16
- - Geometry collection
17
-
18
- They can be in 2D, 3DZ, 3DM, and 4D.
19
-
20
- On top of this an Envelope class is available, to contain the bounding box of a geometry.
21
-
22
-
23
- === Input and output
24
-
25
- These geometries can be input and output in WKB/EWKB/WKT/EWKT format (as well as the related HexWKB and HexEWKB formats). HexEWKB and WKB are the default form under which geometric data is returned respectively from PostGIS and MySql.
26
-
27
- GeoRSS Simple, GeoRSS W3CGeo, GeoRSS GML can also be input and output. Note that they will not output valid RSS, but just the part strictly concerning the geometry as outlined in http://www.georss.org/1/ . Since the model does not allow multiple geometries, for geometry collections, only the first geometry will be output. Similarly, for polygons, the GeoRSS output will only contain the outer ring. As for W3CGeo output, only points can be output, so the first point of the geometry is chosen. By default the Simple format is output. Envelope can also be output in these formats: The box geometric type is chosen (except for W3CGeo, where the center of the envelope is chose). These formats can also be input and a GeoRuby geometry will be created. Note that it will not read a valid RSS file, only a geometry string.
28
-
29
- On top of that, there is now support for KML output and input. As for GeoRSS, a valid KML file will not be output, but only the geometric data. Options <tt>:id</tt>, <tt>:extrude</tt>, <tt>:tesselate</tt> and <tt>:altitude_mode</tt> can be given. Note that if the <tt>:altitude_mode</tt> option is not passed or set to <tt>clampToGround</tt>, the altitude data will not be output even if present. Envelopes output a LatLonAltBox instead of a geometry. For the output, the following geometric types are supported : Point, LineString, Polygon.
30
-
31
-
32
- === SHP reading et writing
33
-
34
- Georuby has support for reading ESRI shapefiles (http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf). A tool called <tt>shp2sql.rb</tt> is also provided : it shows how to use the SHP reading functionality together with the spatial adapter plugin for Rails to import spatial features into MySQL and PostGIS.
35
-
36
- Here is an example of Shapefile reading, that goes through all the geometries in a file and disaply the values of the attributes :
37
-
38
- require 'geo_ruby/shp'
39
-
40
- ShpFile.open(shpfile) do |shp|
41
- shp.each do |shape|
42
- geom = shape.geometry #a GeoRuby SimpleFeature
43
- att_data = shape.data #a Hash
44
- shp.fields.each do |field|
45
- puts att_data[field.name]
46
- end
47
- end
48
- end
49
-
50
- Support for ESRI shapefile creation and modification has been added as well. New shapefiles can be created given a geometry type and specifications for the DBF fields. Data can be added and removed from an existing shapefile. An update operation is also provided for convenience : it just performs a 'delete' and an 'add', which means the index of the modified record will change. Note that once a shapefile has been created, GeoRuby does not allow the modification of the schema (it will probably be done in a subsequent version).
51
-
52
- Here is an example of how to create a new Shapefile with 2 fields :
53
-
54
- shpfile = ShpFile.create('hello.shp',ShpType::POINT,[Dbf::Field.new("Hoyoyo","C",10),Dbf::Field.new("Boyoul","N",10,0)])
55
-
56
- The file is then open for reading and writing.
57
-
58
- Here is an example of how to write to a shapefile (created or not with GeoRuby) :
59
-
60
- shpfile = ShpFile.open('places.shp')
61
- shpfile.transaction do |tr|
62
- tr.add(ShpRecord.new(Point.from_x_y(123.4,123.4),'Hoyoyo' => "AEZ",'Bouyoul' => 45))
63
- tr.update(4,ShpRecord.new(Point.from_x_y(-16.67,16.41),'Hoyoyo' => "EatMe",'Bouyoul' => 42))
64
- tr.delete(1)
65
- end
66
- shpfile.close
67
-
68
- Note the transaction is just there so the operations on the files can be buffered. Nothing happens on the original files until the block has finished executing. Calling <tt>tr.rollback</tt> at anytime during the execution will prevent the modifications.
69
-
70
- Also currently, error reporting is minimal and it has not been tested that thoroughly so caveat emptor and backup before performing any destructive operation.
71
-
72
-
73
- === GPX Reading
74
-
75
- You can read and convert GPX Files to LineString/Polygon:
76
-
77
- gpxfile = GpxFile.open(tour.gpx')
78
- gpxfile.as_line_string
79
- => GeoRuby::SimpleFeatures::LineString..
80
-
81
-
82
- === Installation
83
-
84
- To install the latest version, just type :
85
-
86
- gem install nofxx-georuby
87
-
88
-
89
- === Changes since the last version
90
-
91
- - Writing of ESRI shapefiles
92
- - Reading of ESRI shapefiles
93
- - Addition of a small tool to import spatial features in MySQL and PostGIS from a SHP file
94
-
95
-
96
- === Coming in the next versions
97
-
98
- - Schema modification of existing shapefiles
99
- - More error reporting when writing shapefiles
100
- - More tests on writing shapefiles ; tests on real-world shapefiles
101
- - Better shp2sql import tool
102
- - Documentation
103
-
104
-
105
- === Acknowledgement
106
-
107
- The SHP reading part uses the DBF library (http://rubyforge.org/projects/dbf/) by Keith Morrison (http://infused.org).
108
- Thanks also to Pramukta Kumar and Pete Schwamb for their contributions.
109
-
110
-
111
- === License
112
-
113
- GeoRuby is released under the MIT license.
114
-
115
- === Support
116
-
117
- Any questions, enhancement proposals, bug notifications or corrections
118
- can be sent to mailto:guilhem.vellut@gmail.com.