postgis_adapter 0.7.5 → 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.5
1
+ 0.7.7
@@ -38,7 +38,8 @@ module PostgisFunctions
38
38
  # DistanceSphere/Spheroid => meters
39
39
  #
40
40
  def construct_geometric_sql(type,geoms,options)
41
- not_db, on_db = geoms.partition { |g| g.is_a? Geometry }
41
+ not_db, on_db = geoms.partition { |g| g.is_a?(Geometry) || g.new_record? }
42
+ not_db.map! {|o| o.respond_to?(:new_record?) ? o.geom : o }
42
43
 
43
44
  tables = on_db.map do |t| {
44
45
  :name => t.class.table_name,
@@ -58,10 +59,7 @@ module PostgisFunctions
58
59
  fields << not_db.map { |g| "'#{g.as_hex_ewkb}'::geometry"} unless not_db.empty?
59
60
  fields.map! { |f| "ST_Transform(#{f}, #{transform})" } if transform # ST_Transform(W1.geom,x)
60
61
  fields.map! { |f| "ST_Union(#{f})" } if stcollect # ST_Transform(W1.geom,x)
61
- conditions = tables.map do |f|
62
- raise unless f[:uid]
63
- "#{f[:uid]}.id = #{f[:id]}"
64
- end # W1.id = 5
62
+ conditions = tables.map {|f| "#{f[:uid]}.id = #{f[:id]}" } # W1.id = 5
65
63
  tables.map! { |f| "#{f[:name]} #{f[:uid]}" } # streets W1
66
64
 
67
65
  #
@@ -106,7 +104,7 @@ module PostgisFunctions
106
104
  GeoRuby::SimpleFeatures::Geometry.from_hex_ewkb(value) rescue value
107
105
  end
108
106
  rescue Exception => e
109
- raise StandardError, "#{e}"
107
+ raise StandardError, e.to_s #+ e.backtrace.inspect
110
108
  end
111
109
 
112
110
  # Get a unique ID for tables
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{postgis_adapter}
8
- s.version = "0.7.5"
8
+ s.version = "0.7.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marcos Piccinini"]
@@ -400,6 +400,10 @@ describe "Common Functions" do
400
400
  @m1.geom.geometries[0].length.should eql(2)
401
401
  end
402
402
 
403
+ it "should calculate multi line string length" do
404
+ @m1.length_spheroid.should be_close(470464.54, 0.01)
405
+ end
406
+
403
407
  it "should line merge!" do
404
408
  merged = @m1.line_merge
405
409
  merged.should be_instance_of(LineString)
@@ -407,6 +411,7 @@ describe "Common Functions" do
407
411
  end
408
412
 
409
413
  it "should line merge collect" do
414
+ pending
410
415
  co = @m2.line_merge
411
416
  co.should be_instance_of(LineString)
412
417
  end
@@ -31,11 +31,18 @@ describe "PostgisFunctions" do
31
31
  @p1.distance_to(Point.from_x_y(5,5,4326)).should be_close(55.0726792520575, 0.001)
32
32
  end
33
33
 
34
+ it "should work with unsaved objects" do
35
+ ss = Street.new(:data => "Street1", :geom => LineString.from_coordinates([[-44,-21],[-43,-29]],4326))
36
+ ss.length_spheroid.should be_close(891908.39, 0.01)
37
+ end
38
+
34
39
  it { @c1.area(32640).should be_close(9165235788987.37, 0.01) }
35
40
 
36
41
  it { @c1.area.should be_close(720.0, 0.1) }
37
42
 
38
- it { @p1.should be_strictly_left_of(@c1) }
43
+ it "should be strictly left of city" do
44
+ @p1.should be_strictly_left_of(@c1)
45
+ end
39
46
 
40
47
  it { @s1.length.should be_close(8.06225774829855, 0.001) }
41
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postgis_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Piccinini