unidom-geo 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +4 -0
- data/Rakefile +24 -0
- data/app/assets/javascripts/unidom/geo/application.js +13 -0
- data/app/assets/stylesheets/unidom/geo/application.css +15 -0
- data/app/controllers/unidom/geo/application_controller.rb +2 -0
- data/app/helpers/unidom/geo/application_helper.rb +2 -0
- data/app/models/unidom/geo/locating.rb +15 -0
- data/app/models/unidom/geo/location.rb +23 -0
- data/app/views/layouts/unidom/geo/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20010401000000_create_unidom_locations.rb +46 -0
- data/db/migrate/20010402000000_create_unidom_locatings.rb +29 -0
- data/lib/tasks/geo_tasks.rake +4 -0
- data/lib/unidom/geo/engine.rb +15 -0
- data/lib/unidom/geo/version.rb +5 -0
- data/lib/unidom/geo.rb +6 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a11115c8685e48e0e25e316fa37d0d2a03b1ff67
|
4
|
+
data.tar.gz: cea7e9c320d8016ea500283c3744e9504db9fdb8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 210a93b25ca3047b5aa9d4e37c8cb923529d4b171eb13983e35b783f07a7c9ae05598a15d2ae79b02f84cdd6a56f80daef949588f5bc4623de2e797dce451a3b
|
7
|
+
data.tar.gz: 7023c5e4cf4b37762ff601669056381bf31d14f47ff6e0b1a3379b42deaef8d25ed80d22d24e0834eb3de2d62c7545d0253d84ae85dccfe6547e5e4dcb9c9fed
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Topbit Du
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Geo'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
load 'rails/tasks/statistics.rake'
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
Bundler::GemHelper.install_tasks
|
24
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Locating 是地理定位,表示地理位置和被定位物体之间的关联。
|
2
|
+
|
3
|
+
class Unidom::Geo::Location < ActiveRecord::Base
|
4
|
+
|
5
|
+
self.table_name = 'unidom_locatings'
|
6
|
+
|
7
|
+
belongs_to :location, class_name: 'Unidom::Geo::Location'
|
8
|
+
belongs_to :located, polymorphic: true
|
9
|
+
belongs_to :locator, polymorphic: true
|
10
|
+
|
11
|
+
scope :location_is, ->(location) { where location: location }
|
12
|
+
scope :located_is, ->(located) { where located: located }
|
13
|
+
scope :located_by, ->(locator) { where locator: locator }
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Location 是地理位置。具体对应到某一个街道地址。
|
2
|
+
|
3
|
+
class Unidom::Geo::Location < ActiveRecord::Base
|
4
|
+
|
5
|
+
self.table_name = 'unidom_locations'
|
6
|
+
|
7
|
+
validates :latitude, presence: true, numericality: { greater_than_or_equal_to: -90, less_than_or_equal_to: 90 }
|
8
|
+
validates :longitude, presence: true, numericality: { greater_than_or_equal_to: -180, less_than_or_equal_to: 180 }
|
9
|
+
|
10
|
+
validates :postal_address, presence: true, length: { in: 2..self.columns_hash['postal_address'].limit }
|
11
|
+
validates :postal_code, presence: true, length: { in: 3..self.columns_hash['postal_code'].limit }
|
12
|
+
|
13
|
+
validates :minimum_latitude, presence: true, numericality: { greater_than_or_equal_to: -90, less_than_or_equal_to: 90 }
|
14
|
+
validates :maximum_latitude, presence: true, numericality: { greater_than_or_equal_to: -90, less_than_or_equal_to: 90 }
|
15
|
+
validates :minimum_longitude, presence: true, numericality: { greater_than_or_equal_to: -180, less_than_or_equal_to: 180 }
|
16
|
+
validates :maximum_longitude, presence: true, numericality: { greater_than_or_equal_to: -180, less_than_or_equal_to: 180 }
|
17
|
+
|
18
|
+
belongs_to :region, polymorphic: true
|
19
|
+
|
20
|
+
scope :region_is, ->(region) { where region: region }
|
21
|
+
scope :postal_address_is, ->(postal_address) { where postal_address: postal_address }
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Unidom Geo</title>
|
5
|
+
<%= stylesheet_link_tag 'unidom/geo/application', media: 'all' %>
|
6
|
+
<%= javascript_include_tag 'unidom/geo/application' %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
class CreateUnidomLocations < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
|
5
|
+
create_table :unidom_locations, id: :uuid do |t|
|
6
|
+
|
7
|
+
t.references :region, type: :uuid, null: false,
|
8
|
+
polymorphic: { null: false, default: '', limit: 200 }
|
9
|
+
|
10
|
+
t.decimal :longitude, null: false, default: 0.0, precision: 10, scale: 6
|
11
|
+
t.decimal :latitude, null: false, default: 0.0, precision: 10, scale: 6
|
12
|
+
|
13
|
+
t.string :postal_address, null: false, default: '', limit: 200
|
14
|
+
t.string :postal_code, null: false, default: '', limit: 20
|
15
|
+
|
16
|
+
t.decimal :minimum_longitude, null: false, default: 0.0, precision: 10, scale: 6
|
17
|
+
t.decimal :minimum_latitude, null: false, default: 0.0, precision: 10, scale: 6
|
18
|
+
t.decimal :maximum_longitude, null: false, default: 0.0, precision: 10, scale: 6
|
19
|
+
t.decimal :maximum_latitude, null: false, default: 0.0, precision: 10, scale: 6
|
20
|
+
|
21
|
+
t.column :accuarcy_code, 'char(1)', null: false, default: 'N'
|
22
|
+
|
23
|
+
t.string :slug, null: false, default: nil, limit: 200
|
24
|
+
t.column :state, 'char(1)', null: false, default: 'C'
|
25
|
+
t.datetime :opened_at, null: false, default: ::Time.utc(1970)
|
26
|
+
t.datetime :closed_at, null: false, default: ::Time.utc(3000)
|
27
|
+
t.boolean :defunct, null: false, default: false
|
28
|
+
t.jsonb :notation, null: false, default: {}
|
29
|
+
|
30
|
+
t.timestamps null: false
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
add_index :unidom_locations, :region_id
|
35
|
+
add_index :unidom_locations, :latitude
|
36
|
+
add_index :unidom_locations, :longitude
|
37
|
+
add_index :unidom_locations, :minimum_latitude
|
38
|
+
add_index :unidom_locations, :minimum_longitude
|
39
|
+
add_index :unidom_locations, :maximum_latitude
|
40
|
+
add_index :unidom_locations, :maximum_longitude
|
41
|
+
add_index :unidom_locations, :slug, unique: true
|
42
|
+
# add_index :unidom_locations, [ :postal_address, :region_id, :region_type ], unique: true
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class CreateUnidomLocatings < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
|
5
|
+
create_table :unidom_locatings, id: :uuid do |t|
|
6
|
+
|
7
|
+
t.references :location, type: :uuid, null: false
|
8
|
+
t.references :located, type: :uuid, null: false,
|
9
|
+
polymorphic: { null: false, default: '', limit: 200 }
|
10
|
+
t.references :locator, type: :uuid, null: false,
|
11
|
+
polymorphic: { null: false, default: '', limit: 200 }
|
12
|
+
|
13
|
+
t.column :state, 'char(1)', null: false, default: 'C'
|
14
|
+
t.datetime :opened_at, null: false, default: ::Time.utc(1970)
|
15
|
+
t.datetime :closed_at, null: false, default: ::Time.utc(3000)
|
16
|
+
t.boolean :defunct, null: false, default: false
|
17
|
+
t.jsonb :notation, null: false, default: {}
|
18
|
+
|
19
|
+
t.timestamps null: false
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
add_index :unidom_locatings, :location_id
|
24
|
+
add_index :unidom_locatings, :located_id
|
25
|
+
add_index :unidom_locatings, :locator_id
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Unidom
|
2
|
+
module Geo
|
3
|
+
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
|
6
|
+
isolate_namespace Unidom::Geo
|
7
|
+
|
8
|
+
initializer :append_migrations do |app|
|
9
|
+
config.paths['db/migrate'].expanded.each { |expanded_path| app.config.paths['db/migrate'] << expanded_path } unless app.root.to_s.match root.to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
data/lib/unidom/geo.rb
ADDED
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: unidom-geo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Topbit Du
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pg
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|
42
|
+
The Geo domain model engine includes Region, Town, and Location models. Unidom (统一领域对象模型)是一系列的领域模型引擎。地理领域模型引擎包括行政区划、乡镇和街道地址的模型。
|
43
|
+
email:
|
44
|
+
- topbit.du@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- MIT-LICENSE
|
50
|
+
- README.rdoc
|
51
|
+
- Rakefile
|
52
|
+
- app/assets/javascripts/unidom/geo/application.js
|
53
|
+
- app/assets/stylesheets/unidom/geo/application.css
|
54
|
+
- app/controllers/unidom/geo/application_controller.rb
|
55
|
+
- app/helpers/unidom/geo/application_helper.rb
|
56
|
+
- app/models/unidom/geo/locating.rb
|
57
|
+
- app/models/unidom/geo/location.rb
|
58
|
+
- app/views/layouts/unidom/geo/application.html.erb
|
59
|
+
- config/routes.rb
|
60
|
+
- db/migrate/20010401000000_create_unidom_locations.rb
|
61
|
+
- db/migrate/20010402000000_create_unidom_locatings.rb
|
62
|
+
- lib/tasks/geo_tasks.rake
|
63
|
+
- lib/unidom/geo.rb
|
64
|
+
- lib/unidom/geo/engine.rb
|
65
|
+
- lib/unidom/geo/version.rb
|
66
|
+
homepage: https://github.com/topbitdu/unidom-geo
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.4.7
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: The Geo domain model engine includes Region, Town, and Location models.
|
90
|
+
test_files: []
|