schleyfox-rgeo 0.2.5
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/History.rdoc +199 -0
- data/README.rdoc +172 -0
- data/Spatial_Programming_With_RGeo.rdoc +440 -0
- data/Version +1 -0
- data/ext/geos_c_impl/extconf.rb +84 -0
- data/ext/geos_c_impl/factory.c +468 -0
- data/ext/geos_c_impl/factory.h +224 -0
- data/ext/geos_c_impl/geometry.c +705 -0
- data/ext/geos_c_impl/geometry.h +55 -0
- data/ext/geos_c_impl/geometry_collection.c +482 -0
- data/ext/geos_c_impl/geometry_collection.h +69 -0
- data/ext/geos_c_impl/line_string.c +509 -0
- data/ext/geos_c_impl/line_string.h +64 -0
- data/ext/geos_c_impl/main.c +70 -0
- data/ext/geos_c_impl/point.c +193 -0
- data/ext/geos_c_impl/point.h +62 -0
- data/ext/geos_c_impl/polygon.c +265 -0
- data/ext/geos_c_impl/polygon.h +66 -0
- data/ext/geos_c_impl/preface.h +50 -0
- data/ext/proj4_c_impl/extconf.rb +88 -0
- data/ext/proj4_c_impl/main.c +271 -0
- data/lib/rgeo.rb +124 -0
- data/lib/rgeo/cartesian.rb +60 -0
- data/lib/rgeo/cartesian/analysis.rb +118 -0
- data/lib/rgeo/cartesian/bounding_box.rb +337 -0
- data/lib/rgeo/cartesian/calculations.rb +161 -0
- data/lib/rgeo/cartesian/factory.rb +209 -0
- data/lib/rgeo/cartesian/feature_classes.rb +173 -0
- data/lib/rgeo/cartesian/feature_methods.rb +106 -0
- data/lib/rgeo/cartesian/interface.rb +150 -0
- data/lib/rgeo/coord_sys.rb +79 -0
- data/lib/rgeo/coord_sys/cs/entities.rb +1524 -0
- data/lib/rgeo/coord_sys/cs/factories.rb +208 -0
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +308 -0
- data/lib/rgeo/coord_sys/proj4.rb +312 -0
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +194 -0
- data/lib/rgeo/coord_sys/srs_database/interface.rb +165 -0
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +188 -0
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +108 -0
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +108 -0
- data/lib/rgeo/error.rb +63 -0
- data/lib/rgeo/feature.rb +88 -0
- data/lib/rgeo/feature/curve.rb +156 -0
- data/lib/rgeo/feature/factory.rb +332 -0
- data/lib/rgeo/feature/factory_generator.rb +138 -0
- data/lib/rgeo/feature/geometry.rb +614 -0
- data/lib/rgeo/feature/geometry_collection.rb +129 -0
- data/lib/rgeo/feature/line.rb +66 -0
- data/lib/rgeo/feature/line_string.rb +102 -0
- data/lib/rgeo/feature/linear_ring.rb +66 -0
- data/lib/rgeo/feature/multi_curve.rb +113 -0
- data/lib/rgeo/feature/multi_line_string.rb +66 -0
- data/lib/rgeo/feature/multi_point.rb +73 -0
- data/lib/rgeo/feature/multi_polygon.rb +97 -0
- data/lib/rgeo/feature/multi_surface.rb +116 -0
- data/lib/rgeo/feature/point.rb +120 -0
- data/lib/rgeo/feature/polygon.rb +141 -0
- data/lib/rgeo/feature/surface.rb +122 -0
- data/lib/rgeo/feature/types.rb +305 -0
- data/lib/rgeo/geographic.rb +75 -0
- data/lib/rgeo/geographic/factory.rb +287 -0
- data/lib/rgeo/geographic/interface.rb +410 -0
- data/lib/rgeo/geographic/proj4_projector.rb +98 -0
- data/lib/rgeo/geographic/projected_feature_classes.rb +213 -0
- data/lib/rgeo/geographic/projected_feature_methods.rb +228 -0
- data/lib/rgeo/geographic/projected_window.rb +467 -0
- data/lib/rgeo/geographic/simple_mercator_projector.rb +157 -0
- data/lib/rgeo/geographic/spherical_feature_classes.rb +212 -0
- data/lib/rgeo/geographic/spherical_feature_methods.rb +97 -0
- data/lib/rgeo/geographic/spherical_math.rb +206 -0
- data/lib/rgeo/geos.rb +72 -0
- data/lib/rgeo/geos/factory.rb +301 -0
- data/lib/rgeo/geos/impl_additions.rb +76 -0
- data/lib/rgeo/geos/interface.rb +139 -0
- data/lib/rgeo/geos/zm_factory.rb +275 -0
- data/lib/rgeo/geos/zm_impl.rb +432 -0
- data/lib/rgeo/impl_helper.rb +53 -0
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +235 -0
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +85 -0
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +197 -0
- data/lib/rgeo/impl_helper/basic_point_methods.rb +138 -0
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +121 -0
- data/lib/rgeo/impl_helper/math.rb +50 -0
- data/lib/rgeo/version.rb +52 -0
- data/lib/rgeo/wkrep.rb +72 -0
- data/lib/rgeo/wkrep/wkb_generator.rb +267 -0
- data/lib/rgeo/wkrep/wkb_parser.rb +315 -0
- data/lib/rgeo/wkrep/wkt_generator.rb +275 -0
- data/lib/rgeo/wkrep/wkt_parser.rb +496 -0
- data/test/common/geometry_collection_tests.rb +238 -0
- data/test/common/line_string_tests.rb +324 -0
- data/test/common/multi_line_string_tests.rb +209 -0
- data/test/common/multi_point_tests.rb +201 -0
- data/test/common/multi_polygon_tests.rb +208 -0
- data/test/common/point_tests.rb +331 -0
- data/test/common/polygon_tests.rb +232 -0
- data/test/coord_sys/tc_active_record_table.rb +102 -0
- data/test/coord_sys/tc_ogc_cs.rb +356 -0
- data/test/coord_sys/tc_proj4.rb +138 -0
- data/test/coord_sys/tc_proj4_srs_data.rb +76 -0
- data/test/coord_sys/tc_sr_org.rb +70 -0
- data/test/coord_sys/tc_url_reader.rb +82 -0
- data/test/geos/tc_factory.rb +91 -0
- data/test/geos/tc_geometry_collection.rb +62 -0
- data/test/geos/tc_line_string.rb +62 -0
- data/test/geos/tc_misc.rb +72 -0
- data/test/geos/tc_multi_line_string.rb +62 -0
- data/test/geos/tc_multi_point.rb +62 -0
- data/test/geos/tc_multi_polygon.rb +63 -0
- data/test/geos/tc_point.rb +86 -0
- data/test/geos/tc_polygon.rb +86 -0
- data/test/geos/tc_zmfactory.rb +85 -0
- data/test/projected_geographic/tc_geometry_collection.rb +62 -0
- data/test/projected_geographic/tc_line_string.rb +62 -0
- data/test/projected_geographic/tc_multi_line_string.rb +62 -0
- data/test/projected_geographic/tc_multi_point.rb +62 -0
- data/test/projected_geographic/tc_multi_polygon.rb +63 -0
- data/test/projected_geographic/tc_point.rb +93 -0
- data/test/projected_geographic/tc_polygon.rb +62 -0
- data/test/simple_cartesian/tc_calculations.rb +145 -0
- data/test/simple_cartesian/tc_geometry_collection.rb +69 -0
- data/test/simple_cartesian/tc_line_string.rb +70 -0
- data/test/simple_cartesian/tc_multi_line_string.rb +67 -0
- data/test/simple_cartesian/tc_multi_point.rb +67 -0
- data/test/simple_cartesian/tc_multi_polygon.rb +70 -0
- data/test/simple_cartesian/tc_point.rb +91 -0
- data/test/simple_cartesian/tc_polygon.rb +67 -0
- data/test/simple_mercator/tc_geometry_collection.rb +62 -0
- data/test/simple_mercator/tc_line_string.rb +62 -0
- data/test/simple_mercator/tc_multi_line_string.rb +62 -0
- data/test/simple_mercator/tc_multi_point.rb +62 -0
- data/test/simple_mercator/tc_multi_polygon.rb +63 -0
- data/test/simple_mercator/tc_point.rb +93 -0
- data/test/simple_mercator/tc_polygon.rb +62 -0
- data/test/simple_mercator/tc_window.rb +219 -0
- data/test/spherical_geographic/tc_calculations.rb +203 -0
- data/test/spherical_geographic/tc_geometry_collection.rb +70 -0
- data/test/spherical_geographic/tc_line_string.rb +70 -0
- data/test/spherical_geographic/tc_multi_line_string.rb +67 -0
- data/test/spherical_geographic/tc_multi_point.rb +67 -0
- data/test/spherical_geographic/tc_multi_polygon.rb +70 -0
- data/test/spherical_geographic/tc_point.rb +100 -0
- data/test/spherical_geographic/tc_polygon.rb +67 -0
- data/test/tc_cartesian_analysis.rb +107 -0
- data/test/tc_oneoff.rb +63 -0
- data/test/wkrep/tc_wkb_generator.rb +249 -0
- data/test/wkrep/tc_wkb_parser.rb +353 -0
- data/test/wkrep/tc_wkt_generator.rb +362 -0
- data/test/wkrep/tc_wkt_parser.rb +480 -0
- metadata +267 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple spherical multi polygon 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
|
+
require ::File.expand_path('../common/multi_polygon_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module SphericalGeographic # :nodoc:
|
46
|
+
|
47
|
+
class TestMultiPolygon < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def create_factories
|
51
|
+
@factory = ::RGeo::Geographic.spherical_factory
|
52
|
+
@lenient_factory = ::RGeo::Geographic.spherical_factory(:lenient_multi_polygon_assertions => true)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
include ::RGeo::Tests::Common::MultiPolygonTests
|
57
|
+
|
58
|
+
|
59
|
+
undef_method :test_creation_wrong_type
|
60
|
+
undef_method :test_creation_overlapping
|
61
|
+
undef_method :test_creation_connected
|
62
|
+
undef_method :test_equal
|
63
|
+
undef_method :test_not_equal
|
64
|
+
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple spherical point 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
|
+
require ::File.expand_path('../common/point_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module SphericalGeographic # :nodoc:
|
46
|
+
|
47
|
+
class TestPoint < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def setup
|
51
|
+
@factory = ::RGeo::Geographic.spherical_factory
|
52
|
+
@zfactory = ::RGeo::Geographic.spherical_factory(:has_z_coordinate => true)
|
53
|
+
@mfactory = ::RGeo::Geographic.spherical_factory(:has_m_coordinate => true)
|
54
|
+
@zmfactory = ::RGeo::Geographic.spherical_factory(:has_z_coordinate => true, :has_m_coordinate => true)
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
include ::RGeo::Tests::Common::PointTests
|
59
|
+
|
60
|
+
|
61
|
+
def test_latlon
|
62
|
+
point_ = @factory.point(21, -22)
|
63
|
+
assert_equal(21, point_.longitude)
|
64
|
+
assert_equal(-22, point_.latitude)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def test_srid
|
69
|
+
point_ = @factory.point(11, 12)
|
70
|
+
assert_equal(4055, point_.srid)
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def test_distance
|
75
|
+
point1_ = @factory.point(0, 10)
|
76
|
+
point2_ = @factory.point(0, 10)
|
77
|
+
point3_ = @factory.point(0, 40)
|
78
|
+
assert_in_delta(0, point1_.distance(point2_), 0.0001)
|
79
|
+
assert_in_delta(::Math::PI / 6.0 * ::RGeo::Geographic::SphericalMath::RADIUS, point1_.distance(point3_), 0.0001)
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
undef_method :test_disjoint
|
84
|
+
undef_method :test_intersects
|
85
|
+
undef_method :test_touches
|
86
|
+
undef_method :test_crosses
|
87
|
+
undef_method :test_within
|
88
|
+
undef_method :test_contains
|
89
|
+
undef_method :test_overlaps
|
90
|
+
undef_method :test_intersection
|
91
|
+
undef_method :test_union
|
92
|
+
undef_method :test_difference
|
93
|
+
undef_method :test_sym_difference
|
94
|
+
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple spherical polygon 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
|
+
require ::File.expand_path('../common/polygon_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module SphericalGeographic # :nodoc:
|
46
|
+
|
47
|
+
class TestPolygon < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def setup
|
51
|
+
@factory = ::RGeo::Geographic.spherical_factory
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
include ::RGeo::Tests::Common::PolygonTests
|
56
|
+
|
57
|
+
|
58
|
+
undef_method :test_fully_equal
|
59
|
+
undef_method :test_geometrically_equal_but_ordered_different
|
60
|
+
undef_method :test_geometrically_equal_but_different_directions
|
61
|
+
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for basic GeoJSON usage
|
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
|
+
|
44
|
+
class TestCartesianAnalysis < ::Test::Unit::TestCase # :nodoc:
|
45
|
+
|
46
|
+
|
47
|
+
def setup
|
48
|
+
@factory = ::RGeo::Cartesian.simple_factory
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def test_ring_direction_clockwise_triangle
|
53
|
+
p1_ = @factory.point(1, 1)
|
54
|
+
p2_ = @factory.point(2, 4)
|
55
|
+
p3_ = @factory.point(5, 2)
|
56
|
+
ring_ = @factory.line_string([p1_, p2_, p3_, p1_])
|
57
|
+
assert_equal(-1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def test_ring_direction_counterclockwise_triangle
|
62
|
+
p1_ = @factory.point(1, 1)
|
63
|
+
p2_ = @factory.point(2, 4)
|
64
|
+
p3_ = @factory.point(5, 2)
|
65
|
+
ring_ = @factory.line_string([p1_, p3_, p2_, p1_])
|
66
|
+
assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def test_ring_direction_clockwise_puckered_quad
|
71
|
+
p1_ = @factory.point(1, 1)
|
72
|
+
p2_ = @factory.point(2, 6)
|
73
|
+
p3_ = @factory.point(3, 3)
|
74
|
+
p4_ = @factory.point(5, 2)
|
75
|
+
ring_ = @factory.line_string([p1_, p2_, p3_, p4_, p1_])
|
76
|
+
assert_equal(-1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
def test_ring_direction_counterclockwise_puckered_quad
|
81
|
+
p1_ = @factory.point(1, 1)
|
82
|
+
p2_ = @factory.point(2, 6)
|
83
|
+
p3_ = @factory.point(3, 3)
|
84
|
+
p4_ = @factory.point(5, 2)
|
85
|
+
ring_ = @factory.line_string([p1_, p4_, p3_, p2_, p1_])
|
86
|
+
assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
def test_ring_direction_counterclockwise_near_circle
|
91
|
+
p1_ = @factory.point(0, -3)
|
92
|
+
p2_ = @factory.point(2, -2)
|
93
|
+
p3_ = @factory.point(3, 0)
|
94
|
+
p4_ = @factory.point(2, 2)
|
95
|
+
p5_ = @factory.point(0, 3)
|
96
|
+
p6_ = @factory.point(-2, 2)
|
97
|
+
p7_ = @factory.point(-3, 0)
|
98
|
+
p8_ = @factory.point(-2, -2)
|
99
|
+
ring_ = @factory.line_string([p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_, p1_])
|
100
|
+
assert_equal(1, ::RGeo::Cartesian::Analysis.ring_direction(ring_))
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
data/test/tc_oneoff.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# A container file for one-off tests
|
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
|
+
|
44
|
+
class TestOneOff < ::Test::Unit::TestCase # :nodoc:
|
45
|
+
|
46
|
+
|
47
|
+
def setup
|
48
|
+
# @mercator_factory = ::RGeo::Geographic.simple_mercator_factory
|
49
|
+
# @spherical_factory = ::RGeo::Geographic.spherical_factory(:has_z_coordinate => true)
|
50
|
+
# @projected_factory = ::RGeo::Geographic.projected_factory(:projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857, :has_z_coordinate => true)
|
51
|
+
# @geos_factory = ::RGeo::Geos.factory(:srid => 4326, :has_z_coordinate => true)
|
52
|
+
# @cartesian_factory = ::RGeo::Cartesian.simple_factory(:srid => 1, :has_z_coordinate => true)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def test_dummy
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,249 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for WKT generator
|
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 WKRep # :nodoc:
|
44
|
+
|
45
|
+
class TestWKBGenerator < ::Test::Unit::TestCase # :nodoc:
|
46
|
+
|
47
|
+
|
48
|
+
def setup
|
49
|
+
@factory = ::RGeo::Cartesian.preferred_factory(:srid => 1000)
|
50
|
+
@factoryz = ::RGeo::Cartesian.preferred_factory(:srid => 1000, :has_z_coordinate => true)
|
51
|
+
@factorym = ::RGeo::Cartesian.preferred_factory(:srid => 1000, :has_m_coordinate => true)
|
52
|
+
@factoryzm = ::RGeo::Cartesian.preferred_factory(:srid => 1000, :has_z_coordinate => true, :has_m_coordinate => true)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def test_point_basic_xdr
|
57
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
58
|
+
obj_ = @factory.point(1, 2)
|
59
|
+
assert_equal('00000000013ff00000000000004000000000000000', generator_.generate(obj_))
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def test_point_basic_ndr
|
64
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :little_endian => true)
|
65
|
+
obj_ = @factory.point(1, 2)
|
66
|
+
assert_equal('0101000000000000000000f03f0000000000000040', generator_.generate(obj_))
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def test_point_2d_ewkb
|
71
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
|
72
|
+
obj_ = @factory.point(1, 2)
|
73
|
+
assert_equal('00000000013ff00000000000004000000000000000', generator_.generate(obj_))
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
def test_point_2d_wkb12
|
78
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :wkb12)
|
79
|
+
obj_ = @factory.point(1, 2)
|
80
|
+
assert_equal('00000000013ff00000000000004000000000000000', generator_.generate(obj_))
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def test_point_2d_ewkb_with_srid
|
85
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb, :emit_ewkb_srid => true)
|
86
|
+
obj_ = @factory.point(1, 2)
|
87
|
+
assert_equal('0020000001000003e83ff00000000000004000000000000000', generator_.generate(obj_))
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def test_point_with_ewkb_z
|
92
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
|
93
|
+
obj_ = @factoryz.point(1, 2, 3)
|
94
|
+
assert_equal('00800000013ff000000000000040000000000000004008000000000000', generator_.generate(obj_))
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def test_point_with_ewkb_m
|
99
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
|
100
|
+
obj_ = @factorym.point(1, 2, 3)
|
101
|
+
assert_equal('00400000013ff000000000000040000000000000004008000000000000', generator_.generate(obj_))
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
def test_point_with_ewkb_zm
|
106
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
|
107
|
+
obj_ = @factoryzm.point(1, 2, 3, 4)
|
108
|
+
assert_equal('00c00000013ff0000000000000400000000000000040080000000000004010000000000000', generator_.generate(obj_))
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
def test_point_with_wkb12_z
|
113
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :wkb12)
|
114
|
+
obj_ = @factoryz.point(1, 2, 3)
|
115
|
+
assert_equal('00000003e93ff000000000000040000000000000004008000000000000', generator_.generate(obj_))
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
def test_point_with_wkb12_m
|
120
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :wkb12)
|
121
|
+
obj_ = @factorym.point(1, 2, 3)
|
122
|
+
assert_equal('00000007d13ff000000000000040000000000000004008000000000000', generator_.generate(obj_))
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
def test_point_with_wkb12_zm
|
127
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :wkb12)
|
128
|
+
obj_ = @factoryzm.point(1, 2, 3, 4)
|
129
|
+
assert_equal('0000000bb93ff0000000000000400000000000000040080000000000004010000000000000', generator_.generate(obj_))
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
def test_linestring_basic
|
134
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
135
|
+
obj_ = @factory.line_string([@factory.point(1, 2), @factory.point(3, 4), @factory.point(5, 6)])
|
136
|
+
assert_equal('0000000002000000033ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000', generator_.generate(obj_))
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
def test_linestring_with_ewkb_z
|
141
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
|
142
|
+
obj_ = @factoryz.line_string([@factoryz.point(1, 2, 3), @factoryz.point(4, 5, 6)])
|
143
|
+
assert_equal('0080000002000000023ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000', generator_.generate(obj_))
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
def test_linestring_with_ewkb_z_and_srid
|
148
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb, :emit_ewkb_srid => true)
|
149
|
+
obj_ = @factoryz.line_string([@factoryz.point(1, 2, 3), @factoryz.point(4, 5, 6)])
|
150
|
+
assert_equal('00a0000002000003e8000000023ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000', generator_.generate(obj_))
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
def test_linestring_with_wkb12_m
|
155
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :wkb12)
|
156
|
+
obj_ = @factorym.line_string([@factorym.point(1, 2, 3), @factorym.point(4, 5, 6)])
|
157
|
+
assert_equal('00000007d2000000023ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000', generator_.generate(obj_))
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
def test_linestring_empty
|
162
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
163
|
+
obj_ = @factory.line_string([])
|
164
|
+
assert_equal('000000000200000000', generator_.generate(obj_))
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
def test_polygon_basic
|
169
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
170
|
+
obj_ = @factory.polygon(@factory.linear_ring([@factory.point(1, 2), @factory.point(3, 4), @factory.point(6, 5), @factory.point(1, 2)]))
|
171
|
+
assert_equal('000000000300000001000000043ff0000000000000400000000000000040080000000000004010000000000000401800000000000040140000000000003ff00000000000004000000000000000', generator_.generate(obj_))
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
def test_polygon_empty
|
176
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
177
|
+
obj_ = @factory.polygon(@factory.linear_ring([]))
|
178
|
+
assert_equal('000000000300000000', generator_.generate(obj_))
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
def test_multipoint_basic
|
183
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
184
|
+
obj_ = @factory.multi_point([@factory.point(1, 2), @factory.point(3, 4)])
|
185
|
+
assert_equal('00000000040000000200000000013ff00000000000004000000000000000000000000140080000000000004010000000000000', generator_.generate(obj_))
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
def test_multipoint_with_ewkb_z
|
190
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true, :type_format => :ewkb)
|
191
|
+
obj_ = @factoryz.multi_point([@factoryz.point(1, 2, 5), @factoryz.point(3, 4, 6)])
|
192
|
+
assert_equal('00800000040000000200800000013ff0000000000000400000000000000040140000000000000080000001400800000000000040100000000000004018000000000000', generator_.generate(obj_))
|
193
|
+
end
|
194
|
+
|
195
|
+
|
196
|
+
def test_multipoint_empty
|
197
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
198
|
+
obj_ = @factory.multi_point([])
|
199
|
+
assert_equal('000000000400000000', generator_.generate(obj_))
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
def test_multilinestring_basic
|
204
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
205
|
+
obj_ = @factory.multi_line_string([@factory.line_string([@factory.point(1, 2), @factory.point(3, 4), @factory.point(5, 6)]), @factory.line_string([@factory.point(-1, -2), @factory.point(-3, -4)])])
|
206
|
+
assert_equal('0000000005000000020000000002000000033ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000000000000200000002bff0000000000000c000000000000000c008000000000000c010000000000000', generator_.generate(obj_))
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
def test_multilinestring_empty
|
211
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
212
|
+
obj_ = @factory.multi_line_string([])
|
213
|
+
assert_equal('000000000500000000', generator_.generate(obj_))
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
def test_multipolygon_basic
|
218
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
219
|
+
obj_ = @factory.multi_polygon([@factory.polygon(@factory.linear_ring([@factory.point(1, 2), @factory.point(3, 4), @factory.point(6, 5), @factory.point(1, 2)])), @factory.polygon(@factory.linear_ring([]))])
|
220
|
+
assert_equal('000000000600000002000000000300000001000000043ff0000000000000400000000000000040080000000000004010000000000000401800000000000040140000000000003ff00000000000004000000000000000000000000300000000', generator_.generate(obj_))
|
221
|
+
end
|
222
|
+
|
223
|
+
|
224
|
+
def test_multipolygon_empty
|
225
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
226
|
+
obj_ = @factory.multi_polygon([])
|
227
|
+
assert_equal('000000000600000000', generator_.generate(obj_))
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
def test_collection_basic
|
232
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
233
|
+
obj_ = @factory.collection([@factory.line_string([@factory.point(1, 2), @factory.point(3, 4), @factory.point(5, 6)]), @factory.point(-1, -2)])
|
234
|
+
assert_equal('0000000007000000020000000002000000033ff0000000000000400000000000000040080000000000004010000000000000401400000000000040180000000000000000000001bff0000000000000c000000000000000', generator_.generate(obj_))
|
235
|
+
end
|
236
|
+
|
237
|
+
|
238
|
+
def test_collection_empty
|
239
|
+
generator_ = ::RGeo::WKRep::WKBGenerator.new(:hex_format => true)
|
240
|
+
obj_ = @factory.collection([])
|
241
|
+
assert_equal('000000000700000000', generator_.generate(obj_))
|
242
|
+
end
|
243
|
+
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|