nofxx-georuby 1.3.7 → 1.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/.gitignore +6 -0
  2. data/README.txt +61 -37
  3. data/VERSION.yml +1 -1
  4. data/georuby.gemspec +112 -0
  5. data/lib/geo_ruby/shp4r/shp.rb +32 -32
  6. data/lib/geo_ruby/{base → simple_features}/envelope.rb +1 -1
  7. data/lib/geo_ruby/{base → simple_features}/ewkb_parser.rb +9 -9
  8. data/lib/geo_ruby/{base → simple_features}/ewkt_parser.rb +9 -9
  9. data/lib/geo_ruby/{base → simple_features}/geometry.rb +2 -2
  10. data/lib/geo_ruby/{base → simple_features}/geometry_collection.rb +2 -2
  11. data/lib/geo_ruby/{base → simple_features}/geometry_factory.rb +9 -9
  12. data/lib/geo_ruby/{base → simple_features}/georss_parser.rb +10 -10
  13. data/lib/geo_ruby/{base → simple_features}/helper.rb +1 -1
  14. data/lib/geo_ruby/{base → simple_features}/line_string.rb +2 -2
  15. data/lib/geo_ruby/{base → simple_features}/linear_ring.rb +2 -2
  16. data/lib/geo_ruby/{base → simple_features}/multi_line_string.rb +2 -2
  17. data/lib/geo_ruby/{base → simple_features}/multi_point.rb +2 -2
  18. data/lib/geo_ruby/{base → simple_features}/multi_polygon.rb +2 -2
  19. data/lib/geo_ruby/{base → simple_features}/point.rb +26 -2
  20. data/lib/geo_ruby/{base → simple_features}/polygon.rb +2 -2
  21. data/lib/geo_ruby.rb +15 -17
  22. data/script/console +10 -0
  23. data/script/destroy +14 -0
  24. data/script/generate +14 -0
  25. data/script/txt2html +82 -0
  26. data/spec/geo_ruby/shp4r/shp_spec.rb +1 -1
  27. data/spec/geo_ruby/{base → simple_features}/envelope_spec.rb +0 -0
  28. data/spec/geo_ruby/{base → simple_features}/ewkb_parser_spec.rb +0 -0
  29. data/spec/geo_ruby/{base → simple_features}/ewkt_parser_spec.rb +0 -0
  30. data/spec/geo_ruby/{base → simple_features}/geometry_collection_spec.rb +0 -0
  31. data/spec/geo_ruby/{base → simple_features}/geometry_factory_spec.rb +0 -0
  32. data/spec/geo_ruby/{base → simple_features}/geometry_spec.rb +0 -0
  33. data/spec/geo_ruby/{base → simple_features}/georss_parser_spec.rb +0 -0
  34. data/spec/geo_ruby/{base → simple_features}/line_string_spec.rb +0 -0
  35. data/spec/geo_ruby/{base → simple_features}/linear_ring_spec.rb +0 -0
  36. data/spec/geo_ruby/{base → simple_features}/multi_line_string_spec.rb +0 -0
  37. data/spec/geo_ruby/{base → simple_features}/multi_point_spec.rb +0 -0
  38. data/spec/geo_ruby/{base → simple_features}/multi_polygon_spec.rb +0 -0
  39. data/spec/geo_ruby/{base → simple_features}/point_spec.rb +38 -1
  40. data/spec/geo_ruby/{base → simple_features}/polygon_spec.rb +0 -0
  41. data/spec/geo_ruby_spec.rb +1 -1
  42. data/spec/spec_helper.rb +1 -1
  43. metadata +51 -45
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ pkg/*.gem
3
+ pkg/*.tgz
4
+ pkg/**/*
5
+ coverage/*
6
+ doc/*
data/README.txt CHANGED
@@ -1,29 +1,9 @@
1
- = geo_ruby
1
+ =GeoRuby
2
2
 
3
- Experiment with GeoRuby (http://georuby.rubyforge.org) with the fast Geo (http://geo.rubyforge.org).
4
-
5
-
6
- == DESCRIPTION:
7
-
8
- the objective is provide all the georuby functionalities, with time consuming calculus in C.
9
- _this is not usable yet_
10
-
11
- See:
12
- GeoRuby (http://georuby.rubyforge.org)
13
- Copyright (c) 2006 Guilhem Vellut <guilhem.vellut+georuby@gmail.com>
14
-
15
- Geo (http://geo.rubyforge.org)
16
- Copyright (C) 2007 Martin Kihlgren
17
-
18
-
19
- == REQUIREMENTS:
20
-
21
- glib:: http://www.gtk.org/
22
-
23
- == FEATURES:
24
-
25
- =Available data types
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).
26
4
 
5
+ ===Available data types
6
+ The following geometric data types are provided :
27
7
  - Point
28
8
  - Line string
29
9
  - Linear ring
@@ -35,25 +15,69 @@ glib:: http://www.gtk.org/
35
15
 
36
16
  They can be in 2D, 3DZ, 3DM, and 4D.
37
17
 
18
+ On top of this an Envelope class is available, to contain the bounding box of a geometry.
19
+
20
+ ===Input and output
21
+ 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.
22
+
23
+ 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.
24
+
25
+ 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.
26
+
27
+ ===SHP reading et writing
28
+ 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.
38
29
 
39
- Geo::Point:: A 2D point providing some common geometry operations.
40
- Geo::Line:: A 2D line consisting of 2 Geo::Points providing some common geometry operations.
41
- Geo::Triangle:: A 2D triangle consisting of 3 Geo::Points providing some common geometry operations.
42
- Geo::PointSet:: A Set-like container of Points.
43
- Geo::LineSet:: A Set-like container of Lines that provides optimized versions of some common geometry operations on lines.
44
- Geo::TriangleSet:: A Set-like container of Triangles that provides optimized versions of some common geometry operations on lines.
30
+ Here is an example of Shapefile reading, that goes through all the geometries in a file and disaply the values of the attributes :
31
+ ShpFile.open(shpfile) do |shp|
32
+ shp.each do |shape|
33
+ geom = shape.geometry #a GeoRuby SimpleFeature
34
+ att_data = shape.data #a Hash
35
+ shp.fields.each do |field|
36
+ puts att_data[field.name]
37
+ end
38
+ end
39
+ end
45
40
 
46
- == Usage:
41
+ 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).
47
42
 
48
- Just install the gem.
43
+ Here is an example of how to create a new Shapefile with 2 fields :
44
+ shpfile = ShpFile.create('hello.shp',ShpType::POINT,[Dbf::Field.new("Hoyoyo","C",10),Dbf::Field.new("Boyoul","N",10,0)])
45
+ The file is then open for reading and writing.
49
46
 
50
- == Examples:
47
+ Here is an example of how to write to a shapefile (created or not with GeoRuby) :
48
+ shpfile = ShpFile.open('places.shp')
49
+ shpfile.transaction do |tr|
50
+ tr.add(ShpRecord.new(Point.from_x_y(123.4,123.4),'Hoyoyo' => "AEZ",'Bouyoul' => 45))
51
+ tr.update(4,ShpRecord.new(Point.from_x_y(-16.67,16.41),'Hoyoyo' => "EatMe",'Bouyoul' => 42))
52
+ tr.delete(1)
53
+ end
54
+ shpfile.close
51
55
 
52
- To find if a given line intersects a set of 100 000 other lines:
56
+ 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.
53
57
 
54
- :include:examples/intersects.rb
58
+ Also currently, error reporting is minimal and it has not been tested that thoroughly so caveat emptor and backup before performing any destructive operation.
55
59
 
56
- == License:
60
+ ===Installation
61
+ To install the latest version, just type :
62
+ gem install GeoRuby
57
63
 
64
+ ===Changes since the last version
65
+ - Writing of ESRI shapefiles
66
+ - Reading of ESRI shapefiles
67
+ - Addition of a small tool to import spatial features in MySQL and PostGIS from a SHP file
68
+
69
+ ===Coming in the next versions
70
+ - Schema modification of existing shapefiles
71
+ - More error reporting when writing shapefiles
72
+ - More tests on writing shapefiles ; tests on real-world shapefiles
73
+ - Better shp2sql import tool
74
+ - Documentation
75
+
76
+ ===Acknowledgement
77
+ The SHP reading part uses a modified version of the DBF library (http://rubyforge.org/projects/dbf/) by Keith Morrison (http://infused.org). Thanks also to Pramukta Kumar and Pete Schwamb for their contributions.
78
+
79
+ ===License
58
80
  GeoRuby is released under the MIT license.
59
- geo is provided under the GPL-2.
81
+
82
+ ===Support
83
+ Any questions, enhancement proposals, bug notifications or corrections can be sent to mailto:guilhem.vellut@gmail.com.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 3
4
- :patch: 7
4
+ :patch: 9
data/georuby.gemspec ADDED
@@ -0,0 +1,112 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{georuby}
5
+ s.version = "1.3.9"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Guilhem Vellut", "Marcos Augusto"]
9
+ s.date = %q{2009-05-07}
10
+ s.description = %q{GeoRuby provides geometric data types from the OGC 'Simple Features' specification.}
11
+ s.email = %q{x@nofxx.com}
12
+ s.extra_rdoc_files = [
13
+ "LICENSE",
14
+ "README.txt"
15
+ ]
16
+ s.files = [
17
+ ".gitignore",
18
+ "History.txt",
19
+ "LICENSE",
20
+ "README.txt",
21
+ "Rakefile",
22
+ "VERSION.yml",
23
+ "georuby.gemspec",
24
+ "lib/geo_ruby.rb",
25
+ "lib/geo_ruby/shp4r/dbf.rb",
26
+ "lib/geo_ruby/shp4r/shp.rb",
27
+ "lib/geo_ruby/simple_features/envelope.rb",
28
+ "lib/geo_ruby/simple_features/ewkb_parser.rb",
29
+ "lib/geo_ruby/simple_features/ewkt_parser.rb",
30
+ "lib/geo_ruby/simple_features/geometry.rb",
31
+ "lib/geo_ruby/simple_features/geometry_collection.rb",
32
+ "lib/geo_ruby/simple_features/geometry_factory.rb",
33
+ "lib/geo_ruby/simple_features/georss_parser.rb",
34
+ "lib/geo_ruby/simple_features/helper.rb",
35
+ "lib/geo_ruby/simple_features/line_string.rb",
36
+ "lib/geo_ruby/simple_features/linear_ring.rb",
37
+ "lib/geo_ruby/simple_features/multi_line_string.rb",
38
+ "lib/geo_ruby/simple_features/multi_point.rb",
39
+ "lib/geo_ruby/simple_features/multi_polygon.rb",
40
+ "lib/geo_ruby/simple_features/point.rb",
41
+ "lib/geo_ruby/simple_features/polygon.rb",
42
+ "script/console",
43
+ "script/destroy",
44
+ "script/generate",
45
+ "script/txt2html",
46
+ "spec/data/multipoint.dbf",
47
+ "spec/data/multipoint.shp",
48
+ "spec/data/multipoint.shx",
49
+ "spec/data/point.dbf",
50
+ "spec/data/point.shp",
51
+ "spec/data/point.shx",
52
+ "spec/data/polygon.dbf",
53
+ "spec/data/polygon.shp",
54
+ "spec/data/polygon.shx",
55
+ "spec/data/polyline.dbf",
56
+ "spec/data/polyline.shp",
57
+ "spec/data/polyline.shx",
58
+ "spec/geo_ruby/shp4r/shp_spec.rb",
59
+ "spec/geo_ruby/simple_features/envelope_spec.rb",
60
+ "spec/geo_ruby/simple_features/ewkb_parser_spec.rb",
61
+ "spec/geo_ruby/simple_features/ewkt_parser_spec.rb",
62
+ "spec/geo_ruby/simple_features/geometry_collection_spec.rb",
63
+ "spec/geo_ruby/simple_features/geometry_factory_spec.rb",
64
+ "spec/geo_ruby/simple_features/geometry_spec.rb",
65
+ "spec/geo_ruby/simple_features/georss_parser_spec.rb",
66
+ "spec/geo_ruby/simple_features/line_string_spec.rb",
67
+ "spec/geo_ruby/simple_features/linear_ring_spec.rb",
68
+ "spec/geo_ruby/simple_features/multi_line_string_spec.rb",
69
+ "spec/geo_ruby/simple_features/multi_point_spec.rb",
70
+ "spec/geo_ruby/simple_features/multi_polygon_spec.rb",
71
+ "spec/geo_ruby/simple_features/point_spec.rb",
72
+ "spec/geo_ruby/simple_features/polygon_spec.rb",
73
+ "spec/geo_ruby_spec.rb",
74
+ "spec/spec.opts",
75
+ "spec/spec_helper.rb"
76
+ ]
77
+ s.has_rdoc = true
78
+ s.homepage = %q{http://github.com/nofxx/georuby}
79
+ s.rdoc_options = ["--charset=UTF-8"]
80
+ s.require_paths = ["lib"]
81
+ s.rubygems_version = %q{1.3.2}
82
+ s.summary = %q{Ruby data holder for OGC Simple Features}
83
+ s.test_files = [
84
+ "spec/geo_ruby/shp4r/shp_spec.rb",
85
+ "spec/geo_ruby/simple_features/polygon_spec.rb",
86
+ "spec/geo_ruby/simple_features/linear_ring_spec.rb",
87
+ "spec/geo_ruby/simple_features/geometry_factory_spec.rb",
88
+ "spec/geo_ruby/simple_features/geometry_spec.rb",
89
+ "spec/geo_ruby/simple_features/georss_parser_spec.rb",
90
+ "spec/geo_ruby/simple_features/multi_point_spec.rb",
91
+ "spec/geo_ruby/simple_features/ewkt_parser_spec.rb",
92
+ "spec/geo_ruby/simple_features/line_string_spec.rb",
93
+ "spec/geo_ruby/simple_features/multi_line_string_spec.rb",
94
+ "spec/geo_ruby/simple_features/geometry_collection_spec.rb",
95
+ "spec/geo_ruby/simple_features/ewkb_parser_spec.rb",
96
+ "spec/geo_ruby/simple_features/multi_polygon_spec.rb",
97
+ "spec/geo_ruby/simple_features/point_spec.rb",
98
+ "spec/geo_ruby/simple_features/envelope_spec.rb",
99
+ "spec/geo_ruby_spec.rb",
100
+ "spec/spec_helper.rb"
101
+ ]
102
+
103
+ if s.respond_to? :specification_version then
104
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
105
+ s.specification_version = 3
106
+
107
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
108
+ else
109
+ end
110
+ else
111
+ end
112
+ end
@@ -161,7 +161,7 @@ module GeoRuby
161
161
  case(rec_shp_type)
162
162
  when ShpType::POINT
163
163
  x, y = @shp.read(16).unpack("E2")
164
- geometry = GeoRuby::Base::Point.from_x_y(x,y)
164
+ geometry = GeoRuby::SimpleFeatures::Point.from_x_y(x,y)
165
165
  when ShpType::POLYLINE #actually creates a multi_polyline
166
166
  @shp.seek(32,IO::SEEK_CUR) #extent
167
167
  num_parts, num_points = @shp.read(8).unpack("V2")
@@ -169,12 +169,12 @@ module GeoRuby
169
169
  parts << num_points #indexes for LS of idx i go to parts of idx i to idx i +1
170
170
  points = Array.new(num_points) do
171
171
  x, y = @shp.read(16).unpack("E2")
172
- GeoRuby::Base::Point.from_x_y(x,y)
172
+ GeoRuby::SimpleFeatures::Point.from_x_y(x,y)
173
173
  end
174
174
  line_strings = Array.new(num_parts) do |i|
175
- GeoRuby::Base::LineString.from_points(points[(parts[i])...(parts[i+1])])
175
+ GeoRuby::SimpleFeatures::LineString.from_points(points[(parts[i])...(parts[i+1])])
176
176
  end
177
- geometry = GeoRuby::Base::MultiLineString.from_line_strings(line_strings)
177
+ geometry = GeoRuby::SimpleFeatures::MultiLineString.from_line_strings(line_strings)
178
178
  when ShpType::POLYGON
179
179
  #TODO : TO CORRECT
180
180
  #does not take into account the possibility that the outer loop could be after the inner loops in the SHP + more than one outer loop
@@ -185,25 +185,25 @@ module GeoRuby
185
185
  parts << num_points #indexes for LS of idx i go to parts of idx i to idx i +1
186
186
  points = Array.new(num_points) do
187
187
  x, y = @shp.read(16).unpack("E2")
188
- GeoRuby::Base::Point.from_x_y(x,y)
188
+ GeoRuby::SimpleFeatures::Point.from_x_y(x,y)
189
189
  end
190
190
  linear_rings = Array.new(num_parts) do |i|
191
- GeoRuby::Base::LinearRing.from_points(points[(parts[i])...(parts[i+1])])
191
+ GeoRuby::SimpleFeatures::LinearRing.from_points(points[(parts[i])...(parts[i+1])])
192
192
  end
193
- geometry = GeoRuby::Base::MultiPolygon.from_polygons([GeoRuby::Base::Polygon.from_linear_rings(linear_rings)])
193
+ geometry = GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_linear_rings(linear_rings)])
194
194
  when ShpType::MULTIPOINT
195
195
  @shp.seek(32,IO::SEEK_CUR)
196
196
  num_points = @shp.read(4).unpack("V")[0]
197
197
  points = Array.new(num_points) do
198
198
  x, y = @shp.read(16).unpack("E2")
199
- GeoRuby::Base::Point.from_x_y(x,y)
199
+ GeoRuby::SimpleFeatures::Point.from_x_y(x,y)
200
200
  end
201
- geometry = GeoRuby::Base::MultiPoint.from_points(points)
201
+ geometry = GeoRuby::SimpleFeatures::MultiPoint.from_points(points)
202
202
 
203
203
 
204
204
  when ShpType::POINTZ
205
205
  x, y, z, m = @shp.read(24).unpack("E4")
206
- geometry = GeoRuby::Base::Point.from_x_y_z_m(x,y,z,m)
206
+ geometry = GeoRuby::SimpleFeatures::Point.from_x_y_z_m(x,y,z,m)
207
207
 
208
208
 
209
209
  when ShpType::POLYLINEZ
@@ -217,12 +217,12 @@ module GeoRuby
217
217
  @shp.seek(16,IO::SEEK_CUR)
218
218
  ms = Array.new(num_points) {@shp.read(8).unpack("E")[0]}
219
219
  points = Array.new(num_points) do |i|
220
- GeoRuby::Base::Point.from_x_y_z_m(xys[i][0],xys[i][1],zs[i],ms[i])
220
+ GeoRuby::SimpleFeatures::Point.from_x_y_z_m(xys[i][0],xys[i][1],zs[i],ms[i])
221
221
  end
222
222
  line_strings = Array.new(num_parts) do |i|
223
- GeoRuby::Base::LineString.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::Base::default_srid,true,true)
223
+ GeoRuby::SimpleFeatures::LineString.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::SimpleFeatures::default_srid,true,true)
224
224
  end
225
- geometry = GeoRuby::Base::MultiLineString.from_line_strings(line_strings,GeoRuby::Base::default_srid,true,true)
225
+ geometry = GeoRuby::SimpleFeatures::MultiLineString.from_line_strings(line_strings,GeoRuby::SimpleFeatures::default_srid,true,true)
226
226
 
227
227
 
228
228
  when ShpType::POLYGONZ
@@ -241,9 +241,9 @@ module GeoRuby
241
241
  Point.from_x_y_z_m(xys[i][0],xys[i][1],zs[i],ms[i])
242
242
  end
243
243
  linear_rings = Array.new(num_parts) do |i|
244
- GeoRuby::Base::LinearRing.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::Base::default_srid,true,true)
244
+ GeoRuby::SimpleFeatures::LinearRing.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::SimpleFeatures::default_srid,true,true)
245
245
  end
246
- geometry = GeoRuby::Base::MultiPolygon.from_polygons([GeoRuby::Base::Polygon.from_linear_rings(linear_rings)],GeoRuby::Base::default_srid,true,true)
246
+ geometry = GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_linear_rings(linear_rings)],GeoRuby::SimpleFeatures::default_srid,true,true)
247
247
 
248
248
 
249
249
  when ShpType::MULTIPOINTZ
@@ -259,11 +259,11 @@ module GeoRuby
259
259
  Point.from_x_y_z_m(xys[i][0],xys[i][1],zs[i],ms[i])
260
260
  end
261
261
 
262
- geometry = GeoRuby::Base::MultiPoint.from_points(points,GeoRuby::Base::default_srid,true,true)
262
+ geometry = GeoRuby::SimpleFeatures::MultiPoint.from_points(points,GeoRuby::SimpleFeatures::default_srid,true,true)
263
263
 
264
264
  when ShpType::POINTM
265
265
  x, y, m = @shp.read(24).unpack("E3")
266
- geometry = GeoRuby::Base::Point.from_x_y_m(x,y,m)
266
+ geometry = GeoRuby::SimpleFeatures::Point.from_x_y_m(x,y,m)
267
267
 
268
268
  when ShpType::POLYLINEM
269
269
  @shp.seek(32,IO::SEEK_CUR)
@@ -277,9 +277,9 @@ module GeoRuby
277
277
  Point.from_x_y_m(xys[i][0],xys[i][1],ms[i])
278
278
  end
279
279
  line_strings = Array.new(num_parts) do |i|
280
- GeoRuby::Base::LineString.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::Base::default_srid,false,true)
280
+ GeoRuby::SimpleFeatures::LineString.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::SimpleFeatures::default_srid,false,true)
281
281
  end
282
- geometry = GeoRuby::Base::MultiLineString.from_line_strings(line_strings,GeoRuby::Base::default_srid,false,true)
282
+ geometry = GeoRuby::SimpleFeatures::MultiLineString.from_line_strings(line_strings,GeoRuby::SimpleFeatures::default_srid,false,true)
283
283
 
284
284
 
285
285
  when ShpType::POLYGONM
@@ -296,9 +296,9 @@ module GeoRuby
296
296
  Point.from_x_y_m(xys[i][0],xys[i][1],ms[i])
297
297
  end
298
298
  linear_rings = Array.new(num_parts) do |i|
299
- GeoRuby::Base::LinearRing.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::Base::default_srid,false,true)
299
+ GeoRuby::SimpleFeatures::LinearRing.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::SimpleFeatures::default_srid,false,true)
300
300
  end
301
- geometry = GeoRuby::Base::MultiPolygon.from_polygons([GeoRuby::Base::Polygon.from_linear_rings(linear_rings)],GeoRuby::Base::default_srid,false,true)
301
+ geometry = GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_linear_rings(linear_rings)],GeoRuby::SimpleFeatures::default_srid,false,true)
302
302
 
303
303
 
304
304
  when ShpType::MULTIPOINTM
@@ -312,7 +312,7 @@ module GeoRuby
312
312
  Point.from_x_y_m(xys[i][0],xys[i][1],ms[i])
313
313
  end
314
314
 
315
- geometry = GeoRuby::Base::MultiPoint.from_points(points,GeoRuby::Base::default_srid,false,true)
315
+ geometry = GeoRuby::SimpleFeatures::MultiPoint.from_points(points,GeoRuby::SimpleFeatures::default_srid,false,true)
316
316
  else
317
317
  geometry = nil
318
318
  end
@@ -402,17 +402,17 @@ module GeoRuby
402
402
  private
403
403
 
404
404
  def to_shp_type(geom)
405
- root = if geom.is_a? GeoRuby::Base::Point
405
+ root = if geom.is_a? GeoRuby::SimpleFeatures::Point
406
406
  "POINT"
407
- elsif geom.is_a? GeoRuby::Base::LineString
407
+ elsif geom.is_a? GeoRuby::SimpleFeatures::LineString
408
408
  "POLYLINE"
409
- elsif geom.is_a? GeoRuby::Base::Polygon
409
+ elsif geom.is_a? GeoRuby::SimpleFeatures::Polygon
410
410
  "POLYGON"
411
- elsif geom.is_a? GeoRuby::Base::MultiPoint
411
+ elsif geom.is_a? GeoRuby::SimpleFeatures::MultiPoint
412
412
  "MULTIPOINT"
413
- elsif geom.is_a? GeoRuby::Base::MultiLineString
413
+ elsif geom.is_a? GeoRuby::SimpleFeatures::MultiLineString
414
414
  "POLYLINE"
415
- elsif geom.is_a? GeoRuby::Base::MultiPolygon
415
+ elsif geom.is_a? GeoRuby::SimpleFeatures::MultiPolygon
416
416
  "POLYGON"
417
417
  else
418
418
  false
@@ -589,7 +589,7 @@ module GeoRuby
589
589
  end
590
590
 
591
591
  def build_polyline(geometry,str)
592
- if geometry.is_a? GeoRuby::Base::LineString
592
+ if geometry.is_a? GeoRuby::SimpleFeatures::LineString
593
593
  str << [1,geometry.length,0].pack("V3")
594
594
  geometry.each do |point|
595
595
  str << [point.x,point.y].pack("E2")
@@ -609,7 +609,7 @@ module GeoRuby
609
609
 
610
610
  def build_polyline_zm(geometry,zm,range,str)
611
611
  str << range.pack("E2")
612
- if geometry.is_a? GeoRuby::Base::LineString
612
+ if geometry.is_a? GeoRuby::SimpleFeatures::LineString
613
613
  geometry.each do |point|
614
614
  str << [point.instance_variable_get(zm)].pack("E")
615
615
  end
@@ -625,7 +625,7 @@ module GeoRuby
625
625
  end
626
626
 
627
627
  def build_polygon(geometry,str)
628
- if geometry.is_a? GeoRuby::Base::Polygon
628
+ if geometry.is_a? GeoRuby::SimpleFeatures::Polygon
629
629
  str << [geometry.length,geometry.inject(0) {|l, lr| l + lr.length}].pack("V2")
630
630
  str << geometry.inject([0]) {|a,lr| a << (a.last + lr.length)}.pack("V#{geometry.length}") #last element of the previous array is dropped
631
631
  geometry.each do |lr|
@@ -651,7 +651,7 @@ module GeoRuby
651
651
 
652
652
  def build_polygon_zm(geometry,zm,range,str)
653
653
  str << range.pack("E2")
654
- if geometry.is_a? GeoRuby::Base::Polygon
654
+ if geometry.is_a? GeoRuby::SimpleFeatures::Polygon
655
655
  geometry.each do |lr|
656
656
  lr.each do |point|
657
657
  str << [point.instance_variable_get(zm)].pack("E")
@@ -1,5 +1,5 @@
1
1
  module GeoRuby
2
- module Base
2
+ module SimpleFeatures
3
3
 
4
4
  #Contains the bounding box of a geometry
5
5
  class Envelope
@@ -1,14 +1,14 @@
1
- require 'geo_ruby/base/point'
2
- require 'geo_ruby/base/line_string'
3
- require 'geo_ruby/base/linear_ring'
4
- require 'geo_ruby/base/polygon'
5
- require 'geo_ruby/base/multi_point'
6
- require 'geo_ruby/base/multi_line_string'
7
- require 'geo_ruby/base/multi_polygon'
8
- require 'geo_ruby/base/geometry_collection'
1
+ require 'geo_ruby/simple_features/point'
2
+ require 'geo_ruby/simple_features/line_string'
3
+ require 'geo_ruby/simple_features/linear_ring'
4
+ require 'geo_ruby/simple_features/polygon'
5
+ require 'geo_ruby/simple_features/multi_point'
6
+ require 'geo_ruby/simple_features/multi_line_string'
7
+ require 'geo_ruby/simple_features/multi_polygon'
8
+ require 'geo_ruby/simple_features/geometry_collection'
9
9
 
10
10
  module GeoRuby
11
- module Base
11
+ module SimpleFeatures
12
12
 
13
13
  #Raised when an error in the EWKB string is detected
14
14
  class EWKBFormatError < StandardError
@@ -1,16 +1,16 @@
1
- require 'geo_ruby/base/point'
2
- require 'geo_ruby/base/line_string'
3
- require 'geo_ruby/base/linear_ring'
4
- require 'geo_ruby/base/polygon'
5
- require 'geo_ruby/base/multi_point'
6
- require 'geo_ruby/base/multi_line_string'
7
- require 'geo_ruby/base/multi_polygon'
8
- require 'geo_ruby/base/geometry_collection'
1
+ require 'geo_ruby/simple_features/point'
2
+ require 'geo_ruby/simple_features/line_string'
3
+ require 'geo_ruby/simple_features/linear_ring'
4
+ require 'geo_ruby/simple_features/polygon'
5
+ require 'geo_ruby/simple_features/multi_point'
6
+ require 'geo_ruby/simple_features/multi_line_string'
7
+ require 'geo_ruby/simple_features/multi_polygon'
8
+ require 'geo_ruby/simple_features/geometry_collection'
9
9
 
10
10
  require 'strscan'
11
11
 
12
12
  module GeoRuby
13
- module Base
13
+ module SimpleFeatures
14
14
 
15
15
  #Raised when an error in the EWKT string is detected
16
16
  class EWKTFormatError < StandardError
@@ -1,5 +1,5 @@
1
1
  module GeoRuby#:nodoc:
2
- module Base
2
+ module SimpleFeatures
3
3
  #arbitrary default SRID
4
4
  @@default_srid = 4326
5
5
 
@@ -184,7 +184,7 @@ module GeoRuby#:nodoc:
184
184
  #Limitations : Only supports points, linestrings and polygons (no collection for now).
185
185
  #Addapted from Pramukta's code
186
186
  def self.from_kml(kml)
187
- return GeoRuby::Base::Geometry.from_ewkt(kml_to_wkt(kml))
187
+ return GeoRuby::SimpleFeatures::Geometry.from_ewkt(kml_to_wkt(kml))
188
188
  end
189
189
 
190
190
  require 'rexml/document'
@@ -1,7 +1,7 @@
1
- require 'geo_ruby/base/geometry'
1
+ require 'geo_ruby/simple_features/geometry'
2
2
 
3
3
  module GeoRuby
4
- module Base
4
+ module SimpleFeatures
5
5
  #Represents a collection of arbitrary geometries
6
6
  class GeometryCollection < Geometry
7
7
  attr_reader :geometries
@@ -1,15 +1,15 @@
1
- require 'geo_ruby/base/point'
2
- require 'geo_ruby/base/line_string'
3
- require 'geo_ruby/base/linear_ring'
4
- require 'geo_ruby/base/polygon'
5
- require 'geo_ruby/base/multi_point'
6
- require 'geo_ruby/base/multi_line_string'
7
- require 'geo_ruby/base/multi_polygon'
8
- require 'geo_ruby/base/geometry_collection'
1
+ require 'geo_ruby/simple_features/point'
2
+ require 'geo_ruby/simple_features/line_string'
3
+ require 'geo_ruby/simple_features/linear_ring'
4
+ require 'geo_ruby/simple_features/polygon'
5
+ require 'geo_ruby/simple_features/multi_point'
6
+ require 'geo_ruby/simple_features/multi_line_string'
7
+ require 'geo_ruby/simple_features/multi_polygon'
8
+ require 'geo_ruby/simple_features/geometry_collection'
9
9
 
10
10
 
11
11
  module GeoRuby
12
- module Base
12
+ module SimpleFeatures
13
13
  #Creates a new geometry according to constructions received from a parser, for example EWKBParser.
14
14
  class GeometryFactory
15
15
  #the built geometry
@@ -1,15 +1,15 @@
1
- require 'geo_ruby/base/point'
2
- require 'geo_ruby/base/line_string'
3
- require 'geo_ruby/base/linear_ring'
4
- require 'geo_ruby/base/polygon'
5
- require 'geo_ruby/base/multi_point'
6
- require 'geo_ruby/base/multi_line_string'
7
- require 'geo_ruby/base/multi_polygon'
8
- require 'geo_ruby/base/geometry_collection'
9
- require 'geo_ruby/base/envelope'
1
+ require 'geo_ruby/simple_features/point'
2
+ require 'geo_ruby/simple_features/line_string'
3
+ require 'geo_ruby/simple_features/linear_ring'
4
+ require 'geo_ruby/simple_features/polygon'
5
+ require 'geo_ruby/simple_features/multi_point'
6
+ require 'geo_ruby/simple_features/multi_line_string'
7
+ require 'geo_ruby/simple_features/multi_polygon'
8
+ require 'geo_ruby/simple_features/geometry_collection'
9
+ require 'geo_ruby/simple_features/envelope'
10
10
 
11
11
  module GeoRuby
12
- module Base
12
+ module SimpleFeatures
13
13
 
14
14
  #Raised when an error in the GeoRSS string is detected
15
15
  class GeorssFormatError < StandardError
@@ -1,5 +1,5 @@
1
1
  module GeoRuby
2
- module Base
2
+ module SimpleFeatures
3
3
  #indicates the presence of Z coordinates in EWKB strings
4
4
  Z_MASK=0x80000000
5
5
  #indicates the presence of M coordinates in EWKB strings.
@@ -1,7 +1,7 @@
1
- require "geo_ruby/base/geometry"
1
+ require "geo_ruby/simple_features/geometry"
2
2
 
3
3
  module GeoRuby
4
- module Base
4
+ module SimpleFeatures
5
5
  #Represents a line string as an array of points (see Point).
6
6
  class LineString < Geometry
7
7
  #the list of points forming the line string
@@ -1,7 +1,7 @@
1
- require 'geo_ruby/base/line_string'
1
+ require 'geo_ruby/simple_features/line_string'
2
2
 
3
3
  module GeoRuby
4
- module Base
4
+ module SimpleFeatures
5
5
  #Represents a linear ring, which is a closed line string (see LineString). Currently, no check is performed to verify if the linear ring is really closed.
6
6
  class LinearRing < LineString
7
7
  def initialize(srid= @@default_srid,with_z=false,with_m=false)
@@ -1,7 +1,7 @@
1
- require 'geo_ruby/base/geometry_collection'
1
+ require 'geo_ruby/simple_features/geometry_collection'
2
2
 
3
3
  module GeoRuby
4
- module Base
4
+ module SimpleFeatures
5
5
  #Represents a group of line strings (see LineString).
6
6
  class MultiLineString < GeometryCollection
7
7
  def initialize(srid = @@default_srid,with_z=false,with_m=false)
@@ -1,7 +1,7 @@
1
- require 'geo_ruby/base/geometry_collection'
1
+ require 'geo_ruby/simple_features/geometry_collection'
2
2
 
3
3
  module GeoRuby
4
- module Base
4
+ module SimpleFeatures
5
5
  #Represents a group of points (see Point).
6
6
  class MultiPoint < GeometryCollection
7
7
 
@@ -1,7 +1,7 @@
1
- require 'geo_ruby/base/geometry_collection'
1
+ require 'geo_ruby/simple_features/geometry_collection'
2
2
 
3
3
  module GeoRuby
4
- module Base
4
+ module SimpleFeatures
5
5
  #Represents a group of polygons (see Polygon).
6
6
  class MultiPolygon < GeometryCollection
7
7
  def initialize(srid = @@default_srid,with_z=false,with_m=false)
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
- require "geo_ruby/base/geometry"
2
+ require "geo_ruby/simple_features/geometry"
3
3
 
4
4
  module GeoRuby
5
- module Base
5
+ module SimpleFeatures
6
6
  #Represents a point. It is in 3D if the Z coordinate is not +nil+.
7
7
  class Point < Geometry
8
8
  DEG2RAD = 0.0174532925199433
@@ -108,6 +108,30 @@ module GeoRuby
108
108
  b*a_bis*(sigma-deltaSigma)
109
109
  end
110
110
 
111
+ #Bearing from a point to another, in degrees.
112
+ def bearing_to(other)
113
+ return 0 if self == other
114
+ a,b = other.x - self.x, other.y - self.y
115
+ res = Math.acos(b / Math.sqrt(a*a+b*b)) / Math::PI * 180;
116
+ a < 0 ? 360 - res : res
117
+ end
118
+
119
+ #Bearing from a point to another as symbols. (:n, :s, :sw, :ne...)
120
+ def bearing_text(other)
121
+ case bearing_to(other)
122
+ when 1..22 then :n
123
+ when 23..66 then :ne
124
+ when 67..112 then :e
125
+ when 113..146 then :se
126
+ when 147..202 then :s
127
+ when 203..246 then :sw
128
+ when 247..292 then :w
129
+ when 293..336 then :nw
130
+ when 337..360 then :n
131
+ else nil
132
+ end
133
+ end
134
+
111
135
  #Bounding box in 2D/3D. Returns an array of 2 points
112
136
  def bounding_box
113
137
  unless with_z
@@ -1,7 +1,7 @@
1
- require 'geo_ruby/base/geometry'
1
+ require 'geo_ruby/simple_features/geometry'
2
2
 
3
3
  module GeoRuby
4
- module Base
4
+ module SimpleFeatures
5
5
  #Represents a polygon as an array of linear rings (see LinearRing). No check is performed regarding the validity of the geometries forming the polygon.
6
6
  class Polygon < Geometry
7
7
  #the list of rings forming the polygon
data/lib/geo_ruby.rb CHANGED
@@ -1,21 +1,19 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
- require 'geo_ruby/base/helper'
5
- require 'geo_ruby/base/ewkt_parser'
6
- require 'geo_ruby/base/ewkb_parser'
7
- require 'geo_ruby/base/geometry'
8
- require 'geo_ruby/base/point'
9
- require 'geo_ruby/base/line_string'
10
- require 'geo_ruby/base/linear_ring'
11
- require 'geo_ruby/base/polygon'
12
- require 'geo_ruby/base/multi_point'
13
- require 'geo_ruby/base/multi_line_string'
14
- require 'geo_ruby/base/multi_polygon'
15
- require 'geo_ruby/base/geometry_collection'
16
- require 'geo_ruby/base/envelope'
17
- require 'geo_ruby/base/geometry_factory'
18
- require 'geo_ruby/base/georss_parser'
4
+ require 'geo_ruby/simple_features/helper'
5
+ require 'geo_ruby/simple_features/ewkt_parser'
6
+ require 'geo_ruby/simple_features/ewkb_parser'
7
+ require 'geo_ruby/simple_features/geometry'
8
+ require 'geo_ruby/simple_features/point'
9
+ require 'geo_ruby/simple_features/line_string'
10
+ require 'geo_ruby/simple_features/linear_ring'
11
+ require 'geo_ruby/simple_features/polygon'
12
+ require 'geo_ruby/simple_features/multi_point'
13
+ require 'geo_ruby/simple_features/multi_line_string'
14
+ require 'geo_ruby/simple_features/multi_polygon'
15
+ require 'geo_ruby/simple_features/geometry_collection'
16
+ require 'geo_ruby/simple_features/envelope'
17
+ require 'geo_ruby/simple_features/geometry_factory'
18
+ require 'geo_ruby/simple_features/georss_parser'
19
19
  require 'geo_ruby/shp4r/shp'
20
-
21
- GeoRuby::SimpleFeatures = GeoRuby::Base
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/geo_ruby.rb'}"
9
+ puts "Loading geo_ruby gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::SimpleFeatures.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::SimpleFeatures.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
data/script/txt2html ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ GEM_NAME = 'geo_ruby' # what ppl will type to install your gem
4
+ RUBYFORGE_PROJECT = 'geo_ruby'
5
+
6
+ require 'rubygems'
7
+ begin
8
+ require 'newgem'
9
+ require 'rubyforge'
10
+ rescue LoadError
11
+ puts "\n\nGenerating the website requires the newgem RubyGem"
12
+ puts "Install: gem install newgem\n\n"
13
+ exit(1)
14
+ end
15
+ require 'redcloth'
16
+ require 'syntax/convertors/html'
17
+ require 'erb'
18
+ require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
19
+
20
+ version = GeoRuby::VERSION::STRING
21
+ download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
22
+
23
+ def rubyforge_project_id
24
+ RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT]
25
+ end
26
+
27
+ class Fixnum
28
+ def ordinal
29
+ # teens
30
+ return 'th' if (10..19).include?(self % 100)
31
+ # others
32
+ case self % 10
33
+ when 1: return 'st'
34
+ when 2: return 'nd'
35
+ when 3: return 'rd'
36
+ else return 'th'
37
+ end
38
+ end
39
+ end
40
+
41
+ class Time
42
+ def pretty
43
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
44
+ end
45
+ end
46
+
47
+ def convert_syntax(syntax, source)
48
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
49
+ end
50
+
51
+ if ARGV.length >= 1
52
+ src, template = ARGV
53
+ template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
54
+ else
55
+ puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
56
+ exit!
57
+ end
58
+
59
+ template = ERB.new(File.open(template).read)
60
+
61
+ title = nil
62
+ body = nil
63
+ File.open(src) do |fsrc|
64
+ title_text = fsrc.readline
65
+ body_text_template = fsrc.read
66
+ body_text = ERB.new(body_text_template).result(binding)
67
+ syntax_items = []
68
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
69
+ ident = syntax_items.length
70
+ element, syntax, source = $1, $2, $3
71
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
72
+ "syntax-temp-#{ident}"
73
+ }
74
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
75
+ body = RedCloth.new(body_text).to_html
76
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
77
+ end
78
+ stat = File.stat(src)
79
+ created = stat.ctime
80
+ modified = stat.mtime
81
+
82
+ $stdout << template.result(binding)
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  include GeoRuby::Shp4r
4
- include GeoRuby::Base
4
+ include GeoRuby::SimpleFeatures
5
5
 
6
6
  describe Shp4r do
7
7
 
@@ -185,7 +185,7 @@ describe Point do
185
185
 
186
186
  end
187
187
 
188
- describe " > Distance" do
188
+ describe " > Distance & Bearing" do
189
189
 
190
190
  before(:each) do
191
191
  @p1 = Point.from_x_y(1,1)
@@ -207,6 +207,43 @@ describe Point do
207
207
  should be_close(156876.149400742, 0.00000001)
208
208
  end
209
209
 
210
+ it "should calculate the bearing from apoint to another in degrees" do
211
+ @p1.bearing_to(@p2).should be_close(45.0, 0.01)
212
+ end
213
+
214
+ it "should calculate the bearing from apoint to another in degrees" do
215
+ p3 = Point.from_x_y(1,-1)
216
+ @p1.bearing_to(p3).should be_close(180.0, 0.01)
217
+ end
218
+
219
+ it "should calculate the bearing from apoint to another in degrees" do
220
+ p3 = Point.from_x_y(-1,-1)
221
+ @p1.bearing_to(p3).should be_close(225.0, 0.01)
222
+ end
223
+
224
+ it "should calculate the bearing from apoint to another in degrees" do
225
+ p3 = Point.from_x_y(-1,1)
226
+ @p1.bearing_to(p3).should be_close(270.0, 0.01)
227
+ end
228
+
229
+ it "should calculate the bearing from apoint to another in degrees" do
230
+ p3 = Point.from_x_y(2,-1)
231
+ @p1.bearing_to(p3).should be_close(153.4349488, 0.0001)
232
+ end
233
+
234
+ it "should calculate a clone point bearing to 0" do
235
+ @p1.bearing_to(@p1).should eql(0)
236
+ end
237
+
238
+ it "should calculate the bearing from apoint to another in degrees" do
239
+ @p1.bearing_text(@p2).should eql(:ne)
240
+ end
241
+
242
+ it "should calculate the bearing from apoint to another in degrees" do
243
+ p3 = Point.from_x_y(-1,1)
244
+ @p1.bearing_text(p3).should eql(:w)
245
+ end
246
+
210
247
  end
211
248
 
212
249
  describe "> Export Formats" do
@@ -5,7 +5,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
5
5
  describe "GeoRuby Stuff" do
6
6
 
7
7
  it "should instantiate Geometry" do
8
- @geo = GeoRuby::Base::Geometry.new
8
+ @geo = GeoRuby::SimpleFeatures::Geometry.new
9
9
  @geo.class.should eql(Geometry)
10
10
  end
11
11
 
data/spec/spec_helper.rb CHANGED
@@ -9,4 +9,4 @@ end
9
9
  $:.unshift(File.dirname(__FILE__) + '/../lib')
10
10
  require 'geo_ruby'
11
11
  include GeoRuby
12
- include Base
12
+ include SimpleFeatures
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nofxx-georuby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.7
4
+ version: 1.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilhem Vellut
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-05-02 00:00:00 -07:00
13
+ date: 2009-05-07 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -24,29 +24,35 @@ extra_rdoc_files:
24
24
  - LICENSE
25
25
  - README.txt
26
26
  files:
27
+ - .gitignore
27
28
  - History.txt
28
29
  - LICENSE
29
30
  - README.txt
30
31
  - Rakefile
31
32
  - VERSION.yml
33
+ - georuby.gemspec
32
34
  - lib/geo_ruby.rb
33
- - lib/geo_ruby/base/envelope.rb
34
- - lib/geo_ruby/base/ewkb_parser.rb
35
- - lib/geo_ruby/base/ewkt_parser.rb
36
- - lib/geo_ruby/base/geometry.rb
37
- - lib/geo_ruby/base/geometry_collection.rb
38
- - lib/geo_ruby/base/geometry_factory.rb
39
- - lib/geo_ruby/base/georss_parser.rb
40
- - lib/geo_ruby/base/helper.rb
41
- - lib/geo_ruby/base/line_string.rb
42
- - lib/geo_ruby/base/linear_ring.rb
43
- - lib/geo_ruby/base/multi_line_string.rb
44
- - lib/geo_ruby/base/multi_point.rb
45
- - lib/geo_ruby/base/multi_polygon.rb
46
- - lib/geo_ruby/base/point.rb
47
- - lib/geo_ruby/base/polygon.rb
48
35
  - lib/geo_ruby/shp4r/dbf.rb
49
36
  - lib/geo_ruby/shp4r/shp.rb
37
+ - lib/geo_ruby/simple_features/envelope.rb
38
+ - lib/geo_ruby/simple_features/ewkb_parser.rb
39
+ - lib/geo_ruby/simple_features/ewkt_parser.rb
40
+ - lib/geo_ruby/simple_features/geometry.rb
41
+ - lib/geo_ruby/simple_features/geometry_collection.rb
42
+ - lib/geo_ruby/simple_features/geometry_factory.rb
43
+ - lib/geo_ruby/simple_features/georss_parser.rb
44
+ - lib/geo_ruby/simple_features/helper.rb
45
+ - lib/geo_ruby/simple_features/line_string.rb
46
+ - lib/geo_ruby/simple_features/linear_ring.rb
47
+ - lib/geo_ruby/simple_features/multi_line_string.rb
48
+ - lib/geo_ruby/simple_features/multi_point.rb
49
+ - lib/geo_ruby/simple_features/multi_polygon.rb
50
+ - lib/geo_ruby/simple_features/point.rb
51
+ - lib/geo_ruby/simple_features/polygon.rb
52
+ - script/console
53
+ - script/destroy
54
+ - script/generate
55
+ - script/txt2html
50
56
  - spec/data/multipoint.dbf
51
57
  - spec/data/multipoint.shp
52
58
  - spec/data/multipoint.shx
@@ -59,21 +65,21 @@ files:
59
65
  - spec/data/polyline.dbf
60
66
  - spec/data/polyline.shp
61
67
  - spec/data/polyline.shx
62
- - spec/geo_ruby/base/envelope_spec.rb
63
- - spec/geo_ruby/base/ewkb_parser_spec.rb
64
- - spec/geo_ruby/base/ewkt_parser_spec.rb
65
- - spec/geo_ruby/base/geometry_collection_spec.rb
66
- - spec/geo_ruby/base/geometry_factory_spec.rb
67
- - spec/geo_ruby/base/geometry_spec.rb
68
- - spec/geo_ruby/base/georss_parser_spec.rb
69
- - spec/geo_ruby/base/line_string_spec.rb
70
- - spec/geo_ruby/base/linear_ring_spec.rb
71
- - spec/geo_ruby/base/multi_line_string_spec.rb
72
- - spec/geo_ruby/base/multi_point_spec.rb
73
- - spec/geo_ruby/base/multi_polygon_spec.rb
74
- - spec/geo_ruby/base/point_spec.rb
75
- - spec/geo_ruby/base/polygon_spec.rb
76
68
  - spec/geo_ruby/shp4r/shp_spec.rb
69
+ - spec/geo_ruby/simple_features/envelope_spec.rb
70
+ - spec/geo_ruby/simple_features/ewkb_parser_spec.rb
71
+ - spec/geo_ruby/simple_features/ewkt_parser_spec.rb
72
+ - spec/geo_ruby/simple_features/geometry_collection_spec.rb
73
+ - spec/geo_ruby/simple_features/geometry_factory_spec.rb
74
+ - spec/geo_ruby/simple_features/geometry_spec.rb
75
+ - spec/geo_ruby/simple_features/georss_parser_spec.rb
76
+ - spec/geo_ruby/simple_features/line_string_spec.rb
77
+ - spec/geo_ruby/simple_features/linear_ring_spec.rb
78
+ - spec/geo_ruby/simple_features/multi_line_string_spec.rb
79
+ - spec/geo_ruby/simple_features/multi_point_spec.rb
80
+ - spec/geo_ruby/simple_features/multi_polygon_spec.rb
81
+ - spec/geo_ruby/simple_features/point_spec.rb
82
+ - spec/geo_ruby/simple_features/polygon_spec.rb
77
83
  - spec/geo_ruby_spec.rb
78
84
  - spec/spec.opts
79
85
  - spec/spec_helper.rb
@@ -105,19 +111,19 @@ specification_version: 3
105
111
  summary: Ruby data holder for OGC Simple Features
106
112
  test_files:
107
113
  - spec/geo_ruby/shp4r/shp_spec.rb
108
- - spec/geo_ruby/base/polygon_spec.rb
109
- - spec/geo_ruby/base/linear_ring_spec.rb
110
- - spec/geo_ruby/base/geometry_factory_spec.rb
111
- - spec/geo_ruby/base/geometry_spec.rb
112
- - spec/geo_ruby/base/georss_parser_spec.rb
113
- - spec/geo_ruby/base/multi_point_spec.rb
114
- - spec/geo_ruby/base/ewkt_parser_spec.rb
115
- - spec/geo_ruby/base/line_string_spec.rb
116
- - spec/geo_ruby/base/multi_line_string_spec.rb
117
- - spec/geo_ruby/base/geometry_collection_spec.rb
118
- - spec/geo_ruby/base/ewkb_parser_spec.rb
119
- - spec/geo_ruby/base/multi_polygon_spec.rb
120
- - spec/geo_ruby/base/point_spec.rb
121
- - spec/geo_ruby/base/envelope_spec.rb
114
+ - spec/geo_ruby/simple_features/polygon_spec.rb
115
+ - spec/geo_ruby/simple_features/linear_ring_spec.rb
116
+ - spec/geo_ruby/simple_features/geometry_factory_spec.rb
117
+ - spec/geo_ruby/simple_features/geometry_spec.rb
118
+ - spec/geo_ruby/simple_features/georss_parser_spec.rb
119
+ - spec/geo_ruby/simple_features/multi_point_spec.rb
120
+ - spec/geo_ruby/simple_features/ewkt_parser_spec.rb
121
+ - spec/geo_ruby/simple_features/line_string_spec.rb
122
+ - spec/geo_ruby/simple_features/multi_line_string_spec.rb
123
+ - spec/geo_ruby/simple_features/geometry_collection_spec.rb
124
+ - spec/geo_ruby/simple_features/ewkb_parser_spec.rb
125
+ - spec/geo_ruby/simple_features/multi_polygon_spec.rb
126
+ - spec/geo_ruby/simple_features/point_spec.rb
127
+ - spec/geo_ruby/simple_features/envelope_spec.rb
122
128
  - spec/geo_ruby_spec.rb
123
129
  - spec/spec_helper.rb