rgeo 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +22 -0
- data/README.rdoc +124 -0
- data/Version +1 -0
- data/ext/geos_c_impl/extconf.rb +72 -0
- data/ext/geos_c_impl/factory.c +468 -0
- data/ext/geos_c_impl/factory.h +217 -0
- data/ext/geos_c_impl/geometry.c +644 -0
- data/ext/geos_c_impl/geometry.h +65 -0
- data/ext/geos_c_impl/geometry_collection.c +580 -0
- data/ext/geos_c_impl/geometry_collection.h +79 -0
- data/ext/geos_c_impl/globals.h +58 -0
- data/ext/geos_c_impl/line_string.c +468 -0
- data/ext/geos_c_impl/line_string.h +74 -0
- data/ext/geos_c_impl/main.c +65 -0
- data/ext/geos_c_impl/point.c +201 -0
- data/ext/geos_c_impl/point.h +77 -0
- data/ext/geos_c_impl/polygon.c +259 -0
- data/ext/geos_c_impl/polygon.h +76 -0
- data/ext/geos_c_impl/preface.h +42 -0
- data/lib/rgeo.rb +68 -0
- data/lib/rgeo/errors.rb +59 -0
- data/lib/rgeo/features.rb +89 -0
- data/lib/rgeo/features/curve.rb +155 -0
- data/lib/rgeo/features/factory.rb +191 -0
- data/lib/rgeo/features/geometry.rb +560 -0
- data/lib/rgeo/features/geometry_collection.rb +118 -0
- data/lib/rgeo/features/line.rb +65 -0
- data/lib/rgeo/features/line_string.rb +101 -0
- data/lib/rgeo/features/linear_ring.rb +65 -0
- data/lib/rgeo/features/multi_curve.rb +112 -0
- data/lib/rgeo/features/multi_line_string.rb +65 -0
- data/lib/rgeo/features/multi_point.rb +72 -0
- data/lib/rgeo/features/multi_polygon.rb +96 -0
- data/lib/rgeo/features/multi_surface.rb +115 -0
- data/lib/rgeo/features/point.rb +97 -0
- data/lib/rgeo/features/polygon.rb +141 -0
- data/lib/rgeo/features/surface.rb +121 -0
- data/lib/rgeo/geo_json.rb +58 -0
- data/lib/rgeo/geo_json/coder.rb +305 -0
- data/lib/rgeo/geo_json/entities.rb +284 -0
- data/lib/rgeo/geo_json/interface.rb +95 -0
- data/lib/rgeo/geography.rb +75 -0
- data/lib/rgeo/geography/common/geometry_collection_methods.rb +206 -0
- data/lib/rgeo/geography/common/geometry_methods.rb +92 -0
- data/lib/rgeo/geography/common/helper.rb +102 -0
- data/lib/rgeo/geography/common/line_string_methods.rb +187 -0
- data/lib/rgeo/geography/common/point_methods.rb +149 -0
- data/lib/rgeo/geography/common/polygon_methods.rb +122 -0
- data/lib/rgeo/geography/factories.rb +136 -0
- data/lib/rgeo/geography/factory.rb +246 -0
- data/lib/rgeo/geography/projected_window.rb +467 -0
- data/lib/rgeo/geography/simple_mercator/feature_classes.rb +320 -0
- data/lib/rgeo/geography/simple_mercator/feature_methods.rb +291 -0
- data/lib/rgeo/geography/simple_mercator/projector.rb +116 -0
- data/lib/rgeo/geography/simple_spherical/calculations.rb +70 -0
- data/lib/rgeo/geography/simple_spherical/geometry_collection_impl.rb +66 -0
- data/lib/rgeo/geography/simple_spherical/geometry_methods.rb +59 -0
- data/lib/rgeo/geography/simple_spherical/line_string_impl.rb +104 -0
- data/lib/rgeo/geography/simple_spherical/multi_line_string_impl.rb +67 -0
- data/lib/rgeo/geography/simple_spherical/multi_point_impl.rb +67 -0
- data/lib/rgeo/geography/simple_spherical/multi_polygon_impl.rb +67 -0
- data/lib/rgeo/geography/simple_spherical/point_impl.rb +85 -0
- data/lib/rgeo/geography/simple_spherical/polygon_impl.rb +66 -0
- data/lib/rgeo/geos.rb +72 -0
- data/lib/rgeo/geos/factory.rb +260 -0
- data/lib/rgeo/geos/impl_additions.rb +57 -0
- data/lib/rgeo/geos/interface.rb +74 -0
- data/lib/rgeo/version.rb +52 -0
- data/tests/geos/tc_factory.rb +91 -0
- data/tests/geos/tc_geometry_collection.rb +226 -0
- data/tests/geos/tc_line_string.rb +310 -0
- data/tests/geos/tc_misc.rb +72 -0
- data/tests/geos/tc_multi_line_string.rb +211 -0
- data/tests/geos/tc_multi_point.rb +202 -0
- data/tests/geos/tc_multi_polygon.rb +210 -0
- data/tests/geos/tc_point.rb +305 -0
- data/tests/geos/tc_polygon.rb +240 -0
- data/tests/simple_mercator/tc_point.rb +303 -0
- data/tests/simple_mercator/tc_window.rb +219 -0
- data/tests/tc_geojson.rb +230 -0
- data/tests/tc_oneoff.rb +61 -0
- metadata +162 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# GEOS implementation additions written in Ruby
|
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
|
+
# :stopdoc:
|
38
|
+
|
39
|
+
module RGeo
|
40
|
+
|
41
|
+
module Geos
|
42
|
+
|
43
|
+
|
44
|
+
class GeometryImpl
|
45
|
+
|
46
|
+
def inspect
|
47
|
+
"#<#{self.class}:0x#{object_id.to_s(16)} #{as_text.inspect}>"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
# :startdoc:
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# GEOS toplevel interface
|
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
|
+
module RGeo
|
38
|
+
|
39
|
+
module Geos
|
40
|
+
|
41
|
+
@supported = nil
|
42
|
+
|
43
|
+
class << self
|
44
|
+
|
45
|
+
|
46
|
+
# Returns true if GEOS implementation is supported.
|
47
|
+
# If this returns false, GEOS features are not available.
|
48
|
+
|
49
|
+
def supported?
|
50
|
+
@supported.nil? ? (@supported = Factory.respond_to?(:_create)) : @supported
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
# Returns true if the given feature is a GEOS feature, or if the given
|
55
|
+
# factory is a GEOS factory.
|
56
|
+
|
57
|
+
def is_geos?(object_)
|
58
|
+
supported? ? Factory === object_ || GeometryImpl === object_ : false
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# Returns a factory for the GEOS implementation.
|
63
|
+
# Returns nil if the GEOS implementation is not supported.
|
64
|
+
|
65
|
+
def factory(opts_={})
|
66
|
+
supported? ? Factory.create(opts_) : nil
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/lib/rgeo/version.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# RGeo version
|
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
|
+
begin
|
38
|
+
require 'versionomy'
|
39
|
+
rescue ::LoadError
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
|
45
|
+
# Current version of RGeo as a frozen string
|
46
|
+
VERSION_STRING = ::File.read(::File.dirname(__FILE__)+'/../../Version').strip.freeze
|
47
|
+
|
48
|
+
# Current version of RGeo as a Versionomy object, if the Versionomy gem
|
49
|
+
# is available.
|
50
|
+
VERSION = defined?(::Versionomy) ? ::Versionomy.parse(VERSION_STRING) : VERSION_STRING
|
51
|
+
|
52
|
+
end
|
@@ -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 Geos
|
44
|
+
|
45
|
+
class TestFactory < ::Test::Unit::TestCase # :nodoc:
|
46
|
+
|
47
|
+
|
48
|
+
def setup
|
49
|
+
@factory = ::RGeo::Geos.factory(:srid => 4326)
|
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
|
@@ -0,0 +1,226 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the GEOS geometry collection implementation
|
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 Geos
|
44
|
+
|
45
|
+
class TestGeometryCollection < ::Test::Unit::TestCase # :nodoc:
|
46
|
+
|
47
|
+
|
48
|
+
def setup
|
49
|
+
@factory = ::RGeo::Geos.factory
|
50
|
+
@point1 = @factory.point(0, 0)
|
51
|
+
@point2 = @factory.point(1, 0)
|
52
|
+
@point3 = @factory.point(-4, 2)
|
53
|
+
@point4 = @factory.point(-5, 3)
|
54
|
+
@line1 = @factory.line_string([@point3, @point4])
|
55
|
+
@line2 = @factory.line_string([@point3, @point4, @point1])
|
56
|
+
@line3 = @factory.line(@point3, @point4)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
def test_creation_simple
|
61
|
+
geom_ = @factory.collection([@point1, @line1])
|
62
|
+
assert_not_nil(geom_)
|
63
|
+
assert_kind_of(::RGeo::Geos::GeometryCollectionImpl, geom_)
|
64
|
+
assert(::RGeo::Features::GeometryCollection === geom_)
|
65
|
+
assert_equal(::RGeo::Features::GeometryCollection, geom_.geometry_type)
|
66
|
+
assert_equal(2, geom_.num_geometries)
|
67
|
+
assert_equal([@point1, @line1], geom_.to_a)
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def test_creation_empty
|
72
|
+
geom_ = @factory.collection([])
|
73
|
+
assert_not_nil(geom_)
|
74
|
+
assert_kind_of(::RGeo::Geos::GeometryCollectionImpl, geom_)
|
75
|
+
assert(::RGeo::Features::GeometryCollection === geom_)
|
76
|
+
assert_equal(::RGeo::Features::GeometryCollection, geom_.geometry_type)
|
77
|
+
assert_equal(0, geom_.num_geometries)
|
78
|
+
assert_equal([], geom_.to_a)
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def test_creation_save_klass
|
83
|
+
geom_ = @factory.collection([@point1, @line3])
|
84
|
+
assert_not_nil(geom_)
|
85
|
+
assert_kind_of(::RGeo::Geos::GeometryCollectionImpl, geom_)
|
86
|
+
assert(::RGeo::Features::GeometryCollection === geom_)
|
87
|
+
assert_equal(::RGeo::Features::GeometryCollection, geom_.geometry_type)
|
88
|
+
assert_equal(2, geom_.num_geometries)
|
89
|
+
assert(geom_[1].eql?(@line3))
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
def test_creation_compound
|
94
|
+
geom1_ = @factory.collection([@point1, @line1])
|
95
|
+
geom2_ = @factory.collection([@point2, geom1_])
|
96
|
+
assert_not_nil(geom2_)
|
97
|
+
assert_kind_of(::RGeo::Geos::GeometryCollectionImpl, geom2_)
|
98
|
+
assert(::RGeo::Features::GeometryCollection === geom2_)
|
99
|
+
assert_equal(::RGeo::Features::GeometryCollection, geom2_.geometry_type)
|
100
|
+
assert_equal(2, geom2_.num_geometries)
|
101
|
+
assert(geom2_[1].eql?(geom1_))
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
def test_creation_compound_save_klass
|
106
|
+
geom1_ = @factory.collection([@point1, @line3])
|
107
|
+
geom2_ = @factory.collection([@point2, geom1_])
|
108
|
+
::GC.start
|
109
|
+
assert_not_nil(geom2_)
|
110
|
+
assert_kind_of(::RGeo::Geos::GeometryCollectionImpl, geom2_)
|
111
|
+
assert(::RGeo::Features::GeometryCollection === geom2_)
|
112
|
+
assert_equal(::RGeo::Features::GeometryCollection, geom2_.geometry_type)
|
113
|
+
assert_equal(2, geom2_.num_geometries)
|
114
|
+
assert(::RGeo::Features::Line === geom2_[1][1])
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
def test_fully_equal
|
119
|
+
geom1_ = @factory.collection([@point1, @line1])
|
120
|
+
geom2_ = @factory.collection([@point1, @line1])
|
121
|
+
assert(geom1_.eql?(geom2_))
|
122
|
+
assert(geom1_.equals?(geom2_))
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
def test_geometrically_equal
|
127
|
+
geom1_ = @factory.collection([@point2, @line2])
|
128
|
+
geom2_ = @factory.collection([@point2, @line1, @line2])
|
129
|
+
assert(!geom1_.eql?(geom2_))
|
130
|
+
assert(geom1_.equals?(geom2_))
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
def test_empty_equal
|
135
|
+
geom1_ = @factory.collection([])
|
136
|
+
geom2_ = @factory.collection([])
|
137
|
+
assert(geom1_.eql?(geom2_))
|
138
|
+
assert(geom1_.equals?(geom2_))
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
def test_not_equal
|
143
|
+
geom1_ = @factory.collection([@point1, @line1])
|
144
|
+
geom2_ = @factory.collection([@point2, @line1])
|
145
|
+
assert(!geom1_.eql?(geom2_))
|
146
|
+
assert(!geom1_.equals?(geom2_))
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
def test_wkt_creation_simple
|
151
|
+
parsed_geom_ = @factory.parse_wkt('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-4 2, -5 3))')
|
152
|
+
built_geom_ = @factory.collection([@point1, @line1])
|
153
|
+
assert_equal(built_geom_, parsed_geom_)
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
def test_wkt_creation_empty
|
158
|
+
parsed_geom_ = @factory.parse_wkt('GEOMETRYCOLLECTION EMPTY')
|
159
|
+
assert_equal(0, parsed_geom_.num_geometries)
|
160
|
+
assert_equal([], parsed_geom_.to_a)
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
def test_clone
|
165
|
+
geom1_ = @factory.collection([@point1, @line1])
|
166
|
+
geom2_ = geom1_.clone
|
167
|
+
assert_equal(geom1_, geom2_)
|
168
|
+
assert_equal(::RGeo::Features::GeometryCollection, geom2_.geometry_type)
|
169
|
+
assert_equal(2, geom2_.num_geometries)
|
170
|
+
assert_equal([@point1, @line1], geom2_.to_a)
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
def test_type_check
|
175
|
+
geom1_ = @factory.collection([@point1, @line1])
|
176
|
+
assert(::RGeo::Features::Geometry.check_type(geom1_))
|
177
|
+
assert(!::RGeo::Features::Point.check_type(geom1_))
|
178
|
+
assert(::RGeo::Features::GeometryCollection.check_type(geom1_))
|
179
|
+
assert(!::RGeo::Features::MultiPoint.check_type(geom1_))
|
180
|
+
geom2_ = @factory.collection([@point1, @point2])
|
181
|
+
assert(::RGeo::Features::Geometry.check_type(geom2_))
|
182
|
+
assert(!::RGeo::Features::Point.check_type(geom2_))
|
183
|
+
assert(::RGeo::Features::GeometryCollection.check_type(geom2_))
|
184
|
+
assert(!::RGeo::Features::MultiPoint.check_type(geom2_))
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
def test_as_text_wkt_round_trip
|
189
|
+
geom1_ = @factory.collection([@point1, @line1])
|
190
|
+
text_ = geom1_.as_text
|
191
|
+
geom2_ = @factory.parse_wkt(text_)
|
192
|
+
assert_equal(geom1_, geom2_)
|
193
|
+
end
|
194
|
+
|
195
|
+
|
196
|
+
def test_as_binary_wkb_round_trip
|
197
|
+
geom1_ = @factory.collection([@point1, @line1])
|
198
|
+
binary_ = geom1_.as_binary
|
199
|
+
geom2_ = @factory.parse_wkb(binary_)
|
200
|
+
assert_equal(geom1_, geom2_)
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
def test_dimension
|
205
|
+
geom1_ = @factory.collection([@point1, @line1])
|
206
|
+
assert_equal(1, geom1_.dimension)
|
207
|
+
geom2_ = @factory.collection([@point1, @point2])
|
208
|
+
assert_equal(0, geom2_.dimension)
|
209
|
+
geom3_ = @factory.collection([])
|
210
|
+
assert_equal(-1, geom3_.dimension)
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
def test_is_empty
|
215
|
+
geom1_ = @factory.collection([@point1, @line1])
|
216
|
+
assert(!geom1_.is_empty?)
|
217
|
+
geom2_ = @factory.collection([])
|
218
|
+
assert(geom2_.is_empty?)
|
219
|
+
end
|
220
|
+
|
221
|
+
|
222
|
+
end
|
223
|
+
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|