postgis_adapter 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/MIT-LICENSE +21 -0
- data/Manifest.txt +36 -0
- data/README.rdoc +311 -0
- data/Rakefile +100 -0
- data/init.rb +1 -0
- data/install.rb +0 -0
- data/lib/postgis_adapter.rb +388 -0
- data/lib/postgis_adapter/acts_as_geom.rb +39 -0
- data/lib/postgis_adapter/common_spatial_adapter.rb +179 -0
- data/lib/postgis_functions.rb +158 -0
- data/lib/postgis_functions/bbox.rb +128 -0
- data/lib/postgis_functions/class.rb +64 -0
- data/lib/postgis_functions/common.rb +438 -0
- data/lib/postgis_functions/linestring.rb +172 -0
- data/lib/postgis_functions/point.rb +89 -0
- data/lib/postgis_functions/polygon.rb +78 -0
- data/postgis_adapter.gemspec +38 -0
- data/rails/init.rb +8 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/acts_as_geom_spec.rb +15 -0
- data/spec/common_spatial_adapter_spec.rb +254 -0
- data/spec/db/database_postgis.yml +4 -0
- data/spec/db/models_postgis.rb +56 -0
- data/spec/db/schema_postgis.rb +86 -0
- data/spec/postgis_adapter_spec.rb +174 -0
- data/spec/postgis_functions/bbox_spec.rb +84 -0
- data/spec/postgis_functions/linestring_spec.rb +219 -0
- data/spec/postgis_functions/point_spec.rb +136 -0
- data/spec/postgis_functions/polygon_spec.rb +146 -0
- data/spec/postgis_functions_spec.rb +51 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +25 -0
- data/uninstall.rb +0 -0
- metadata +121 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "PostgisFunctions" do
|
4
|
+
before(:all) do
|
5
|
+
#load_schema
|
6
|
+
@c1 ||= City.create!(:data => "City1", :geom => Polygon.from_coordinates([[[12,45],[45,41],[4,1],[12,45]],[[2,5],[5,1],[14,1],[2,5]]],123))
|
7
|
+
@s1 ||= Street.create!(:data => "Street1", :geom => LineString.from_coordinates([[-43,-20],[-42,-28]],123))
|
8
|
+
@p1 ||= Position.create!(:data => "Point1", :geom => Point.from_x_y(-43,-22,123))
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "Common Mix" do
|
12
|
+
|
13
|
+
|
14
|
+
it "should calculate distance point to line" do
|
15
|
+
@p1.distance_to(@s1).should be_close(0.248069469178417, 0.00000001)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should calculate inside a city" do
|
19
|
+
@p1.should_not be_inside(@c1)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
#TODO is sorted rspec helper
|
27
|
+
describe "Class methods" do
|
28
|
+
|
29
|
+
it "should find all dwithin one" do
|
30
|
+
Position.all_within(@s1.geom).should be_instance_of(Array)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should find all dwithin one" do
|
34
|
+
City.by_perimeter.should be_instance_of(Array)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should sort by polygon area" do
|
38
|
+
City.by_area.should be_instance_of(Array)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should sort by all within" do
|
42
|
+
City.all_within(@s1.geom).should be_instance_of(Array)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should sort by all within" do
|
46
|
+
City.by_boundaries.should be_instance_of(Array)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
begin
|
2
|
+
require 'rspec_spinner'
|
3
|
+
require 'spec'
|
4
|
+
require 'postgres'
|
5
|
+
require 'activerecord'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
gem 'rspec'
|
9
|
+
require 'spec'
|
10
|
+
require 'postgres'
|
11
|
+
require 'activerecord'
|
12
|
+
end
|
13
|
+
|
14
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
15
|
+
config = YAML.load_file(File.dirname(__FILE__) + '/db/database_postgis.yml')
|
16
|
+
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
17
|
+
ActiveRecord::Base.establish_connection(config)
|
18
|
+
|
19
|
+
require File.dirname(__FILE__) + '/../init.rb'
|
20
|
+
require File.dirname(__FILE__) + '/db/models_postgis.rb'
|
21
|
+
|
22
|
+
def load_schema
|
23
|
+
load(File.dirname(__FILE__) + "/db/schema_postgis.rb")
|
24
|
+
end
|
25
|
+
|
data/uninstall.rb
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: postgis_adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.8
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marcos Piccinini
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-21 00:00:00 -02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activerecord
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: newgem
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.1
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: hoe
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.8.0
|
44
|
+
version:
|
45
|
+
description: Postgis Adapter for Activer Record
|
46
|
+
email:
|
47
|
+
- x@nofxx.com
|
48
|
+
executables: []
|
49
|
+
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- History.txt
|
54
|
+
- Manifest.txt
|
55
|
+
- README.rdoc
|
56
|
+
files:
|
57
|
+
- History.txt
|
58
|
+
- MIT-LICENSE
|
59
|
+
- Manifest.txt
|
60
|
+
- README.rdoc
|
61
|
+
- Rakefile
|
62
|
+
- init.rb
|
63
|
+
- install.rb
|
64
|
+
- lib/postgis_adapter.rb
|
65
|
+
- lib/postgis_adapter/acts_as_geom.rb
|
66
|
+
- lib/postgis_adapter/common_spatial_adapter.rb
|
67
|
+
- lib/postgis_functions.rb
|
68
|
+
- lib/postgis_functions/bbox.rb
|
69
|
+
- lib/postgis_functions/class.rb
|
70
|
+
- lib/postgis_functions/common.rb
|
71
|
+
- lib/postgis_functions/linestring.rb
|
72
|
+
- lib/postgis_functions/point.rb
|
73
|
+
- lib/postgis_functions/polygon.rb
|
74
|
+
- postgis_adapter.gemspec
|
75
|
+
- rails/init.rb
|
76
|
+
- script/console
|
77
|
+
- script/destroy
|
78
|
+
- script/generate
|
79
|
+
- spec/acts_as_geom_spec.rb
|
80
|
+
- spec/common_spatial_adapter_spec.rb
|
81
|
+
- spec/db/database_postgis.yml
|
82
|
+
- spec/db/models_postgis.rb
|
83
|
+
- spec/db/schema_postgis.rb
|
84
|
+
- spec/postgis_adapter_spec.rb
|
85
|
+
- spec/postgis_functions/bbox_spec.rb
|
86
|
+
- spec/postgis_functions/linestring_spec.rb
|
87
|
+
- spec/postgis_functions/point_spec.rb
|
88
|
+
- spec/postgis_functions/polygon_spec.rb
|
89
|
+
- spec/postgis_functions_spec.rb
|
90
|
+
- spec/spec.opts
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
- uninstall.rb
|
93
|
+
has_rdoc: true
|
94
|
+
homepage: http://github.com/nofxx/postgis_adapter
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options:
|
97
|
+
- --main
|
98
|
+
- README.rdoc
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: "0"
|
106
|
+
version:
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: "0"
|
112
|
+
version:
|
113
|
+
requirements: []
|
114
|
+
|
115
|
+
rubyforge_project: postgis_adapter
|
116
|
+
rubygems_version: 1.3.1
|
117
|
+
signing_key:
|
118
|
+
specification_version: 2
|
119
|
+
summary: Postgis Adapter for Activer Record
|
120
|
+
test_files: []
|
121
|
+
|