rgeo 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +29 -0
- data/ext/geos_c_impl/Makefile_2.2.3 +260 -0
- data/ext/geos_c_impl/coordinates.c +65 -0
- data/ext/geos_c_impl/coordinates.h +2 -0
- data/ext/geos_c_impl/extconf.rb +19 -43
- data/ext/geos_c_impl/geometry.c +24 -0
- data/ext/geos_c_impl/geometry_collection.c +99 -1
- data/ext/geos_c_impl/geos_c_impl_2.2.3.bundle +0 -0
- data/ext/geos_c_impl/line_string.c +38 -0
- data/ext/geos_c_impl/mkmf.log +123 -0
- data/ext/geos_c_impl/point.c +27 -0
- data/ext/geos_c_impl/polygon.c +26 -0
- data/ext/proj4_c_impl/Makefile_2.2.3 +260 -0
- data/ext/proj4_c_impl/extconf.rb +32 -32
- data/ext/proj4_c_impl/mkmf.log +47 -0
- data/ext/proj4_c_impl/proj4_c_impl_2.2.3.bundle +0 -0
- data/lib/rgeo.rb +10 -11
- data/lib/rgeo/cartesian.rb +7 -12
- data/lib/rgeo/cartesian/analysis.rb +13 -26
- data/lib/rgeo/cartesian/bounding_box.rb +45 -114
- data/lib/rgeo/cartesian/calculations.rb +3 -21
- data/lib/rgeo/cartesian/factory.rb +101 -122
- data/lib/rgeo/cartesian/feature_classes.rb +9 -59
- data/lib/rgeo/cartesian/feature_methods.rb +15 -45
- data/lib/rgeo/cartesian/interface.rb +6 -17
- data/lib/rgeo/coord_sys.rb +9 -15
- data/lib/rgeo/coord_sys/cs/entities.rb +84 -330
- data/lib/rgeo/coord_sys/cs/factories.rb +2 -32
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +52 -80
- data/lib/rgeo/coord_sys/proj4.rb +28 -67
- data/lib/rgeo/coord_sys/proj4_c_impl.bundle +0 -0
- data/lib/rgeo/coord_sys/srs_database/interface.rb +4 -24
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +20 -38
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +6 -22
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +6 -21
- data/lib/rgeo/error.rb +0 -6
- data/lib/rgeo/feature.rb +18 -23
- data/lib/rgeo/feature/curve.rb +0 -14
- data/lib/rgeo/feature/factory.rb +13 -38
- data/lib/rgeo/feature/factory_generator.rb +4 -16
- data/lib/rgeo/feature/geometry.rb +18 -60
- data/lib/rgeo/feature/geometry_collection.rb +3 -17
- data/lib/rgeo/feature/line.rb +0 -10
- data/lib/rgeo/feature/line_string.rb +1 -13
- data/lib/rgeo/feature/linear_ring.rb +0 -9
- data/lib/rgeo/feature/mixins.rb +11 -36
- data/lib/rgeo/feature/multi_curve.rb +0 -11
- data/lib/rgeo/feature/multi_line_string.rb +0 -9
- data/lib/rgeo/feature/multi_point.rb +0 -9
- data/lib/rgeo/feature/multi_polygon.rb +0 -9
- data/lib/rgeo/feature/multi_surface.rb +0 -12
- data/lib/rgeo/feature/point.rb +0 -13
- data/lib/rgeo/feature/polygon.rb +1 -14
- data/lib/rgeo/feature/surface.rb +0 -12
- data/lib/rgeo/feature/types.rb +19 -61
- data/lib/rgeo/geographic.rb +10 -15
- data/lib/rgeo/geographic/factory.rb +126 -147
- data/lib/rgeo/geographic/interface.rb +67 -81
- data/lib/rgeo/geographic/proj4_projector.rb +13 -37
- data/lib/rgeo/geographic/projected_feature_classes.rb +7 -66
- data/lib/rgeo/geographic/projected_feature_methods.rb +15 -80
- data/lib/rgeo/geographic/projected_window.rb +15 -67
- data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -56
- data/lib/rgeo/geographic/spherical_feature_classes.rb +9 -68
- data/lib/rgeo/geographic/spherical_feature_methods.rb +18 -51
- data/lib/rgeo/geographic/spherical_math.rb +26 -51
- data/lib/rgeo/geos.rb +23 -20
- data/lib/rgeo/geos/capi_factory.rb +125 -131
- data/lib/rgeo/geos/capi_feature_classes.rb +21 -88
- data/lib/rgeo/geos/ffi_factory.rb +90 -143
- data/lib/rgeo/geos/ffi_feature_classes.rb +8 -63
- data/lib/rgeo/geos/ffi_feature_methods.rb +46 -162
- data/lib/rgeo/geos/geos_c_impl.bundle +0 -0
- data/lib/rgeo/geos/interface.rb +4 -23
- data/lib/rgeo/geos/utils.rb +4 -19
- data/lib/rgeo/geos/zm_factory.rb +82 -131
- data/lib/rgeo/geos/zm_feature_classes.rb +8 -63
- data/lib/rgeo/geos/zm_feature_methods.rb +34 -107
- data/lib/rgeo/impl_helper.rb +8 -13
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +27 -71
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +10 -28
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +21 -57
- data/lib/rgeo/impl_helper/basic_point_methods.rb +12 -30
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +9 -28
- data/lib/rgeo/impl_helper/math.rb +4 -10
- data/lib/rgeo/impl_helper/utils.rb +2 -10
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep.rb +4 -9
- data/lib/rgeo/wkrep/wkb_generator.rb +22 -46
- data/lib/rgeo/wkrep/wkb_parser.rb +25 -52
- data/lib/rgeo/wkrep/wkt_generator.rb +39 -69
- data/lib/rgeo/wkrep/wkt_parser.rb +52 -89
- data/lib/rgeo/yaml.rb +1 -7
- data/test/common/factory_tests.rb +4 -19
- data/test/common/geometry_collection_tests.rb +6 -39
- data/test/common/line_string_tests.rb +10 -39
- data/test/common/multi_line_string_tests.rb +10 -30
- data/test/common/multi_point_tests.rb +15 -34
- data/test/common/multi_polygon_tests.rb +26 -28
- data/test/common/point_tests.rb +37 -59
- data/test/common/polygon_tests.rb +16 -25
- data/test/coord_sys/tc_ogc_cs.rb +151 -186
- data/test/coord_sys/tc_proj4.rb +35 -60
- data/test/coord_sys/tc_proj4_srs_data.rb +15 -24
- data/test/coord_sys/tc_sr_org.rb +11 -19
- data/test/coord_sys/tc_url_reader.rb +13 -23
- data/test/geos_capi/tc_factory.rb +7 -16
- data/test/geos_capi/tc_geometry_collection.rb +6 -14
- data/test/geos_capi/tc_line_string.rb +7 -15
- data/test/geos_capi/tc_misc.rb +26 -41
- data/test/geos_capi/tc_multi_line_string.rb +6 -14
- data/test/geos_capi/tc_multi_point.rb +7 -15
- data/test/geos_capi/tc_multi_polygon.rb +8 -18
- data/test/geos_capi/tc_parsing_unparsing.rb +11 -21
- data/test/geos_capi/tc_point.rb +12 -26
- data/test/geos_capi/tc_polygon.rb +52 -17
- data/test/geos_capi/tc_zmfactory.rb +7 -18
- data/test/geos_ffi/tc_factory.rb +7 -16
- data/test/geos_ffi/tc_geometry_collection.rb +7 -15
- data/test/geos_ffi/tc_line_string.rb +7 -15
- data/test/geos_ffi/tc_misc.rb +8 -18
- data/test/geos_ffi/tc_multi_line_string.rb +7 -15
- data/test/geos_ffi/tc_multi_point.rb +8 -16
- data/test/geos_ffi/tc_multi_polygon.rb +9 -18
- data/test/geos_ffi/tc_parsing_unparsing.rb +14 -24
- data/test/geos_ffi/tc_point.rb +13 -28
- data/test/geos_ffi/tc_polygon.rb +7 -17
- data/test/geos_ffi/tc_zmfactory.rb +8 -19
- data/test/projected_geographic/tc_factory.rb +7 -15
- data/test/projected_geographic/tc_geometry_collection.rb +7 -15
- data/test/projected_geographic/tc_line_string.rb +7 -15
- data/test/projected_geographic/tc_multi_line_string.rb +7 -16
- data/test/projected_geographic/tc_multi_point.rb +8 -17
- data/test/projected_geographic/tc_multi_polygon.rb +8 -16
- data/test/projected_geographic/tc_point.rb +11 -23
- data/test/projected_geographic/tc_polygon.rb +7 -15
- data/test/simple_cartesian/tc_calculations.rb +6 -22
- data/test/simple_cartesian/tc_factory.rb +7 -16
- data/test/simple_cartesian/tc_geometry_collection.rb +6 -15
- data/test/simple_cartesian/tc_line_string.rb +6 -15
- data/test/simple_cartesian/tc_multi_line_string.rb +6 -15
- data/test/simple_cartesian/tc_multi_point.rb +7 -16
- data/test/simple_cartesian/tc_multi_polygon.rb +7 -16
- data/test/simple_cartesian/tc_point.rb +10 -21
- data/test/simple_cartesian/tc_polygon.rb +6 -15
- data/test/simple_mercator/tc_factory.rb +6 -14
- data/test/simple_mercator/tc_geometry_collection.rb +6 -14
- data/test/simple_mercator/tc_line_string.rb +6 -14
- data/test/simple_mercator/tc_multi_line_string.rb +6 -15
- data/test/simple_mercator/tc_multi_point.rb +7 -16
- data/test/simple_mercator/tc_multi_polygon.rb +7 -15
- data/test/simple_mercator/tc_point.rb +11 -24
- data/test/simple_mercator/tc_polygon.rb +6 -14
- data/test/simple_mercator/tc_window.rb +10 -34
- data/test/spherical_geographic/tc_calculations.rb +5 -32
- data/test/spherical_geographic/tc_factory.rb +6 -15
- data/test/spherical_geographic/tc_geometry_collection.rb +6 -15
- data/test/spherical_geographic/tc_line_string.rb +6 -15
- data/test/spherical_geographic/tc_multi_line_string.rb +6 -15
- data/test/spherical_geographic/tc_multi_point.rb +7 -16
- data/test/spherical_geographic/tc_multi_polygon.rb +7 -16
- data/test/spherical_geographic/tc_point.rb +10 -22
- data/test/spherical_geographic/tc_polygon.rb +6 -15
- data/test/tc_cartesian_analysis.rb +4 -16
- data/test/tc_cartesian_bbox.rb +7 -21
- data/test/tc_mixins.rb +8 -25
- data/test/tc_oneoff.rb +5 -13
- data/test/tc_types.rb +7 -16
- data/test/wkrep/tc_wkb_generator.rb +63 -97
- data/test/wkrep/tc_wkb_parser.rb +63 -100
- data/test/wkrep/tc_wkt_generator.rb +54 -92
- data/test/wkrep/tc_wkt_parser.rb +84 -133
- metadata +39 -9
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +0 -166
- data/test/coord_sys/tc_active_record_table.rb +0 -79
@@ -4,29 +4,21 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
10
|
-
require ::File.expand_path('../common/line_string_tests.rb', ::File.dirname(__FILE__))
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
11
9
|
|
10
|
+
require ::File.expand_path("../common/line_string_tests.rb", ::File.dirname(__FILE__))
|
12
11
|
|
13
12
|
module RGeo
|
14
|
-
module Tests
|
15
|
-
module GeosCAPI
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
module Tests # :nodoc:
|
14
|
+
module GeosCAPI # :nodoc:
|
15
|
+
class TestLineString < ::Test::Unit::TestCase # :nodoc:
|
16
|
+
include ::RGeo::Tests::Common::LineStringTests
|
19
17
|
|
20
18
|
def setup
|
21
19
|
@factory = ::RGeo::Geos.factory
|
22
20
|
end
|
23
|
-
|
24
|
-
|
25
|
-
include ::RGeo::Tests::Common::LineStringTests
|
26
|
-
|
27
|
-
|
28
21
|
end
|
29
|
-
|
30
22
|
end
|
31
23
|
end
|
32
24
|
end if ::RGeo::Geos.capi_supported?
|
data/test/geos_capi/tc_misc.rb
CHANGED
@@ -4,65 +4,57 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
10
9
|
|
11
10
|
module RGeo
|
12
|
-
module Tests
|
13
|
-
module GeosCAPI
|
14
|
-
|
15
|
-
class TestMisc < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
|
17
|
-
|
11
|
+
module Tests # :nodoc:
|
12
|
+
module GeosCAPI # :nodoc:
|
13
|
+
class TestMisc < ::Test::Unit::TestCase # :nodoc:
|
18
14
|
def setup
|
19
|
-
@factory = ::RGeo::Geos.factory(:
|
15
|
+
@factory = ::RGeo::Geos.factory(srid: 4326)
|
20
16
|
end
|
21
17
|
|
22
|
-
|
23
18
|
def test_marshal_dump_with_geos
|
24
19
|
@factory = ::RGeo::Geos.factory(
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
20
|
+
srid: 4326,
|
21
|
+
wkt_generator: :geos,
|
22
|
+
wkb_generator: :geos,
|
23
|
+
wkt_parser: :geos,
|
24
|
+
wkb_parser: :geos
|
30
25
|
)
|
31
26
|
|
32
27
|
dump = nil
|
33
28
|
assert_nothing_raised { dump = @factory.marshal_dump }
|
34
|
-
assert_equal({}, dump[
|
35
|
-
assert_equal({}, dump[
|
36
|
-
assert_equal({}, dump[
|
37
|
-
assert_equal({}, dump[
|
29
|
+
assert_equal({}, dump["wktg"])
|
30
|
+
assert_equal({}, dump["wkbg"])
|
31
|
+
assert_equal({}, dump["wktp"])
|
32
|
+
assert_equal({}, dump["wkbp"])
|
38
33
|
end
|
39
34
|
|
40
|
-
|
41
35
|
def test_encode_with_geos
|
42
36
|
@factory = ::RGeo::Geos.factory(
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
37
|
+
srid: 4326,
|
38
|
+
wkt_generator: :geos,
|
39
|
+
wkb_generator: :geos,
|
40
|
+
wkt_parser: :geos,
|
41
|
+
wkb_parser: :geos
|
48
42
|
)
|
49
|
-
coder = Psych::Coder.new(
|
43
|
+
coder = Psych::Coder.new("test")
|
50
44
|
|
51
45
|
assert_nothing_raised { @factory.encode_with(coder) }
|
52
|
-
assert_equal({}, coder[
|
53
|
-
assert_equal({}, coder[
|
54
|
-
assert_equal({}, coder[
|
55
|
-
assert_equal({}, coder[
|
46
|
+
assert_equal({}, coder["wkt_generator"])
|
47
|
+
assert_equal({}, coder["wkb_generator"])
|
48
|
+
assert_equal({}, coder["wkt_parser"])
|
49
|
+
assert_equal({}, coder["wkb_parser"])
|
56
50
|
end
|
57
51
|
|
58
|
-
|
59
52
|
def test_uninitialized
|
60
53
|
geom_ = ::RGeo::Geos::CAPIGeometryImpl.new
|
61
54
|
assert_equal(false, geom_.initialized?)
|
62
55
|
assert_nil(geom_.geometry_type)
|
63
56
|
end
|
64
57
|
|
65
|
-
|
66
58
|
def test_empty_geometries_equal
|
67
59
|
geom1_ = @factory.collection([])
|
68
60
|
geom2_ = @factory.line_string([])
|
@@ -70,7 +62,6 @@ module RGeo
|
|
70
62
|
assert(geom1_.equals?(geom2_))
|
71
63
|
end
|
72
64
|
|
73
|
-
|
74
65
|
def test_prepare
|
75
66
|
p1_ = @factory.point(1, 2)
|
76
67
|
p2_ = @factory.point(3, 4)
|
@@ -81,7 +72,6 @@ module RGeo
|
|
81
72
|
assert_equal(true, polygon_.prepared?)
|
82
73
|
end
|
83
74
|
|
84
|
-
|
85
75
|
def test_auto_prepare
|
86
76
|
p1_ = @factory.point(1, 2)
|
87
77
|
p2_ = @factory.point(3, 4)
|
@@ -93,7 +83,7 @@ module RGeo
|
|
93
83
|
polygon_.intersects?(p2_)
|
94
84
|
assert_equal(true, polygon_.prepared?)
|
95
85
|
|
96
|
-
factory_no_auto_prepare_ = ::RGeo::Geos.factory(:
|
86
|
+
factory_no_auto_prepare_ = ::RGeo::Geos.factory(srid: 4326, auto_prepare: :disabled)
|
97
87
|
polygon2_ = factory_no_auto_prepare_.polygon(
|
98
88
|
factory_no_auto_prepare_.linear_ring([p1_, p2_, p3_, p1_]))
|
99
89
|
assert_equal(false, polygon2_.prepared?)
|
@@ -103,7 +93,6 @@ module RGeo
|
|
103
93
|
assert_equal(false, polygon2_.prepared?)
|
104
94
|
end
|
105
95
|
|
106
|
-
|
107
96
|
def test_gh_21
|
108
97
|
# Test for GH-21 (seg fault in rgeo_convert_to_geos_geometry)
|
109
98
|
# This seemed to fail under Ruby 1.8.7 only.
|
@@ -114,14 +103,10 @@ module RGeo
|
|
114
103
|
loc2_.intersection(loc_)
|
115
104
|
end
|
116
105
|
|
117
|
-
|
118
106
|
def test_geos_version
|
119
107
|
assert_match(/^\d+\.\d+(\.\d+)?$/, ::RGeo::Geos.version)
|
120
108
|
end
|
121
|
-
|
122
|
-
|
123
109
|
end
|
124
|
-
|
125
110
|
end
|
126
111
|
end
|
127
112
|
end if ::RGeo::Geos.capi_supported?
|
@@ -4,29 +4,21 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
10
|
-
require ::File.expand_path('../common/multi_line_string_tests.rb', ::File.dirname(__FILE__))
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
11
9
|
|
10
|
+
require ::File.expand_path("../common/multi_line_string_tests.rb", ::File.dirname(__FILE__))
|
12
11
|
|
13
12
|
module RGeo
|
14
|
-
module Tests
|
15
|
-
module GeosCAPI
|
16
|
-
|
17
|
-
class TestMultiLineString < ::Test::Unit::TestCase # :nodoc:
|
18
|
-
|
19
|
-
|
13
|
+
module Tests # :nodoc:
|
14
|
+
module GeosCAPI # :nodoc:
|
15
|
+
class TestMultiLineString < ::Test::Unit::TestCase # :nodoc:
|
20
16
|
def create_factory
|
21
17
|
::RGeo::Geos.factory
|
22
18
|
end
|
23
19
|
|
24
|
-
|
25
20
|
include ::RGeo::Tests::Common::MultiLineStringTests
|
26
|
-
|
27
|
-
|
28
21
|
end
|
29
|
-
|
30
22
|
end
|
31
23
|
end
|
32
24
|
end if ::RGeo::Geos.capi_supported?
|
@@ -4,29 +4,21 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
10
|
-
require ::File.expand_path('../common/multi_point_tests.rb', ::File.dirname(__FILE__))
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
11
9
|
|
10
|
+
require ::File.expand_path("../common/multi_point_tests.rb", ::File.dirname(__FILE__))
|
12
11
|
|
13
12
|
module RGeo
|
14
|
-
module Tests
|
15
|
-
module GeosCAPI
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def create_factory(opts_={})
|
13
|
+
module Tests # :nodoc:
|
14
|
+
module GeosCAPI # :nodoc:
|
15
|
+
class TestMultiPoint < ::Test::Unit::TestCase # :nodoc:
|
16
|
+
def create_factory(opts_ = {})
|
21
17
|
::RGeo::Geos.factory(opts_)
|
22
18
|
end
|
23
19
|
|
24
|
-
|
25
20
|
include ::RGeo::Tests::Common::MultiPointTests
|
26
|
-
|
27
|
-
|
28
21
|
end
|
29
|
-
|
30
22
|
end
|
31
23
|
end
|
32
24
|
end if ::RGeo::Geos.capi_supported?
|
@@ -4,46 +4,36 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
10
|
-
require ::File.expand_path('../common/multi_polygon_tests.rb', ::File.dirname(__FILE__))
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
11
9
|
|
10
|
+
require ::File.expand_path("../common/multi_polygon_tests.rb", ::File.dirname(__FILE__))
|
12
11
|
|
13
12
|
module RGeo
|
14
|
-
module Tests
|
15
|
-
module GeosCAPI
|
16
|
-
|
17
|
-
class TestMultiPolygon < ::Test::Unit::TestCase # :nodoc:
|
18
|
-
|
19
|
-
|
13
|
+
module Tests # :nodoc:
|
14
|
+
module GeosCAPI # :nodoc:
|
15
|
+
class TestMultiPolygon < ::Test::Unit::TestCase # :nodoc:
|
20
16
|
def create_factories
|
21
17
|
@factory = ::RGeo::Geos.factory
|
22
|
-
@lenient_factory = ::RGeo::Geos.factory(:
|
18
|
+
@lenient_factory = ::RGeo::Geos.factory(lenient_multi_polygon_assertions: true)
|
23
19
|
end
|
24
20
|
|
25
|
-
|
26
21
|
include ::RGeo::Tests::Common::MultiPolygonTests
|
27
22
|
|
28
|
-
|
29
23
|
# Centroid of an empty should return an empty collection rather than crash
|
30
24
|
|
31
25
|
def test_empty_centroid
|
32
26
|
assert_equal(@factory.collection([]), @factory.multi_polygon([]).centroid)
|
33
27
|
end
|
34
28
|
|
35
|
-
|
36
29
|
def _test_geos_bug_582
|
37
|
-
f_ = ::RGeo::Geos.factory(:
|
30
|
+
f_ = ::RGeo::Geos.factory(buffer_resolution: 2)
|
38
31
|
p1_ = f_.polygon(f_.linear_ring([]))
|
39
32
|
p2_ = f_.polygon(f_.linear_ring([f_.point(0, 0), f_.point(0, 1), f_.point(1, 1), f_.point(1, 0)]))
|
40
33
|
mp_ = f_.multi_polygon([p2_, p1_])
|
41
34
|
mp_.centroid.as_text
|
42
35
|
end
|
43
|
-
|
44
|
-
|
45
36
|
end
|
46
|
-
|
47
37
|
end
|
48
38
|
end
|
49
39
|
end if ::RGeo::Geos.capi_supported?
|
@@ -4,47 +4,37 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
10
9
|
|
11
10
|
module RGeo
|
12
|
-
module Tests
|
13
|
-
module GeosCAPI
|
14
|
-
|
15
|
-
class TestParsingUnparsing < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
|
17
|
-
|
11
|
+
module Tests # :nodoc:
|
12
|
+
module GeosCAPI # :nodoc:
|
13
|
+
class TestParsingUnparsing < ::Test::Unit::TestCase # :nodoc:
|
18
14
|
def test_wkt_generator_default_floating_point
|
19
15
|
# Bug report GH-4
|
20
16
|
factory_ = ::RGeo::Geos.factory
|
21
17
|
point_ = factory_.point(111.99, -40.37)
|
22
|
-
assert_equal(
|
18
|
+
assert_equal("POINT (111.99 -40.37)", point_.as_text)
|
23
19
|
end
|
24
20
|
|
25
|
-
|
26
21
|
def test_wkt_generator_downcase
|
27
|
-
factory_ = ::RGeo::Geos.factory(:
|
22
|
+
factory_ = ::RGeo::Geos.factory(wkt_generator: { convert_case: :lower })
|
28
23
|
point_ = factory_.point(1, 1)
|
29
|
-
assert_equal(
|
24
|
+
assert_equal("point (1.0 1.0)", point_.as_text)
|
30
25
|
end
|
31
26
|
|
32
|
-
|
33
27
|
def test_wkt_generator_geos
|
34
|
-
factory_ = ::RGeo::Geos.factory(:
|
28
|
+
factory_ = ::RGeo::Geos.factory(wkt_generator: :geos)
|
35
29
|
point_ = factory_.point(1, 1)
|
36
|
-
assert_equal(
|
30
|
+
assert_equal("POINT (1.0000000000000000 1.0000000000000000)", point_.as_text)
|
37
31
|
end
|
38
32
|
|
39
|
-
|
40
33
|
def test_wkt_parser_default_with_non_geosable_input
|
41
34
|
factory_ = ::RGeo::Geos.factory
|
42
|
-
assert_not_nil(factory_.parse_wkt(
|
35
|
+
assert_not_nil(factory_.parse_wkt("Point (1 1)"))
|
43
36
|
end
|
44
|
-
|
45
|
-
|
46
37
|
end
|
47
|
-
|
48
38
|
end
|
49
39
|
end
|
50
40
|
end if ::RGeo::Geos.capi_supported?
|
data/test/geos_capi/tc_point.rb
CHANGED
@@ -4,30 +4,24 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
10
|
-
require ::File.expand_path('../common/point_tests.rb', ::File.dirname(__FILE__))
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
11
9
|
|
10
|
+
require ::File.expand_path("../common/point_tests.rb", ::File.dirname(__FILE__))
|
12
11
|
|
13
12
|
module RGeo
|
14
|
-
module Tests
|
15
|
-
module GeosCAPI
|
16
|
-
|
17
|
-
class TestPoint < ::Test::Unit::TestCase # :nodoc:
|
18
|
-
|
19
|
-
|
13
|
+
module Tests # :nodoc:
|
14
|
+
module GeosCAPI # :nodoc:
|
15
|
+
class TestPoint < ::Test::Unit::TestCase # :nodoc:
|
20
16
|
def setup
|
21
|
-
@factory = ::RGeo::Geos.factory(:
|
22
|
-
@zfactory = ::RGeo::Geos.factory(:
|
23
|
-
@mfactory = ::RGeo::Geos.factory(:
|
24
|
-
@zmfactory = ::RGeo::Geos.factory(:
|
17
|
+
@factory = ::RGeo::Geos.factory(buffer_resolution: 8)
|
18
|
+
@zfactory = ::RGeo::Geos.factory(has_z_coordinate: true)
|
19
|
+
@mfactory = ::RGeo::Geos.factory(has_m_coordinate: true)
|
20
|
+
@zmfactory = ::RGeo::Geos.factory(has_z_coordinate: true, has_m_coordinate: true)
|
25
21
|
end
|
26
22
|
|
27
|
-
|
28
23
|
include ::RGeo::Tests::Common::PointTests
|
29
24
|
|
30
|
-
|
31
25
|
def test_is_geos
|
32
26
|
point_ = @factory.point(21, -22)
|
33
27
|
assert_equal(true, ::RGeo::Geos.is_geos?(point_))
|
@@ -39,19 +33,16 @@ module RGeo
|
|
39
33
|
assert_equal(false, ::RGeo::Geos.is_ffi_geos?(point2_))
|
40
34
|
end
|
41
35
|
|
42
|
-
|
43
36
|
def test_has_no_projection
|
44
37
|
point_ = @factory.point(21, -22)
|
45
38
|
assert(!point_.respond_to?(:projection))
|
46
39
|
end
|
47
40
|
|
48
|
-
|
49
41
|
def test_srid
|
50
42
|
point_ = @factory.point(11, 12)
|
51
43
|
assert_equal(0, point_.srid)
|
52
44
|
end
|
53
45
|
|
54
|
-
|
55
46
|
def test_distance
|
56
47
|
point1_ = @factory.point(11, 12)
|
57
48
|
point2_ = @factory.point(11, 12)
|
@@ -60,27 +51,22 @@ module RGeo
|
|
60
51
|
assert_equal(2, point1_.distance(point3_))
|
61
52
|
end
|
62
53
|
|
63
|
-
|
64
54
|
if defined?(::Encoding)
|
65
55
|
|
66
56
|
def test_as_text_encoding
|
67
|
-
factory_ = ::RGeo::Geos.factory(:
|
57
|
+
factory_ = ::RGeo::Geos.factory(wkt_generator: :geos)
|
68
58
|
point_ = factory_.point(11, 12)
|
69
59
|
assert_equal(::Encoding::US_ASCII, point_.as_text.encoding)
|
70
60
|
end
|
71
61
|
|
72
|
-
|
73
62
|
def test_as_binary_encoding
|
74
|
-
factory_ = ::RGeo::Geos.factory(:
|
63
|
+
factory_ = ::RGeo::Geos.factory(wkb_generator: :geos)
|
75
64
|
point_ = factory_.point(11, 12)
|
76
65
|
assert_equal(::Encoding::ASCII_8BIT, point_.as_binary.encoding)
|
77
66
|
end
|
78
67
|
|
79
68
|
end
|
80
|
-
|
81
|
-
|
82
69
|
end
|
83
|
-
|
84
70
|
end
|
85
71
|
end
|
86
72
|
end if ::RGeo::Geos.capi_supported?
|