rgeo 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/History.rdoc +6 -0
  2. data/README.rdoc +1 -1
  3. data/Version +1 -1
  4. data/ext/geos_c_impl/extconf.rb +13 -13
  5. data/ext/geos_c_impl/factory.c +30 -18
  6. data/ext/geos_c_impl/factory.h +18 -12
  7. data/ext/geos_c_impl/geometry.c +11 -11
  8. data/ext/geos_c_impl/geometry.h +7 -7
  9. data/ext/geos_c_impl/geometry_collection.c +15 -15
  10. data/ext/geos_c_impl/geometry_collection.h +8 -8
  11. data/ext/geos_c_impl/line_string.c +14 -14
  12. data/ext/geos_c_impl/line_string.h +7 -7
  13. data/ext/geos_c_impl/main.c +7 -7
  14. data/ext/geos_c_impl/point.c +9 -9
  15. data/ext/geos_c_impl/point.h +7 -7
  16. data/ext/geos_c_impl/polygon.c +9 -9
  17. data/ext/geos_c_impl/polygon.h +7 -7
  18. data/ext/geos_c_impl/preface.h +7 -7
  19. data/ext/proj4_c_impl/extconf.rb +13 -13
  20. data/ext/proj4_c_impl/main.c +12 -12
  21. data/lib/rgeo.rb +26 -26
  22. data/lib/rgeo/cartesian.rb +12 -12
  23. data/lib/rgeo/cartesian/analysis.rb +26 -26
  24. data/lib/rgeo/cartesian/bounding_box.rb +83 -83
  25. data/lib/rgeo/cartesian/calculations.rb +36 -36
  26. data/lib/rgeo/cartesian/factory.rb +78 -78
  27. data/lib/rgeo/cartesian/feature_classes.rb +74 -74
  28. data/lib/rgeo/cartesian/feature_methods.rb +34 -34
  29. data/lib/rgeo/cartesian/interface.rb +33 -33
  30. data/lib/rgeo/coord_sys.rb +15 -15
  31. data/lib/rgeo/coord_sys/cs/entities.rb +533 -534
  32. data/lib/rgeo/coord_sys/cs/factories.rb +69 -69
  33. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +44 -44
  34. data/lib/rgeo/coord_sys/proj4.rb +85 -85
  35. data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +31 -31
  36. data/lib/rgeo/coord_sys/srs_database/interface.rb +44 -44
  37. data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +31 -31
  38. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +31 -31
  39. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +29 -29
  40. data/lib/rgeo/error.rb +17 -17
  41. data/lib/rgeo/feature.rb +15 -15
  42. data/lib/rgeo/feature/curve.rb +58 -58
  43. data/lib/rgeo/feature/factory.rb +84 -84
  44. data/lib/rgeo/feature/factory_generator.rb +32 -32
  45. data/lib/rgeo/feature/geometry.rb +215 -215
  46. data/lib/rgeo/feature/geometry_collection.rb +46 -46
  47. data/lib/rgeo/feature/line.rb +21 -21
  48. data/lib/rgeo/feature/line_string.rb +35 -35
  49. data/lib/rgeo/feature/linear_ring.rb +20 -20
  50. data/lib/rgeo/feature/mixins.rb +61 -61
  51. data/lib/rgeo/feature/multi_curve.rb +37 -37
  52. data/lib/rgeo/feature/multi_line_string.rb +20 -20
  53. data/lib/rgeo/feature/multi_point.rb +22 -22
  54. data/lib/rgeo/feature/multi_polygon.rb +28 -28
  55. data/lib/rgeo/feature/multi_surface.rb +39 -39
  56. data/lib/rgeo/feature/point.rb +42 -42
  57. data/lib/rgeo/feature/polygon.rb +50 -50
  58. data/lib/rgeo/feature/surface.rb +42 -42
  59. data/lib/rgeo/feature/types.rb +58 -58
  60. data/lib/rgeo/geographic.rb +14 -14
  61. data/lib/rgeo/geographic/factory.rb +87 -87
  62. data/lib/rgeo/geographic/interface.rb +55 -55
  63. data/lib/rgeo/geographic/proj4_projector.rb +35 -35
  64. data/lib/rgeo/geographic/projected_feature_classes.rb +95 -95
  65. data/lib/rgeo/geographic/projected_feature_methods.rb +81 -81
  66. data/lib/rgeo/geographic/projected_window.rb +103 -103
  67. data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -32
  68. data/lib/rgeo/geographic/spherical_feature_classes.rb +93 -93
  69. data/lib/rgeo/geographic/spherical_feature_methods.rb +25 -25
  70. data/lib/rgeo/geographic/spherical_math.rb +58 -58
  71. data/lib/rgeo/geos.rb +22 -17
  72. data/lib/rgeo/geos/factory.rb +93 -93
  73. data/lib/rgeo/geos/ffi_classes.rb +306 -231
  74. data/lib/rgeo/geos/ffi_factory.rb +100 -96
  75. data/lib/rgeo/geos/impl_additions.rb +22 -22
  76. data/lib/rgeo/geos/interface.rb +45 -45
  77. data/lib/rgeo/geos/zm_factory.rb +90 -90
  78. data/lib/rgeo/geos/zm_impl.rb +167 -167
  79. data/lib/rgeo/impl_helper.rb +11 -11
  80. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +71 -71
  81. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +29 -29
  82. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +61 -61
  83. data/lib/rgeo/impl_helper/basic_point_methods.rb +43 -43
  84. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +35 -35
  85. data/lib/rgeo/impl_helper/math.rb +13 -13
  86. data/lib/rgeo/version.rb +10 -10
  87. data/lib/rgeo/wkrep.rb +16 -16
  88. data/lib/rgeo/wkrep/wkb_generator.rb +51 -51
  89. data/lib/rgeo/wkrep/wkb_parser.rb +52 -52
  90. data/lib/rgeo/wkrep/wkt_generator.rb +51 -51
  91. data/lib/rgeo/wkrep/wkt_parser.rb +66 -66
  92. data/lib/rgeo/yaml.rb +14 -14
  93. data/test/common/geometry_collection_tests.rb +53 -53
  94. data/test/common/line_string_tests.rb +57 -57
  95. data/test/common/multi_line_string_tests.rb +43 -43
  96. data/test/common/multi_point_tests.rb +43 -43
  97. data/test/common/multi_polygon_tests.rb +43 -43
  98. data/test/common/point_tests.rb +75 -75
  99. data/test/common/polygon_tests.rb +37 -37
  100. data/test/coord_sys/tc_active_record_table.rb +25 -25
  101. data/test/coord_sys/tc_ogc_cs.rb +72 -72
  102. data/test/coord_sys/tc_proj4.rb +51 -51
  103. data/test/coord_sys/tc_proj4_srs_data.rb +17 -17
  104. data/test/coord_sys/tc_sr_org.rb +15 -15
  105. data/test/coord_sys/tc_url_reader.rb +19 -19
  106. data/test/geos_capi/tc_factory.rb +21 -21
  107. data/test/geos_capi/tc_geometry_collection.rb +15 -15
  108. data/test/geos_capi/tc_line_string.rb +15 -15
  109. data/test/geos_capi/tc_misc.rb +33 -22
  110. data/test/geos_capi/tc_multi_line_string.rb +15 -15
  111. data/test/geos_capi/tc_multi_point.rb +15 -15
  112. data/test/geos_capi/tc_multi_polygon.rb +15 -15
  113. data/test/geos_capi/tc_parsing_unparsing.rb +19 -19
  114. data/test/geos_capi/tc_point.rb +21 -21
  115. data/test/geos_capi/tc_polygon.rb +19 -19
  116. data/test/geos_capi/tc_zmfactory.rb +17 -17
  117. data/test/geos_ffi/tc_factory.rb +21 -21
  118. data/test/geos_ffi/tc_geometry_collection.rb +15 -15
  119. data/test/geos_ffi/tc_line_string.rb +15 -15
  120. data/test/geos_ffi/tc_misc.rb +49 -15
  121. data/test/geos_ffi/tc_multi_line_string.rb +15 -15
  122. data/test/geos_ffi/tc_multi_point.rb +15 -15
  123. data/test/geos_ffi/tc_multi_polygon.rb +15 -15
  124. data/test/geos_ffi/tc_parsing_unparsing.rb +19 -19
  125. data/test/geos_ffi/tc_point.rb +21 -21
  126. data/test/geos_ffi/tc_polygon.rb +19 -19
  127. data/test/geos_ffi/tc_zmfactory.rb +17 -17
  128. data/test/projected_geographic/tc_geometry_collection.rb +15 -15
  129. data/test/projected_geographic/tc_line_string.rb +15 -15
  130. data/test/projected_geographic/tc_multi_line_string.rb +15 -15
  131. data/test/projected_geographic/tc_multi_point.rb +15 -15
  132. data/test/projected_geographic/tc_multi_polygon.rb +15 -15
  133. data/test/projected_geographic/tc_point.rb +23 -23
  134. data/test/projected_geographic/tc_polygon.rb +15 -15
  135. data/test/simple_cartesian/tc_calculations.rb +31 -31
  136. data/test/simple_cartesian/tc_geometry_collection.rb +17 -17
  137. data/test/simple_cartesian/tc_line_string.rb +17 -17
  138. data/test/simple_cartesian/tc_multi_line_string.rb +17 -17
  139. data/test/simple_cartesian/tc_multi_point.rb +17 -17
  140. data/test/simple_cartesian/tc_multi_polygon.rb +17 -17
  141. data/test/simple_cartesian/tc_point.rb +21 -21
  142. data/test/simple_cartesian/tc_polygon.rb +17 -17
  143. data/test/simple_mercator/tc_geometry_collection.rb +15 -15
  144. data/test/simple_mercator/tc_line_string.rb +15 -15
  145. data/test/simple_mercator/tc_multi_line_string.rb +15 -15
  146. data/test/simple_mercator/tc_multi_point.rb +15 -15
  147. data/test/simple_mercator/tc_multi_polygon.rb +15 -15
  148. data/test/simple_mercator/tc_point.rb +23 -23
  149. data/test/simple_mercator/tc_polygon.rb +15 -15
  150. data/test/simple_mercator/tc_window.rb +50 -50
  151. data/test/spherical_geographic/tc_calculations.rb +47 -47
  152. data/test/spherical_geographic/tc_geometry_collection.rb +17 -17
  153. data/test/spherical_geographic/tc_line_string.rb +17 -17
  154. data/test/spherical_geographic/tc_multi_line_string.rb +17 -17
  155. data/test/spherical_geographic/tc_multi_point.rb +17 -17
  156. data/test/spherical_geographic/tc_multi_polygon.rb +17 -17
  157. data/test/spherical_geographic/tc_point.rb +23 -23
  158. data/test/spherical_geographic/tc_polygon.rb +17 -17
  159. data/test/tc_cartesian_analysis.rb +23 -23
  160. data/test/tc_mixins.rb +39 -39
  161. data/test/tc_oneoff.rb +15 -15
  162. data/test/tc_types.rb +17 -17
  163. data/test/wkrep/tc_wkb_generator.rb +67 -67
  164. data/test/wkrep/tc_wkb_parser.rb +73 -73
  165. data/test/wkrep/tc_wkt_generator.rb +75 -75
  166. data/test/wkrep/tc_wkt_parser.rb +97 -97
  167. metadata +3 -3
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Tests for basic GeoJSON usage
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2010 Daniel Azuma
7
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -40,15 +40,15 @@ require 'rgeo'
40
40
 
41
41
  module RGeo
42
42
  module Tests # :nodoc:
43
-
43
+
44
44
  class TestCartesianAnalysis < ::Test::Unit::TestCase # :nodoc:
45
-
46
-
45
+
46
+
47
47
  def setup
48
48
  @factory = ::RGeo::Cartesian.simple_factory
49
49
  end
50
-
51
-
50
+
51
+
52
52
  def test_ring_direction_clockwise_triangle
53
53
  p1_ = @factory.point(1, 1)
54
54
  p2_ = @factory.point(2, 4)
@@ -56,8 +56,8 @@ module RGeo
56
56
  ring_ = @factory.line_string([p1_, p2_, p3_, p1_])
57
57
  assert_equal(-1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
58
58
  end
59
-
60
-
59
+
60
+
61
61
  def test_ring_direction_counterclockwise_triangle
62
62
  p1_ = @factory.point(1, 1)
63
63
  p2_ = @factory.point(2, 4)
@@ -65,8 +65,8 @@ module RGeo
65
65
  ring_ = @factory.line_string([p1_, p3_, p2_, p1_])
66
66
  assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
67
67
  end
68
-
69
-
68
+
69
+
70
70
  def test_ring_direction_clockwise_puckered_quad
71
71
  p1_ = @factory.point(1, 1)
72
72
  p2_ = @factory.point(2, 6)
@@ -75,8 +75,8 @@ module RGeo
75
75
  ring_ = @factory.line_string([p1_, p2_, p3_, p4_, p1_])
76
76
  assert_equal(-1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
77
77
  end
78
-
79
-
78
+
79
+
80
80
  def test_ring_direction_counterclockwise_puckered_quad
81
81
  p1_ = @factory.point(1, 1)
82
82
  p2_ = @factory.point(2, 6)
@@ -85,8 +85,8 @@ module RGeo
85
85
  ring_ = @factory.line_string([p1_, p4_, p3_, p2_, p1_])
86
86
  assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
87
87
  end
88
-
89
-
88
+
89
+
90
90
  def test_ring_direction_counterclockwise_near_circle
91
91
  p1_ = @factory.point(0, -3)
92
92
  p2_ = @factory.point(2, -2)
@@ -99,9 +99,9 @@ module RGeo
99
99
  ring_ = @factory.line_string([p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_, p1_])
100
100
  assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
101
101
  end
102
-
103
-
102
+
103
+
104
104
  end
105
-
105
+
106
106
  end
107
107
  end
data/test/tc_mixins.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Tests for mixin system
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2010 Daniel Azuma
7
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -40,25 +40,25 @@ require 'rgeo'
40
40
 
41
41
  module RGeo
42
42
  module Tests # :nodoc:
43
-
43
+
44
44
  class TestMixins < ::Test::Unit::TestCase # :nodoc:
45
-
46
-
45
+
46
+
47
47
  module Mixin1 # :nodoc:
48
48
  def mixin1_method
49
49
  end
50
50
  end
51
-
51
+
52
52
  module Mixin2 # :nodoc:
53
53
  def mixin2_method
54
54
  end
55
55
  end
56
-
56
+
57
57
  ::RGeo::Feature::MixinCollection::GLOBAL.for_type(::RGeo::Feature::Point).add(Mixin1)
58
58
  ::RGeo::Feature::MixinCollection::GLOBAL.for_type(::RGeo::Feature::GeometryCollection).add(Mixin1)
59
59
  ::RGeo::Feature::MixinCollection::GLOBAL.for_type(::RGeo::Feature::MultiCurve).add(Mixin2)
60
-
61
-
60
+
61
+
62
62
  def test_basic_mixin_cartesian
63
63
  factory_ = ::RGeo::Cartesian.simple_factory
64
64
  assert_equal(::RGeo::Cartesian::PointImpl, factory_.point(1, 1).class)
@@ -67,8 +67,8 @@ module RGeo
67
67
  assert(factory_.point(1, 1).respond_to?(:mixin1_method))
68
68
  assert(!factory_.point(1, 1).respond_to?(:mixin2_method))
69
69
  end
70
-
71
-
70
+
71
+
72
72
  def test_inherited_mixin_cartesian
73
73
  factory_ = ::RGeo::Cartesian.simple_factory
74
74
  assert(factory_.collection([]).class.include?(Mixin1))
@@ -80,10 +80,10 @@ module RGeo
80
80
  assert(factory_.multi_line_string([]).respond_to?(:mixin1_method))
81
81
  assert(factory_.multi_line_string([]).respond_to?(:mixin2_method))
82
82
  end
83
-
84
-
83
+
84
+
85
85
  if ::RGeo::Geos.capi_supported?
86
-
86
+
87
87
  def test_basic_mixin_geos_capi
88
88
  factory_ = ::RGeo::Geos.factory(:native_interface => :capi)
89
89
  assert_equal(::RGeo::Geos::PointImpl, factory_.point(1, 1).class)
@@ -92,8 +92,8 @@ module RGeo
92
92
  assert(factory_.point(1, 1).respond_to?(:mixin1_method))
93
93
  assert(!factory_.point(1, 1).respond_to?(:mixin2_method))
94
94
  end
95
-
96
-
95
+
96
+
97
97
  def test_inherited_mixin_geos_capi
98
98
  factory_ = ::RGeo::Geos.factory(:native_interface => :capi)
99
99
  assert(factory_.collection([]).class.include?(Mixin1))
@@ -105,12 +105,12 @@ module RGeo
105
105
  assert(factory_.multi_line_string([]).respond_to?(:mixin1_method))
106
106
  assert(factory_.multi_line_string([]).respond_to?(:mixin2_method))
107
107
  end
108
-
108
+
109
109
  end
110
-
111
-
110
+
111
+
112
112
  if ::RGeo::Geos.ffi_supported?
113
-
113
+
114
114
  def test_basic_mixin_geos_ffi
115
115
  factory_ = ::RGeo::Geos.factory(:native_interface => :ffi)
116
116
  assert_equal(::RGeo::Geos::FFIPointImpl, factory_.point(1, 1).class)
@@ -119,8 +119,8 @@ module RGeo
119
119
  assert(factory_.point(1, 1).respond_to?(:mixin1_method))
120
120
  assert(!factory_.point(1, 1).respond_to?(:mixin2_method))
121
121
  end
122
-
123
-
122
+
123
+
124
124
  def test_inherited_mixin_geos_ffi
125
125
  factory_ = ::RGeo::Geos.factory(:native_interface => :ffi)
126
126
  assert(factory_.collection([]).class.include?(Mixin1))
@@ -132,10 +132,10 @@ module RGeo
132
132
  assert(factory_.multi_line_string([]).respond_to?(:mixin1_method))
133
133
  assert(factory_.multi_line_string([]).respond_to?(:mixin2_method))
134
134
  end
135
-
135
+
136
136
  end
137
-
138
-
137
+
138
+
139
139
  def test_basic_mixin_spherical
140
140
  factory_ = ::RGeo::Geographic.spherical_factory
141
141
  assert_equal(::RGeo::Geographic::SphericalPointImpl, factory_.point(1, 1).class)
@@ -144,8 +144,8 @@ module RGeo
144
144
  assert(factory_.point(1, 1).respond_to?(:mixin1_method))
145
145
  assert(!factory_.point(1, 1).respond_to?(:mixin2_method))
146
146
  end
147
-
148
-
147
+
148
+
149
149
  def test_inherited_mixin_spherical
150
150
  factory_ = ::RGeo::Geographic.spherical_factory
151
151
  assert(factory_.collection([]).class.include?(Mixin1))
@@ -157,8 +157,8 @@ module RGeo
157
157
  assert(factory_.multi_line_string([]).respond_to?(:mixin1_method))
158
158
  assert(factory_.multi_line_string([]).respond_to?(:mixin2_method))
159
159
  end
160
-
161
-
160
+
161
+
162
162
  def test_basic_mixin_simple_mercator
163
163
  factory_ = ::RGeo::Geographic.simple_mercator_factory
164
164
  assert_equal(::RGeo::Geographic::ProjectedPointImpl, factory_.point(1, 1).class)
@@ -167,8 +167,8 @@ module RGeo
167
167
  assert(factory_.point(1, 1).respond_to?(:mixin1_method))
168
168
  assert(!factory_.point(1, 1).respond_to?(:mixin2_method))
169
169
  end
170
-
171
-
170
+
171
+
172
172
  def test_inherited_mixin_simple_mercator
173
173
  factory_ = ::RGeo::Geographic.simple_mercator_factory
174
174
  assert(factory_.collection([]).class.include?(Mixin1))
@@ -180,9 +180,9 @@ module RGeo
180
180
  assert(factory_.multi_line_string([]).respond_to?(:mixin1_method))
181
181
  assert(factory_.multi_line_string([]).respond_to?(:mixin2_method))
182
182
  end
183
-
184
-
183
+
184
+
185
185
  end
186
-
186
+
187
187
  end
188
188
  end
data/test/tc_oneoff.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # A container file for one-off tests
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2010 Daniel Azuma
7
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -40,10 +40,10 @@ require 'rgeo'
40
40
 
41
41
  module RGeo
42
42
  module Tests # :nodoc:
43
-
43
+
44
44
  class TestOneOff < ::Test::Unit::TestCase # :nodoc:
45
-
46
-
45
+
46
+
47
47
  def setup
48
48
  # @mercator_factory = ::RGeo::Geographic.simple_mercator_factory
49
49
  # @spherical_factory = ::RGeo::Geographic.spherical_factory(:has_z_coordinate => true)
@@ -51,13 +51,13 @@ module RGeo
51
51
  # @geos_factory = ::RGeo::Geos.factory(:srid => 4326, :has_z_coordinate => true)
52
52
  # @cartesian_factory = ::RGeo::Cartesian.simple_factory(:srid => 1, :has_z_coordinate => true)
53
53
  end
54
-
55
-
54
+
55
+
56
56
  def test_dummy
57
57
  end
58
-
59
-
58
+
59
+
60
60
  end
61
-
61
+
62
62
  end
63
63
  end
data/test/tc_types.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Tests for type properties
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2010 Daniel Azuma
7
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -40,18 +40,18 @@ require 'rgeo'
40
40
 
41
41
  module RGeo
42
42
  module Tests # :nodoc:
43
-
43
+
44
44
  class TestTypes < ::Test::Unit::TestCase # :nodoc:
45
-
46
-
45
+
46
+
47
47
  def test_geometry
48
48
  assert_equal('Geometry', ::RGeo::Feature::Geometry.type_name)
49
49
  assert_nil(::RGeo::Feature::Geometry.supertype)
50
50
  assert(::RGeo::Feature::Geometry.subtype_of?(::RGeo::Feature::Geometry))
51
51
  assert(!::RGeo::Feature::Geometry.subtype_of?(::RGeo::Feature::Point))
52
52
  end
53
-
54
-
53
+
54
+
55
55
  def test_point
56
56
  assert_equal('Point', ::RGeo::Feature::Point.type_name)
57
57
  assert_equal(::RGeo::Feature::Geometry, ::RGeo::Feature::Point.supertype)
@@ -59,8 +59,8 @@ module RGeo
59
59
  assert(::RGeo::Feature::Point.subtype_of?(::RGeo::Feature::Geometry))
60
60
  assert(!::RGeo::Feature::Point.subtype_of?(::RGeo::Feature::LineString))
61
61
  end
62
-
63
-
62
+
63
+
64
64
  def test_line_string
65
65
  assert_equal('LineString', ::RGeo::Feature::LineString.type_name)
66
66
  assert_equal(::RGeo::Feature::Curve, ::RGeo::Feature::LineString.supertype)
@@ -69,9 +69,9 @@ module RGeo
69
69
  assert(::RGeo::Feature::LineString.subtype_of?(::RGeo::Feature::Geometry))
70
70
  assert(!::RGeo::Feature::LineString.subtype_of?(::RGeo::Feature::Line))
71
71
  end
72
-
73
-
72
+
73
+
74
74
  end
75
-
75
+
76
76
  end
77
77
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Tests for WKT generator
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2010 Daniel Azuma
7
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -41,209 +41,209 @@ require 'rgeo'
41
41
  module RGeo
42
42
  module Tests # :nodoc:
43
43
  module WKRep # :nodoc:
44
-
44
+
45
45
  class TestWKBGenerator < ::Test::Unit::TestCase # :nodoc:
46
-
47
-
46
+
47
+
48
48
  def setup
49
49
  @factory = ::RGeo::Cartesian.preferred_factory(:srid => 1000)
50
50
  @factoryz = ::RGeo::Cartesian.preferred_factory(:srid => 1000, :has_z_coordinate => true)
51
51
  @factorym = ::RGeo::Cartesian.preferred_factory(:srid => 1000, :has_m_coordinate => true)
52
52
  @factoryzm = ::RGeo::Cartesian.preferred_factory(:srid => 1000, :has_z_coordinate => true, :has_m_coordinate => true)
53
53
  end
54
-
55
-
54
+
55
+
56
56
  def test_point_basic_xdr
57
57
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
58
58
  obj_ = @factory.point(1, 2)
59
59
  assert_equal('00000000013ff00000000000004000000000000000', generator_.generate(obj_))
60
60
  end
61
-
62
-
61
+
62
+
63
63
  def test_point_basic_ndr
64
64
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :little_endian => true)
65
65
  obj_ = @factory.point(1, 2)
66
66
  assert_equal('0101000000000000000000f03f0000000000000040', generator_.generate(obj_))
67
67
  end
68
-
69
-
68
+
69
+
70
70
  def test_point_2d_ewkb
71
71
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
72
72
  obj_ = @factory.point(1, 2)
73
73
  assert_equal('00000000013ff00000000000004000000000000000', generator_.generate(obj_))
74
74
  end
75
-
76
-
75
+
76
+
77
77
  def test_point_2d_wkb12
78
78
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :wkb12)
79
79
  obj_ = @factory.point(1, 2)
80
80
  assert_equal('00000000013ff00000000000004000000000000000', generator_.generate(obj_))
81
81
  end
82
-
83
-
82
+
83
+
84
84
  def test_point_2d_ewkb_with_srid
85
85
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb, :emit_ewkb_srid => true)
86
86
  obj_ = @factory.point(1, 2)
87
87
  assert_equal('0020000001000003e83ff00000000000004000000000000000', generator_.generate(obj_))
88
88
  end
89
-
90
-
89
+
90
+
91
91
  def test_point_with_ewkb_z
92
92
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
93
93
  obj_ = @factoryz.point(1, 2, 3)
94
94
  assert_equal('00800000013ff000000000000040000000000000004008000000000000', generator_.generate(obj_))
95
95
  end
96
-
97
-
96
+
97
+
98
98
  def test_point_with_ewkb_m
99
99
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
100
100
  obj_ = @factorym.point(1, 2, 3)
101
101
  assert_equal('00400000013ff000000000000040000000000000004008000000000000', generator_.generate(obj_))
102
102
  end
103
-
104
-
103
+
104
+
105
105
  def test_point_with_ewkb_zm
106
106
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
107
107
  obj_ = @factoryzm.point(1, 2, 3, 4)
108
108
  assert_equal('00c00000013ff0000000000000400000000000000040080000000000004010000000000000', generator_.generate(obj_))
109
109
  end
110
-
111
-
110
+
111
+
112
112
  def test_point_with_wkb12_z
113
113
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :wkb12)
114
114
  obj_ = @factoryz.point(1, 2, 3)
115
115
  assert_equal('00000003e93ff000000000000040000000000000004008000000000000', generator_.generate(obj_))
116
116
  end
117
-
118
-
117
+
118
+
119
119
  def test_point_with_wkb12_m
120
120
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :wkb12)
121
121
  obj_ = @factorym.point(1, 2, 3)
122
122
  assert_equal('00000007d13ff000000000000040000000000000004008000000000000', generator_.generate(obj_))
123
123
  end
124
-
125
-
124
+
125
+
126
126
  def test_point_with_wkb12_zm
127
127
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :wkb12)
128
128
  obj_ = @factoryzm.point(1, 2, 3, 4)
129
129
  assert_equal('0000000bb93ff0000000000000400000000000000040080000000000004010000000000000', generator_.generate(obj_))
130
130
  end
131
-
132
-
131
+
132
+
133
133
  def test_linestring_basic
134
134
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
135
135
  obj_ = @factory.line_string([@factory.point(1, 2), @factory.point(3, 4), @factory.point(5, 6)])
136
136
  assert_equal('0000000002000000033ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000', generator_.generate(obj_))
137
137
  end
138
-
139
-
138
+
139
+
140
140
  def test_linestring_with_ewkb_z
141
141
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
142
142
  obj_ = @factoryz.line_string([@factoryz.point(1, 2, 3), @factoryz.point(4, 5, 6)])
143
143
  assert_equal('0080000002000000023ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000', generator_.generate(obj_))
144
144
  end
145
-
146
-
145
+
146
+
147
147
  def test_linestring_with_ewkb_z_and_srid
148
148
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb, :emit_ewkb_srid => true)
149
149
  obj_ = @factoryz.line_string([@factoryz.point(1, 2, 3), @factoryz.point(4, 5, 6)])
150
150
  assert_equal('00a0000002000003e8000000023ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000', generator_.generate(obj_))
151
151
  end
152
-
153
-
152
+
153
+
154
154
  def test_linestring_with_wkb12_m
155
155
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :wkb12)
156
156
  obj_ = @factorym.line_string([@factorym.point(1, 2, 3), @factorym.point(4, 5, 6)])
157
157
  assert_equal('00000007d2000000023ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000', generator_.generate(obj_))
158
158
  end
159
-
160
-
159
+
160
+
161
161
  def test_linestring_empty
162
162
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
163
163
  obj_ = @factory.line_string([])
164
164
  assert_equal('000000000200000000', generator_.generate(obj_))
165
165
  end
166
-
167
-
166
+
167
+
168
168
  def test_polygon_basic
169
169
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
170
170
  obj_ = @factory.polygon(@factory.linear_ring([@factory.point(1, 2), @factory.point(3, 4), @factory.point(6, 5), @factory.point(1, 2)]))
171
171
  assert_equal('000000000300000001000000043ff0000000000000400000000000000040080000000000004010000000000000401800000000000040140000000000003ff00000000000004000000000000000', generator_.generate(obj_))
172
172
  end
173
-
174
-
173
+
174
+
175
175
  def test_polygon_empty
176
176
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
177
177
  obj_ = @factory.polygon(@factory.linear_ring([]))
178
178
  assert_equal('000000000300000000', generator_.generate(obj_))
179
179
  end
180
-
181
-
180
+
181
+
182
182
  def test_multipoint_basic
183
183
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
184
184
  obj_ = @factory.multi_point([@factory.point(1, 2), @factory.point(3, 4)])
185
185
  assert_equal('00000000040000000200000000013ff00000000000004000000000000000000000000140080000000000004010000000000000', generator_.generate(obj_))
186
186
  end
187
-
188
-
187
+
188
+
189
189
  def test_multipoint_with_ewkb_z
190
190
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
191
191
  obj_ = @factoryz.multi_point([@factoryz.point(1, 2, 5), @factoryz.point(3, 4, 6)])
192
192
  assert_equal('00800000040000000200800000013ff0000000000000400000000000000040140000000000000080000001400800000000000040100000000000004018000000000000', generator_.generate(obj_))
193
193
  end
194
-
195
-
194
+
195
+
196
196
  def test_multipoint_empty
197
197
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
198
198
  obj_ = @factory.multi_point([])
199
199
  assert_equal('000000000400000000', generator_.generate(obj_))
200
200
  end
201
-
202
-
201
+
202
+
203
203
  def test_multilinestring_basic
204
204
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
205
205
  obj_ = @factory.multi_line_string([@factory.line_string([@factory.point(1, 2), @factory.point(3, 4), @factory.point(5, 6)]), @factory.line_string([@factory.point(-1, -2), @factory.point(-3, -4)])])
206
206
  assert_equal('0000000005000000020000000002000000033ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000000000000200000002bff0000000000000c000000000000000c008000000000000c010000000000000', generator_.generate(obj_))
207
207
  end
208
-
209
-
208
+
209
+
210
210
  def test_multilinestring_empty
211
211
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
212
212
  obj_ = @factory.multi_line_string([])
213
213
  assert_equal('000000000500000000', generator_.generate(obj_))
214
214
  end
215
-
216
-
215
+
216
+
217
217
  def test_multipolygon_basic
218
218
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
219
219
  obj_ = @factory.multi_polygon([@factory.polygon(@factory.linear_ring([@factory.point(1, 2), @factory.point(3, 4), @factory.point(6, 5), @factory.point(1, 2)])), @factory.polygon(@factory.linear_ring([]))])
220
220
  assert_equal('000000000600000002000000000300000001000000043ff0000000000000400000000000000040080000000000004010000000000000401800000000000040140000000000003ff00000000000004000000000000000000000000300000000', generator_.generate(obj_))
221
221
  end
222
-
223
-
222
+
223
+
224
224
  def test_multipolygon_empty
225
225
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
226
226
  obj_ = @factory.multi_polygon([])
227
227
  assert_equal('000000000600000000', generator_.generate(obj_))
228
228
  end
229
-
230
-
229
+
230
+
231
231
  def test_collection_basic
232
232
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
233
233
  obj_ = @factory.collection([@factory.line_string([@factory.point(1, 2), @factory.point(3, 4), @factory.point(5, 6)]), @factory.point(-1, -2)])
234
234
  assert_equal('0000000007000000020000000002000000033ff0000000000000400000000000000040080000000000004010000000000000401400000000000040180000000000000000000001bff0000000000000c000000000000000', generator_.generate(obj_))
235
235
  end
236
-
237
-
236
+
237
+
238
238
  def test_collection_empty
239
239
  generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
240
240
  obj_ = @factory.collection([])
241
241
  assert_equal('000000000700000000', generator_.generate(obj_))
242
242
  end
243
-
244
-
243
+
244
+
245
245
  end
246
-
246
+
247
247
  end
248
248
  end
249
249
  end