rgeo 0.1.10 → 0.1.11

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.
Files changed (43) hide show
  1. data/History.rdoc +13 -0
  2. data/README.rdoc +6 -0
  3. data/Version +1 -1
  4. data/ext/geos_c_impl/factory.c +2 -2
  5. data/lib/rgeo/features/factory.rb +2 -2
  6. data/lib/rgeo/features/geometry.rb +26 -4
  7. data/lib/rgeo/features/geometry_collection.rb +12 -2
  8. data/lib/rgeo/geography/common/geometry_collection_methods.rb +12 -1
  9. data/lib/rgeo/geography/common/helper.rb +4 -4
  10. data/lib/rgeo/geography/common/line_string_methods.rb +1 -1
  11. data/lib/rgeo/geography/common/point_methods.rb +1 -1
  12. data/lib/rgeo/geography/common/polygon_methods.rb +1 -1
  13. data/lib/rgeo/geography/factories.rb +19 -6
  14. data/lib/rgeo/geography/factory.rb +31 -10
  15. data/lib/rgeo/geography/simple_mercator/feature_classes.rb +26 -26
  16. data/lib/rgeo/geography/simple_mercator/feature_methods.rb +14 -14
  17. data/lib/rgeo/geography/simple_mercator/projector.rb +1 -1
  18. data/lib/rgeo/geography/simple_spherical/calculations.rb +61 -0
  19. data/lib/rgeo/geography/simple_spherical/point_impl.rb +5 -0
  20. data/lib/rgeo/geos/factory.rb +12 -11
  21. data/tests/common/geometry_collection_tests.rb +220 -0
  22. data/tests/common/line_string_tests.rb +300 -0
  23. data/tests/common/multi_line_string_tests.rb +206 -0
  24. data/tests/common/multi_point_tests.rb +198 -0
  25. data/tests/common/multi_polygon_tests.rb +206 -0
  26. data/tests/common/point_tests.rb +281 -0
  27. data/tests/common/polygon_tests.rb +232 -0
  28. data/tests/geos/tc_geometry_collection.rb +5 -169
  29. data/tests/geos/tc_line_string.rb +4 -252
  30. data/tests/geos/tc_multi_line_string.rb +5 -154
  31. data/tests/geos/tc_multi_point.rb +5 -145
  32. data/tests/geos/tc_multi_polygon.rb +4 -151
  33. data/tests/geos/tc_point.rb +11 -213
  34. data/tests/geos/tc_polygon.rb +4 -182
  35. data/tests/simple_mercator/tc_geometry_collection.rb +62 -0
  36. data/tests/simple_mercator/tc_line_string.rb +62 -0
  37. data/tests/simple_mercator/tc_multi_line_string.rb +62 -0
  38. data/tests/simple_mercator/tc_multi_point.rb +62 -0
  39. data/tests/simple_mercator/tc_multi_polygon.rb +63 -0
  40. data/tests/simple_mercator/tc_point.rb +7 -220
  41. data/tests/simple_mercator/tc_polygon.rb +62 -0
  42. data/tests/simple_spherical/tc_point.rb +165 -0
  43. metadata +48 -9
@@ -0,0 +1,165 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for the simple spherical point implementation
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ require 'test/unit'
38
+ require 'rgeo'
39
+
40
+
41
+ module RGeo
42
+ module Tests # :nodoc:
43
+ module SimpleSpherical # :nodoc:
44
+
45
+ class TestPoint < ::Test::Unit::TestCase # :nodoc:
46
+
47
+
48
+ def setup
49
+ @factory = ::RGeo::Geography.simple_spherical
50
+ end
51
+
52
+
53
+ def test_creation
54
+ point_ = @factory.point(21, -22)
55
+ assert(!point_.respond_to?(:projection))
56
+ assert_equal(21, point_.x)
57
+ assert_equal(-22, point_.y)
58
+ assert_equal(21, point_.longitude)
59
+ assert_equal(-22, point_.latitude)
60
+ end
61
+
62
+
63
+ def test_wkt_creation
64
+ point1_ = @factory.parse_wkt('POINT(21 -22)')
65
+ assert_equal(21, point1_.x)
66
+ assert_equal(-22, point1_.y)
67
+ assert_equal(21, point1_.longitude)
68
+ assert_equal(-22, point1_.latitude)
69
+ end
70
+
71
+
72
+ def test_clone
73
+ point1_ = @factory.point(11, 12)
74
+ point2_ = point1_.clone
75
+ assert_equal(point1_, point2_)
76
+ point3_ = @factory.point(13, 12)
77
+ point4_ = point3_.dup
78
+ assert_equal(point3_, point4_)
79
+ assert_not_equal(point2_, point4_)
80
+ end
81
+
82
+
83
+ def test_type_check
84
+ point_ = @factory.point(21, 22)
85
+ assert(::RGeo::Features::Geometry.check_type(point_))
86
+ assert(::RGeo::Features::Point.check_type(point_))
87
+ assert(!::RGeo::Features::GeometryCollection.check_type(point_))
88
+ assert(!::RGeo::Features::Curve.check_type(point_))
89
+ end
90
+
91
+
92
+ def test_geometry_type
93
+ point_ = @factory.point(11, 12)
94
+ assert_equal(::RGeo::Features::Point, point_.geometry_type)
95
+ end
96
+
97
+
98
+ def test_dimension
99
+ point_ = @factory.point(11, 12)
100
+ assert_equal(0, point_.dimension)
101
+ end
102
+
103
+
104
+ def test_srid
105
+ point_ = @factory.point(11, 12)
106
+ assert_equal(4326, point_.srid)
107
+ end
108
+
109
+
110
+ def test_envelope
111
+ point_ = @factory.point(11, 12)
112
+ assert_equal(point_, point_.envelope)
113
+ end
114
+
115
+
116
+ def test_as_text_wkt_round_trip
117
+ point1_ = @factory.point(11, 12)
118
+ text_ = point1_.as_text
119
+ point2_ = @factory.parse_wkt(text_)
120
+ assert_equal(point2_, point1_)
121
+ end
122
+
123
+
124
+ def test_as_binary_wkb_round_trip
125
+ point1_ = @factory.point(211, 12)
126
+ binary_ = point1_.as_binary
127
+ point2_ = @factory.parse_wkb(binary_)
128
+ assert_equal(point2_, point1_)
129
+ end
130
+
131
+
132
+ def test_is_empty
133
+ point1_ = @factory.point(0, 0)
134
+ assert(!point1_.is_empty?)
135
+ end
136
+
137
+
138
+ def test_is_simple
139
+ point1_ = @factory.point(0, 0)
140
+ assert(point1_.is_simple?)
141
+ end
142
+
143
+
144
+ def test_boundary
145
+ point_ = @factory.point(11, 12)
146
+ boundary_ = point_.boundary
147
+ assert_equal(::RGeo::Features::GeometryCollection, boundary_.geometry_type)
148
+ assert(boundary_.is_empty?)
149
+ end
150
+
151
+
152
+ def test_equals
153
+ point1_ = @factory.point(11, 12)
154
+ point2_ = @factory.point(11, 12)
155
+ point3_ = @factory.point(13, 12)
156
+ assert_equal(point1_, point2_)
157
+ assert_not_equal(point1_, point3_)
158
+ end
159
+
160
+
161
+ end
162
+
163
+ end
164
+ end
165
+ end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgeo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 10
10
- version: 0.1.10
8
+ - 11
9
+ version: 0.1.11
11
10
  platform: ruby
12
11
  authors:
13
12
  - Daniel Azuma
@@ -15,10 +14,24 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-10-19 00:00:00 -07:00
17
+ date: 2010-10-21 00:00:00 -07:00
19
18
  default_executable:
20
- dependencies: []
21
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: json
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 4
31
+ - 6
32
+ version: 1.4.6
33
+ type: :runtime
34
+ version_requirements: *id001
22
35
  description: RGeo is a spatial data library for Ruby. It provides an implementation of the Open Geospatial Consortium's Simple Features Specification, used by most standard spatial/geographic data storage systems such as PostGIS. It also provides a suite of useful tools for writing location-based applications using Ruby-based frameworks such as Ruby On Rails.
23
36
  email: dazuma@gmail.com
24
37
  executables: []
@@ -80,6 +93,13 @@ files:
80
93
  - lib/rgeo.rb
81
94
  - History.rdoc
82
95
  - README.rdoc
96
+ - tests/common/geometry_collection_tests.rb
97
+ - tests/common/line_string_tests.rb
98
+ - tests/common/multi_line_string_tests.rb
99
+ - tests/common/multi_point_tests.rb
100
+ - tests/common/multi_polygon_tests.rb
101
+ - tests/common/point_tests.rb
102
+ - tests/common/polygon_tests.rb
83
103
  - tests/geos/tc_factory.rb
84
104
  - tests/geos/tc_geometry_collection.rb
85
105
  - tests/geos/tc_line_string.rb
@@ -89,8 +109,15 @@ files:
89
109
  - tests/geos/tc_multi_polygon.rb
90
110
  - tests/geos/tc_point.rb
91
111
  - tests/geos/tc_polygon.rb
112
+ - tests/simple_mercator/tc_geometry_collection.rb
113
+ - tests/simple_mercator/tc_line_string.rb
114
+ - tests/simple_mercator/tc_multi_line_string.rb
115
+ - tests/simple_mercator/tc_multi_point.rb
116
+ - tests/simple_mercator/tc_multi_polygon.rb
92
117
  - tests/simple_mercator/tc_point.rb
118
+ - tests/simple_mercator/tc_polygon.rb
93
119
  - tests/simple_mercator/tc_window.rb
120
+ - tests/simple_spherical/tc_point.rb
94
121
  - tests/tc_geojson.rb
95
122
  - tests/tc_oneoff.rb
96
123
  - ext/geos_c_impl/extconf.rb
@@ -124,7 +151,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
151
  requirements:
125
152
  - - ">="
126
153
  - !ruby/object:Gem::Version
127
- hash: 57
128
154
  segments:
129
155
  - 1
130
156
  - 8
@@ -135,7 +161,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
161
  requirements:
136
162
  - - ">="
137
163
  - !ruby/object:Gem::Version
138
- hash: 3
139
164
  segments:
140
165
  - 0
141
166
  version: "0"
@@ -145,8 +170,15 @@ rubyforge_project: virtuoso
145
170
  rubygems_version: 1.3.7
146
171
  signing_key:
147
172
  specification_version: 3
148
- summary: Spatial data library for Ruby.
173
+ summary: RGeo is a spatial data library for Ruby.
149
174
  test_files:
175
+ - tests/common/geometry_collection_tests.rb
176
+ - tests/common/line_string_tests.rb
177
+ - tests/common/multi_line_string_tests.rb
178
+ - tests/common/multi_point_tests.rb
179
+ - tests/common/multi_polygon_tests.rb
180
+ - tests/common/point_tests.rb
181
+ - tests/common/polygon_tests.rb
150
182
  - tests/geos/tc_factory.rb
151
183
  - tests/geos/tc_geometry_collection.rb
152
184
  - tests/geos/tc_line_string.rb
@@ -156,7 +188,14 @@ test_files:
156
188
  - tests/geos/tc_multi_polygon.rb
157
189
  - tests/geos/tc_point.rb
158
190
  - tests/geos/tc_polygon.rb
191
+ - tests/simple_mercator/tc_geometry_collection.rb
192
+ - tests/simple_mercator/tc_line_string.rb
193
+ - tests/simple_mercator/tc_multi_line_string.rb
194
+ - tests/simple_mercator/tc_multi_point.rb
195
+ - tests/simple_mercator/tc_multi_polygon.rb
159
196
  - tests/simple_mercator/tc_point.rb
197
+ - tests/simple_mercator/tc_polygon.rb
160
198
  - tests/simple_mercator/tc_window.rb
199
+ - tests/simple_spherical/tc_point.rb
161
200
  - tests/tc_geojson.rb
162
201
  - tests/tc_oneoff.rb