rgeo 0.1.19 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/History.rdoc +11 -0
  2. data/README.rdoc +23 -7
  3. data/Version +1 -1
  4. data/ext/geos_c_impl/factory.c +1 -1
  5. data/{lib/rgeo/geography/simple_mercator.rb → ext/proj4_c_impl/extconf.rb} +35 -30
  6. data/ext/proj4_c_impl/main.c +256 -0
  7. data/lib/rgeo.rb +54 -42
  8. data/lib/rgeo/active_record/arel_modifications.rb +2 -2
  9. data/lib/rgeo/active_record/base_modifications.rb +1 -1
  10. data/lib/rgeo/active_record/mysql_common.rb +12 -12
  11. data/lib/rgeo/all.rb +5 -4
  12. data/lib/rgeo/cartesian.rb +3 -2
  13. data/lib/rgeo/cartesian/bounding_box.rb +9 -9
  14. data/lib/rgeo/cartesian/factory.rb +30 -13
  15. data/lib/rgeo/cartesian/feature_classes.rb +33 -33
  16. data/lib/rgeo/cartesian/interface.rb +2 -2
  17. data/lib/rgeo/{geography/all.rb → coord_sys.rb} +22 -4
  18. data/lib/rgeo/coord_sys/proj4.rb +275 -0
  19. data/lib/rgeo/{errors.rb → error.rb} +5 -6
  20. data/lib/rgeo/{features.rb → feature.rb} +22 -20
  21. data/lib/rgeo/{features → feature}/curve.rb +6 -6
  22. data/lib/rgeo/{features → feature}/factory.rb +19 -3
  23. data/lib/rgeo/{features → feature}/factory_generator.rb +1 -1
  24. data/lib/rgeo/{features → feature}/geometry.rb +34 -34
  25. data/lib/rgeo/{features → feature}/geometry_collection.rb +4 -4
  26. data/lib/rgeo/{features → feature}/line.rb +1 -1
  27. data/lib/rgeo/{features → feature}/line_string.rb +4 -4
  28. data/lib/rgeo/{features → feature}/linear_ring.rb +1 -1
  29. data/lib/rgeo/{features → feature}/multi_curve.rb +3 -3
  30. data/lib/rgeo/{features → feature}/multi_line_string.rb +1 -1
  31. data/lib/rgeo/{features → feature}/multi_point.rb +1 -1
  32. data/lib/rgeo/{features → feature}/multi_polygon.rb +1 -1
  33. data/lib/rgeo/{features → feature}/multi_surface.rb +4 -4
  34. data/lib/rgeo/{features → feature}/point.rb +5 -5
  35. data/lib/rgeo/{features → feature}/polygon.rb +5 -5
  36. data/lib/rgeo/{features → feature}/surface.rb +4 -4
  37. data/lib/rgeo/feature/types.rb +301 -0
  38. data/lib/rgeo/geo_json.rb +1 -1
  39. data/lib/rgeo/geo_json/coder.rb +13 -13
  40. data/lib/rgeo/geo_json/interface.rb +2 -2
  41. data/lib/rgeo/geography.rb +33 -6
  42. data/lib/rgeo/geography/factory.rb +82 -39
  43. data/lib/rgeo/geography/interface.rb +135 -89
  44. data/lib/rgeo/geography/proj4_projector.rb +98 -0
  45. data/lib/rgeo/geography/projected_feature_classes.rb +213 -0
  46. data/lib/rgeo/geography/projected_feature_methods.rb +228 -0
  47. data/lib/rgeo/geography/projected_window.rb +7 -7
  48. data/lib/rgeo/geography/simple_mercator_projector.rb +133 -0
  49. data/lib/rgeo/geography/spherical_feature_classes.rb +212 -0
  50. data/lib/rgeo/geography/{simple_spherical/feature_methods.rb → spherical_feature_methods.rb} +39 -43
  51. data/lib/rgeo/geography/{simple_spherical/calculations.rb → spherical_math.rb} +7 -7
  52. data/lib/rgeo/geos.rb +1 -1
  53. data/lib/rgeo/geos/factory.rb +37 -19
  54. data/lib/rgeo/geos/impl_additions.rb +10 -11
  55. data/lib/rgeo/geos/interface.rb +1 -1
  56. data/lib/rgeo/geos/zm_factory.rb +15 -15
  57. data/lib/rgeo/geos/zm_impl.rb +10 -10
  58. data/lib/rgeo/{impl_helpers.rb → impl_helper.rb} +8 -8
  59. data/lib/rgeo/{impl_helpers → impl_helper}/basic_geometry_collection_methods.rb +13 -13
  60. data/lib/rgeo/{impl_helpers → impl_helper}/basic_geometry_methods.rb +2 -2
  61. data/lib/rgeo/{impl_helpers → impl_helper}/basic_line_string_methods.rb +13 -13
  62. data/lib/rgeo/{impl_helpers → impl_helper}/basic_point_methods.rb +5 -5
  63. data/lib/rgeo/{impl_helpers → impl_helper}/basic_polygon_methods.rb +6 -6
  64. data/lib/rgeo/{impl_helpers → impl_helper}/math.rb +1 -1
  65. data/lib/rgeo/shapefile.rb +1 -1
  66. data/lib/rgeo/shapefile/reader.rb +3 -3
  67. data/lib/rgeo/wkrep.rb +1 -1
  68. data/lib/rgeo/wkrep/wkb_generator.rb +17 -17
  69. data/lib/rgeo/wkrep/wkb_parser.rb +12 -12
  70. data/lib/rgeo/wkrep/wkt_generator.rb +8 -8
  71. data/lib/rgeo/wkrep/wkt_parser.rb +10 -10
  72. data/{tests → test}/active_record/readme.txt +0 -0
  73. data/{tests → test}/active_record/tc_mysqlspatial.rb +2 -2
  74. data/{tests → test}/common/geometry_collection_tests.rb +22 -22
  75. data/{tests → test}/common/line_string_tests.rb +20 -20
  76. data/{tests → test}/common/multi_line_string_tests.rb +19 -19
  77. data/{tests → test}/common/multi_point_tests.rb +17 -17
  78. data/{tests → test}/common/multi_polygon_tests.rb +16 -16
  79. data/{tests → test}/common/point_tests.rb +9 -9
  80. data/{tests → test}/common/polygon_tests.rb +9 -9
  81. data/test/coord_sys/tc_proj4.rb +111 -0
  82. data/{tests → test}/geos/tc_factory.rb +1 -1
  83. data/{tests → test}/geos/tc_geometry_collection.rb +1 -1
  84. data/{tests → test}/geos/tc_line_string.rb +0 -0
  85. data/{tests → test}/geos/tc_misc.rb +1 -1
  86. data/{tests → test}/geos/tc_multi_line_string.rb +1 -1
  87. data/{tests → test}/geos/tc_multi_point.rb +1 -1
  88. data/{tests → test}/geos/tc_multi_polygon.rb +1 -1
  89. data/{tests → test}/geos/tc_point.rb +1 -1
  90. data/{tests → test}/geos/tc_polygon.rb +0 -0
  91. data/{tests → test}/geos/tc_zmfactory.rb +2 -2
  92. data/test/projected_geography/tc_geometry_collection.rb +62 -0
  93. data/test/projected_geography/tc_line_string.rb +62 -0
  94. data/test/projected_geography/tc_multi_line_string.rb +62 -0
  95. data/test/projected_geography/tc_multi_point.rb +62 -0
  96. data/test/projected_geography/tc_multi_polygon.rb +63 -0
  97. data/test/projected_geography/tc_point.rb +93 -0
  98. data/test/projected_geography/tc_polygon.rb +62 -0
  99. data/{tests → test}/shapefile/shapelib_testcases/readme.txt +0 -0
  100. data/{tests → test}/shapefile/shapelib_testcases/test.dbf +0 -0
  101. data/{tests → test}/shapefile/shapelib_testcases/test.shp +0 -0
  102. data/{tests → test}/shapefile/shapelib_testcases/test.shx +0 -0
  103. data/{tests → test}/shapefile/shapelib_testcases/test0.shp +0 -0
  104. data/{tests → test}/shapefile/shapelib_testcases/test0.shx +0 -0
  105. data/{tests → test}/shapefile/shapelib_testcases/test1.shp +0 -0
  106. data/{tests → test}/shapefile/shapelib_testcases/test1.shx +0 -0
  107. data/{tests → test}/shapefile/shapelib_testcases/test10.shp +0 -0
  108. data/{tests → test}/shapefile/shapelib_testcases/test10.shx +0 -0
  109. data/{tests → test}/shapefile/shapelib_testcases/test11.shp +0 -0
  110. data/{tests → test}/shapefile/shapelib_testcases/test11.shx +0 -0
  111. data/{tests → test}/shapefile/shapelib_testcases/test12.shp +0 -0
  112. data/{tests → test}/shapefile/shapelib_testcases/test12.shx +0 -0
  113. data/{tests → test}/shapefile/shapelib_testcases/test13.shp +0 -0
  114. data/{tests → test}/shapefile/shapelib_testcases/test13.shx +0 -0
  115. data/{tests → test}/shapefile/shapelib_testcases/test2.shp +0 -0
  116. data/{tests → test}/shapefile/shapelib_testcases/test2.shx +0 -0
  117. data/{tests → test}/shapefile/shapelib_testcases/test3.shp +0 -0
  118. data/{tests → test}/shapefile/shapelib_testcases/test3.shx +0 -0
  119. data/{tests → test}/shapefile/shapelib_testcases/test4.shp +0 -0
  120. data/{tests → test}/shapefile/shapelib_testcases/test4.shx +0 -0
  121. data/{tests → test}/shapefile/shapelib_testcases/test5.shp +0 -0
  122. data/{tests → test}/shapefile/shapelib_testcases/test5.shx +0 -0
  123. data/{tests → test}/shapefile/shapelib_testcases/test6.shp +0 -0
  124. data/{tests → test}/shapefile/shapelib_testcases/test6.shx +0 -0
  125. data/{tests → test}/shapefile/shapelib_testcases/test7.shp +0 -0
  126. data/{tests → test}/shapefile/shapelib_testcases/test7.shx +0 -0
  127. data/{tests → test}/shapefile/shapelib_testcases/test8.shp +0 -0
  128. data/{tests → test}/shapefile/shapelib_testcases/test8.shx +0 -0
  129. data/{tests → test}/shapefile/shapelib_testcases/test9.shp +0 -0
  130. data/{tests → test}/shapefile/shapelib_testcases/test9.shx +0 -0
  131. data/{tests → test}/shapefile/tc_shapelib_tests.rb +17 -17
  132. data/{tests → test}/simple_cartesian/tc_calculations.rb +0 -0
  133. data/{tests → test}/simple_cartesian/tc_geometry_collection.rb +0 -0
  134. data/{tests → test}/simple_cartesian/tc_line_string.rb +0 -0
  135. data/{tests → test}/simple_cartesian/tc_multi_line_string.rb +0 -0
  136. data/{tests → test}/simple_cartesian/tc_multi_point.rb +0 -0
  137. data/{tests → test}/simple_cartesian/tc_multi_polygon.rb +0 -0
  138. data/{tests → test}/simple_cartesian/tc_point.rb +0 -0
  139. data/{tests → test}/simple_cartesian/tc_polygon.rb +0 -0
  140. data/{tests → test}/simple_mercator/tc_geometry_collection.rb +1 -1
  141. data/{tests → test}/simple_mercator/tc_line_string.rb +0 -0
  142. data/{tests → test}/simple_mercator/tc_multi_line_string.rb +1 -1
  143. data/{tests → test}/simple_mercator/tc_multi_point.rb +1 -1
  144. data/{tests → test}/simple_mercator/tc_multi_polygon.rb +1 -1
  145. data/{tests → test}/simple_mercator/tc_point.rb +2 -2
  146. data/{tests → test}/simple_mercator/tc_polygon.rb +0 -0
  147. data/{tests → test}/simple_mercator/tc_window.rb +1 -1
  148. data/test/spherical_geography/tc_calculations.rb +203 -0
  149. data/{tests/simple_spherical → test/spherical_geography}/tc_geometry_collection.rb +2 -2
  150. data/{tests/simple_spherical → test/spherical_geography}/tc_line_string.rb +2 -2
  151. data/{tests/simple_spherical → test/spherical_geography}/tc_multi_line_string.rb +2 -2
  152. data/{tests/simple_spherical → test/spherical_geography}/tc_multi_point.rb +2 -2
  153. data/{tests/simple_spherical → test/spherical_geography}/tc_multi_polygon.rb +3 -3
  154. data/{tests/simple_spherical → test/spherical_geography}/tc_point.rb +7 -7
  155. data/{tests/simple_spherical → test/spherical_geography}/tc_polygon.rb +2 -2
  156. data/{tests → test}/tc_cartesian_analysis.rb +0 -0
  157. data/{tests → test}/tc_geojson.rb +0 -0
  158. data/{tests → test}/tc_oneoff.rb +2 -1
  159. data/{tests → test}/wkrep/tc_wkb_generator.rb +0 -0
  160. data/{tests → test}/wkrep/tc_wkb_parser.rb +32 -32
  161. data/{tests → test}/wkrep/tc_wkt_generator.rb +0 -0
  162. data/{tests → test}/wkrep/tc_wkt_parser.rb +46 -46
  163. metadata +183 -164
  164. data/lib/rgeo/features/types.rb +0 -272
  165. data/lib/rgeo/geography/simple_mercator/feature_classes.rb +0 -279
  166. data/lib/rgeo/geography/simple_mercator/feature_methods.rb +0 -278
  167. data/lib/rgeo/geography/simple_mercator/projector.rb +0 -112
  168. data/lib/rgeo/geography/simple_spherical.rb +0 -68
  169. data/lib/rgeo/geography/simple_spherical/feature_classes.rb +0 -216
  170. data/tests/simple_spherical/tc_calculations.rb +0 -203
@@ -0,0 +1,62 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for the simple mercator multi line string 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
+ require ::File.expand_path('../common/multi_line_string_tests.rb', ::File.dirname(__FILE__))
41
+
42
+
43
+ module RGeo
44
+ module Tests # :nodoc:
45
+ module ProjectedGeography # :nodoc:
46
+
47
+ class TestMultiLineString < ::Test::Unit::TestCase # :nodoc:
48
+
49
+
50
+ def create_factory
51
+ ::RGeo::Geography.projected(:projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857)
52
+ end
53
+
54
+
55
+ include ::RGeo::Tests::Common::MultiLineStringTests
56
+
57
+
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,62 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for the simple mercator multi 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
+ require ::File.expand_path('../common/multi_point_tests.rb', ::File.dirname(__FILE__))
41
+
42
+
43
+ module RGeo
44
+ module Tests # :nodoc:
45
+ module ProjectedGeography # :nodoc:
46
+
47
+ class TestMultiPoint < ::Test::Unit::TestCase # :nodoc:
48
+
49
+
50
+ def create_factory
51
+ ::RGeo::Geography.projected(:projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857)
52
+ end
53
+
54
+
55
+ include ::RGeo::Tests::Common::MultiPointTests
56
+
57
+
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,63 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for the simple mercator multi polygon 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
+ require ::File.expand_path('../common/multi_polygon_tests.rb', ::File.dirname(__FILE__))
41
+
42
+
43
+ module RGeo
44
+ module Tests # :nodoc:
45
+ module ProjectedGeography # :nodoc:
46
+
47
+ class TestMultiPolygon < ::Test::Unit::TestCase # :nodoc:
48
+
49
+
50
+ def create_factories
51
+ @factory = ::RGeo::Geography.projected(:projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857)
52
+ @lenient_factory = ::RGeo::Geography.projected(:projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857, :lenient_multi_polygon_assertions => true)
53
+ end
54
+
55
+
56
+ include ::RGeo::Tests::Common::MultiPolygonTests
57
+
58
+
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,93 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for the simple mercator 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
+ require ::File.expand_path('../common/point_tests.rb', ::File.dirname(__FILE__))
41
+
42
+
43
+ module RGeo
44
+ module Tests # :nodoc:
45
+ module ProjectedGeography # :nodoc:
46
+
47
+ class TestPoint < ::Test::Unit::TestCase # :nodoc:
48
+
49
+
50
+ def setup
51
+ @factory = ::RGeo::Geography.projected(:projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857)
52
+ @zfactory = ::RGeo::Geography.projected(:support_z_coordinate => true, :projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857)
53
+ @mfactory = ::RGeo::Geography.projected(:support_m_coordinate => true, :projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857)
54
+ @zmfactory = ::RGeo::Geography.projected(:support_z_coordinate => true, :support_m_coordinate => true, :projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857)
55
+ end
56
+
57
+
58
+ include ::RGeo::Tests::Common::PointTests
59
+
60
+
61
+ def test_has_projection
62
+ point_ = @factory.point(21, -22)
63
+ assert(point_.respond_to?(:projection))
64
+ end
65
+
66
+
67
+ def test_latlon
68
+ point_ = @factory.point(21, -22)
69
+ assert_equal(21, point_.longitude)
70
+ assert_equal(-22, point_.latitude)
71
+ end
72
+
73
+
74
+ def test_srid
75
+ point_ = @factory.point(11, 12)
76
+ assert_equal(4326, point_.srid)
77
+ end
78
+
79
+
80
+ def test_distance
81
+ point1_ = @factory.point(11, 12)
82
+ point2_ = @factory.point(11, 12)
83
+ point3_ = @factory.point(13, 12)
84
+ assert_in_delta(0, point1_.distance(point2_), 0.0001)
85
+ assert_in_delta(222638, point1_.distance(point3_), 1)
86
+ end
87
+
88
+
89
+ end
90
+
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,62 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for the simple mercator polygon 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
+ require ::File.expand_path('../common/polygon_tests.rb', ::File.dirname(__FILE__))
41
+
42
+
43
+ module RGeo
44
+ module Tests # :nodoc:
45
+ module ProjectedGeography # :nodoc:
46
+
47
+ class TestPolygon < ::Test::Unit::TestCase # :nodoc:
48
+
49
+
50
+ def setup
51
+ @factory = ::RGeo::Geography.projected(:projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857)
52
+ end
53
+
54
+
55
+ include ::RGeo::Tests::Common::PolygonTests
56
+
57
+
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -130,14 +130,14 @@ module RGeo
130
130
  assert_equal(has_m_, file_.factory.has_capability?(:m_coordinate))
131
131
  rec_ = file_.next
132
132
  assert_equal(0, rec_.index)
133
- assert_equal(::RGeo::Features::Point, rec_.geometry.geometry_type)
133
+ assert_equal(::RGeo::Feature::Point, rec_.geometry.geometry_type)
134
134
  assert_equal(1, rec_.geometry.x)
135
135
  assert_equal(2, rec_.geometry.y)
136
136
  assert_equal(3, rec_.geometry.z) if has_z_
137
137
  assert_equal(4, rec_.geometry.m) if has_m_
138
138
  rec_ = file_.next
139
139
  assert_equal(1, rec_.index)
140
- assert_equal(::RGeo::Features::Point, rec_.geometry.geometry_type)
140
+ assert_equal(::RGeo::Feature::Point, rec_.geometry.geometry_type)
141
141
  assert_equal(10, rec_.geometry.x)
142
142
  assert_equal(20, rec_.geometry.y)
143
143
  assert_equal(30, rec_.geometry.z) if has_z_
@@ -169,7 +169,7 @@ module RGeo
169
169
  assert_equal(has_z_, file_.factory.has_capability?(:z_coordinate))
170
170
  assert_equal(has_m_, file_.factory.has_capability?(:m_coordinate))
171
171
  rec_ = file_.next
172
- assert_equal(::RGeo::Features::MultiPoint, rec_.geometry.geometry_type)
172
+ assert_equal(::RGeo::Feature::MultiPoint, rec_.geometry.geometry_type)
173
173
  assert_equal(4, rec_.geometry.num_geometries)
174
174
  assert_equal(1.15, rec_.geometry[0].x)
175
175
  assert_equal(2.25, rec_.geometry[0].y)
@@ -180,10 +180,10 @@ module RGeo
180
180
  assert_equal(6.35, rec_.geometry[3].z) if has_z_
181
181
  assert_equal(7.45, rec_.geometry[3].m) if has_m_
182
182
  rec_ = file_.next
183
- assert_equal(::RGeo::Features::MultiPoint, rec_.geometry.geometry_type)
183
+ assert_equal(::RGeo::Feature::MultiPoint, rec_.geometry.geometry_type)
184
184
  assert_equal(4, rec_.geometry.num_geometries)
185
185
  rec_ = file_.next
186
- assert_equal(::RGeo::Features::MultiPoint, rec_.geometry.geometry_type)
186
+ assert_equal(::RGeo::Feature::MultiPoint, rec_.geometry.geometry_type)
187
187
  assert_equal(4, rec_.geometry.num_geometries)
188
188
  assert_equal(21.15, rec_.geometry[0].x)
189
189
  assert_equal(22.25, rec_.geometry[0].y)
@@ -220,7 +220,7 @@ module RGeo
220
220
  assert_equal(has_z_, file_.factory.has_capability?(:z_coordinate))
221
221
  assert_equal(has_m_, file_.factory.has_capability?(:m_coordinate))
222
222
  rec_ = file_.next
223
- assert_equal(::RGeo::Features::MultiLineString, rec_.geometry.geometry_type)
223
+ assert_equal(::RGeo::Feature::MultiLineString, rec_.geometry.geometry_type)
224
224
  assert_equal(1, rec_.geometry.num_geometries)
225
225
  assert_equal(5, rec_.geometry[0].num_points)
226
226
  assert_equal(1, rec_.geometry[0].point_n(0).x)
@@ -240,10 +240,10 @@ module RGeo
240
240
  assert_equal(7.35, rec_.geometry[0].point_n(4).z) if has_z_
241
241
  assert_equal(8.45, rec_.geometry[0].point_n(4).m) if has_m_
242
242
  rec_ = file_.next
243
- assert_equal(::RGeo::Features::MultiLineString, rec_.geometry.geometry_type)
243
+ assert_equal(::RGeo::Feature::MultiLineString, rec_.geometry.geometry_type)
244
244
  assert_equal(1, rec_.geometry.num_geometries)
245
245
  rec_ = file_.next
246
- assert_equal(::RGeo::Features::MultiLineString, rec_.geometry.geometry_type)
246
+ assert_equal(::RGeo::Feature::MultiLineString, rec_.geometry.geometry_type)
247
247
  assert_equal(1, rec_.geometry.num_geometries)
248
248
  assert_equal(5, rec_.geometry[0].num_points)
249
249
  assert_equal(1, rec_.geometry[0].point_n(0).x)
@@ -263,7 +263,7 @@ module RGeo
263
263
  assert_equal(27.35, rec_.geometry[0].point_n(4).z) if has_z_
264
264
  assert_equal(28.45, rec_.geometry[0].point_n(4).m) if has_m_
265
265
  rec_ = file_.next
266
- assert_equal(::RGeo::Features::MultiLineString, rec_.geometry.geometry_type)
266
+ assert_equal(::RGeo::Feature::MultiLineString, rec_.geometry.geometry_type)
267
267
  assert_equal(3, rec_.geometry.num_geometries)
268
268
  assert_equal(5, rec_.geometry[0].num_points)
269
269
  assert_equal(0, rec_.geometry[0].point_n(0).x)
@@ -330,7 +330,7 @@ module RGeo
330
330
  assert_equal(has_z_, file_.factory.has_capability?(:z_coordinate))
331
331
  assert_equal(has_m_, file_.factory.has_capability?(:m_coordinate))
332
332
  rec_ = file_.next
333
- assert_equal(::RGeo::Features::MultiPolygon, rec_.geometry.geometry_type)
333
+ assert_equal(::RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
334
334
  assert_equal(1, rec_.geometry.num_geometries)
335
335
  assert_equal(0, rec_.geometry[0].num_interior_rings)
336
336
  assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
@@ -351,10 +351,10 @@ module RGeo
351
351
  assert_equal(7.35, rec_.geometry[0].exterior_ring.point_n(4).z) if has_z_
352
352
  assert_equal(8.45, rec_.geometry[0].exterior_ring.point_n(4).m) if has_m_
353
353
  rec_ = file_.next
354
- assert_equal(::RGeo::Features::MultiPolygon, rec_.geometry.geometry_type)
354
+ assert_equal(::RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
355
355
  assert_equal(1, rec_.geometry.num_geometries)
356
356
  rec_ = file_.next
357
- assert_equal(::RGeo::Features::MultiPolygon, rec_.geometry.geometry_type)
357
+ assert_equal(::RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
358
358
  assert_equal(1, rec_.geometry.num_geometries)
359
359
  assert_equal(0, rec_.geometry[0].num_interior_rings)
360
360
  assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
@@ -375,7 +375,7 @@ module RGeo
375
375
  assert_equal(27.35, rec_.geometry[0].exterior_ring.point_n(4).z) if has_z_
376
376
  assert_equal(28.45, rec_.geometry[0].exterior_ring.point_n(4).m) if has_m_
377
377
  rec_ = file_.next
378
- assert_equal(::RGeo::Features::MultiPolygon, rec_.geometry.geometry_type)
378
+ assert_equal(::RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
379
379
  assert_equal(1, rec_.geometry.num_geometries)
380
380
  assert_equal(2, rec_.geometry[0].num_interior_rings)
381
381
  assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
@@ -446,7 +446,7 @@ module RGeo
446
446
  # disabled this test:
447
447
  # assert_equal(false, file_.factory.has_capability?(:m_coordinate))
448
448
  rec_ = file_.next
449
- assert_equal(::RGeo::Features::GeometryCollection, rec_.geometry.geometry_type)
449
+ assert_equal(::RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
450
450
  assert_equal(1, rec_.geometry.num_geometries)
451
451
  assert_equal(0, rec_.geometry[0].num_interior_rings)
452
452
  assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
@@ -463,10 +463,10 @@ module RGeo
463
463
  assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).y)
464
464
  assert_equal(7.35, rec_.geometry[0].exterior_ring.point_n(4).z)
465
465
  rec_ = file_.next
466
- assert_equal(::RGeo::Features::GeometryCollection, rec_.geometry.geometry_type)
466
+ assert_equal(::RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
467
467
  assert_equal(1, rec_.geometry.num_geometries)
468
468
  rec_ = file_.next
469
- assert_equal(::RGeo::Features::GeometryCollection, rec_.geometry.geometry_type)
469
+ assert_equal(::RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
470
470
  assert_equal(1, rec_.geometry.num_geometries)
471
471
  assert_equal(0, rec_.geometry[0].num_interior_rings)
472
472
  assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
@@ -483,7 +483,7 @@ module RGeo
483
483
  assert_equal(7, rec_.geometry[0].exterior_ring.point_n(4).y)
484
484
  assert_equal(27.35, rec_.geometry[0].exterior_ring.point_n(4).z)
485
485
  rec_ = file_.next
486
- assert_equal(::RGeo::Features::GeometryCollection, rec_.geometry.geometry_type)
486
+ assert_equal(::RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
487
487
  assert_equal(1, rec_.geometry.num_geometries)
488
488
  assert_equal(2, rec_.geometry[0].num_interior_rings)
489
489
  assert_equal(5, rec_.geometry[0].exterior_ring.num_points)