postgis_adapter 0.7.5 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/postgis_functions.rb +4 -6
- data/postgis_adapter.gemspec +1 -1
- data/spec/postgis_functions/common_spec.rb +5 -0
- data/spec/postgis_functions_spec.rb +8 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.7
|
data/lib/postgis_functions.rb
CHANGED
@@ -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?
|
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
|
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,
|
107
|
+
raise StandardError, e.to_s #+ e.backtrace.inspect
|
110
108
|
end
|
111
109
|
|
112
110
|
# Get a unique ID for tables
|
data/postgis_adapter.gemspec
CHANGED
@@ -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
|
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
|
|