GeoRuby 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/geo_ruby/simple_features/geometry.rb +3 -3
- data/lib/geo_ruby/simple_features/line_string.rb +9 -4
- data/lib/geo_ruby/simple_features/point.rb +1 -1
- data/lib/geo_ruby/simple_features/polygon.rb +1 -1
- data/rakefile.rb +1 -1
- data/test/test_georss_kml.rb +16 -0
- data/test/test_shp_write.rb +1 -1
- data/test/test_simple_features.rb +1 -1
- data/tools/lib/spatial_adapter/init.rb +8 -4
- data/tools/lib/spatial_adapter/lib/mysql_spatial_adapter.rb +31 -1
- data/tools/lib/spatial_adapter/lib/post_gis_adapter.rb +46 -7
- data/tools/lib/spatial_adapter/test/access_postgis_test.rb +15 -15
- data/tools/lib/spatial_adapter/test/common/common_mysql.rb +1 -1
- data/tools/lib/spatial_adapter/test/common/common_postgis.rb +1 -1
- data/tools/lib/spatial_adapter/test/db/database_postgis.yml +2 -2
- data/tools/lib/spatial_adapter/test/find_postgis_test.rb +2 -2
- data/tools/lib/spatial_adapter/test/migration_mysql_test.rb +69 -0
- data/tools/lib/spatial_adapter/test/migration_postgis_test.rb +9 -9
- data/tools/lib/spatial_adapter/test/schema/schema_postgis.rb +16 -20
- data/tools/shp2sql.rb +1 -1
- metadata +45 -41
- data/lib/geo_ruby/simple_features/io/ewkb_parser.rb +0 -213
- data/lib/geo_ruby/simple_features/io/ewkt_parser.rb +0 -335
- data/lib/geo_ruby/simple_features/io/geometry_factory.rb +0 -65
@@ -7,7 +7,7 @@ module GeoRuby#:nodoc:
|
|
7
7
|
#Objects of class Geometry should not be instantiated.
|
8
8
|
class Geometry
|
9
9
|
#SRID of the geometry
|
10
|
-
|
10
|
+
attr_reader :srid #writer defined below
|
11
11
|
#Flag indicating if the z ordinate of the geometry is meaningful
|
12
12
|
attr_accessor :with_z
|
13
13
|
#Flag indicating if the m ordinate of the geometry is meaningful
|
@@ -56,7 +56,7 @@ module GeoRuby#:nodoc:
|
|
56
56
|
if @with_m and allow_m
|
57
57
|
type = type | M_MASK
|
58
58
|
end
|
59
|
-
if
|
59
|
+
if allow_srid
|
60
60
|
type = type | SRID_MASK
|
61
61
|
ewkb << [type,@srid].pack("VV")
|
62
62
|
else
|
@@ -84,7 +84,7 @@ module GeoRuby#:nodoc:
|
|
84
84
|
|
85
85
|
#Outputs the geometry as an EWKT string.
|
86
86
|
def as_ewkt(allow_srid=true,allow_z=true,allow_m=true)
|
87
|
-
if
|
87
|
+
if allow_srid
|
88
88
|
ewkt="SRID=#{@srid};"
|
89
89
|
else
|
90
90
|
ewkt=""
|
@@ -127,7 +127,7 @@ module GeoRuby
|
|
127
127
|
#it won't be used by GE anyway: clampToGround is the default)
|
128
128
|
def kml_representation(options = {}) #:nodoc:
|
129
129
|
result = "<LineString#{options[:id_attr]}>\n"
|
130
|
-
result += options[:geom_data]
|
130
|
+
result += options[:geom_data] if options[:geom_data]
|
131
131
|
result += "<coordinates>"
|
132
132
|
result += kml_poslist(options)
|
133
133
|
result += "</coordinates>\n"
|
@@ -135,11 +135,16 @@ module GeoRuby
|
|
135
135
|
end
|
136
136
|
|
137
137
|
def kml_poslist(options) #:nodoc:
|
138
|
-
|
139
|
-
|
138
|
+
pos_list = if options[:allow_z]
|
139
|
+
map {|point| "#{point.x},#{point.y},#{options[:fixed_z] || point.z || 0}" }
|
140
140
|
else
|
141
|
-
map {|point| "#{point.x},#{point.y}" }
|
141
|
+
map {|point| "#{point.x},#{point.y}" }
|
142
142
|
end
|
143
|
+
if(options[:reverse])
|
144
|
+
pos_list.reverse.join(" ")
|
145
|
+
else
|
146
|
+
pos_list.join(" ")
|
147
|
+
end
|
143
148
|
end
|
144
149
|
|
145
150
|
#Creates a new line string. Accept an array of points as argument
|
@@ -177,7 +177,7 @@ module GeoRuby
|
|
177
177
|
#it won't be used by GE anyway: clampToGround is the default)
|
178
178
|
def kml_representation(options = {}) #:nodoc:
|
179
179
|
result = "<Point#{options[:id_attr]}>\n"
|
180
|
-
result += options[:geom_data]
|
180
|
+
result += options[:geom_data] if options[:geom_data]
|
181
181
|
result += "<coordinates>#{x},#{y}"
|
182
182
|
result += ",#{options[:fixed_z] || z ||0}" if options[:allow_z]
|
183
183
|
result += "</coordinates>\n"
|
@@ -109,7 +109,7 @@ module GeoRuby
|
|
109
109
|
#it won't be used by GE anyway: clampToGround is the default)
|
110
110
|
def kml_representation(options = {})
|
111
111
|
result = "<Polygon#{options[:id_attr]}>\n"
|
112
|
-
result += options[:geom_data]
|
112
|
+
result += options[:geom_data] if options[:geom_data]
|
113
113
|
rings.each_with_index do |ring, i|
|
114
114
|
if i == 0
|
115
115
|
boundary = "outerBoundaryIs"
|
data/rakefile.rb
CHANGED
@@ -24,7 +24,7 @@ spec = Gem::Specification::new do |s|
|
|
24
24
|
s.platform = Gem::Platform::RUBY
|
25
25
|
|
26
26
|
s.name = 'GeoRuby'
|
27
|
-
s.version = "1.3.
|
27
|
+
s.version = "1.3.3"
|
28
28
|
s.summary = "Ruby data holder for OGC Simple Features"
|
29
29
|
s.description = <<EOF
|
30
30
|
GeoRuby is intended as a holder for data returned from PostGIS and MySQL Spatial queries. The data model roughly follows the OGC "Simple Features for SQL" specification (see www.opengis.org/docs/99-049.pdf), although without any kind of advanced functionalities (such as geometric operators or reprojections)
|
data/test/test_georss_kml.rb
CHANGED
@@ -211,5 +211,21 @@ class TestGeorssKml < Test::Unit::TestCase
|
|
211
211
|
|
212
212
|
end
|
213
213
|
|
214
|
+
def test_to_kml_for_point_does_not_raise_type_error_if_geom_data_not_provided
|
215
|
+
point = Point.from_coordinates([1.6,2.8],123)
|
216
|
+
assert_nothing_raised(TypeError) { point.kml_representation }
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_to_kml_for_polygon_does_not_raise_type_error_if_geom_data_not_provided
|
220
|
+
polygon = Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]],256)
|
221
|
+
|
222
|
+
assert_nothing_raised(TypeError) { polygon.kml_representation }
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_to_kml_for_line_string_does_not_raise_type_error_if_geom_data_not_provided
|
226
|
+
ls = LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
|
227
|
+
assert_nothing_raised(TypeError) { ls.kml_representation }
|
228
|
+
end
|
229
|
+
|
214
230
|
|
215
231
|
end
|
data/test/test_shp_write.rb
CHANGED
@@ -476,7 +476,7 @@ class TestSimpleFeatures < Test::Unit::TestCase
|
|
476
476
|
assert_equal("SRID=256;MULTIPOLYGON(((12.4 -45.3,45.4 41.6,4.456 1.0698,12.4 -45.3),(2.4 5.3,5.4 1.4263,14.46 1.06,2.4 5.3)),((0 0,4 0,4 4,0 4,0 0),(1 1,3 1,3 3,1 3,1 1)))",multi_polygon.as_ewkt)
|
477
477
|
|
478
478
|
multi_polygon = MultiPolygon.from_polygons([Polygon.from_coordinates([[[12.4,-45.3,2],[45.4,41.6,3],[4.456,1.0698,4],[12.4,-45.3,2]],[[2.4,5.3,1],[5.4,1.4263,3.44],[14.46,1.06,4.5],[2.4,5.3,1]]],DEFAULT_SRID,true),Polygon.from_coordinates([[[0,0,5.6],[4,0,5.4],[4,4,1],[0,4,23],[0,0,5.6]],[[1,1,2.3],[3,1,4],[3,3,5],[1,3,6],[1,1,2.3]]],DEFAULT_SRID,true)],DEFAULT_SRID,true)
|
479
|
-
assert_equal("MULTIPOLYGON(((12.4 -45.3 2,45.4 41.6 3,4.456 1.0698 4,12.4 -45.3 2),(2.4 5.3 1,5.4 1.4263 3.44,14.46 1.06 4.5,2.4 5.3 1)),((0 0 5.6,4 0 5.4,4 4 1,0 4 23,0 0 5.6),(1 1 2.3,3 1 4,3 3 5,1 3 6,1 1 2.3)))",multi_polygon.as_ewkt)
|
479
|
+
assert_equal("SRID=-1;MULTIPOLYGON(((12.4 -45.3 2,45.4 41.6 3,4.456 1.0698 4,12.4 -45.3 2),(2.4 5.3 1,5.4 1.4263 3.44,14.46 1.06 4.5,2.4 5.3 1)),((0 0 5.6,4 0 5.4,4 4 1,0 4 23,0 0 5.6),(1 1 2.3,3 1 4,3 3 5,1 3 6,1 1 2.3)))",multi_polygon.as_ewkt)
|
480
480
|
|
481
481
|
end
|
482
482
|
|
@@ -1,10 +1,14 @@
|
|
1
1
|
class SpatialAdapterNotCompatibleError < StandardError
|
2
2
|
end
|
3
3
|
|
4
|
-
|
4
|
+
|
5
|
+
case ActiveRecord::Base.connection.adapter_name
|
6
|
+
when 'MySQL'
|
5
7
|
require 'mysql_spatial_adapter'
|
6
|
-
|
8
|
+
when 'PostgreSQL'
|
7
9
|
require 'post_gis_adapter'
|
8
|
-
else
|
10
|
+
else
|
9
11
|
raise SpatialAdapterNotCompatibleError.new("Only MySQL and PostgreSQL are currently supported by the spatial adapter plugin.")
|
10
|
-
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
@@ -52,17 +52,47 @@ ActiveRecord::Base.class_eval do
|
|
52
52
|
end
|
53
53
|
end.join(' AND ')
|
54
54
|
end
|
55
|
+
def self.get_rails2_conditions(attrs)
|
56
|
+
attrs.map do |attr, value|
|
57
|
+
attr = attr.to_s
|
58
|
+
if columns_hash[attr].is_a?(SpatialColumn)
|
59
|
+
if value.is_a?(Array)
|
60
|
+
#using some georuby utility : The multipoint has a bbox whose corners are the 2 points passed as parameters : [ pt1, pt2]
|
61
|
+
attrs[attr.to_sym]=MultiPoint.from_coordinates(value)
|
62
|
+
elsif value.is_a?(Envelope)
|
63
|
+
attrs[attr.to_sym]=MultiPoint.from_points([value.lower_corner,value.upper_corner])
|
64
|
+
end
|
65
|
+
"MBRIntersects(?, #{table_name}.#{connection.quote_column_name(attr)}) "
|
66
|
+
else
|
67
|
+
#original stuff
|
68
|
+
# Extract table name from qualified attribute names.
|
69
|
+
if attr.include?('.')
|
70
|
+
table_name, attr = attr.split('.', 2)
|
71
|
+
table_name = connection.quote_table_name(table_name)
|
72
|
+
else
|
73
|
+
table_name = quoted_table_name
|
74
|
+
end
|
75
|
+
"#{table_name}.#{connection.quote_column_name(attr)} #{attribute_condition(value)}"
|
76
|
+
end
|
77
|
+
end.join(' AND ')
|
78
|
+
end
|
55
79
|
if ActiveRecord::VERSION::STRING == "1.15.1"
|
56
80
|
def self.sanitize_sql_hash(attrs)
|
57
81
|
conditions = get_conditions(attrs)
|
58
82
|
replace_bind_variables(conditions, attrs.values)
|
59
83
|
end
|
60
|
-
|
84
|
+
elsif ActiveRecord::VERSION::STRING.starts_with?("1.15")
|
61
85
|
#For Rails >= 1.2
|
62
86
|
def self.sanitize_sql_hash(attrs)
|
63
87
|
conditions = get_conditions(attrs)
|
64
88
|
replace_bind_variables(conditions, expand_range_bind_variables(attrs.values))
|
65
89
|
end
|
90
|
+
else
|
91
|
+
#For Rails >= 2
|
92
|
+
def self.sanitize_sql_hash_for_conditions(attrs)
|
93
|
+
conditions = get_rails2_conditions(attrs)
|
94
|
+
replace_bind_variables(conditions, expand_range_bind_variables(attrs.values))
|
95
|
+
end
|
66
96
|
end
|
67
97
|
end
|
68
98
|
end
|
@@ -3,6 +3,7 @@ require 'geo_ruby'
|
|
3
3
|
require 'common_spatial_adapter'
|
4
4
|
|
5
5
|
include GeoRuby::SimpleFeatures
|
6
|
+
include SpatialAdapter
|
6
7
|
|
7
8
|
#tables to ignore in migration : relative to PostGIS management of geometric columns
|
8
9
|
ActiveRecord::SchemaDumper.ignore_tables << "spatial_ref_sys" << "geometry_columns"
|
@@ -41,14 +42,16 @@ ActiveRecord::Base.class_eval do
|
|
41
42
|
[ conditions.join(" AND "), *arguments[0...attribute_names.length] ]
|
42
43
|
end
|
43
44
|
else
|
45
|
+
#Vit Ondruch & Tilmann Singer 's patch
|
44
46
|
def self.get_conditions(attrs)
|
45
47
|
attrs.map do |attr, value|
|
48
|
+
attr = attr.to_s
|
46
49
|
if columns_hash[attr].is_a?(SpatialColumn)
|
47
50
|
if value.is_a?(Array)
|
48
|
-
attrs[attr]= "BOX3D(" + value[0].join(" ") + "," + value[1].join(" ") + ")"
|
51
|
+
attrs[attr.to_sym]= "BOX3D(" + value[0].join(" ") + "," + value[1].join(" ") + ")"
|
49
52
|
"#{table_name}.#{connection.quote_column_name(attr)} && SetSRID(?::box3d, #{value[2] || DEFAULT_SRID} ) "
|
50
53
|
elsif value.is_a?(Envelope)
|
51
|
-
attrs[attr]= "BOX3D(" + value.lower_corner.text_representation + "," + value.upper_corner.text_representation + ")"
|
54
|
+
attrs[attr.to_sym]= "BOX3D(" + value.lower_corner.text_representation + "," + value.upper_corner.text_representation + ")"
|
52
55
|
"#{table_name}.#{connection.quote_column_name(attr)} && SetSRID(?::box3d, #{value.srid} ) "
|
53
56
|
else
|
54
57
|
"#{table_name}.#{connection.quote_column_name(attr)} && ? "
|
@@ -63,11 +66,17 @@ ActiveRecord::Base.class_eval do
|
|
63
66
|
conditions = get_conditions(attrs)
|
64
67
|
replace_bind_variables(conditions, attrs.values)
|
65
68
|
end
|
66
|
-
|
69
|
+
elsif ActiveRecord::VERSION::STRING.starts_with?("1.15")
|
67
70
|
def self.sanitize_sql_hash(attrs)
|
68
71
|
conditions = get_conditions(attrs)
|
69
72
|
replace_bind_variables(conditions, expand_range_bind_variables(attrs.values))
|
70
73
|
end
|
74
|
+
else
|
75
|
+
#For Rails >= 2
|
76
|
+
def self.sanitize_sql_hash_for_conditions(attrs)
|
77
|
+
conditions = get_conditions(attrs)
|
78
|
+
replace_bind_variables(conditions, expand_range_bind_variables(attrs.values))
|
79
|
+
end
|
71
80
|
end
|
72
81
|
end
|
73
82
|
end
|
@@ -194,13 +203,31 @@ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
|
|
194
203
|
column_definitions(table_name).collect do |name, type, default, notnull|
|
195
204
|
if type =~ /geometry/i and raw_geom_infos[name]
|
196
205
|
raw_geom_info = raw_geom_infos[name]
|
197
|
-
|
198
|
-
|
206
|
+
if ActiveRecord::VERSION::STRING >= "2.0.0"
|
207
|
+
ActiveRecord::ConnectionAdapters::SpatialPostgreSQLColumn.new(name, default,raw_geom_info.type, notnull == "f", raw_geom_info.srid, raw_geom_info.with_z, raw_geom_info.with_m)
|
208
|
+
else
|
209
|
+
ActiveRecord::ConnectionAdapters::SpatialPostgreSQLColumn.new(name, default_value(default), raw_geom_info.type, notnull == "f", raw_geom_info.srid, raw_geom_info.with_z, raw_geom_info.with_m)
|
210
|
+
end
|
199
211
|
else
|
200
|
-
ActiveRecord::
|
212
|
+
if ActiveRecord::VERSION::STRING >= "2.0.0"
|
213
|
+
ActiveRecord::ConnectionAdapters::Column.new(name, ActiveRecord::ConnectionAdapters::PostgreSQLColumn.extract_value_from_default( default), type,notnull == "f")
|
214
|
+
else
|
215
|
+
#Vit Ondruch & Tilmann Singer 's patch
|
216
|
+
ActiveRecord::ConnectionAdapters::Column.new(name, default_value(default), translate_field_type(type),notnull == "f")
|
217
|
+
end
|
201
218
|
end
|
202
219
|
end
|
203
220
|
end
|
221
|
+
|
222
|
+
#Pete Deffendol's patch
|
223
|
+
alias :original_disable_referential_integrity :disable_referential_integrity
|
224
|
+
def disable_referential_integrity(&block) #:nodoc:
|
225
|
+
ignore_tables = %w{ geometry_columns spatial_ref_sys }
|
226
|
+
execute(tables.select { |name| !ignore_tables.include?(name) }.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";"))
|
227
|
+
yield
|
228
|
+
ensure
|
229
|
+
execute(tables.select { |name| !ignore_tables.include?(name)}.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";"))
|
230
|
+
end
|
204
231
|
|
205
232
|
private
|
206
233
|
|
@@ -284,7 +311,7 @@ module ActiveRecord
|
|
284
311
|
attr_reader :geom_columns
|
285
312
|
|
286
313
|
def column(name, type, options = {})
|
287
|
-
unless @base.geometry_data_types[type].nil?
|
314
|
+
unless @base.geometry_data_types[type.to_sym].nil?
|
288
315
|
geom_column = PostgreSQLColumnDefinition.new(@base,name, type)
|
289
316
|
geom_column.null = options[:null]
|
290
317
|
geom_column.srid = options[:srid] || -1
|
@@ -297,6 +324,17 @@ module ActiveRecord
|
|
297
324
|
super(name,type,options)
|
298
325
|
end
|
299
326
|
end
|
327
|
+
|
328
|
+
SpatialAdapter.geometry_data_types.keys.each do |column_type|
|
329
|
+
class_eval <<-EOV
|
330
|
+
def #{column_type}(*args)
|
331
|
+
options = args.extract_options!
|
332
|
+
column_names = args
|
333
|
+
|
334
|
+
column_names.each { |name| column(name, '#{column_type}', options) }
|
335
|
+
end
|
336
|
+
EOV
|
337
|
+
end
|
300
338
|
end
|
301
339
|
|
302
340
|
class PostgreSQLColumnDefinition < ColumnDefinition
|
@@ -357,3 +395,4 @@ module ActiveRecord
|
|
357
395
|
end
|
358
396
|
end
|
359
397
|
end
|
398
|
+
|
@@ -11,12 +11,12 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
11
11
|
pt = TablePoint.new(:data => "Test", :geom => Point.from_x_y(1.2,4.5))
|
12
12
|
assert(pt.save)
|
13
13
|
|
14
|
-
pt = TablePoint.
|
14
|
+
pt = TablePoint.find(:first)
|
15
15
|
assert(pt)
|
16
16
|
assert_equal("Test",pt.data)
|
17
17
|
assert_equal(Point.from_x_y(1.2,4.5),pt.geom)
|
18
18
|
|
19
|
-
pts = TablePoint.
|
19
|
+
pts = TablePoint.find(:all)
|
20
20
|
pts.each do |pt|
|
21
21
|
assert(pt.geom.is_a?(Point))
|
22
22
|
end
|
@@ -27,7 +27,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
27
27
|
pt = TableKeywordColumnPoint.new(:location => Point.from_x_y(1.2,4.5))
|
28
28
|
assert(pt.save)
|
29
29
|
|
30
|
-
pt = TableKeywordColumnPoint.
|
30
|
+
pt = TableKeywordColumnPoint.find(:first)
|
31
31
|
assert(pt)
|
32
32
|
assert_equal(Point.from_x_y(1.2,4.5),pt.location)
|
33
33
|
|
@@ -37,7 +37,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
37
37
|
ls = TableLineString.new(:value => 3, :geom => LineString.from_coordinates([[1.4,2.5],[1.5,6.7]]))
|
38
38
|
assert(ls.save)
|
39
39
|
|
40
|
-
ls = TableLineString.
|
40
|
+
ls = TableLineString.find(:first)
|
41
41
|
assert(ls)
|
42
42
|
assert_equal(3,ls.value)
|
43
43
|
assert_equal(LineString.from_coordinates([[1.4,2.5],[1.5,6.7]]),ls.geom)
|
@@ -48,7 +48,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
48
48
|
pg = TablePolygon.new(:geom => Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]]))
|
49
49
|
assert(pg.save)
|
50
50
|
|
51
|
-
pg = TablePolygon.
|
51
|
+
pg = TablePolygon.find(:first)
|
52
52
|
assert(pg)
|
53
53
|
assert_equal(Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]]),pg.geom)
|
54
54
|
end
|
@@ -57,7 +57,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
57
57
|
mp = TableMultiPoint.new(:geom => MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]]))
|
58
58
|
assert(mp.save)
|
59
59
|
|
60
|
-
mp = TableMultiPoint.
|
60
|
+
mp = TableMultiPoint.find(:first)
|
61
61
|
assert(mp)
|
62
62
|
assert_equal(MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]]),mp.geom)
|
63
63
|
end
|
@@ -66,7 +66,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
66
66
|
ml = TableMultiLineString.new(:geom => MultiLineString.from_line_strings([LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012]]),LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]])]))
|
67
67
|
assert(ml.save)
|
68
68
|
|
69
|
-
ml = TableMultiLineString.
|
69
|
+
ml = TableMultiLineString.find(:first)
|
70
70
|
assert(ml)
|
71
71
|
assert_equal(MultiLineString.from_line_strings([LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012]]),LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]])]),ml.geom)
|
72
72
|
end
|
@@ -75,7 +75,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
75
75
|
mp = TableMultiPolygon.new( :geom => MultiPolygon.from_polygons([Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]]),Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]])]))
|
76
76
|
assert(mp.save)
|
77
77
|
|
78
|
-
mp = TableMultiPolygon.
|
78
|
+
mp = TableMultiPolygon.find(:first)
|
79
79
|
assert(mp)
|
80
80
|
assert_equal(MultiPolygon.from_polygons([Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]]),Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]])]),mp.geom)
|
81
81
|
end
|
@@ -84,7 +84,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
84
84
|
gm = TableGeometry.new(:geom => LineString.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698]]))
|
85
85
|
assert(gm.save)
|
86
86
|
|
87
|
-
gm = TableGeometry.
|
87
|
+
gm = TableGeometry.find(:first)
|
88
88
|
assert(gm)
|
89
89
|
assert_equal(LineString.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698]]),gm.geom)
|
90
90
|
end
|
@@ -93,7 +93,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
93
93
|
gc = TableGeometryCollection.new(:geom => GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4),LineString.from_coordinates([[5.7,12.45],[67.55,54]])]))
|
94
94
|
assert(gc.save)
|
95
95
|
|
96
|
-
gc = TableGeometryCollection.
|
96
|
+
gc = TableGeometryCollection.find(:first)
|
97
97
|
assert(gc)
|
98
98
|
assert_equal(GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4),LineString.from_coordinates([[5.7,12.45],[67.55,54]])]),gc.geom)
|
99
99
|
end
|
@@ -102,7 +102,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
102
102
|
pt = Table3dzPoint.new(:data => "Hello!",:geom => Point.from_x_y_z(-1.6,2.8,-3.4))
|
103
103
|
assert(pt.save)
|
104
104
|
|
105
|
-
pt = Table3dzPoint.
|
105
|
+
pt = Table3dzPoint.find(:first)
|
106
106
|
assert(pt)
|
107
107
|
assert_equal(Point.from_x_y_z(-1.6,2.8,-3.4),pt.geom)
|
108
108
|
end
|
@@ -111,7 +111,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
111
111
|
pt = Table3dmPoint.new(:geom => Point.from_x_y_m(-1.6,2.8,-3.4))
|
112
112
|
assert(pt.save)
|
113
113
|
|
114
|
-
pt = Table3dmPoint.
|
114
|
+
pt = Table3dmPoint.find(:first)
|
115
115
|
assert(pt)
|
116
116
|
assert_equal(Point.from_x_y_m(-1.6,2.8,-3.4),pt.geom)
|
117
117
|
end
|
@@ -120,7 +120,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
120
120
|
pt = Table4dPoint.new(:geom => Point.from_x_y_z_m(-1.6,2.8,-3.4,15))
|
121
121
|
assert(pt.save)
|
122
122
|
|
123
|
-
pt = Table4dPoint.
|
123
|
+
pt = Table4dPoint.find(:first)
|
124
124
|
assert(pt)
|
125
125
|
assert_equal(Point.from_x_y_z_m(-1.6,2.8,-3.4,15),pt.geom)
|
126
126
|
end
|
@@ -129,7 +129,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
129
129
|
ls = TableSridLineString.new(:geom => LineString.from_coordinates([[1.4,2.5],[1.5,6.7]],123))
|
130
130
|
assert(ls.save)
|
131
131
|
|
132
|
-
ls = TableSridLineString.
|
132
|
+
ls = TableSridLineString.find(:first)
|
133
133
|
assert(ls)
|
134
134
|
ls_e = LineString.from_coordinates([[1.4,2.5],[1.5,6.7]],123)
|
135
135
|
assert_equal(ls_e,ls.geom)
|
@@ -140,7 +140,7 @@ class AccessPostgisTest < Test::Unit::TestCase
|
|
140
140
|
pg = TableSrid4dPolygon.new(:geom => Polygon.from_coordinates([[[0,0,2,-45.1],[4,0,2,5],[4,4,2,4.67],[0,4,2,1.34],[0,0,2,-45.1]],[[1,1,2,12.3],[3,1,2,123],[3,3,2,12.2],[1,3,2,12],[1,1,2,12.3]]],123,true,true))
|
141
141
|
assert(pg.save)
|
142
142
|
|
143
|
-
pg = TableSrid4dPolygon.
|
143
|
+
pg = TableSrid4dPolygon.find(:first)
|
144
144
|
assert(pg)
|
145
145
|
pg_e = Polygon.from_coordinates([[[0,0,2,-45.1],[4,0,2,5],[4,4,2,4.67],[0,4,2,1.34],[0,0,2,-45.1]],[[1,1,2,12.3],[3,1,2,123],[3,3,2,12.2],[1,3,2,12],[1,1,2,12.3]]],123,true,true)
|
146
146
|
assert_equal(pg_e,pg.geom)
|