rgeo 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +29 -0
  3. data/ext/geos_c_impl/Makefile_2.2.3 +260 -0
  4. data/ext/geos_c_impl/coordinates.c +65 -0
  5. data/ext/geos_c_impl/coordinates.h +2 -0
  6. data/ext/geos_c_impl/extconf.rb +19 -43
  7. data/ext/geos_c_impl/geometry.c +24 -0
  8. data/ext/geos_c_impl/geometry_collection.c +99 -1
  9. data/ext/geos_c_impl/geos_c_impl_2.2.3.bundle +0 -0
  10. data/ext/geos_c_impl/line_string.c +38 -0
  11. data/ext/geos_c_impl/mkmf.log +123 -0
  12. data/ext/geos_c_impl/point.c +27 -0
  13. data/ext/geos_c_impl/polygon.c +26 -0
  14. data/ext/proj4_c_impl/Makefile_2.2.3 +260 -0
  15. data/ext/proj4_c_impl/extconf.rb +32 -32
  16. data/ext/proj4_c_impl/mkmf.log +47 -0
  17. data/ext/proj4_c_impl/proj4_c_impl_2.2.3.bundle +0 -0
  18. data/lib/rgeo.rb +10 -11
  19. data/lib/rgeo/cartesian.rb +7 -12
  20. data/lib/rgeo/cartesian/analysis.rb +13 -26
  21. data/lib/rgeo/cartesian/bounding_box.rb +45 -114
  22. data/lib/rgeo/cartesian/calculations.rb +3 -21
  23. data/lib/rgeo/cartesian/factory.rb +101 -122
  24. data/lib/rgeo/cartesian/feature_classes.rb +9 -59
  25. data/lib/rgeo/cartesian/feature_methods.rb +15 -45
  26. data/lib/rgeo/cartesian/interface.rb +6 -17
  27. data/lib/rgeo/coord_sys.rb +9 -15
  28. data/lib/rgeo/coord_sys/cs/entities.rb +84 -330
  29. data/lib/rgeo/coord_sys/cs/factories.rb +2 -32
  30. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +52 -80
  31. data/lib/rgeo/coord_sys/proj4.rb +28 -67
  32. data/lib/rgeo/coord_sys/proj4_c_impl.bundle +0 -0
  33. data/lib/rgeo/coord_sys/srs_database/interface.rb +4 -24
  34. data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +20 -38
  35. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +6 -22
  36. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +6 -21
  37. data/lib/rgeo/error.rb +0 -6
  38. data/lib/rgeo/feature.rb +18 -23
  39. data/lib/rgeo/feature/curve.rb +0 -14
  40. data/lib/rgeo/feature/factory.rb +13 -38
  41. data/lib/rgeo/feature/factory_generator.rb +4 -16
  42. data/lib/rgeo/feature/geometry.rb +18 -60
  43. data/lib/rgeo/feature/geometry_collection.rb +3 -17
  44. data/lib/rgeo/feature/line.rb +0 -10
  45. data/lib/rgeo/feature/line_string.rb +1 -13
  46. data/lib/rgeo/feature/linear_ring.rb +0 -9
  47. data/lib/rgeo/feature/mixins.rb +11 -36
  48. data/lib/rgeo/feature/multi_curve.rb +0 -11
  49. data/lib/rgeo/feature/multi_line_string.rb +0 -9
  50. data/lib/rgeo/feature/multi_point.rb +0 -9
  51. data/lib/rgeo/feature/multi_polygon.rb +0 -9
  52. data/lib/rgeo/feature/multi_surface.rb +0 -12
  53. data/lib/rgeo/feature/point.rb +0 -13
  54. data/lib/rgeo/feature/polygon.rb +1 -14
  55. data/lib/rgeo/feature/surface.rb +0 -12
  56. data/lib/rgeo/feature/types.rb +19 -61
  57. data/lib/rgeo/geographic.rb +10 -15
  58. data/lib/rgeo/geographic/factory.rb +126 -147
  59. data/lib/rgeo/geographic/interface.rb +67 -81
  60. data/lib/rgeo/geographic/proj4_projector.rb +13 -37
  61. data/lib/rgeo/geographic/projected_feature_classes.rb +7 -66
  62. data/lib/rgeo/geographic/projected_feature_methods.rb +15 -80
  63. data/lib/rgeo/geographic/projected_window.rb +15 -67
  64. data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -56
  65. data/lib/rgeo/geographic/spherical_feature_classes.rb +9 -68
  66. data/lib/rgeo/geographic/spherical_feature_methods.rb +18 -51
  67. data/lib/rgeo/geographic/spherical_math.rb +26 -51
  68. data/lib/rgeo/geos.rb +23 -20
  69. data/lib/rgeo/geos/capi_factory.rb +125 -131
  70. data/lib/rgeo/geos/capi_feature_classes.rb +21 -88
  71. data/lib/rgeo/geos/ffi_factory.rb +90 -143
  72. data/lib/rgeo/geos/ffi_feature_classes.rb +8 -63
  73. data/lib/rgeo/geos/ffi_feature_methods.rb +46 -162
  74. data/lib/rgeo/geos/geos_c_impl.bundle +0 -0
  75. data/lib/rgeo/geos/interface.rb +4 -23
  76. data/lib/rgeo/geos/utils.rb +4 -19
  77. data/lib/rgeo/geos/zm_factory.rb +82 -131
  78. data/lib/rgeo/geos/zm_feature_classes.rb +8 -63
  79. data/lib/rgeo/geos/zm_feature_methods.rb +34 -107
  80. data/lib/rgeo/impl_helper.rb +8 -13
  81. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +27 -71
  82. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +10 -28
  83. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +21 -57
  84. data/lib/rgeo/impl_helper/basic_point_methods.rb +12 -30
  85. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +9 -28
  86. data/lib/rgeo/impl_helper/math.rb +4 -10
  87. data/lib/rgeo/impl_helper/utils.rb +2 -10
  88. data/lib/rgeo/version.rb +1 -1
  89. data/lib/rgeo/wkrep.rb +4 -9
  90. data/lib/rgeo/wkrep/wkb_generator.rb +22 -46
  91. data/lib/rgeo/wkrep/wkb_parser.rb +25 -52
  92. data/lib/rgeo/wkrep/wkt_generator.rb +39 -69
  93. data/lib/rgeo/wkrep/wkt_parser.rb +52 -89
  94. data/lib/rgeo/yaml.rb +1 -7
  95. data/test/common/factory_tests.rb +4 -19
  96. data/test/common/geometry_collection_tests.rb +6 -39
  97. data/test/common/line_string_tests.rb +10 -39
  98. data/test/common/multi_line_string_tests.rb +10 -30
  99. data/test/common/multi_point_tests.rb +15 -34
  100. data/test/common/multi_polygon_tests.rb +26 -28
  101. data/test/common/point_tests.rb +37 -59
  102. data/test/common/polygon_tests.rb +16 -25
  103. data/test/coord_sys/tc_ogc_cs.rb +151 -186
  104. data/test/coord_sys/tc_proj4.rb +35 -60
  105. data/test/coord_sys/tc_proj4_srs_data.rb +15 -24
  106. data/test/coord_sys/tc_sr_org.rb +11 -19
  107. data/test/coord_sys/tc_url_reader.rb +13 -23
  108. data/test/geos_capi/tc_factory.rb +7 -16
  109. data/test/geos_capi/tc_geometry_collection.rb +6 -14
  110. data/test/geos_capi/tc_line_string.rb +7 -15
  111. data/test/geos_capi/tc_misc.rb +26 -41
  112. data/test/geos_capi/tc_multi_line_string.rb +6 -14
  113. data/test/geos_capi/tc_multi_point.rb +7 -15
  114. data/test/geos_capi/tc_multi_polygon.rb +8 -18
  115. data/test/geos_capi/tc_parsing_unparsing.rb +11 -21
  116. data/test/geos_capi/tc_point.rb +12 -26
  117. data/test/geos_capi/tc_polygon.rb +52 -17
  118. data/test/geos_capi/tc_zmfactory.rb +7 -18
  119. data/test/geos_ffi/tc_factory.rb +7 -16
  120. data/test/geos_ffi/tc_geometry_collection.rb +7 -15
  121. data/test/geos_ffi/tc_line_string.rb +7 -15
  122. data/test/geos_ffi/tc_misc.rb +8 -18
  123. data/test/geos_ffi/tc_multi_line_string.rb +7 -15
  124. data/test/geos_ffi/tc_multi_point.rb +8 -16
  125. data/test/geos_ffi/tc_multi_polygon.rb +9 -18
  126. data/test/geos_ffi/tc_parsing_unparsing.rb +14 -24
  127. data/test/geos_ffi/tc_point.rb +13 -28
  128. data/test/geos_ffi/tc_polygon.rb +7 -17
  129. data/test/geos_ffi/tc_zmfactory.rb +8 -19
  130. data/test/projected_geographic/tc_factory.rb +7 -15
  131. data/test/projected_geographic/tc_geometry_collection.rb +7 -15
  132. data/test/projected_geographic/tc_line_string.rb +7 -15
  133. data/test/projected_geographic/tc_multi_line_string.rb +7 -16
  134. data/test/projected_geographic/tc_multi_point.rb +8 -17
  135. data/test/projected_geographic/tc_multi_polygon.rb +8 -16
  136. data/test/projected_geographic/tc_point.rb +11 -23
  137. data/test/projected_geographic/tc_polygon.rb +7 -15
  138. data/test/simple_cartesian/tc_calculations.rb +6 -22
  139. data/test/simple_cartesian/tc_factory.rb +7 -16
  140. data/test/simple_cartesian/tc_geometry_collection.rb +6 -15
  141. data/test/simple_cartesian/tc_line_string.rb +6 -15
  142. data/test/simple_cartesian/tc_multi_line_string.rb +6 -15
  143. data/test/simple_cartesian/tc_multi_point.rb +7 -16
  144. data/test/simple_cartesian/tc_multi_polygon.rb +7 -16
  145. data/test/simple_cartesian/tc_point.rb +10 -21
  146. data/test/simple_cartesian/tc_polygon.rb +6 -15
  147. data/test/simple_mercator/tc_factory.rb +6 -14
  148. data/test/simple_mercator/tc_geometry_collection.rb +6 -14
  149. data/test/simple_mercator/tc_line_string.rb +6 -14
  150. data/test/simple_mercator/tc_multi_line_string.rb +6 -15
  151. data/test/simple_mercator/tc_multi_point.rb +7 -16
  152. data/test/simple_mercator/tc_multi_polygon.rb +7 -15
  153. data/test/simple_mercator/tc_point.rb +11 -24
  154. data/test/simple_mercator/tc_polygon.rb +6 -14
  155. data/test/simple_mercator/tc_window.rb +10 -34
  156. data/test/spherical_geographic/tc_calculations.rb +5 -32
  157. data/test/spherical_geographic/tc_factory.rb +6 -15
  158. data/test/spherical_geographic/tc_geometry_collection.rb +6 -15
  159. data/test/spherical_geographic/tc_line_string.rb +6 -15
  160. data/test/spherical_geographic/tc_multi_line_string.rb +6 -15
  161. data/test/spherical_geographic/tc_multi_point.rb +7 -16
  162. data/test/spherical_geographic/tc_multi_polygon.rb +7 -16
  163. data/test/spherical_geographic/tc_point.rb +10 -22
  164. data/test/spherical_geographic/tc_polygon.rb +6 -15
  165. data/test/tc_cartesian_analysis.rb +4 -16
  166. data/test/tc_cartesian_bbox.rb +7 -21
  167. data/test/tc_mixins.rb +8 -25
  168. data/test/tc_oneoff.rb +5 -13
  169. data/test/tc_types.rb +7 -16
  170. data/test/wkrep/tc_wkb_generator.rb +63 -97
  171. data/test/wkrep/tc_wkb_parser.rb +63 -100
  172. data/test/wkrep/tc_wkt_generator.rb +54 -92
  173. data/test/wkrep/tc_wkt_parser.rb +84 -133
  174. metadata +39 -9
  175. data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +0 -166
  176. data/test/coord_sys/tc_active_record_table.rb +0 -79
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgeo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
- - Daniel Azuma
7
+ - Daniel Azuma, Tee Parham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-27 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -66,18 +66,36 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.35'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.35'
69
83
  description: RGeo is a geospatial data library for Ruby. It provides an implementation
70
84
  of the Open Geospatial Consortium's Simple Features Specification, used by most
71
85
  standard spatial/geographic data storage systems such as PostGIS. A number of add-on
72
86
  modules are also available to help with writing location-based applications using
73
87
  Ruby-based frameworks such as Ruby On Rails.
74
- email: dazuma@gmail.com
88
+ email: dazuma@gmail.com, parhameter@gmail.com
75
89
  executables: []
76
90
  extensions:
77
91
  - ext/geos_c_impl/extconf.rb
78
92
  - ext/proj4_c_impl/extconf.rb
79
93
  extra_rdoc_files: []
80
94
  files:
95
+ - LICENSE.txt
96
+ - ext/geos_c_impl/Makefile_2.2.3
97
+ - ext/geos_c_impl/coordinates.c
98
+ - ext/geos_c_impl/coordinates.h
81
99
  - ext/geos_c_impl/extconf.rb
82
100
  - ext/geos_c_impl/factory.c
83
101
  - ext/geos_c_impl/factory.h
@@ -85,16 +103,21 @@ files:
85
103
  - ext/geos_c_impl/geometry.h
86
104
  - ext/geos_c_impl/geometry_collection.c
87
105
  - ext/geos_c_impl/geometry_collection.h
106
+ - ext/geos_c_impl/geos_c_impl_2.2.3.bundle
88
107
  - ext/geos_c_impl/line_string.c
89
108
  - ext/geos_c_impl/line_string.h
90
109
  - ext/geos_c_impl/main.c
110
+ - ext/geos_c_impl/mkmf.log
91
111
  - ext/geos_c_impl/point.c
92
112
  - ext/geos_c_impl/point.h
93
113
  - ext/geos_c_impl/polygon.c
94
114
  - ext/geos_c_impl/polygon.h
95
115
  - ext/geos_c_impl/preface.h
116
+ - ext/proj4_c_impl/Makefile_2.2.3
96
117
  - ext/proj4_c_impl/extconf.rb
97
118
  - ext/proj4_c_impl/main.c
119
+ - ext/proj4_c_impl/mkmf.log
120
+ - ext/proj4_c_impl/proj4_c_impl_2.2.3.bundle
98
121
  - lib/rgeo.rb
99
122
  - lib/rgeo/cartesian.rb
100
123
  - lib/rgeo/cartesian/analysis.rb
@@ -109,7 +132,7 @@ files:
109
132
  - lib/rgeo/coord_sys/cs/factories.rb
110
133
  - lib/rgeo/coord_sys/cs/wkt_parser.rb
111
134
  - lib/rgeo/coord_sys/proj4.rb
112
- - lib/rgeo/coord_sys/srs_database/active_record_table.rb
135
+ - lib/rgeo/coord_sys/proj4_c_impl.bundle
113
136
  - lib/rgeo/coord_sys/srs_database/interface.rb
114
137
  - lib/rgeo/coord_sys/srs_database/proj4_data.rb
115
138
  - lib/rgeo/coord_sys/srs_database/sr_org.rb
@@ -151,6 +174,7 @@ files:
151
174
  - lib/rgeo/geos/ffi_factory.rb
152
175
  - lib/rgeo/geos/ffi_feature_classes.rb
153
176
  - lib/rgeo/geos/ffi_feature_methods.rb
177
+ - lib/rgeo/geos/geos_c_impl.bundle
154
178
  - lib/rgeo/geos/interface.rb
155
179
  - lib/rgeo/geos/utils.rb
156
180
  - lib/rgeo/geos/zm_factory.rb
@@ -179,7 +203,6 @@ files:
179
203
  - test/common/multi_polygon_tests.rb
180
204
  - test/common/point_tests.rb
181
205
  - test/common/polygon_tests.rb
182
- - test/coord_sys/tc_active_record_table.rb
183
206
  - test/coord_sys/tc_ogc_cs.rb
184
207
  - test/coord_sys/tc_proj4.rb
185
208
  - test/coord_sys/tc_proj4_srs_data.rb
@@ -251,7 +274,7 @@ files:
251
274
  - test/wkrep/tc_wkb_parser.rb
252
275
  - test/wkrep/tc_wkt_generator.rb
253
276
  - test/wkrep/tc_wkt_parser.rb
254
- homepage: http://github.com/rgeo/rgeo
277
+ homepage: https://github.com/rgeo/rgeo
255
278
  licenses: []
256
279
  metadata: {}
257
280
  post_install_message:
@@ -270,12 +293,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
293
  version: '0'
271
294
  requirements: []
272
295
  rubyforge_project:
273
- rubygems_version: 2.4.8
296
+ rubygems_version: 2.5.0
274
297
  signing_key:
275
298
  specification_version: 4
276
299
  summary: RGeo is a geospatial data library for Ruby.
277
300
  test_files:
278
- - test/coord_sys/tc_active_record_table.rb
301
+ - test/common/factory_tests.rb
302
+ - test/common/geometry_collection_tests.rb
303
+ - test/common/line_string_tests.rb
304
+ - test/common/multi_line_string_tests.rb
305
+ - test/common/multi_point_tests.rb
306
+ - test/common/multi_polygon_tests.rb
307
+ - test/common/point_tests.rb
308
+ - test/common/polygon_tests.rb
279
309
  - test/coord_sys/tc_ogc_cs.rb
280
310
  - test/coord_sys/tc_proj4.rb
281
311
  - test/coord_sys/tc_proj4_srs_data.rb
@@ -1,166 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # SRS database interface
4
- #
5
- # -----------------------------------------------------------------------------
6
-
7
- module RGeo
8
-
9
- module CoordSys
10
-
11
- module SRSDatabase
12
-
13
-
14
- # A spatial reference database implementation that uses ActiveRecord
15
- # to access a spatial reference table provided by a spatial database
16
- # implementation. You can use this class to obtain coordinate system
17
- # information from your installation of, e.g. PostGIS.
18
-
19
- class ActiveRecordTable
20
-
21
- @@class_counter = 0
22
-
23
-
24
- # Create a new ActiveRecord-backed database connection.
25
- #
26
- # Options include:
27
- #
28
- # [<tt>:ar_class</tt>]
29
- # An ActiveRecord class to use. You may provide this if you
30
- # already have an ActiveRecord class that accesses the table.
31
- # If not provided, an ActiveRecord class will be generated
32
- # for you, using the <tt>:ar_base_class</tt>,
33
- # <tt>:database_config</tt>, and <tt>:table_name</tt> options.
34
- # [<tt>:ar_base_class</tt>]
35
- # Specify an ActiveRecord base class to use when generating an
36
- # ActiveRecord class. Default is ::ActiveRecord::Base. You may
37
- # want to use this if you have a base class already that
38
- # specifies an existing database connection and/or other
39
- # class-scope options.
40
- # [<tt>:database_config</tt>]
41
- # If provided, <tt>establish_connection</tt> will be called on
42
- # the generated ActiveRecord class, with the given value.
43
- # [<tt>:table_name</tt>]
44
- # The table name for the new ActiveRecord class. Defaults to
45
- # the value <tt>spatial_ref_sys</tt>, which is the OGC-specified
46
- # name for this table.
47
- # [<tt>:srid_column</tt>]
48
- # The name of the SRID column. Defaults to "srid", which is the
49
- # OGC-specified name for this column.
50
- # [<tt>:auth_name_column</tt>]
51
- # The name of the authority name column. On an OGC-compliant
52
- # database, this column should be named "auth_name". However,
53
- # the default is set to nil; you should set this option
54
- # explicitly if you want to read the authority name.
55
- # [<tt>:auth_srid_column</tt>]
56
- # The name of the authority srid column. On an OGC-compliant
57
- # database, this column should be named "auth_srid". However,
58
- # the default is set to nil; you should set this option
59
- # explicitly if you want to read the authority's srid.
60
- # [<tt>:name_column</tt>]
61
- # The name of the coordinate system name column. This column is
62
- # not part of the OGC spec, but it is included in some spatial
63
- # database implementations. Default is nil.
64
- # [<tt>:description_column</tt>]
65
- # The name of the coordinate system description column. This
66
- # column is not part of the OGC spec, but may be included in
67
- # some spatial database implementations. Default is nil.
68
- # [<tt>:srtext_column</tt>]
69
- # The name of the spatial reference WKT column. On an
70
- # OGC-compliant database, this column should be named "srtext".
71
- # However, not all databases include this column, so the default
72
- # is set to nil; you should set this option explicitly if you
73
- # want to read the OGC coordinate system specification.
74
- # [<tt>:proj4text_column</tt>]
75
- # The name of the Proj4 format projection spec column. This
76
- # column is not part of the OGC spec, but may be included in
77
- # some spatial database implementations. Default is nil.
78
- # [<tt>:cache</tt>]
79
- # If set to true, entries are cached when first retrieved, so
80
- # subsequent requests do not have to make a database round trip.
81
- # Default is false.
82
- #
83
- # Some option settings may be provided by the ActiveRecord
84
- # connection adapter, if the ActiveRecord class's connection uses
85
- # an adapter that is RGeo-savvy. The "postgis" and "spatialite"
86
- # adapters are such adapters. They automatically provide the
87
- # <tt>:table_name</tt> and all the relevant column settings for
88
- # the database-provided spatial reference table as defaults.
89
- # However, you can still override those settings if you want to
90
- # use a custom table.
91
-
92
- def initialize(opts_={})
93
- @cache = opts_[:cache] ? {} : nil
94
- @ar_class = opts_[:ar_class]
95
- unless @ar_class
96
- ar_base_class_ = opts_[:ar_base_class] || ::ActiveRecord::Base
97
- @ar_class = ::Class.new(ar_base_class_)
98
- self.class.const_set("Klass#{@@class_counter}", @ar_class)
99
- @@class_counter += 1
100
- if opts_[:database_config]
101
- @ar_class.class_eval do
102
- establish_connection(opts_[:database_config])
103
- end
104
- end
105
- end
106
- connection_ = @ar_class.connection
107
- if connection_.respond_to?(:srs_database_columns)
108
- opts_ = connection_.srs_database_columns.merge(opts_)
109
- end
110
- unless opts_[:ar_class]
111
- @ar_class.class_eval do
112
- self.table_name = opts_[:table_name] || 'spatial_ref_sys'
113
- end
114
- end
115
- @srid_column = opts_[:srid_column] || 'srid'
116
- @auth_name_column = opts_[:auth_name_column]
117
- @auth_srid_column = opts_[:auth_srid_column]
118
- @name_column = opts_[:name_column]
119
- @description_column = opts_[:description_column]
120
- @srtext_column = opts_[:srtext_column]
121
- @proj4text_column = opts_[:proj4text_column]
122
- end
123
-
124
-
125
- # Retrieve an Entry given an integer SRID.
126
-
127
- def get(ident_)
128
- ident_ = ident_.to_i
129
- return @cache[ident_] if @cache && @cache.include?(ident_)
130
- obj_ = @ar_class.where(@srid_column => ident_).first
131
- unless obj_
132
- @cache[ident_] = nil if @cache
133
- return nil
134
- end
135
- auth_name_ = @auth_name_column ? obj_[@auth_name_column] : nil
136
- auth_srid_ = @auth_srid_column ? obj_[@auth_srid_column] : nil
137
- name_ = @name_column ? obj_[@name_column] : nil
138
- description_ = @description_column ? obj_[@description_column] : nil
139
- coord_sys_ = proj4_ = nil
140
- if @srtext_column
141
- coord_sys_ = CS.create_from_wkt(obj_[@srtext_column]) rescue nil
142
- end
143
- if @proj4text_column && Proj4.supported?
144
- proj4_ = Proj4.create(obj_[@proj4text_column].strip) rescue nil
145
- end
146
- result_ = Entry.new(ident_, :authority => auth_name_, :authority_code => auth_srid_, :name => name_, :description => description_, :coord_sys => coord_sys_, :proj4 => proj4_)
147
- @cache[ident_] = result_ if @cache
148
- result_
149
- end
150
-
151
-
152
- # Clears the cache if a cache is active.
153
-
154
- def clear_cache
155
- @cache.clear if @cache
156
- end
157
-
158
-
159
- end
160
-
161
-
162
- end
163
-
164
- end
165
-
166
- end
@@ -1,79 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # Tests for OGC CS classes
4
- #
5
- # -----------------------------------------------------------------------------
6
-
7
- require 'test/unit'
8
- require 'rgeo'
9
- require 'yaml'
10
-
11
-
12
- module RGeo
13
- module Tests # :nodoc:
14
- module CoordSys # :nodoc:
15
- module ActiveRecordTableTests # :nodoc:
16
-
17
- database_configs_ = ::YAML.load_file(::File.dirname(__FILE__)+'/database.yml') rescue nil
18
- if database_configs_
19
- begin
20
- require 'active_record'
21
- rescue ::LoadError
22
- database_configs_ = nil
23
- end
24
- end
25
-
26
- if database_configs_
27
-
28
- PostGIS_CONFIG = database_configs_['postgis'] rescue nil
29
-
30
-
31
- if PostGIS_CONFIG
32
-
33
- class TestPostGIS < ::Test::Unit::TestCase # :nodoc:
34
-
35
- @@db = ::RGeo::CoordSys::SRSDatabase::ActiveRecordTable.new(
36
- :database_config => PostGIS_CONFIG,
37
- :auth_name_column => 'auth_name', :auth_srid_column => 'auth_srid',
38
- :srtext_column => 'srtext', :proj4text_column => 'proj4text')
39
-
40
-
41
- def test_4326
42
- entry_ = @@db.get(4326)
43
- allowed_vals_ = [
44
- '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', # Proj 4.7
45
- '+proj=longlat +datum=WGS84 +no_defs' # Proj 4.8
46
- ]
47
- assert(allowed_vals_.include?(entry_.proj4.original_str))
48
- assert_kind_of(::RGeo::CoordSys::CS::GeographicCoordinateSystem, entry_.coord_sys)
49
- assert_equal('WGS 84', entry_.name)
50
- end
51
-
52
-
53
- def test_3857
54
- entry_ = @@db.get(3857)
55
- allowed_vals_ = [
56
- '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +units=m +k=1.0 +nadgrids=@null +no_defs', # Proj 4.7
57
- '+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' # Proj 4.8
58
- ]
59
- assert(allowed_vals_.include?(entry_.proj4.original_str))
60
- assert_kind_of(::RGeo::CoordSys::CS::ProjectedCoordinateSystem, entry_.coord_sys)
61
- assert_equal('Popular Visualisation CRS / Mercator (deprecated)', entry_.name)
62
- end
63
-
64
-
65
- end
66
-
67
- else
68
- puts "WARNING: No postgis section in database.yml; skipping PostGIS tests."
69
- end
70
-
71
-
72
- else
73
- puts "WARNING: Couldn't find database.yml or ActiveRecord gem is not present; skipping ActiveRecord tests."
74
- end
75
-
76
- end
77
- end
78
- end
79
- end