dr-postgis_adapter 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "http://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  platforms :jruby do
7
- gem 'activerecord-jdbcpostgresql-adapter', :git => 'git://github.com/dryade/activerecord-jdbc-adapter.git'
7
+ gem 'activerecord-jdbcpostgresql-adapter'
8
8
  gem 'jruby-openssl'
9
9
  end
10
10
 
data/Gemfile.lock CHANGED
@@ -1,16 +1,7 @@
1
- GIT
2
- remote: git://github.com/dryade/activerecord-jdbc-adapter.git
3
- revision: 0bf424bc3bcaf9f44646976cc4c1a8e9e57f11b4
4
- specs:
5
- activerecord-jdbc-adapter (1.2.2)
6
- activerecord-jdbcpostgresql-adapter (1.2.2)
7
- activerecord-jdbc-adapter (~> 1.2.2)
8
- jdbc-postgres (>= 9.0, < 9.2)
9
-
10
1
  PATH
11
2
  remote: .
12
3
  specs:
13
- dr-postgis_adapter (0.8.3)
4
+ dr-postgis_adapter (0.8.4)
14
5
  nofxx-georuby
15
6
  rake
16
7
 
@@ -20,16 +11,11 @@ GEM
20
11
  ZenTest (4.5.0)
21
12
  autotest (4.4.6)
22
13
  ZenTest (>= 4.4.1)
23
- bouncy-castle-java (1.5.0146.1)
24
- diff-lcs (1.1.2)
25
- jdbc-postgres (9.0.801)
26
- jruby-openssl (0.7.7)
27
- bouncy-castle-java (>= 1.5.0146.1)
14
+ diff-lcs (1.1.3)
28
15
  nofxx-georuby (1.9.2)
29
16
  pg (0.11.0)
30
- rake (10.1.1)
17
+ rake (10.3.1)
31
18
  rcov (0.9.9)
32
- rcov (0.9.9-java)
33
19
  rspec (2.3.0)
34
20
  rspec-core (~> 2.3.0)
35
21
  rspec-expectations (~> 2.3.0)
@@ -40,11 +26,10 @@ GEM
40
26
  rspec-mocks (2.3.0)
41
27
 
42
28
  PLATFORMS
43
- java
44
29
  ruby
45
30
 
46
31
  DEPENDENCIES
47
- activerecord-jdbcpostgresql-adapter!
32
+ activerecord-jdbcpostgresql-adapter
48
33
  autotest
49
34
  dr-postgis_adapter!
50
35
  jruby-openssl
@@ -4,46 +4,43 @@
4
4
  # http://github.com/nofxx/postgis_adapter
5
5
  #
6
6
  module PostgisAdapter
7
- module Functions
8
- def self.included(base)
9
- base.send :extend, ClassMethods
10
- end
7
+ module Functions
8
+ def self.included(base)
9
+ base.send :extend, ClassMethods
10
+ end
11
11
 
12
- module ClassMethods
12
+ module ClassMethods
13
13
 
14
- # has_geom :db_field => :geom_type
15
- # Examples:
16
- #
17
- # has_geom :data => :point
18
- # has_geom :geom => :line_string
19
- # has_geom :geom => :polygon
20
- #
21
- def has_geom(*geom)
22
- cattr_accessor :postgis_geoms
23
- self.postgis_geoms = geom[0].keys.first # {:columns => column }
24
- send :include, case geom[0].values[0]
25
- when :point then PointFunctions
26
- when :polygon then PolygonFunctions
27
- when :line_string, :multi_line_string then LineStringFunctions
28
- when :multi_polygon then MultiPolygonFunctions
29
- when :geometry then GeometryFunctions
30
- end unless geom[0].kind_of? Symbol
31
- end
32
- alias :acts_as_geom :has_geom
14
+ # has_geom :db_field => :geom_type
15
+ # Examples:
16
+ #
17
+ # has_geom :data => :point
18
+ # has_geom :geom => :line_string
19
+ # has_geom :geom => :polygon
20
+ #
21
+ def has_geom(*geom)
22
+ cattr_accessor :postgis_geoms
23
+ self.postgis_geoms = geom[0].keys.first # {:columns => column }
24
+ send :include, case geom[0].values[0]
25
+ when :point then PointFunctions
26
+ when :polygon then PolygonFunctions
27
+ when :line_string, :multi_line_string then LineStringFunctions
28
+ when :multi_polygon then MultiPolygonFunctions
29
+ when :geometry then GeometryFunctions
30
+ end unless geom[0].kind_of? Symbol
31
+ end
32
+ alias :acts_as_geom :has_geom
33
33
 
34
- def get_geom_type(column)
35
- self.postgis_geoms.values[0] rescue nil
36
- # self.columns.select { |c| c.name == column.to_s }[0].geometry_type
37
- # rescue ActiveRecord::StatementInvalid => e
38
- # nil
39
- end
34
+ def get_geom_type(column)
35
+ self.postgis_geoms.values[0] rescue nil
36
+ end
40
37
 
41
- def default_geometry
42
- postgis_geoms
43
- end
38
+ def default_geometry
39
+ postgis_geoms
40
+ end
44
41
 
42
+ end
45
43
  end
46
44
  end
47
- end
48
45
 
49
46
  ActiveRecord::Base.send :include, PostgisAdapter::Functions
@@ -1,5 +1,5 @@
1
1
  module PostgisAdapter
2
- module Functions
2
+ module Functions
3
3
 
4
4
  #
5
5
  # Class Methods
@@ -10,59 +10,54 @@ module Functions
10
10
  # Returns the closest record
11
11
  def closest_to(p, opts = {})
12
12
  srid = opts.delete(:srid) || 4326
13
- opts.merge!(:order => "ST_Distance(#{default_geometry}, GeomFromText('POINT(#{p.x} #{p.y})', #{srid}))")
14
- find(:first, opts)
13
+ order("ST_Distance(#{default_geometry}, '#{p.as_ewkt}' )").first
15
14
  end
16
15
 
17
16
  #
18
17
  # Order by distance
19
18
  def close_to(p, opts = {})
20
19
  srid = opts.delete(:srid) || 4326
21
- opts.merge!(:order => "ST_Distance(geom, GeomFromText('POINT(#{p.x} #{p.y})', #{srid}))")
22
- find(:all, opts)
20
+ order "ST_Distance(#{default_geometry}, '#{p.as_ewkt}' )"
23
21
  end
24
22
 
25
23
  def by_length opts = {}
26
24
  sort = opts.delete(:sort) || 'asc'
27
- opts.merge!(:order => "ST_length(geom) #{sort}")
28
- find(:all, opts)
25
+ order "ST_length(#{default_geometry}) #{sort}"
29
26
  end
30
27
 
31
28
  def longest
32
- find(:first, :order => "ST_length(geom) DESC")
29
+ order("ST_length(geom) DESC").first
33
30
  end
34
31
 
35
32
  def contains(p, srid=4326)
36
- find(:all, :conditions => ["ST_Contains(geom, GeomFromText('POINT(#{p.x} #{p.y})', #{srid}))"])
33
+ where "ST_Contains(#{default_geometry}, '#{p.as_ewkt}' )"
37
34
  end
38
35
 
39
36
  def contain(p, srid=4326)
40
- find(:first, :conditions => ["ST_Contains(geom, GeomFromText('POINT(#{p.x} #{p.y})', #{srid}))"])
37
+ where("ST_Contains(#{default_geometry}, '#{p.as_ewkt}' )").first
41
38
  end
42
39
 
43
40
  def by_area sort='asc'
44
- find(:all, :order => "ST_Area(geom) #{sort}" )
41
+ order "ST_Area(#{default_geometry}) #{sort}"
45
42
  end
46
43
 
47
44
  def by_perimeter sort='asc'
48
- find(:all, :order => "ST_Perimeter(geom) #{sort}" )
45
+ order "ST_Perimeter(#{default_geometry}) #{sort}"
49
46
  end
50
47
 
51
48
  def all_dwithin(other, margin=1)
52
- # find(:all, :conditions => "ST_DWithin(geom, ST_GeomFromEWKB(E'#{other.as_ewkt}'), #{margin})")
53
- # where "ST_DWithin(ST_GeomFromText(?, 4326), geometry, ?)", location_as_text, distance
54
- where "ST_DWithin(#{default_geometry}, ST_GeomFromEWKT(?), ?)", other.as_hex_ewkb, margin
49
+ where "ST_DWithin(#{default_geometry}, '#{other.as_ewkt}', #{margin})"
55
50
  end
56
51
 
57
52
  def all_within(other)
58
- find(:all, :conditions => "ST_Within(geom, ST_GeomFromEWKT(E'#{other.as_hex_ewkb}'))")
53
+ where "ST_Within(#{default_geometry}, '#{other.as_ewkt}' )"
59
54
  end
60
55
 
61
56
  def by_boundaries sort='asc'
62
- find(:all, :order => "ST_Boundary(geom) #{sort}" )
57
+ order "ST_Boundary(#{default_geometry}) #{sort}"
63
58
  end
64
59
 
65
60
  end
66
61
 
67
- end
62
+ end
68
63
  end
Binary file
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'dr-postgis_adapter'
3
- spec.version = '0.8.3'
3
+ spec.version = '0.8.4'
4
4
  spec.authors = ['Marcos Piccinini', 'Luc Donnet', 'Marc Florisson']
5
5
  spec.summary = 'PostGIS Adapter for Active Record'
6
6
  spec.email = 'x@nofxx.com, luc.donnet@free.fr, mflorisson@gmail.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dr-postgis_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-02-05 00:00:00.000000000 Z
14
+ date: 2014-05-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: nofxx-georuby
@@ -52,34 +52,36 @@ extensions: []
52
52
  extra_rdoc_files:
53
53
  - README.rdoc
54
54
  files:
55
- - Gemfile
56
- - Gemfile.lock
55
+ - rails/init.rb
57
56
  - History.txt
58
- - lib/postgis_adapter/acts_as_geom.rb
59
57
  - lib/postgis_adapter/common_spatial_adapter.rb
60
- - lib/postgis_adapter/functions/bbox.rb
58
+ - lib/postgis_adapter/functions.rb
59
+ - lib/postgis_adapter/railtie.rb
60
+ - lib/postgis_adapter/acts_as_geom.rb
61
61
  - lib/postgis_adapter/functions/class.rb
62
62
  - lib/postgis_adapter/functions/common.rb
63
- - lib/postgis_adapter/functions.rb
63
+ - lib/postgis_adapter/functions/bbox.rb
64
64
  - lib/postgis_adapter/init.rb
65
- - lib/postgis_adapter/railtie.rb
66
65
  - lib/postgis_adapter.rb
67
- - MIT-LICENSE
68
- - pkg/dr-postgis_adapter-0.8.3.gem
69
- - postgis_adapter.gemspec
70
- - rails/init.rb
66
+ - pkg/dr-postgis_adapter-0.8.4.gem
67
+ - pkg/dr-postgis_adapter-0.8.2.gem
68
+ - pkg/dr-postgis_adapter-0.8.1.gem
69
+ - Gemfile.lock
71
70
  - Rakefile
72
- - README.rdoc
73
- - spec/db/models_postgis.rb
74
- - spec/db/schema_postgis.rb
75
71
  - spec/postgis_adapter/acts_as_geom_spec.rb
76
72
  - spec/postgis_adapter/common_spatial_adapter_spec.rb
73
+ - spec/postgis_adapter/functions_spec.rb
77
74
  - spec/postgis_adapter/functions/bbox_spec.rb
78
- - spec/postgis_adapter/functions/class_spec.rb
79
75
  - spec/postgis_adapter/functions/common_spec.rb
80
- - spec/postgis_adapter/functions_spec.rb
81
- - spec/postgis_adapter_spec.rb
76
+ - spec/postgis_adapter/functions/class_spec.rb
82
77
  - spec/spec_helper.rb
78
+ - spec/postgis_adapter_spec.rb
79
+ - spec/db/schema_postgis.rb
80
+ - spec/db/models_postgis.rb
81
+ - README.rdoc
82
+ - postgis_adapter.gemspec
83
+ - Gemfile
84
+ - MIT-LICENSE
83
85
  homepage: http://github.com/dryade/postgis_adapter
84
86
  licenses: []
85
87
  post_install_message:
@@ -95,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
97
  version: '0'
96
98
  segments:
97
99
  - 0
98
- hash: -4083219340546474572
100
+ hash: -2230142580083608280
99
101
  required_rubygems_version: !ruby/object:Gem::Requirement
100
102
  none: false
101
103
  requirements:
@@ -104,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
106
  version: '0'
105
107
  segments:
106
108
  - 0
107
- hash: -4083219340546474572
109
+ hash: -2230142580083608280
108
110
  requirements: []
109
111
  rubyforge_project: postgis_adapter
110
112
  rubygems_version: 1.8.23
@@ -112,13 +114,13 @@ signing_key:
112
114
  specification_version: 3
113
115
  summary: PostGIS Adapter for Active Record
114
116
  test_files:
115
- - spec/db/models_postgis.rb
116
- - spec/db/schema_postgis.rb
117
117
  - spec/postgis_adapter/acts_as_geom_spec.rb
118
118
  - spec/postgis_adapter/common_spatial_adapter_spec.rb
119
+ - spec/postgis_adapter/functions_spec.rb
119
120
  - spec/postgis_adapter/functions/bbox_spec.rb
120
- - spec/postgis_adapter/functions/class_spec.rb
121
121
  - spec/postgis_adapter/functions/common_spec.rb
122
- - spec/postgis_adapter/functions_spec.rb
123
- - spec/postgis_adapter_spec.rb
122
+ - spec/postgis_adapter/functions/class_spec.rb
124
123
  - spec/spec_helper.rb
124
+ - spec/postgis_adapter_spec.rb
125
+ - spec/db/schema_postgis.rb
126
+ - spec/db/models_postgis.rb
Binary file