rgeo 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +11 -0
- data/README.rdoc +3 -3
- data/Spatial_Programming_With_RGeo.rdoc +19 -8
- data/Version +1 -1
- data/ext/geos_c_impl/factory.c +1 -0
- data/ext/geos_c_impl/factory.h +1 -0
- data/ext/geos_c_impl/geometry.c +4 -5
- data/ext/geos_c_impl/geometry_collection.c +15 -0
- data/ext/geos_c_impl/line_string.c +10 -0
- data/ext/geos_c_impl/point.c +2 -0
- data/ext/geos_c_impl/polygon.c +4 -0
- data/lib/rgeo/cartesian/feature_classes.rb +23 -17
- data/lib/rgeo/cartesian/feature_methods.rb +20 -1
- data/lib/rgeo/feature.rb +1 -0
- data/lib/rgeo/feature/curve.rb +1 -2
- data/lib/rgeo/feature/geometry_collection.rb +1 -1
- data/lib/rgeo/feature/line.rb +1 -1
- data/lib/rgeo/feature/line_string.rb +1 -2
- data/lib/rgeo/feature/linear_ring.rb +1 -2
- data/lib/rgeo/feature/mixins.rb +198 -0
- data/lib/rgeo/feature/multi_curve.rb +1 -2
- data/lib/rgeo/feature/multi_line_string.rb +1 -2
- data/lib/rgeo/feature/multi_point.rb +1 -2
- data/lib/rgeo/feature/multi_polygon.rb +1 -2
- data/lib/rgeo/feature/multi_surface.rb +1 -2
- data/lib/rgeo/feature/point.rb +1 -2
- data/lib/rgeo/feature/polygon.rb +1 -3
- data/lib/rgeo/feature/surface.rb +1 -2
- data/lib/rgeo/feature/types.rb +27 -0
- data/lib/rgeo/geographic/projected_feature_classes.rb +31 -4
- data/lib/rgeo/geographic/projected_feature_methods.rb +2 -1
- data/lib/rgeo/geographic/spherical_feature_classes.rb +30 -3
- data/lib/rgeo/geos.rb +22 -0
- data/lib/rgeo/geos/factory.rb +11 -5
- data/lib/rgeo/geos/ffi_classes.rb +655 -0
- data/lib/rgeo/geos/ffi_factory.rb +503 -0
- data/lib/rgeo/geos/impl_additions.rb +1 -1
- data/lib/rgeo/geos/interface.rb +63 -8
- data/lib/rgeo/geos/zm_factory.rb +10 -4
- data/test/common/geometry_collection_tests.rb +1 -3
- data/test/coord_sys/tc_ogc_cs.rb +13 -2
- data/test/coord_sys/tc_proj4_srs_data.rb +1 -1
- data/test/{geos → geos_capi}/tc_factory.rb +2 -2
- data/test/{geos → geos_capi}/tc_geometry_collection.rb +2 -2
- data/test/{geos → geos_capi}/tc_line_string.rb +2 -2
- data/test/{geos → geos_capi}/tc_misc.rb +6 -2
- data/test/{geos → geos_capi}/tc_multi_line_string.rb +2 -2
- data/test/{geos → geos_capi}/tc_multi_point.rb +2 -2
- data/test/{geos → geos_capi}/tc_multi_polygon.rb +2 -2
- data/test/{geos → geos_capi}/tc_parsing_unparsing.rb +2 -2
- data/test/{geos → geos_capi}/tc_point.rb +2 -2
- data/test/{geos → geos_capi}/tc_polygon.rb +2 -2
- data/test/{geos → geos_capi}/tc_zmfactory.rb +2 -2
- data/test/geos_ffi/tc_factory.rb +91 -0
- data/test/geos_ffi/tc_geometry_collection.rb +62 -0
- data/test/geos_ffi/tc_line_string.rb +62 -0
- data/test/geos_ffi/tc_misc.rb +69 -0
- data/test/geos_ffi/tc_multi_line_string.rb +62 -0
- data/test/geos_ffi/tc_multi_point.rb +62 -0
- data/test/geos_ffi/tc_multi_polygon.rb +64 -0
- data/test/geos_ffi/tc_parsing_unparsing.rb +81 -0
- data/test/geos_ffi/tc_point.rb +87 -0
- data/test/geos_ffi/tc_polygon.rb +86 -0
- data/test/geos_ffi/tc_zmfactory.rb +86 -0
- data/test/tc_mixins.rb +188 -0
- data/test/tc_types.rb +77 -0
- metadata +54 -25
data/lib/rgeo/geos/interface.rb
CHANGED
@@ -38,16 +38,48 @@ module RGeo
|
|
38
38
|
|
39
39
|
module Geos
|
40
40
|
|
41
|
-
@supported = nil
|
42
|
-
|
43
41
|
class << self
|
44
42
|
|
45
43
|
|
46
|
-
# Returns true if GEOS implementation is supported.
|
47
|
-
|
44
|
+
# Returns true if CAPI GEOS implementation is supported.
|
45
|
+
|
46
|
+
def capi_supported?
|
47
|
+
CAPI_SUPPORTED
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
# Returns true if FFI GEOS implementation is supported.
|
52
|
+
|
53
|
+
def ffi_supported?
|
54
|
+
FFI_SUPPORTED
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# Returns true if any GEOS implementation is supported.
|
59
|
+
# If this returns false, GEOS features are not available at all.
|
48
60
|
|
49
61
|
def supported?
|
50
|
-
|
62
|
+
FFI_SUPPORTED || CAPI_SUPPORTED
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
# Returns true if the given feature is a CAPI GEOS feature, or if
|
67
|
+
# the given factory is a native GEOS factory.
|
68
|
+
|
69
|
+
def is_capi_geos?(object_)
|
70
|
+
Factory === object_ || GeometryImpl === object_ ||
|
71
|
+
ZMFactory === object_ && Factory === object_.z_factory ||
|
72
|
+
ZMGeometryImpl === object_ && GeometryImpl === object_.z_geometry
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# Returns true if the given feature is an FFI GEOS feature, or if
|
77
|
+
# the given factory is an FFI GEOS factory.
|
78
|
+
|
79
|
+
def is_ffi_geos?(object_)
|
80
|
+
FFIFactory === object_ || FFIGeometryImpl === object_ ||
|
81
|
+
ZMFactory === object_ && FFIFactory === object_.z_factory ||
|
82
|
+
ZMGeometryImpl === object_ && FFIGeometryImpl === object_.z_geometry
|
51
83
|
end
|
52
84
|
|
53
85
|
|
@@ -55,10 +87,25 @@ module RGeo
|
|
55
87
|
# factory is a GEOS factory.
|
56
88
|
|
57
89
|
def is_geos?(object_)
|
58
|
-
|
90
|
+
Factory === object_ || GeometryImpl === object_ ||
|
91
|
+
FFIFactory === object_ || FFIGeometryImpl === object_ ||
|
92
|
+
ZMFactory === object_ || ZMGeometryImpl === object_
|
59
93
|
end
|
60
94
|
|
61
95
|
|
96
|
+
# The preferred native interface. This is the native interface
|
97
|
+
# used by default when a factory is created.
|
98
|
+
# Supported values are <tt>:capi</tt> and <tt>:ffi</tt>.
|
99
|
+
#
|
100
|
+
# This is set automatically when RGeo loads, to <tt>:capi</tt>
|
101
|
+
# if the CAPI interface is available, otheriwse to <tt>:ffi</tt>
|
102
|
+
# if FFI is available, otherwise to nil if no GEOS interface is
|
103
|
+
# available. You can override this setting if you want to prefer
|
104
|
+
# FFI over CAPI.
|
105
|
+
|
106
|
+
attr_accessor :preferred_native_interface
|
107
|
+
|
108
|
+
|
62
109
|
# Returns a factory for the GEOS implementation.
|
63
110
|
# Returns nil if the GEOS implementation is not supported.
|
64
111
|
#
|
@@ -71,12 +118,17 @@ module RGeo
|
|
71
118
|
#
|
72
119
|
# Options include:
|
73
120
|
#
|
74
|
-
# [<tt>:
|
121
|
+
# [<tt>:native_interface</tt>]
|
122
|
+
# Specifies which native interface to use. Possible values are
|
123
|
+
# <tt>:capi</tt> and <tt>:ffi</tt>. The default is the value
|
124
|
+
# of the preferred_native_interface.
|
125
|
+
# [<tt>:uses_lenient_multi_polygon_assertions</tt>]
|
75
126
|
# If set to true, assertion checking on MultiPolygon is disabled.
|
76
127
|
# This may speed up creation of MultiPolygon objects, at the
|
77
128
|
# expense of not doing the proper checking for OGC MultiPolygon
|
78
129
|
# compliance. See RGeo::Feature::MultiPolygon for details on
|
79
|
-
# the MultiPolygon assertions. Default is false.
|
130
|
+
# the MultiPolygon assertions. Default is false. Also called
|
131
|
+
# <tt>:lenient_multi_polygon_assertions</tt>.
|
80
132
|
# [<tt>:buffer_resolution</tt>]
|
81
133
|
# The resolution of buffers around geometries created by this
|
82
134
|
# factory. This controls the number of line segments used to
|
@@ -139,8 +191,11 @@ module RGeo
|
|
139
191
|
|
140
192
|
def factory(opts_={})
|
141
193
|
if supported?
|
194
|
+
native_interface_ = opts_[:native_interface] || Geos.preferred_native_interface
|
142
195
|
if opts_[:has_z_coordinate] && opts_[:has_m_coordinate]
|
143
196
|
ZMFactory.new(opts_)
|
197
|
+
elsif native_interface_ == :ffi
|
198
|
+
FFIFactory.new(opts_)
|
144
199
|
else
|
145
200
|
Factory.create(opts_)
|
146
201
|
end
|
data/lib/rgeo/geos/zm_factory.rb
CHANGED
@@ -80,8 +80,14 @@ module RGeo
|
|
80
80
|
:wkb_generator => opts_[:wkb_generator], :wkb_parser => opts_[:wkb_parser],
|
81
81
|
:srid => srid_.to_i, :proj4 => proj4_, :coord_sys => coord_sys_,
|
82
82
|
}
|
83
|
-
|
84
|
-
|
83
|
+
native_interface_ = opts_[:native_interface] || Geos.preferred_native_interface
|
84
|
+
if native_interface_ == :ffi
|
85
|
+
@zfactory = FFIFactory.new(config_.merge(:has_z_coordinate => true))
|
86
|
+
@mfactory = FFIFactory.new(config_.merge(:has_m_coordinate => true))
|
87
|
+
else
|
88
|
+
@zfactory = Factory.create(config_.merge(:has_z_coordinate => true))
|
89
|
+
@mfactory = Factory.create(config_.merge(:has_m_coordinate => true))
|
90
|
+
end
|
85
91
|
|
86
92
|
wkt_generator_ = opts_[:wkt_generator]
|
87
93
|
case wkt_generator_
|
@@ -117,7 +123,7 @@ module RGeo
|
|
117
123
|
# Returns the SRID of geometries created by this factory.
|
118
124
|
|
119
125
|
def srid
|
120
|
-
@zfactory.
|
126
|
+
@zfactory.srid
|
121
127
|
end
|
122
128
|
|
123
129
|
|
@@ -125,7 +131,7 @@ module RGeo
|
|
125
131
|
# created by this factory
|
126
132
|
|
127
133
|
def buffer_resolution
|
128
|
-
@zfactory.
|
134
|
+
@zfactory.buffer_resolution
|
129
135
|
end
|
130
136
|
|
131
137
|
|
@@ -233,9 +233,7 @@ module RGeo
|
|
233
233
|
|
234
234
|
def test_empty_collection_boundary
|
235
235
|
empty_ = @factory.collection([])
|
236
|
-
|
237
|
-
assert_equal(Feature::GeometryCollection, boundary_.geometry_type)
|
238
|
-
assert_equal(0, boundary_.num_geometries)
|
236
|
+
assert_nil(empty_.boundary)
|
239
237
|
end
|
240
238
|
|
241
239
|
|
data/test/coord_sys/tc_ogc_cs.rb
CHANGED
@@ -45,6 +45,17 @@ module RGeo
|
|
45
45
|
class TestOgcCs < ::Test::Unit::TestCase # :nodoc:
|
46
46
|
|
47
47
|
|
48
|
+
# Handle differences in floating-point output.
|
49
|
+
|
50
|
+
def _lenient_regex_for(str_)
|
51
|
+
::Regexp.new(str_.gsub(/(\d)\.(\d{10,})/) do |m_|
|
52
|
+
before_ = $1
|
53
|
+
after_ = $2[0,10]
|
54
|
+
"#{before_}.#{after_}\\d*"
|
55
|
+
end.gsub(/(\.|\[|\]|\(|\)|\$|\^|\||\+)/){ |m_| "\\#{$1}"})
|
56
|
+
end
|
57
|
+
|
58
|
+
|
48
59
|
def test_axis_info_by_value
|
49
60
|
obj_ = ::RGeo::CoordSys::CS::AxisInfo.create('N', ::RGeo::CoordSys::CS::AO_NORTH)
|
50
61
|
assert_equal('N', obj_.name)
|
@@ -277,7 +288,7 @@ module RGeo
|
|
277
288
|
assert_nil(obj_.get_axis(1))
|
278
289
|
assert_equal('degree', obj_.get_units(0).name)
|
279
290
|
assert_equal('degree', obj_.get_units(1).name)
|
280
|
-
|
291
|
+
assert_match(_lenient_regex_for('GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137.0,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]'), obj_.to_wkt)
|
281
292
|
end
|
282
293
|
|
283
294
|
|
@@ -345,7 +356,7 @@ module RGeo
|
|
345
356
|
assert_kind_of(::RGeo::CoordSys::CS::ProjectedCoordinateSystem, obj_.head)
|
346
357
|
assert_kind_of(::RGeo::CoordSys::CS::VerticalCoordinateSystem, obj_.tail)
|
347
358
|
assert_equal(3, obj_.dimension)
|
348
|
-
|
359
|
+
assert_match(_lenient_regex_for(input_), obj_.to_wkt)
|
349
360
|
end
|
350
361
|
|
351
362
|
|
@@ -40,7 +40,7 @@ require 'rgeo'
|
|
40
40
|
|
41
41
|
module RGeo
|
42
42
|
module Tests # :nodoc:
|
43
|
-
module
|
43
|
+
module GeosCAPI # :nodoc:
|
44
44
|
|
45
45
|
class TestFactory < ::Test::Unit::TestCase # :nodoc:
|
46
46
|
|
@@ -88,4 +88,4 @@ module RGeo
|
|
88
88
|
|
89
89
|
end
|
90
90
|
end
|
91
|
-
end if ::RGeo::Geos.
|
91
|
+
end if ::RGeo::Geos.capi_supported?
|
@@ -42,7 +42,7 @@ require ::File.expand_path('../common/geometry_collection_tests.rb', ::File.dirn
|
|
42
42
|
|
43
43
|
module RGeo
|
44
44
|
module Tests # :nodoc:
|
45
|
-
module
|
45
|
+
module GeosCAPI # :nodoc:
|
46
46
|
|
47
47
|
class TestGeometryCollection < ::Test::Unit::TestCase # :nodoc:
|
48
48
|
|
@@ -59,4 +59,4 @@ module RGeo
|
|
59
59
|
|
60
60
|
end
|
61
61
|
end
|
62
|
-
end if ::RGeo::Geos.
|
62
|
+
end if ::RGeo::Geos.capi_supported?
|
@@ -42,7 +42,7 @@ require ::File.expand_path('../common/line_string_tests.rb', ::File.dirname(__FI
|
|
42
42
|
|
43
43
|
module RGeo
|
44
44
|
module Tests # :nodoc:
|
45
|
-
module
|
45
|
+
module GeosCAPI # :nodoc:
|
46
46
|
|
47
47
|
class TestLineString < ::Test::Unit::TestCase # :nodoc:
|
48
48
|
|
@@ -59,4 +59,4 @@ module RGeo
|
|
59
59
|
|
60
60
|
end
|
61
61
|
end
|
62
|
-
end if ::RGeo::Geos.
|
62
|
+
end if ::RGeo::Geos.capi_supported?
|
@@ -40,7 +40,7 @@ require 'rgeo'
|
|
40
40
|
|
41
41
|
module RGeo
|
42
42
|
module Tests # :nodoc:
|
43
|
-
module
|
43
|
+
module GeosCAPI # :nodoc:
|
44
44
|
|
45
45
|
class TestMisc < ::Test::Unit::TestCase # :nodoc:
|
46
46
|
|
@@ -69,4 +69,8 @@ module RGeo
|
|
69
69
|
|
70
70
|
end
|
71
71
|
end
|
72
|
-
end if ::RGeo::Geos.
|
72
|
+
end if ::RGeo::Geos.capi_supported?
|
73
|
+
|
74
|
+
unless ::RGeo::Geos.capi_supported?
|
75
|
+
puts "WARNING: GEOS CAPI support not available. Related tests skipped."
|
76
|
+
end
|
@@ -42,7 +42,7 @@ require ::File.expand_path('../common/multi_line_string_tests.rb', ::File.dirnam
|
|
42
42
|
|
43
43
|
module RGeo
|
44
44
|
module Tests # :nodoc:
|
45
|
-
module
|
45
|
+
module GeosCAPI # :nodoc:
|
46
46
|
|
47
47
|
class TestMultiLineString < ::Test::Unit::TestCase # :nodoc:
|
48
48
|
|
@@ -59,4 +59,4 @@ module RGeo
|
|
59
59
|
|
60
60
|
end
|
61
61
|
end
|
62
|
-
end if ::RGeo::Geos.
|
62
|
+
end if ::RGeo::Geos.capi_supported?
|
@@ -42,7 +42,7 @@ require ::File.expand_path('../common/multi_point_tests.rb', ::File.dirname(__FI
|
|
42
42
|
|
43
43
|
module RGeo
|
44
44
|
module Tests # :nodoc:
|
45
|
-
module
|
45
|
+
module GeosCAPI # :nodoc:
|
46
46
|
|
47
47
|
class TestMultiPoint < ::Test::Unit::TestCase # :nodoc:
|
48
48
|
|
@@ -59,4 +59,4 @@ module RGeo
|
|
59
59
|
|
60
60
|
end
|
61
61
|
end
|
62
|
-
end if ::RGeo::Geos.
|
62
|
+
end if ::RGeo::Geos.capi_supported?
|
@@ -42,7 +42,7 @@ require ::File.expand_path('../common/multi_polygon_tests.rb', ::File.dirname(__
|
|
42
42
|
|
43
43
|
module RGeo
|
44
44
|
module Tests # :nodoc:
|
45
|
-
module
|
45
|
+
module GeosCAPI # :nodoc:
|
46
46
|
|
47
47
|
class TestMultiPolygon < ::Test::Unit::TestCase # :nodoc:
|
48
48
|
|
@@ -60,4 +60,4 @@ module RGeo
|
|
60
60
|
|
61
61
|
end
|
62
62
|
end
|
63
|
-
end if ::RGeo::Geos.
|
63
|
+
end if ::RGeo::Geos.capi_supported?
|
@@ -40,7 +40,7 @@ require 'rgeo'
|
|
40
40
|
|
41
41
|
module RGeo
|
42
42
|
module Tests # :nodoc:
|
43
|
-
module
|
43
|
+
module GeosCAPI # :nodoc:
|
44
44
|
|
45
45
|
class TestParsingUnparsing < ::Test::Unit::TestCase # :nodoc:
|
46
46
|
|
@@ -77,4 +77,4 @@ module RGeo
|
|
77
77
|
|
78
78
|
end
|
79
79
|
end
|
80
|
-
end if ::RGeo::Geos.
|
80
|
+
end if ::RGeo::Geos.capi_supported?
|
@@ -42,7 +42,7 @@ require ::File.expand_path('../common/point_tests.rb', ::File.dirname(__FILE__))
|
|
42
42
|
|
43
43
|
module RGeo
|
44
44
|
module Tests # :nodoc:
|
45
|
-
module
|
45
|
+
module GeosCAPI # :nodoc:
|
46
46
|
|
47
47
|
class TestPoint < ::Test::Unit::TestCase # :nodoc:
|
48
48
|
|
@@ -83,4 +83,4 @@ module RGeo
|
|
83
83
|
|
84
84
|
end
|
85
85
|
end
|
86
|
-
end if ::RGeo::Geos.
|
86
|
+
end if ::RGeo::Geos.capi_supported?
|
@@ -42,7 +42,7 @@ require ::File.expand_path('../common/polygon_tests.rb', ::File.dirname(__FILE__
|
|
42
42
|
|
43
43
|
module RGeo
|
44
44
|
module Tests # :nodoc:
|
45
|
-
module
|
45
|
+
module GeosCAPI # :nodoc:
|
46
46
|
|
47
47
|
class TestPolygon < ::Test::Unit::TestCase # :nodoc:
|
48
48
|
|
@@ -83,4 +83,4 @@ module RGeo
|
|
83
83
|
|
84
84
|
end
|
85
85
|
end
|
86
|
-
end if ::RGeo::Geos.
|
86
|
+
end if ::RGeo::Geos.capi_supported?
|
@@ -40,7 +40,7 @@ require 'rgeo'
|
|
40
40
|
|
41
41
|
module RGeo
|
42
42
|
module Tests # :nodoc:
|
43
|
-
module
|
43
|
+
module GeosCAPI # :nodoc:
|
44
44
|
|
45
45
|
class TestZMFactory < ::Test::Unit::TestCase # :nodoc:
|
46
46
|
|
@@ -82,4 +82,4 @@ module RGeo
|
|
82
82
|
|
83
83
|
end
|
84
84
|
end
|
85
|
-
end if ::RGeo::Geos.
|
85
|
+
end if ::RGeo::Geos.capi_supported?
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the GEOS factory
|
4
|
+
#
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# Copyright 2010 Daniel Azuma
|
7
|
+
#
|
8
|
+
# All rights reserved.
|
9
|
+
#
|
10
|
+
# Redistribution and use in source and binary forms, with or without
|
11
|
+
# modification, are permitted provided that the following conditions are met:
|
12
|
+
#
|
13
|
+
# * Redistributions of source code must retain the above copyright notice,
|
14
|
+
# this list of conditions and the following disclaimer.
|
15
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
16
|
+
# this list of conditions and the following disclaimer in the documentation
|
17
|
+
# and/or other materials provided with the distribution.
|
18
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
19
|
+
# contributors to this software, may be used to endorse or promote products
|
20
|
+
# derived from this software without specific prior written permission.
|
21
|
+
#
|
22
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
# -----------------------------------------------------------------------------
|
34
|
+
;
|
35
|
+
|
36
|
+
|
37
|
+
require 'test/unit'
|
38
|
+
require 'rgeo'
|
39
|
+
|
40
|
+
|
41
|
+
module RGeo
|
42
|
+
module Tests # :nodoc:
|
43
|
+
module GeosFFI # :nodoc:
|
44
|
+
|
45
|
+
class TestFactory < ::Test::Unit::TestCase # :nodoc:
|
46
|
+
|
47
|
+
|
48
|
+
def setup
|
49
|
+
@factory = ::RGeo::Geos.factory(:srid => 4326, :native_interface => :ffi)
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def test_srid_preserved_through_factory
|
54
|
+
geom_ = @factory.point(-10, 20)
|
55
|
+
assert_equal(4326, geom_.srid)
|
56
|
+
factory_ = geom_.factory
|
57
|
+
assert_equal(4326, factory_.srid)
|
58
|
+
geom2_ = factory_.point(-20, 25)
|
59
|
+
assert_equal(4326, geom2_.srid)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def test_srid_preserved_through_geom_operations
|
64
|
+
geom1_ = @factory.point(-10, 20)
|
65
|
+
geom2_ = @factory.point(-20, 25)
|
66
|
+
geom3_ = geom1_.union(geom2_)
|
67
|
+
assert_equal(4326, geom3_.srid)
|
68
|
+
assert_equal(4326, geom3_.geometry_n(0).srid)
|
69
|
+
assert_equal(4326, geom3_.geometry_n(1).srid)
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def test_srid_preserved_through_geom_functions
|
74
|
+
geom1_ = @factory.point(-10, 20)
|
75
|
+
geom2_ = geom1_.boundary
|
76
|
+
assert_equal(4326, geom2_.srid)
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
def test_srid_preserved_through_dup
|
81
|
+
geom1_ = @factory.point(-10, 20)
|
82
|
+
geom2_ = geom1_.clone
|
83
|
+
assert_equal(4326, geom2_.srid)
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end if ::RGeo::Geos.ffi_supported?
|