rgeo 0.1.17 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/History.rdoc +8 -0
  2. data/README.rdoc +40 -21
  3. data/Version +1 -1
  4. data/lib/rgeo.rb +1 -0
  5. data/lib/rgeo/cartesian.rb +1 -0
  6. data/lib/rgeo/cartesian/analysis.rb +115 -0
  7. data/lib/rgeo/cartesian/feature_classes.rb +0 -14
  8. data/lib/rgeo/features/factory.rb +5 -5
  9. data/lib/rgeo/features/factory_generator.rb +10 -0
  10. data/lib/rgeo/geo_json/coder.rb +49 -14
  11. data/lib/rgeo/geo_json/interface.rb +6 -6
  12. data/lib/rgeo/shapefile.rb +60 -0
  13. data/lib/rgeo/shapefile/reader.rb +898 -0
  14. data/tests/shapefile/shapelib_testcases/readme.txt +11 -0
  15. data/tests/shapefile/shapelib_testcases/test.dbf +0 -0
  16. data/tests/shapefile/shapelib_testcases/test.shp +0 -0
  17. data/tests/shapefile/shapelib_testcases/test.shx +0 -0
  18. data/tests/shapefile/shapelib_testcases/test0.shp +0 -0
  19. data/tests/shapefile/shapelib_testcases/test0.shx +0 -0
  20. data/tests/shapefile/shapelib_testcases/test1.shp +0 -0
  21. data/tests/shapefile/shapelib_testcases/test1.shx +0 -0
  22. data/tests/shapefile/shapelib_testcases/test10.shp +0 -0
  23. data/tests/shapefile/shapelib_testcases/test10.shx +0 -0
  24. data/tests/shapefile/shapelib_testcases/test11.shp +0 -0
  25. data/tests/shapefile/shapelib_testcases/test11.shx +0 -0
  26. data/tests/shapefile/shapelib_testcases/test12.shp +0 -0
  27. data/tests/shapefile/shapelib_testcases/test12.shx +0 -0
  28. data/tests/shapefile/shapelib_testcases/test13.shp +0 -0
  29. data/tests/shapefile/shapelib_testcases/test13.shx +0 -0
  30. data/tests/shapefile/shapelib_testcases/test2.shp +0 -0
  31. data/tests/shapefile/shapelib_testcases/test2.shx +0 -0
  32. data/tests/shapefile/shapelib_testcases/test3.shp +0 -0
  33. data/tests/shapefile/shapelib_testcases/test3.shx +0 -0
  34. data/tests/shapefile/shapelib_testcases/test4.shp +0 -0
  35. data/tests/shapefile/shapelib_testcases/test4.shx +0 -0
  36. data/tests/shapefile/shapelib_testcases/test5.shp +0 -0
  37. data/tests/shapefile/shapelib_testcases/test5.shx +0 -0
  38. data/tests/shapefile/shapelib_testcases/test6.shp +0 -0
  39. data/tests/shapefile/shapelib_testcases/test6.shx +0 -0
  40. data/tests/shapefile/shapelib_testcases/test7.shp +0 -0
  41. data/tests/shapefile/shapelib_testcases/test7.shx +0 -0
  42. data/tests/shapefile/shapelib_testcases/test8.shp +0 -0
  43. data/tests/shapefile/shapelib_testcases/test8.shx +0 -0
  44. data/tests/shapefile/shapelib_testcases/test9.shp +0 -0
  45. data/tests/shapefile/shapelib_testcases/test9.shx +0 -0
  46. data/tests/shapefile/tc_shapelib_tests.rb +527 -0
  47. data/tests/tc_cartesian_analysis.rb +107 -0
  48. data/tests/tc_oneoff.rb +1 -0
  49. metadata +118 -12
@@ -0,0 +1,107 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for basic GeoJSON usage
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
+
44
+ class TestCartesianAnalysis < ::Test::Unit::TestCase # :nodoc:
45
+
46
+
47
+ def setup
48
+ @factory = ::RGeo::Cartesian.simple_factory
49
+ end
50
+
51
+
52
+ def test_ring_direction_clockwise_triangle
53
+ p1_ = @factory.point(1, 1)
54
+ p2_ = @factory.point(2, 4)
55
+ p3_ = @factory.point(5, 2)
56
+ ring_ = @factory.line_string([p1_, p2_, p3_, p1_])
57
+ assert_equal(-1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
58
+ end
59
+
60
+
61
+ def test_ring_direction_counterclockwise_triangle
62
+ p1_ = @factory.point(1, 1)
63
+ p2_ = @factory.point(2, 4)
64
+ p3_ = @factory.point(5, 2)
65
+ ring_ = @factory.line_string([p1_, p3_, p2_, p1_])
66
+ assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
67
+ end
68
+
69
+
70
+ def test_ring_direction_clockwise_puckered_quad
71
+ p1_ = @factory.point(1, 1)
72
+ p2_ = @factory.point(2, 6)
73
+ p3_ = @factory.point(3, 3)
74
+ p4_ = @factory.point(5, 2)
75
+ ring_ = @factory.line_string([p1_, p2_, p3_, p4_, p1_])
76
+ assert_equal(-1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
77
+ end
78
+
79
+
80
+ def test_ring_direction_counterclockwise_puckered_quad
81
+ p1_ = @factory.point(1, 1)
82
+ p2_ = @factory.point(2, 6)
83
+ p3_ = @factory.point(3, 3)
84
+ p4_ = @factory.point(5, 2)
85
+ ring_ = @factory.line_string([p1_, p4_, p3_, p2_, p1_])
86
+ assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
87
+ end
88
+
89
+
90
+ def test_ring_direction_counterclockwise_near_circle
91
+ p1_ = @factory.point(0, -3)
92
+ p2_ = @factory.point(2, -2)
93
+ p3_ = @factory.point(3, 0)
94
+ p4_ = @factory.point(2, 2)
95
+ p5_ = @factory.point(0, 3)
96
+ p6_ = @factory.point(-2, 2)
97
+ p7_ = @factory.point(-3, 0)
98
+ p8_ = @factory.point(-2, -2)
99
+ ring_ = @factory.line_string([p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_, p1_])
100
+ assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
101
+ end
102
+
103
+
104
+ end
105
+
106
+ end
107
+ end
data/tests/tc_oneoff.rb CHANGED
@@ -54,6 +54,7 @@ module RGeo
54
54
 
55
55
 
56
56
  def test_dummy
57
+ RGeo::Shapefile
57
58
  end
58
59
 
59
60
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 17
9
- version: 0.1.17
8
+ - 18
9
+ version: 0.1.18
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Azuma
@@ -14,10 +14,84 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-20 00:00:00 -08:00
17
+ date: 2010-11-22 00:00:00 -08:00
18
18
  default_executable:
19
- dependencies: []
20
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activerecord
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 3
30
+ - 0
31
+ - 3
32
+ version: 3.0.3
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: arel
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ - 0
46
+ - 3
47
+ version: 2.0.3
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: mysql
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 2
60
+ - 8
61
+ - 1
62
+ version: 2.8.1
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: mysql2
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ - 6
76
+ - 2
77
+ version: 0.6.2
78
+ type: :development
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: json
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ segments:
89
+ - 1
90
+ - 4
91
+ - 6
92
+ version: 1.4.6
93
+ type: :development
94
+ version_requirements: *id005
21
95
  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.
22
96
  email: dazuma@gmail.com
23
97
  executables: []
@@ -35,6 +109,7 @@ files:
35
109
  - lib/rgeo/active_record/common.rb
36
110
  - lib/rgeo/active_record/mysql_common.rb
37
111
  - lib/rgeo/all.rb
112
+ - lib/rgeo/cartesian/analysis.rb
38
113
  - lib/rgeo/cartesian/calculations.rb
39
114
  - lib/rgeo/cartesian/factory.rb
40
115
  - lib/rgeo/cartesian/feature_classes.rb
@@ -88,6 +163,8 @@ files:
88
163
  - lib/rgeo/impl_helpers/basic_polygon_methods.rb
89
164
  - lib/rgeo/impl_helpers/math.rb
90
165
  - lib/rgeo/impl_helpers.rb
166
+ - lib/rgeo/shapefile/reader.rb
167
+ - lib/rgeo/shapefile.rb
91
168
  - lib/rgeo/version.rb
92
169
  - lib/rgeo/wkrep/wkb_generator.rb
93
170
  - lib/rgeo/wkrep/wkb_parser.rb
@@ -114,6 +191,7 @@ files:
114
191
  - tests/geos/tc_multi_polygon.rb
115
192
  - tests/geos/tc_point.rb
116
193
  - tests/geos/tc_polygon.rb
194
+ - tests/shapefile/tc_shapelib_tests.rb
117
195
  - tests/simple_cartesian/tc_calculations.rb
118
196
  - tests/simple_cartesian/tc_geometry_collection.rb
119
197
  - tests/simple_cartesian/tc_line_string.rb
@@ -138,6 +216,7 @@ files:
138
216
  - tests/simple_spherical/tc_multi_polygon.rb
139
217
  - tests/simple_spherical/tc_point.rb
140
218
  - tests/simple_spherical/tc_polygon.rb
219
+ - tests/tc_cartesian_analysis.rb
141
220
  - tests/tc_geojson.rb
142
221
  - tests/tc_oneoff.rb
143
222
  - tests/wkrep/tc_wkb_generator.rb
@@ -145,6 +224,38 @@ files:
145
224
  - tests/wkrep/tc_wkt_generator.rb
146
225
  - tests/wkrep/tc_wkt_parser.rb
147
226
  - tests/active_record/readme.txt
227
+ - tests/shapefile/shapelib_testcases/readme.txt
228
+ - tests/shapefile/shapelib_testcases/test.shp
229
+ - tests/shapefile/shapelib_testcases/test0.shp
230
+ - tests/shapefile/shapelib_testcases/test1.shp
231
+ - tests/shapefile/shapelib_testcases/test10.shp
232
+ - tests/shapefile/shapelib_testcases/test11.shp
233
+ - tests/shapefile/shapelib_testcases/test12.shp
234
+ - tests/shapefile/shapelib_testcases/test13.shp
235
+ - tests/shapefile/shapelib_testcases/test2.shp
236
+ - tests/shapefile/shapelib_testcases/test3.shp
237
+ - tests/shapefile/shapelib_testcases/test4.shp
238
+ - tests/shapefile/shapelib_testcases/test5.shp
239
+ - tests/shapefile/shapelib_testcases/test6.shp
240
+ - tests/shapefile/shapelib_testcases/test7.shp
241
+ - tests/shapefile/shapelib_testcases/test8.shp
242
+ - tests/shapefile/shapelib_testcases/test9.shp
243
+ - tests/shapefile/shapelib_testcases/test.shx
244
+ - tests/shapefile/shapelib_testcases/test0.shx
245
+ - tests/shapefile/shapelib_testcases/test1.shx
246
+ - tests/shapefile/shapelib_testcases/test10.shx
247
+ - tests/shapefile/shapelib_testcases/test11.shx
248
+ - tests/shapefile/shapelib_testcases/test12.shx
249
+ - tests/shapefile/shapelib_testcases/test13.shx
250
+ - tests/shapefile/shapelib_testcases/test2.shx
251
+ - tests/shapefile/shapelib_testcases/test3.shx
252
+ - tests/shapefile/shapelib_testcases/test4.shx
253
+ - tests/shapefile/shapelib_testcases/test5.shx
254
+ - tests/shapefile/shapelib_testcases/test6.shx
255
+ - tests/shapefile/shapelib_testcases/test7.shx
256
+ - tests/shapefile/shapelib_testcases/test8.shx
257
+ - tests/shapefile/shapelib_testcases/test9.shx
258
+ - tests/shapefile/shapelib_testcases/test.dbf
148
259
  - ext/geos_c_impl/extconf.rb
149
260
  - ext/geos_c_impl/factory.c
150
261
  - ext/geos_c_impl/geometry.c
@@ -197,13 +308,6 @@ specification_version: 3
197
308
  summary: RGeo is a spatial data library for Ruby.
198
309
  test_files:
199
310
  - tests/active_record/tc_mysqlspatial.rb
200
- - tests/common/geometry_collection_tests.rb
201
- - tests/common/line_string_tests.rb
202
- - tests/common/multi_line_string_tests.rb
203
- - tests/common/multi_point_tests.rb
204
- - tests/common/multi_polygon_tests.rb
205
- - tests/common/point_tests.rb
206
- - tests/common/polygon_tests.rb
207
311
  - tests/geos/tc_factory.rb
208
312
  - tests/geos/tc_geometry_collection.rb
209
313
  - tests/geos/tc_line_string.rb
@@ -213,6 +317,7 @@ test_files:
213
317
  - tests/geos/tc_multi_polygon.rb
214
318
  - tests/geos/tc_point.rb
215
319
  - tests/geos/tc_polygon.rb
320
+ - tests/shapefile/tc_shapelib_tests.rb
216
321
  - tests/simple_cartesian/tc_calculations.rb
217
322
  - tests/simple_cartesian/tc_geometry_collection.rb
218
323
  - tests/simple_cartesian/tc_line_string.rb
@@ -237,6 +342,7 @@ test_files:
237
342
  - tests/simple_spherical/tc_multi_polygon.rb
238
343
  - tests/simple_spherical/tc_point.rb
239
344
  - tests/simple_spherical/tc_polygon.rb
345
+ - tests/tc_cartesian_analysis.rb
240
346
  - tests/tc_geojson.rb
241
347
  - tests/tc_oneoff.rb
242
348
  - tests/wkrep/tc_wkb_generator.rb