activerecord-postgres-earthdistance 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/.document +5 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.lock +84 -0
  4. data/LICENSE +20 -0
  5. data/README.rdoc +17 -0
  6. data/Rakefile +55 -0
  7. data/VERSION +1 -0
  8. data/activerecord-postgres-earthdistance.gemspec +124 -0
  9. data/lib/activerecord-postgres-earthdistance.rb +48 -0
  10. data/lib/activerecord-postgres-earthdistance/activerecord.rb +17 -0
  11. data/lib/templates/cube.sql +326 -0
  12. data/lib/templates/earthdistance.sql +93 -0
  13. data/lib/templates/setup_earthdistance.rb +434 -0
  14. data/test/app/.gitignore +4 -0
  15. data/test/app/Gemfile +5 -0
  16. data/test/app/Gemfile.lock +83 -0
  17. data/test/app/README +256 -0
  18. data/test/app/Rakefile +7 -0
  19. data/test/app/app/controllers/application_controller.rb +3 -0
  20. data/test/app/app/helpers/application_helper.rb +2 -0
  21. data/test/app/app/models/place.rb +3 -0
  22. data/test/app/app/views/layouts/application.html.erb +14 -0
  23. data/test/app/config.ru +4 -0
  24. data/test/app/config/application.rb +42 -0
  25. data/test/app/config/boot.rb +13 -0
  26. data/test/app/config/database.yml +25 -0
  27. data/test/app/config/environment.rb +5 -0
  28. data/test/app/config/environments/development.rb +26 -0
  29. data/test/app/config/environments/production.rb +49 -0
  30. data/test/app/config/environments/test.rb +35 -0
  31. data/test/app/config/initializers/backtrace_silencers.rb +7 -0
  32. data/test/app/config/initializers/inflections.rb +10 -0
  33. data/test/app/config/initializers/mime_types.rb +5 -0
  34. data/test/app/config/initializers/secret_token.rb +7 -0
  35. data/test/app/config/initializers/session_store.rb +8 -0
  36. data/test/app/config/initializers/use_sql_schema.rb +3 -0
  37. data/test/app/config/locales/en.yml +5 -0
  38. data/test/app/config/routes.rb +58 -0
  39. data/test/app/db/development_structure.sql +807 -0
  40. data/test/app/db/migrate/20110225205046_setup_earthdistance.rb +434 -0
  41. data/test/app/db/migrate/20110225205131_create_places.rb +15 -0
  42. data/test/app/db/schema.rb +24 -0
  43. data/test/app/db/seeds.rb +7 -0
  44. data/test/app/doc/README_FOR_APP +2 -0
  45. data/test/app/lib/tasks/.gitkeep +0 -0
  46. data/test/app/public/404.html +26 -0
  47. data/test/app/public/422.html +26 -0
  48. data/test/app/public/500.html +26 -0
  49. data/test/app/public/favicon.ico +0 -0
  50. data/test/app/public/images/rails.png +0 -0
  51. data/test/app/public/index.html +239 -0
  52. data/test/app/public/javascripts/application.js +2 -0
  53. data/test/app/public/javascripts/controls.js +965 -0
  54. data/test/app/public/javascripts/dragdrop.js +974 -0
  55. data/test/app/public/javascripts/effects.js +1123 -0
  56. data/test/app/public/javascripts/prototype.js +6001 -0
  57. data/test/app/public/javascripts/rails.js +175 -0
  58. data/test/app/public/robots.txt +5 -0
  59. data/test/app/public/stylesheets/.gitkeep +0 -0
  60. data/test/app/script/rails +6 -0
  61. data/test/app/test/performance/browsing_test.rb +9 -0
  62. data/test/app/test/test_helper.rb +13 -0
  63. data/test/app/test/unit/place_test.rb +27 -0
  64. data/test/app/vendor/plugins/.gitkeep +0 -0
  65. metadata +205 -0
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install postgresql-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: postgresql
5
+ database: earthdistance_development
6
+ pool: 5
7
+ timeout: 5000
8
+ username: diogo
9
+
10
+ # Warning: The database defined as "test" will be erased and
11
+ # re-generated from your development database when you run "rake".
12
+ # Do not set this db to the same as development or production.
13
+ test:
14
+ adapter: postgresql
15
+ database: earthdistance_test
16
+ pool: 5
17
+ timeout: 5000
18
+ username: diogo
19
+
20
+ production:
21
+ adapter: postgresql
22
+ database: earthdistance_test
23
+ pool: 5
24
+ timeout: 5000
25
+ username: diogo
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ App::Application.initialize!
@@ -0,0 +1,26 @@
1
+ App::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger
21
+ config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
25
+ end
26
+
@@ -0,0 +1,49 @@
1
+ App::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # Specifies the header that your server uses for sending files
13
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
+
15
+ # For nginx:
16
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
20
+
21
+ # See everything in the log (default is :info)
22
+ # config.log_level = :debug
23
+
24
+ # Use a different logger for distributed setups
25
+ # config.logger = SyslogLogger.new
26
+
27
+ # Use a different cache store in production
28
+ # config.cache_store = :mem_cache_store
29
+
30
+ # Disable Rails's static asset server
31
+ # In production, Apache or nginx will already do this
32
+ config.serve_static_assets = false
33
+
34
+ # Enable serving of images, stylesheets, and javascripts from an asset server
35
+ # config.action_controller.asset_host = "http://assets.example.com"
36
+
37
+ # Disable delivery errors, bad email addresses will be ignored
38
+ # config.action_mailer.raise_delivery_errors = false
39
+
40
+ # Enable threaded mode
41
+ # config.threadsafe!
42
+
43
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44
+ # the I18n.default_locale when a translation can not be found)
45
+ config.i18n.fallbacks = true
46
+
47
+ # Send deprecation notices to registered listeners
48
+ config.active_support.deprecation = :notify
49
+ end
@@ -0,0 +1,35 @@
1
+ App::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ App::Application.config.secret_token = 'fd1578c2e92c9d24325e92cea92f48e51c85d39fb7b555391cfe287642d1d5e17735939db1dd5a247d1b39f1794db045b6ae702a57f2e6dc42fc299f9add7609'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ App::Application.config.session_store :cookie_store, :key => '_app_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # App::Application.config.session_store :active_record_store
@@ -0,0 +1,3 @@
1
+ App::Application.configure do
2
+ config.active_record.schema_format = :sql
3
+ end
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,58 @@
1
+ App::Application.routes.draw do
2
+ # The priority is based upon order of creation:
3
+ # first created -> highest priority.
4
+
5
+ # Sample of regular route:
6
+ # match 'products/:id' => 'catalog#view'
7
+ # Keep in mind you can assign values other than :controller and :action
8
+
9
+ # Sample of named route:
10
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
11
+ # This route can be invoked with purchase_url(:id => product.id)
12
+
13
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
14
+ # resources :products
15
+
16
+ # Sample resource route with options:
17
+ # resources :products do
18
+ # member do
19
+ # get 'short'
20
+ # post 'toggle'
21
+ # end
22
+ #
23
+ # collection do
24
+ # get 'sold'
25
+ # end
26
+ # end
27
+
28
+ # Sample resource route with sub-resources:
29
+ # resources :products do
30
+ # resources :comments, :sales
31
+ # resource :seller
32
+ # end
33
+
34
+ # Sample resource route with more complex sub-resources
35
+ # resources :products do
36
+ # resources :comments
37
+ # resources :sales do
38
+ # get 'recent', :on => :collection
39
+ # end
40
+ # end
41
+
42
+ # Sample resource route within a namespace:
43
+ # namespace :admin do
44
+ # # Directs /admin/products/* to Admin::ProductsController
45
+ # # (app/controllers/admin/products_controller.rb)
46
+ # resources :products
47
+ # end
48
+
49
+ # You can have the root of your site routed with "root"
50
+ # just remember to delete public/index.html.
51
+ # root :to => "welcome#index"
52
+
53
+ # See how all your routes lay out with "rake routes"
54
+
55
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
56
+ # Note: This route will make all actions in every controller accessible via GET requests.
57
+ # match ':controller(/:action(/:id(.:format)))'
58
+ end
@@ -0,0 +1,807 @@
1
+ --
2
+ -- PostgreSQL database dump
3
+ --
4
+
5
+ SET statement_timeout = 0;
6
+ SET client_encoding = 'UTF8';
7
+ SET standard_conforming_strings = off;
8
+ SET check_function_bodies = false;
9
+ SET client_min_messages = warning;
10
+ SET escape_string_warning = off;
11
+
12
+ --
13
+ -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -
14
+ --
15
+
16
+ CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql;
17
+
18
+
19
+ SET search_path = public, pg_catalog;
20
+
21
+ --
22
+ -- Name: cube; Type: SHELL TYPE; Schema: public; Owner: -
23
+ --
24
+
25
+ CREATE TYPE cube;
26
+
27
+
28
+ --
29
+ -- Name: cube_in(cstring); Type: FUNCTION; Schema: public; Owner: -
30
+ --
31
+
32
+ CREATE FUNCTION cube_in(cstring) RETURNS cube
33
+ LANGUAGE c IMMUTABLE STRICT
34
+ AS '$libdir/cube', 'cube_in';
35
+
36
+
37
+ --
38
+ -- Name: cube_out(cube); Type: FUNCTION; Schema: public; Owner: -
39
+ --
40
+
41
+ CREATE FUNCTION cube_out(cube) RETURNS cstring
42
+ LANGUAGE c IMMUTABLE STRICT
43
+ AS '$libdir/cube', 'cube_out';
44
+
45
+
46
+ --
47
+ -- Name: cube; Type: TYPE; Schema: public; Owner: -
48
+ --
49
+
50
+ CREATE TYPE cube (
51
+ INTERNALLENGTH = variable,
52
+ INPUT = cube_in,
53
+ OUTPUT = cube_out,
54
+ ALIGNMENT = double,
55
+ STORAGE = plain
56
+ );
57
+
58
+
59
+ --
60
+ -- Name: TYPE cube; Type: COMMENT; Schema: public; Owner: -
61
+ --
62
+
63
+ COMMENT ON TYPE cube IS 'multi-dimensional cube ''(FLOAT-1, FLOAT-2, ..., FLOAT-N), (FLOAT-1, FLOAT-2, ..., FLOAT-N)''';
64
+
65
+
66
+ --
67
+ -- Name: cube_dim(cube); Type: FUNCTION; Schema: public; Owner: -
68
+ --
69
+
70
+ CREATE FUNCTION cube_dim(cube) RETURNS integer
71
+ LANGUAGE c IMMUTABLE STRICT
72
+ AS '$libdir/cube', 'cube_dim';
73
+
74
+
75
+ --
76
+ -- Name: cube_distance(cube, cube); Type: FUNCTION; Schema: public; Owner: -
77
+ --
78
+
79
+ CREATE FUNCTION cube_distance(cube, cube) RETURNS double precision
80
+ LANGUAGE c IMMUTABLE STRICT
81
+ AS '$libdir/cube', 'cube_distance';
82
+
83
+
84
+ --
85
+ -- Name: cube_is_point(cube); Type: FUNCTION; Schema: public; Owner: -
86
+ --
87
+
88
+ CREATE FUNCTION cube_is_point(cube) RETURNS boolean
89
+ LANGUAGE c IMMUTABLE STRICT
90
+ AS '$libdir/cube', 'cube_is_point';
91
+
92
+
93
+ --
94
+ -- Name: earth(); Type: FUNCTION; Schema: public; Owner: -
95
+ --
96
+
97
+ CREATE FUNCTION earth() RETURNS double precision
98
+ LANGUAGE sql IMMUTABLE
99
+ AS $$SELECT '6378168'::float8$$;
100
+
101
+
102
+ --
103
+ -- Name: earth; Type: DOMAIN; Schema: public; Owner: -
104
+ --
105
+
106
+ CREATE DOMAIN earth AS cube
107
+ CONSTRAINT not_3d CHECK ((cube_dim(VALUE) <= 3))
108
+ CONSTRAINT not_point CHECK (cube_is_point(VALUE))
109
+ CONSTRAINT on_surface CHECK ((abs(((cube_distance(VALUE, '(0)'::cube) / earth()) - (1)::double precision)) < 9.99999999999999955e-07::double precision));
110
+
111
+
112
+ --
113
+ -- Name: cube(double precision[]); Type: FUNCTION; Schema: public; Owner: -
114
+ --
115
+
116
+ CREATE FUNCTION cube(double precision[]) RETURNS cube
117
+ LANGUAGE c IMMUTABLE STRICT
118
+ AS '$libdir/cube', 'cube_a_f8';
119
+
120
+
121
+ --
122
+ -- Name: cube(double precision); Type: FUNCTION; Schema: public; Owner: -
123
+ --
124
+
125
+ CREATE FUNCTION cube(double precision) RETURNS cube
126
+ LANGUAGE c IMMUTABLE STRICT
127
+ AS '$libdir/cube', 'cube_f8';
128
+
129
+
130
+ --
131
+ -- Name: cube(double precision[], double precision[]); Type: FUNCTION; Schema: public; Owner: -
132
+ --
133
+
134
+ CREATE FUNCTION cube(double precision[], double precision[]) RETURNS cube
135
+ LANGUAGE c IMMUTABLE STRICT
136
+ AS '$libdir/cube', 'cube_a_f8_f8';
137
+
138
+
139
+ --
140
+ -- Name: cube(double precision, double precision); Type: FUNCTION; Schema: public; Owner: -
141
+ --
142
+
143
+ CREATE FUNCTION cube(double precision, double precision) RETURNS cube
144
+ LANGUAGE c IMMUTABLE STRICT
145
+ AS '$libdir/cube', 'cube_f8_f8';
146
+
147
+
148
+ --
149
+ -- Name: cube(cube, double precision); Type: FUNCTION; Schema: public; Owner: -
150
+ --
151
+
152
+ CREATE FUNCTION cube(cube, double precision) RETURNS cube
153
+ LANGUAGE c IMMUTABLE STRICT
154
+ AS '$libdir/cube', 'cube_c_f8';
155
+
156
+
157
+ --
158
+ -- Name: cube(cube, double precision, double precision); Type: FUNCTION; Schema: public; Owner: -
159
+ --
160
+
161
+ CREATE FUNCTION cube(cube, double precision, double precision) RETURNS cube
162
+ LANGUAGE c IMMUTABLE STRICT
163
+ AS '$libdir/cube', 'cube_c_f8_f8';
164
+
165
+
166
+ --
167
+ -- Name: cube_cmp(cube, cube); Type: FUNCTION; Schema: public; Owner: -
168
+ --
169
+
170
+ CREATE FUNCTION cube_cmp(cube, cube) RETURNS integer
171
+ LANGUAGE c IMMUTABLE STRICT
172
+ AS '$libdir/cube', 'cube_cmp';
173
+
174
+
175
+ --
176
+ -- Name: FUNCTION cube_cmp(cube, cube); Type: COMMENT; Schema: public; Owner: -
177
+ --
178
+
179
+ COMMENT ON FUNCTION cube_cmp(cube, cube) IS 'btree comparison function';
180
+
181
+
182
+ --
183
+ -- Name: cube_contained(cube, cube); Type: FUNCTION; Schema: public; Owner: -
184
+ --
185
+
186
+ CREATE FUNCTION cube_contained(cube, cube) RETURNS boolean
187
+ LANGUAGE c IMMUTABLE STRICT
188
+ AS '$libdir/cube', 'cube_contained';
189
+
190
+
191
+ --
192
+ -- Name: FUNCTION cube_contained(cube, cube); Type: COMMENT; Schema: public; Owner: -
193
+ --
194
+
195
+ COMMENT ON FUNCTION cube_contained(cube, cube) IS 'contained in';
196
+
197
+
198
+ --
199
+ -- Name: cube_contains(cube, cube); Type: FUNCTION; Schema: public; Owner: -
200
+ --
201
+
202
+ CREATE FUNCTION cube_contains(cube, cube) RETURNS boolean
203
+ LANGUAGE c IMMUTABLE STRICT
204
+ AS '$libdir/cube', 'cube_contains';
205
+
206
+
207
+ --
208
+ -- Name: FUNCTION cube_contains(cube, cube); Type: COMMENT; Schema: public; Owner: -
209
+ --
210
+
211
+ COMMENT ON FUNCTION cube_contains(cube, cube) IS 'contains';
212
+
213
+
214
+ --
215
+ -- Name: cube_enlarge(cube, double precision, integer); Type: FUNCTION; Schema: public; Owner: -
216
+ --
217
+
218
+ CREATE FUNCTION cube_enlarge(cube, double precision, integer) RETURNS cube
219
+ LANGUAGE c IMMUTABLE STRICT
220
+ AS '$libdir/cube', 'cube_enlarge';
221
+
222
+
223
+ --
224
+ -- Name: cube_eq(cube, cube); Type: FUNCTION; Schema: public; Owner: -
225
+ --
226
+
227
+ CREATE FUNCTION cube_eq(cube, cube) RETURNS boolean
228
+ LANGUAGE c IMMUTABLE STRICT
229
+ AS '$libdir/cube', 'cube_eq';
230
+
231
+
232
+ --
233
+ -- Name: FUNCTION cube_eq(cube, cube); Type: COMMENT; Schema: public; Owner: -
234
+ --
235
+
236
+ COMMENT ON FUNCTION cube_eq(cube, cube) IS 'same as';
237
+
238
+
239
+ --
240
+ -- Name: cube_ge(cube, cube); Type: FUNCTION; Schema: public; Owner: -
241
+ --
242
+
243
+ CREATE FUNCTION cube_ge(cube, cube) RETURNS boolean
244
+ LANGUAGE c IMMUTABLE STRICT
245
+ AS '$libdir/cube', 'cube_ge';
246
+
247
+
248
+ --
249
+ -- Name: FUNCTION cube_ge(cube, cube); Type: COMMENT; Schema: public; Owner: -
250
+ --
251
+
252
+ COMMENT ON FUNCTION cube_ge(cube, cube) IS 'greater than or equal to';
253
+
254
+
255
+ --
256
+ -- Name: cube_gt(cube, cube); Type: FUNCTION; Schema: public; Owner: -
257
+ --
258
+
259
+ CREATE FUNCTION cube_gt(cube, cube) RETURNS boolean
260
+ LANGUAGE c IMMUTABLE STRICT
261
+ AS '$libdir/cube', 'cube_gt';
262
+
263
+
264
+ --
265
+ -- Name: FUNCTION cube_gt(cube, cube); Type: COMMENT; Schema: public; Owner: -
266
+ --
267
+
268
+ COMMENT ON FUNCTION cube_gt(cube, cube) IS 'greater than';
269
+
270
+
271
+ --
272
+ -- Name: cube_inter(cube, cube); Type: FUNCTION; Schema: public; Owner: -
273
+ --
274
+
275
+ CREATE FUNCTION cube_inter(cube, cube) RETURNS cube
276
+ LANGUAGE c IMMUTABLE STRICT
277
+ AS '$libdir/cube', 'cube_inter';
278
+
279
+
280
+ --
281
+ -- Name: cube_le(cube, cube); Type: FUNCTION; Schema: public; Owner: -
282
+ --
283
+
284
+ CREATE FUNCTION cube_le(cube, cube) RETURNS boolean
285
+ LANGUAGE c IMMUTABLE STRICT
286
+ AS '$libdir/cube', 'cube_le';
287
+
288
+
289
+ --
290
+ -- Name: FUNCTION cube_le(cube, cube); Type: COMMENT; Schema: public; Owner: -
291
+ --
292
+
293
+ COMMENT ON FUNCTION cube_le(cube, cube) IS 'lower than or equal to';
294
+
295
+
296
+ --
297
+ -- Name: cube_ll_coord(cube, integer); Type: FUNCTION; Schema: public; Owner: -
298
+ --
299
+
300
+ CREATE FUNCTION cube_ll_coord(cube, integer) RETURNS double precision
301
+ LANGUAGE c IMMUTABLE STRICT
302
+ AS '$libdir/cube', 'cube_ll_coord';
303
+
304
+
305
+ --
306
+ -- Name: cube_lt(cube, cube); Type: FUNCTION; Schema: public; Owner: -
307
+ --
308
+
309
+ CREATE FUNCTION cube_lt(cube, cube) RETURNS boolean
310
+ LANGUAGE c IMMUTABLE STRICT
311
+ AS '$libdir/cube', 'cube_lt';
312
+
313
+
314
+ --
315
+ -- Name: FUNCTION cube_lt(cube, cube); Type: COMMENT; Schema: public; Owner: -
316
+ --
317
+
318
+ COMMENT ON FUNCTION cube_lt(cube, cube) IS 'lower than';
319
+
320
+
321
+ --
322
+ -- Name: cube_ne(cube, cube); Type: FUNCTION; Schema: public; Owner: -
323
+ --
324
+
325
+ CREATE FUNCTION cube_ne(cube, cube) RETURNS boolean
326
+ LANGUAGE c IMMUTABLE STRICT
327
+ AS '$libdir/cube', 'cube_ne';
328
+
329
+
330
+ --
331
+ -- Name: FUNCTION cube_ne(cube, cube); Type: COMMENT; Schema: public; Owner: -
332
+ --
333
+
334
+ COMMENT ON FUNCTION cube_ne(cube, cube) IS 'different';
335
+
336
+
337
+ --
338
+ -- Name: cube_overlap(cube, cube); Type: FUNCTION; Schema: public; Owner: -
339
+ --
340
+
341
+ CREATE FUNCTION cube_overlap(cube, cube) RETURNS boolean
342
+ LANGUAGE c IMMUTABLE STRICT
343
+ AS '$libdir/cube', 'cube_overlap';
344
+
345
+
346
+ --
347
+ -- Name: FUNCTION cube_overlap(cube, cube); Type: COMMENT; Schema: public; Owner: -
348
+ --
349
+
350
+ COMMENT ON FUNCTION cube_overlap(cube, cube) IS 'overlaps';
351
+
352
+
353
+ --
354
+ -- Name: cube_size(cube); Type: FUNCTION; Schema: public; Owner: -
355
+ --
356
+
357
+ CREATE FUNCTION cube_size(cube) RETURNS double precision
358
+ LANGUAGE c IMMUTABLE STRICT
359
+ AS '$libdir/cube', 'cube_size';
360
+
361
+
362
+ --
363
+ -- Name: cube_subset(cube, integer[]); Type: FUNCTION; Schema: public; Owner: -
364
+ --
365
+
366
+ CREATE FUNCTION cube_subset(cube, integer[]) RETURNS cube
367
+ LANGUAGE c IMMUTABLE STRICT
368
+ AS '$libdir/cube', 'cube_subset';
369
+
370
+
371
+ --
372
+ -- Name: cube_union(cube, cube); Type: FUNCTION; Schema: public; Owner: -
373
+ --
374
+
375
+ CREATE FUNCTION cube_union(cube, cube) RETURNS cube
376
+ LANGUAGE c IMMUTABLE STRICT
377
+ AS '$libdir/cube', 'cube_union';
378
+
379
+
380
+ --
381
+ -- Name: cube_ur_coord(cube, integer); Type: FUNCTION; Schema: public; Owner: -
382
+ --
383
+
384
+ CREATE FUNCTION cube_ur_coord(cube, integer) RETURNS double precision
385
+ LANGUAGE c IMMUTABLE STRICT
386
+ AS '$libdir/cube', 'cube_ur_coord';
387
+
388
+
389
+ --
390
+ -- Name: earth_box(earth, double precision); Type: FUNCTION; Schema: public; Owner: -
391
+ --
392
+
393
+ CREATE FUNCTION earth_box(earth, double precision) RETURNS cube
394
+ LANGUAGE sql IMMUTABLE STRICT
395
+ AS $_$SELECT cube_enlarge($1, gc_to_sec($2), 3)$_$;
396
+
397
+
398
+ --
399
+ -- Name: earth_distance(earth, earth); Type: FUNCTION; Schema: public; Owner: -
400
+ --
401
+
402
+ CREATE FUNCTION earth_distance(earth, earth) RETURNS double precision
403
+ LANGUAGE sql IMMUTABLE STRICT
404
+ AS $_$SELECT sec_to_gc(cube_distance($1, $2))$_$;
405
+
406
+
407
+ --
408
+ -- Name: g_cube_compress(internal); Type: FUNCTION; Schema: public; Owner: -
409
+ --
410
+
411
+ CREATE FUNCTION g_cube_compress(internal) RETURNS internal
412
+ LANGUAGE c IMMUTABLE STRICT
413
+ AS '$libdir/cube', 'g_cube_compress';
414
+
415
+
416
+ --
417
+ -- Name: g_cube_consistent(internal, cube, integer, oid, internal); Type: FUNCTION; Schema: public; Owner: -
418
+ --
419
+
420
+ CREATE FUNCTION g_cube_consistent(internal, cube, integer, oid, internal) RETURNS boolean
421
+ LANGUAGE c IMMUTABLE STRICT
422
+ AS '$libdir/cube', 'g_cube_consistent';
423
+
424
+
425
+ --
426
+ -- Name: g_cube_decompress(internal); Type: FUNCTION; Schema: public; Owner: -
427
+ --
428
+
429
+ CREATE FUNCTION g_cube_decompress(internal) RETURNS internal
430
+ LANGUAGE c IMMUTABLE STRICT
431
+ AS '$libdir/cube', 'g_cube_decompress';
432
+
433
+
434
+ --
435
+ -- Name: g_cube_penalty(internal, internal, internal); Type: FUNCTION; Schema: public; Owner: -
436
+ --
437
+
438
+ CREATE FUNCTION g_cube_penalty(internal, internal, internal) RETURNS internal
439
+ LANGUAGE c IMMUTABLE STRICT
440
+ AS '$libdir/cube', 'g_cube_penalty';
441
+
442
+
443
+ --
444
+ -- Name: g_cube_picksplit(internal, internal); Type: FUNCTION; Schema: public; Owner: -
445
+ --
446
+
447
+ CREATE FUNCTION g_cube_picksplit(internal, internal) RETURNS internal
448
+ LANGUAGE c IMMUTABLE STRICT
449
+ AS '$libdir/cube', 'g_cube_picksplit';
450
+
451
+
452
+ --
453
+ -- Name: g_cube_same(cube, cube, internal); Type: FUNCTION; Schema: public; Owner: -
454
+ --
455
+
456
+ CREATE FUNCTION g_cube_same(cube, cube, internal) RETURNS internal
457
+ LANGUAGE c IMMUTABLE STRICT
458
+ AS '$libdir/cube', 'g_cube_same';
459
+
460
+
461
+ --
462
+ -- Name: g_cube_union(internal, internal); Type: FUNCTION; Schema: public; Owner: -
463
+ --
464
+
465
+ CREATE FUNCTION g_cube_union(internal, internal) RETURNS cube
466
+ LANGUAGE c IMMUTABLE STRICT
467
+ AS '$libdir/cube', 'g_cube_union';
468
+
469
+
470
+ --
471
+ -- Name: gc_to_sec(double precision); Type: FUNCTION; Schema: public; Owner: -
472
+ --
473
+
474
+ CREATE FUNCTION gc_to_sec(double precision) RETURNS double precision
475
+ LANGUAGE sql IMMUTABLE STRICT
476
+ AS $_$SELECT CASE WHEN $1 < 0 THEN 0::float8 WHEN $1/earth() > pi() THEN 2*earth() ELSE 2*earth()*sin($1/(2*earth())) END$_$;
477
+
478
+
479
+ --
480
+ -- Name: geo_distance(point, point); Type: FUNCTION; Schema: public; Owner: -
481
+ --
482
+
483
+ CREATE FUNCTION geo_distance(point, point) RETURNS double precision
484
+ LANGUAGE c IMMUTABLE STRICT
485
+ AS '$libdir/earthdistance', 'geo_distance';
486
+
487
+
488
+ --
489
+ -- Name: latitude(earth); Type: FUNCTION; Schema: public; Owner: -
490
+ --
491
+
492
+ CREATE FUNCTION latitude(earth) RETURNS double precision
493
+ LANGUAGE sql IMMUTABLE STRICT
494
+ AS $_$SELECT CASE WHEN cube_ll_coord($1, 3)/earth() < -1 THEN -90::float8 WHEN cube_ll_coord($1, 3)/earth() > 1 THEN 90::float8 ELSE degrees(asin(cube_ll_coord($1, 3)/earth())) END$_$;
495
+
496
+
497
+ --
498
+ -- Name: ll_to_earth(double precision, double precision); Type: FUNCTION; Schema: public; Owner: -
499
+ --
500
+
501
+ CREATE FUNCTION ll_to_earth(double precision, double precision) RETURNS earth
502
+ LANGUAGE sql IMMUTABLE STRICT
503
+ AS $_$SELECT cube(cube(cube(earth()*cos(radians($1))*cos(radians($2))),earth()*cos(radians($1))*sin(radians($2))),earth()*sin(radians($1)))::earth$_$;
504
+
505
+
506
+ --
507
+ -- Name: longitude(earth); Type: FUNCTION; Schema: public; Owner: -
508
+ --
509
+
510
+ CREATE FUNCTION longitude(earth) RETURNS double precision
511
+ LANGUAGE sql IMMUTABLE STRICT
512
+ AS $_$SELECT degrees(atan2(cube_ll_coord($1, 2), cube_ll_coord($1, 1)))$_$;
513
+
514
+
515
+ --
516
+ -- Name: sec_to_gc(double precision); Type: FUNCTION; Schema: public; Owner: -
517
+ --
518
+
519
+ CREATE FUNCTION sec_to_gc(double precision) RETURNS double precision
520
+ LANGUAGE sql IMMUTABLE STRICT
521
+ AS $_$SELECT CASE WHEN $1 < 0 THEN 0::float8 WHEN $1/(2*earth()) > 1 THEN pi()*earth() ELSE 2*earth()*asin($1/(2*earth())) END$_$;
522
+
523
+
524
+ --
525
+ -- Name: &&; Type: OPERATOR; Schema: public; Owner: -
526
+ --
527
+
528
+ CREATE OPERATOR && (
529
+ PROCEDURE = cube_overlap,
530
+ LEFTARG = cube,
531
+ RIGHTARG = cube,
532
+ COMMUTATOR = &&,
533
+ RESTRICT = areasel,
534
+ JOIN = areajoinsel
535
+ );
536
+
537
+
538
+ --
539
+ -- Name: <; Type: OPERATOR; Schema: public; Owner: -
540
+ --
541
+
542
+ CREATE OPERATOR < (
543
+ PROCEDURE = cube_lt,
544
+ LEFTARG = cube,
545
+ RIGHTARG = cube,
546
+ COMMUTATOR = >,
547
+ NEGATOR = >=,
548
+ RESTRICT = scalarltsel,
549
+ JOIN = scalarltjoinsel
550
+ );
551
+
552
+
553
+ --
554
+ -- Name: <=; Type: OPERATOR; Schema: public; Owner: -
555
+ --
556
+
557
+ CREATE OPERATOR <= (
558
+ PROCEDURE = cube_le,
559
+ LEFTARG = cube,
560
+ RIGHTARG = cube,
561
+ COMMUTATOR = >=,
562
+ NEGATOR = >,
563
+ RESTRICT = scalarltsel,
564
+ JOIN = scalarltjoinsel
565
+ );
566
+
567
+
568
+ --
569
+ -- Name: <>; Type: OPERATOR; Schema: public; Owner: -
570
+ --
571
+
572
+ CREATE OPERATOR <> (
573
+ PROCEDURE = cube_ne,
574
+ LEFTARG = cube,
575
+ RIGHTARG = cube,
576
+ COMMUTATOR = <>,
577
+ NEGATOR = =,
578
+ RESTRICT = neqsel,
579
+ JOIN = neqjoinsel
580
+ );
581
+
582
+
583
+ --
584
+ -- Name: <@; Type: OPERATOR; Schema: public; Owner: -
585
+ --
586
+
587
+ CREATE OPERATOR <@ (
588
+ PROCEDURE = cube_contained,
589
+ LEFTARG = cube,
590
+ RIGHTARG = cube,
591
+ COMMUTATOR = @>,
592
+ RESTRICT = contsel,
593
+ JOIN = contjoinsel
594
+ );
595
+
596
+
597
+ --
598
+ -- Name: <@>; Type: OPERATOR; Schema: public; Owner: -
599
+ --
600
+
601
+ CREATE OPERATOR <@> (
602
+ PROCEDURE = geo_distance,
603
+ LEFTARG = point,
604
+ RIGHTARG = point,
605
+ COMMUTATOR = <@>
606
+ );
607
+
608
+
609
+ --
610
+ -- Name: =; Type: OPERATOR; Schema: public; Owner: -
611
+ --
612
+
613
+ CREATE OPERATOR = (
614
+ PROCEDURE = cube_eq,
615
+ LEFTARG = cube,
616
+ RIGHTARG = cube,
617
+ COMMUTATOR = =,
618
+ NEGATOR = <>,
619
+ MERGES,
620
+ RESTRICT = eqsel,
621
+ JOIN = eqjoinsel
622
+ );
623
+
624
+
625
+ --
626
+ -- Name: >; Type: OPERATOR; Schema: public; Owner: -
627
+ --
628
+
629
+ CREATE OPERATOR > (
630
+ PROCEDURE = cube_gt,
631
+ LEFTARG = cube,
632
+ RIGHTARG = cube,
633
+ COMMUTATOR = <,
634
+ NEGATOR = <=,
635
+ RESTRICT = scalargtsel,
636
+ JOIN = scalargtjoinsel
637
+ );
638
+
639
+
640
+ --
641
+ -- Name: >=; Type: OPERATOR; Schema: public; Owner: -
642
+ --
643
+
644
+ CREATE OPERATOR >= (
645
+ PROCEDURE = cube_ge,
646
+ LEFTARG = cube,
647
+ RIGHTARG = cube,
648
+ COMMUTATOR = <=,
649
+ NEGATOR = <,
650
+ RESTRICT = scalargtsel,
651
+ JOIN = scalargtjoinsel
652
+ );
653
+
654
+
655
+ --
656
+ -- Name: @; Type: OPERATOR; Schema: public; Owner: -
657
+ --
658
+
659
+ CREATE OPERATOR @ (
660
+ PROCEDURE = cube_contains,
661
+ LEFTARG = cube,
662
+ RIGHTARG = cube,
663
+ COMMUTATOR = ~,
664
+ RESTRICT = contsel,
665
+ JOIN = contjoinsel
666
+ );
667
+
668
+
669
+ --
670
+ -- Name: @>; Type: OPERATOR; Schema: public; Owner: -
671
+ --
672
+
673
+ CREATE OPERATOR @> (
674
+ PROCEDURE = cube_contains,
675
+ LEFTARG = cube,
676
+ RIGHTARG = cube,
677
+ COMMUTATOR = <@,
678
+ RESTRICT = contsel,
679
+ JOIN = contjoinsel
680
+ );
681
+
682
+
683
+ --
684
+ -- Name: ~; Type: OPERATOR; Schema: public; Owner: -
685
+ --
686
+
687
+ CREATE OPERATOR ~ (
688
+ PROCEDURE = cube_contained,
689
+ LEFTARG = cube,
690
+ RIGHTARG = cube,
691
+ COMMUTATOR = @,
692
+ RESTRICT = contsel,
693
+ JOIN = contjoinsel
694
+ );
695
+
696
+
697
+ --
698
+ -- Name: cube_ops; Type: OPERATOR CLASS; Schema: public; Owner: -
699
+ --
700
+
701
+ CREATE OPERATOR CLASS cube_ops
702
+ DEFAULT FOR TYPE cube USING btree AS
703
+ OPERATOR 1 <(cube,cube) ,
704
+ OPERATOR 2 <=(cube,cube) ,
705
+ OPERATOR 3 =(cube,cube) ,
706
+ OPERATOR 4 >=(cube,cube) ,
707
+ OPERATOR 5 >(cube,cube) ,
708
+ FUNCTION 1 cube_cmp(cube,cube);
709
+
710
+
711
+ --
712
+ -- Name: gist_cube_ops; Type: OPERATOR CLASS; Schema: public; Owner: -
713
+ --
714
+
715
+ CREATE OPERATOR CLASS gist_cube_ops
716
+ DEFAULT FOR TYPE cube USING gist AS
717
+ OPERATOR 3 &&(cube,cube) ,
718
+ OPERATOR 6 =(cube,cube) ,
719
+ OPERATOR 7 @>(cube,cube) ,
720
+ OPERATOR 8 <@(cube,cube) ,
721
+ OPERATOR 13 @(cube,cube) ,
722
+ OPERATOR 14 ~(cube,cube) ,
723
+ FUNCTION 1 g_cube_consistent(internal,cube,integer,oid,internal) ,
724
+ FUNCTION 2 g_cube_union(internal,internal) ,
725
+ FUNCTION 3 g_cube_compress(internal) ,
726
+ FUNCTION 4 g_cube_decompress(internal) ,
727
+ FUNCTION 5 g_cube_penalty(internal,internal,internal) ,
728
+ FUNCTION 6 g_cube_picksplit(internal,internal) ,
729
+ FUNCTION 7 g_cube_same(cube,cube,internal);
730
+
731
+
732
+ SET default_tablespace = '';
733
+
734
+ SET default_with_oids = false;
735
+
736
+ --
737
+ -- Name: places; Type: TABLE; Schema: public; Owner: -; Tablespace:
738
+ --
739
+
740
+ CREATE TABLE places (
741
+ id integer NOT NULL,
742
+ lt double precision,
743
+ lg double precision,
744
+ lat double precision,
745
+ lng double precision,
746
+ created_at timestamp without time zone,
747
+ updated_at timestamp without time zone
748
+ );
749
+
750
+
751
+ --
752
+ -- Name: places_id_seq; Type: SEQUENCE; Schema: public; Owner: -
753
+ --
754
+
755
+ CREATE SEQUENCE places_id_seq
756
+ START WITH 1
757
+ INCREMENT BY 1
758
+ NO MINVALUE
759
+ NO MAXVALUE
760
+ CACHE 1;
761
+
762
+
763
+ --
764
+ -- Name: places_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
765
+ --
766
+
767
+ ALTER SEQUENCE places_id_seq OWNED BY places.id;
768
+
769
+
770
+ --
771
+ -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace:
772
+ --
773
+
774
+ CREATE TABLE schema_migrations (
775
+ version character varying(255) NOT NULL
776
+ );
777
+
778
+
779
+ --
780
+ -- Name: id; Type: DEFAULT; Schema: public; Owner: -
781
+ --
782
+
783
+ ALTER TABLE places ALTER COLUMN id SET DEFAULT nextval('places_id_seq'::regclass);
784
+
785
+
786
+ --
787
+ -- Name: places_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
788
+ --
789
+
790
+ ALTER TABLE ONLY places
791
+ ADD CONSTRAINT places_pkey PRIMARY KEY (id);
792
+
793
+
794
+ --
795
+ -- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
796
+ --
797
+
798
+ CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version);
799
+
800
+
801
+ --
802
+ -- PostgreSQL database dump complete
803
+ --
804
+
805
+ INSERT INTO schema_migrations (version) VALUES ('20110225205046');
806
+
807
+ INSERT INTO schema_migrations (version) VALUES ('20110225205131');