rgeo 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +6 -0
- data/README.rdoc +1 -1
- data/Version +1 -1
- data/ext/geos_c_impl/extconf.rb +13 -13
- data/ext/geos_c_impl/factory.c +30 -18
- data/ext/geos_c_impl/factory.h +18 -12
- data/ext/geos_c_impl/geometry.c +11 -11
- data/ext/geos_c_impl/geometry.h +7 -7
- data/ext/geos_c_impl/geometry_collection.c +15 -15
- data/ext/geos_c_impl/geometry_collection.h +8 -8
- data/ext/geos_c_impl/line_string.c +14 -14
- data/ext/geos_c_impl/line_string.h +7 -7
- data/ext/geos_c_impl/main.c +7 -7
- data/ext/geos_c_impl/point.c +9 -9
- data/ext/geos_c_impl/point.h +7 -7
- data/ext/geos_c_impl/polygon.c +9 -9
- data/ext/geos_c_impl/polygon.h +7 -7
- data/ext/geos_c_impl/preface.h +7 -7
- data/ext/proj4_c_impl/extconf.rb +13 -13
- data/ext/proj4_c_impl/main.c +12 -12
- data/lib/rgeo.rb +26 -26
- data/lib/rgeo/cartesian.rb +12 -12
- data/lib/rgeo/cartesian/analysis.rb +26 -26
- data/lib/rgeo/cartesian/bounding_box.rb +83 -83
- data/lib/rgeo/cartesian/calculations.rb +36 -36
- data/lib/rgeo/cartesian/factory.rb +78 -78
- data/lib/rgeo/cartesian/feature_classes.rb +74 -74
- data/lib/rgeo/cartesian/feature_methods.rb +34 -34
- data/lib/rgeo/cartesian/interface.rb +33 -33
- data/lib/rgeo/coord_sys.rb +15 -15
- data/lib/rgeo/coord_sys/cs/entities.rb +533 -534
- data/lib/rgeo/coord_sys/cs/factories.rb +69 -69
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +44 -44
- data/lib/rgeo/coord_sys/proj4.rb +85 -85
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/interface.rb +44 -44
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +29 -29
- data/lib/rgeo/error.rb +17 -17
- data/lib/rgeo/feature.rb +15 -15
- data/lib/rgeo/feature/curve.rb +58 -58
- data/lib/rgeo/feature/factory.rb +84 -84
- data/lib/rgeo/feature/factory_generator.rb +32 -32
- data/lib/rgeo/feature/geometry.rb +215 -215
- data/lib/rgeo/feature/geometry_collection.rb +46 -46
- data/lib/rgeo/feature/line.rb +21 -21
- data/lib/rgeo/feature/line_string.rb +35 -35
- data/lib/rgeo/feature/linear_ring.rb +20 -20
- data/lib/rgeo/feature/mixins.rb +61 -61
- data/lib/rgeo/feature/multi_curve.rb +37 -37
- data/lib/rgeo/feature/multi_line_string.rb +20 -20
- data/lib/rgeo/feature/multi_point.rb +22 -22
- data/lib/rgeo/feature/multi_polygon.rb +28 -28
- data/lib/rgeo/feature/multi_surface.rb +39 -39
- data/lib/rgeo/feature/point.rb +42 -42
- data/lib/rgeo/feature/polygon.rb +50 -50
- data/lib/rgeo/feature/surface.rb +42 -42
- data/lib/rgeo/feature/types.rb +58 -58
- data/lib/rgeo/geographic.rb +14 -14
- data/lib/rgeo/geographic/factory.rb +87 -87
- data/lib/rgeo/geographic/interface.rb +55 -55
- data/lib/rgeo/geographic/proj4_projector.rb +35 -35
- data/lib/rgeo/geographic/projected_feature_classes.rb +95 -95
- data/lib/rgeo/geographic/projected_feature_methods.rb +81 -81
- data/lib/rgeo/geographic/projected_window.rb +103 -103
- data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -32
- data/lib/rgeo/geographic/spherical_feature_classes.rb +93 -93
- data/lib/rgeo/geographic/spherical_feature_methods.rb +25 -25
- data/lib/rgeo/geographic/spherical_math.rb +58 -58
- data/lib/rgeo/geos.rb +22 -17
- data/lib/rgeo/geos/factory.rb +93 -93
- data/lib/rgeo/geos/ffi_classes.rb +306 -231
- data/lib/rgeo/geos/ffi_factory.rb +100 -96
- data/lib/rgeo/geos/impl_additions.rb +22 -22
- data/lib/rgeo/geos/interface.rb +45 -45
- data/lib/rgeo/geos/zm_factory.rb +90 -90
- data/lib/rgeo/geos/zm_impl.rb +167 -167
- data/lib/rgeo/impl_helper.rb +11 -11
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +71 -71
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +29 -29
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +61 -61
- data/lib/rgeo/impl_helper/basic_point_methods.rb +43 -43
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +35 -35
- data/lib/rgeo/impl_helper/math.rb +13 -13
- data/lib/rgeo/version.rb +10 -10
- data/lib/rgeo/wkrep.rb +16 -16
- data/lib/rgeo/wkrep/wkb_generator.rb +51 -51
- data/lib/rgeo/wkrep/wkb_parser.rb +52 -52
- data/lib/rgeo/wkrep/wkt_generator.rb +51 -51
- data/lib/rgeo/wkrep/wkt_parser.rb +66 -66
- data/lib/rgeo/yaml.rb +14 -14
- data/test/common/geometry_collection_tests.rb +53 -53
- data/test/common/line_string_tests.rb +57 -57
- data/test/common/multi_line_string_tests.rb +43 -43
- data/test/common/multi_point_tests.rb +43 -43
- data/test/common/multi_polygon_tests.rb +43 -43
- data/test/common/point_tests.rb +75 -75
- data/test/common/polygon_tests.rb +37 -37
- data/test/coord_sys/tc_active_record_table.rb +25 -25
- data/test/coord_sys/tc_ogc_cs.rb +72 -72
- data/test/coord_sys/tc_proj4.rb +51 -51
- data/test/coord_sys/tc_proj4_srs_data.rb +17 -17
- data/test/coord_sys/tc_sr_org.rb +15 -15
- data/test/coord_sys/tc_url_reader.rb +19 -19
- data/test/geos_capi/tc_factory.rb +21 -21
- data/test/geos_capi/tc_geometry_collection.rb +15 -15
- data/test/geos_capi/tc_line_string.rb +15 -15
- data/test/geos_capi/tc_misc.rb +33 -22
- data/test/geos_capi/tc_multi_line_string.rb +15 -15
- data/test/geos_capi/tc_multi_point.rb +15 -15
- data/test/geos_capi/tc_multi_polygon.rb +15 -15
- data/test/geos_capi/tc_parsing_unparsing.rb +19 -19
- data/test/geos_capi/tc_point.rb +21 -21
- data/test/geos_capi/tc_polygon.rb +19 -19
- data/test/geos_capi/tc_zmfactory.rb +17 -17
- data/test/geos_ffi/tc_factory.rb +21 -21
- data/test/geos_ffi/tc_geometry_collection.rb +15 -15
- data/test/geos_ffi/tc_line_string.rb +15 -15
- data/test/geos_ffi/tc_misc.rb +49 -15
- data/test/geos_ffi/tc_multi_line_string.rb +15 -15
- data/test/geos_ffi/tc_multi_point.rb +15 -15
- data/test/geos_ffi/tc_multi_polygon.rb +15 -15
- data/test/geos_ffi/tc_parsing_unparsing.rb +19 -19
- data/test/geos_ffi/tc_point.rb +21 -21
- data/test/geos_ffi/tc_polygon.rb +19 -19
- data/test/geos_ffi/tc_zmfactory.rb +17 -17
- data/test/projected_geographic/tc_geometry_collection.rb +15 -15
- data/test/projected_geographic/tc_line_string.rb +15 -15
- data/test/projected_geographic/tc_multi_line_string.rb +15 -15
- data/test/projected_geographic/tc_multi_point.rb +15 -15
- data/test/projected_geographic/tc_multi_polygon.rb +15 -15
- data/test/projected_geographic/tc_point.rb +23 -23
- data/test/projected_geographic/tc_polygon.rb +15 -15
- data/test/simple_cartesian/tc_calculations.rb +31 -31
- data/test/simple_cartesian/tc_geometry_collection.rb +17 -17
- data/test/simple_cartesian/tc_line_string.rb +17 -17
- data/test/simple_cartesian/tc_multi_line_string.rb +17 -17
- data/test/simple_cartesian/tc_multi_point.rb +17 -17
- data/test/simple_cartesian/tc_multi_polygon.rb +17 -17
- data/test/simple_cartesian/tc_point.rb +21 -21
- data/test/simple_cartesian/tc_polygon.rb +17 -17
- data/test/simple_mercator/tc_geometry_collection.rb +15 -15
- data/test/simple_mercator/tc_line_string.rb +15 -15
- data/test/simple_mercator/tc_multi_line_string.rb +15 -15
- data/test/simple_mercator/tc_multi_point.rb +15 -15
- data/test/simple_mercator/tc_multi_polygon.rb +15 -15
- data/test/simple_mercator/tc_point.rb +23 -23
- data/test/simple_mercator/tc_polygon.rb +15 -15
- data/test/simple_mercator/tc_window.rb +50 -50
- data/test/spherical_geographic/tc_calculations.rb +47 -47
- data/test/spherical_geographic/tc_geometry_collection.rb +17 -17
- data/test/spherical_geographic/tc_line_string.rb +17 -17
- data/test/spherical_geographic/tc_multi_line_string.rb +17 -17
- data/test/spherical_geographic/tc_multi_point.rb +17 -17
- data/test/spherical_geographic/tc_multi_polygon.rb +17 -17
- data/test/spherical_geographic/tc_point.rb +23 -23
- data/test/spherical_geographic/tc_polygon.rb +17 -17
- data/test/tc_cartesian_analysis.rb +23 -23
- data/test/tc_mixins.rb +39 -39
- data/test/tc_oneoff.rb +15 -15
- data/test/tc_types.rb +17 -17
- data/test/wkrep/tc_wkb_generator.rb +67 -67
- data/test/wkrep/tc_wkb_parser.rb +73 -73
- data/test/wkrep/tc_wkt_generator.rb +75 -75
- data/test/wkrep/tc_wkt_parser.rb +97 -97
- metadata +3 -3
data/lib/rgeo/error.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Error classes for RGeo
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -35,29 +35,29 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module RGeo
|
38
|
-
|
39
|
-
|
38
|
+
|
39
|
+
|
40
40
|
# All RGeo errors are members of this namespace.
|
41
|
-
|
41
|
+
|
42
42
|
module Error
|
43
|
-
|
43
|
+
|
44
44
|
# Base class for all RGeo-related exceptions
|
45
45
|
class RGeoError < ::RuntimeError
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
# The specified geometry is invalid
|
49
49
|
class InvalidGeometry < RGeoError
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
# The specified operation is not supported or not implemented
|
53
53
|
class UnsupportedOperation < RGeoError
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
# Parsing failed
|
57
57
|
class ParseError < RGeoError
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
end
|
61
|
-
|
62
|
-
|
61
|
+
|
62
|
+
|
63
63
|
end
|
data/lib/rgeo/feature.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Features namespace for RGeo
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -35,19 +35,19 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module RGeo
|
38
|
-
|
39
|
-
|
38
|
+
|
39
|
+
|
40
40
|
# The Feature namespace contains interfaces and general tools for
|
41
41
|
# implementations of the Open Geospatial Consortium Simple Features
|
42
42
|
# Specification (SFS), version 1.1.0.
|
43
|
-
#
|
43
|
+
#
|
44
44
|
# Each interface is defined as a module, and is provided primarily for
|
45
45
|
# the sake of documentation. Implementations do not necessarily include
|
46
46
|
# the modules themselves. Therefore, you should not depend on the
|
47
47
|
# kind_of? method to check type. Instead, each interface module will
|
48
48
|
# provide a check_type class method (and a corresponding === operator
|
49
49
|
# to support case-when constructs).
|
50
|
-
#
|
50
|
+
#
|
51
51
|
# In addition, a Factory interface is defined here. A factory is an
|
52
52
|
# object that knows how to construct geometry instances for a given
|
53
53
|
# implementation. Each implementation's front-end consists of a way to
|
@@ -55,16 +55,16 @@ module RGeo
|
|
55
55
|
# building the features themselves. Note that, like the geometry
|
56
56
|
# modules, the Factory module itself may not actually be included in a
|
57
57
|
# factory implementation.
|
58
|
-
#
|
58
|
+
#
|
59
59
|
# Any particular implementation may extend these interfaces to provide
|
60
60
|
# implementation-specific features beyond what is stated in the SFS
|
61
61
|
# itself. The implementation should separately document any such
|
62
62
|
# extensions that it may provide.
|
63
|
-
|
63
|
+
|
64
64
|
module Feature
|
65
65
|
end
|
66
|
-
|
67
|
-
|
66
|
+
|
67
|
+
|
68
68
|
end
|
69
69
|
|
70
70
|
|
data/lib/rgeo/feature/curve.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Curve feature interface
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -35,121 +35,121 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module RGeo
|
38
|
-
|
38
|
+
|
39
39
|
module Feature
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
# == SFS 1.1 Description
|
43
|
-
#
|
43
|
+
#
|
44
44
|
# A Curve is a 1-dimensional geometric object usually stored as a
|
45
45
|
# sequence of Points, with the subtype of Curve specifying the form of
|
46
46
|
# the interpolation between Points. This part of ISO 19125 defines only
|
47
47
|
# one subclass of Curve, LineString, which uses linear interpolation
|
48
48
|
# between Points.
|
49
|
-
#
|
49
|
+
#
|
50
50
|
# A Curve is a 1-dimensional geometric object that is the homeomorphic
|
51
51
|
# image of a real, closed interval D=[a,b] under a mapping f:[a,b]->R2.
|
52
|
-
#
|
52
|
+
#
|
53
53
|
# A Curve is simple if it does not pass through the same Point twice.
|
54
|
-
#
|
54
|
+
#
|
55
55
|
# A Curve is closed if its start Point is equal to its end Point.
|
56
|
-
#
|
56
|
+
#
|
57
57
|
# The boundary of a closed Curve is empty.
|
58
|
-
#
|
58
|
+
#
|
59
59
|
# A Curve that is simple and closed is a Ring.
|
60
|
-
#
|
60
|
+
#
|
61
61
|
# The boundary of a non-closed Curve consists of its two end Points.
|
62
|
-
#
|
62
|
+
#
|
63
63
|
# A Curve is defined as topologically closed.
|
64
|
-
#
|
64
|
+
#
|
65
65
|
# == Notes
|
66
|
-
#
|
66
|
+
#
|
67
67
|
# Curve is defined as a module and is provided primarily
|
68
68
|
# for the sake of documentation. Implementations need not necessarily
|
69
69
|
# include this module itself. Therefore, you should not depend on the
|
70
70
|
# kind_of? method to check type. Instead, use the provided check_type
|
71
71
|
# class method (or === operator) defined in the Type module.
|
72
|
-
#
|
72
|
+
#
|
73
73
|
# Some implementations may support higher dimensional points.
|
74
|
-
|
74
|
+
|
75
75
|
module Curve
|
76
|
-
|
76
|
+
|
77
77
|
include Geometry
|
78
78
|
extend Type
|
79
|
-
|
80
|
-
|
79
|
+
|
80
|
+
|
81
81
|
# === SFS 1.1 Description
|
82
|
-
#
|
82
|
+
#
|
83
83
|
# The length of this Curve in its associated spatial reference.
|
84
|
-
#
|
84
|
+
#
|
85
85
|
# === Notes
|
86
|
-
#
|
86
|
+
#
|
87
87
|
# Returns a floating-point scalar value.
|
88
|
-
|
88
|
+
|
89
89
|
def length
|
90
90
|
raise Error::UnsupportedOperation, "Method Curve#length not defined."
|
91
91
|
end
|
92
|
-
|
93
|
-
|
92
|
+
|
93
|
+
|
94
94
|
# === SFS 1.1 Description
|
95
|
-
#
|
95
|
+
#
|
96
96
|
# The start Point of this Curve.
|
97
|
-
#
|
97
|
+
#
|
98
98
|
# === Notes
|
99
|
-
#
|
99
|
+
#
|
100
100
|
# Returns an object that supports the Point interface.
|
101
|
-
|
101
|
+
|
102
102
|
def start_point
|
103
103
|
raise Error::UnsupportedOperation, "Method Curve#start_point not defined."
|
104
104
|
end
|
105
|
-
|
106
|
-
|
105
|
+
|
106
|
+
|
107
107
|
# === SFS 1.1 Description
|
108
|
-
#
|
108
|
+
#
|
109
109
|
# The end Point of this Curve.
|
110
|
-
#
|
110
|
+
#
|
111
111
|
# === Notes
|
112
|
-
#
|
112
|
+
#
|
113
113
|
# Returns an object that supports the Point interface.
|
114
|
-
|
114
|
+
|
115
115
|
def end_point
|
116
116
|
raise Error::UnsupportedOperation, "Method Curve#end_point not defined."
|
117
117
|
end
|
118
|
-
|
119
|
-
|
118
|
+
|
119
|
+
|
120
120
|
# === SFS 1.1 Description
|
121
|
-
#
|
121
|
+
#
|
122
122
|
# Returns true if this Curve is closed [StartPoint() = EndPoint()].
|
123
|
-
#
|
123
|
+
#
|
124
124
|
# === Notes
|
125
|
-
#
|
125
|
+
#
|
126
126
|
# Returns a boolean value. Note that this is different from the SFS
|
127
127
|
# specification, which stipulates an integer return value.
|
128
|
-
|
128
|
+
|
129
129
|
def is_closed?
|
130
130
|
raise Error::UnsupportedOperation, "Method Curve#is_closed? not defined."
|
131
131
|
end
|
132
|
-
|
133
|
-
|
132
|
+
|
133
|
+
|
134
134
|
# === SFS 1.1 Description
|
135
|
-
#
|
135
|
+
#
|
136
136
|
# Returns true if this Curve is closed [StartPoint() = EndPoint()]
|
137
137
|
# and this Curve is simple (does not pass through the same Point
|
138
138
|
# more than once).
|
139
|
-
#
|
139
|
+
#
|
140
140
|
# === Notes
|
141
|
-
#
|
141
|
+
#
|
142
142
|
# Returns a boolean value. Note that this is different from the SFS
|
143
143
|
# specification, which stipulates an integer return value.
|
144
|
-
|
144
|
+
|
145
145
|
def is_ring?
|
146
146
|
raise Error::UnsupportedOperation, "Method Curve#is_ring? not defined."
|
147
147
|
end
|
148
|
-
|
149
|
-
|
148
|
+
|
149
|
+
|
150
150
|
end
|
151
|
-
|
152
|
-
|
151
|
+
|
152
|
+
|
153
153
|
end
|
154
|
-
|
154
|
+
|
155
155
|
end
|
data/lib/rgeo/feature/factory.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Feature factory interface
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -35,24 +35,24 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module RGeo
|
38
|
-
|
38
|
+
|
39
39
|
module Feature
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
# This is a standard interface for factories of features.
|
43
43
|
# Generally, each Feature implementation will implement these
|
44
44
|
# methods as a standard way to create features.
|
45
|
-
#
|
45
|
+
#
|
46
46
|
# If the implementation is unable to create the given feature,
|
47
47
|
# it should generally return nil. Implementations may also choose to
|
48
48
|
# raise an exception on failure.
|
49
|
-
#
|
49
|
+
#
|
50
50
|
# Some implementations may extend this interface to provide facilities
|
51
51
|
# for creating additional objects according to the capabilities
|
52
52
|
# provided by that implementation. Examples might include
|
53
53
|
# higher-dimensional coordinates or additional subclasses not
|
54
54
|
# explicitly required by the Simple Features Specification.
|
55
|
-
#
|
55
|
+
#
|
56
56
|
# Factory is defined as a module and is provided primarily for the
|
57
57
|
# sake of documentation. Implementations need not necessarily include
|
58
58
|
# this module itself. Therefore, you should not depend on the result
|
@@ -61,27 +61,27 @@ module RGeo
|
|
61
61
|
# is provided. All factory implementation classes MUST include
|
62
62
|
# <tt>Factory::Instance</tt>, and you may use it in <tt>is_a?</tt>,
|
63
63
|
# <tt>===</tt>, and case-when constructs.
|
64
|
-
|
64
|
+
|
65
65
|
module Factory
|
66
|
-
|
67
|
-
|
66
|
+
|
67
|
+
|
68
68
|
# All factory implementations MUST include this submodule.
|
69
69
|
# This serves as a marker that may be used to test an object for
|
70
70
|
# factory-ness.
|
71
|
-
|
71
|
+
|
72
72
|
module Instance
|
73
73
|
end
|
74
|
-
|
75
|
-
|
74
|
+
|
75
|
+
|
76
76
|
# Returns meta-information about this factory, by key. This
|
77
77
|
# information may involve support for optional functionality,
|
78
78
|
# properties of the coordinate system, or other characteristics.
|
79
|
-
#
|
79
|
+
#
|
80
80
|
# Each property has a symbolic name. Names that have no periods are
|
81
81
|
# considered well-known names and are reserved for use by RGeo. If
|
82
82
|
# you want to define your own properties, use a name that is
|
83
83
|
# namespaced with periods, such as <tt>:'mycompany.myprop'</tt>.
|
84
|
-
#
|
84
|
+
#
|
85
85
|
# Property values are dependent on the individual property.
|
86
86
|
# Generally, properties that involve testing for functionality
|
87
87
|
# should return true if the functionality is support, or false or
|
@@ -89,9 +89,9 @@ module RGeo
|
|
89
89
|
# indicating different levels of support. In any case, the factory
|
90
90
|
# should return nil for property names it does not recognize. This
|
91
91
|
# value is considered the "default" or "no value" value.
|
92
|
-
#
|
92
|
+
#
|
93
93
|
# Currently defined well-known properties are:
|
94
|
-
#
|
94
|
+
#
|
95
95
|
# [<tt>:has_z_coordinate</tt>]
|
96
96
|
# Set to true if geometries created by this factory include a Z
|
97
97
|
# coordinate, and the Point#z method is available.
|
@@ -107,147 +107,147 @@ module RGeo
|
|
107
107
|
# interpreted as x=longitude and y=latitude. If false or nil, no
|
108
108
|
# information is present about whether the coordinate system is
|
109
109
|
# meant to be so interpreted.
|
110
|
-
|
110
|
+
|
111
111
|
def property(name_)
|
112
112
|
nil
|
113
113
|
end
|
114
|
-
|
115
|
-
|
114
|
+
|
115
|
+
|
116
116
|
# Parse the given string in well-known-text format and return the
|
117
117
|
# resulting feature. Returns nil if the string couldn't be parsed.
|
118
|
-
|
118
|
+
|
119
119
|
def parse_wkt(str_)
|
120
120
|
nil
|
121
121
|
end
|
122
|
-
|
123
|
-
|
122
|
+
|
123
|
+
|
124
124
|
# Parse the given string in well-known-binary format and return the
|
125
125
|
# resulting feature. Returns nil if the string couldn't be parsed.
|
126
|
-
|
126
|
+
|
127
127
|
def parse_wkb(str_)
|
128
128
|
nil
|
129
129
|
end
|
130
|
-
|
131
|
-
|
130
|
+
|
131
|
+
|
132
132
|
# Create a feature of type Point.
|
133
133
|
# The x and y parameters should be Float values.
|
134
|
-
#
|
134
|
+
#
|
135
135
|
# The extra parameters should be the Z and/or M coordinates, if
|
136
136
|
# supported. If both Z and M coordinates are supported, Z should
|
137
137
|
# be passed first.
|
138
|
-
|
138
|
+
|
139
139
|
def point(x_, y_, *extra_)
|
140
140
|
nil
|
141
141
|
end
|
142
|
-
|
143
|
-
|
142
|
+
|
143
|
+
|
144
144
|
# Create a feature of type LineString.
|
145
145
|
# The given points argument should be an Enumerable of Point
|
146
146
|
# objects, or objects that can be cast to Point.
|
147
|
-
#
|
147
|
+
#
|
148
148
|
# Although implementations are free to attempt to handle input
|
149
149
|
# objects that are not of this factory, strictly speaking, the
|
150
150
|
# result of building geometries from objects of the wrong factory
|
151
151
|
# is undefined.
|
152
|
-
|
152
|
+
|
153
153
|
def line_string(points_)
|
154
154
|
nil
|
155
155
|
end
|
156
|
-
|
157
|
-
|
156
|
+
|
157
|
+
|
158
158
|
# Create a feature of type Line.
|
159
159
|
# The given point arguments should be Point objects, or objects
|
160
160
|
# that can be cast to Point.
|
161
|
-
#
|
161
|
+
#
|
162
162
|
# Although implementations are free to attempt to handle input
|
163
163
|
# objects that are not of this factory, strictly speaking, the
|
164
164
|
# result of building geometries from objects of the wrong factory
|
165
165
|
# is undefined.
|
166
|
-
|
166
|
+
|
167
167
|
def line(start_, end_)
|
168
168
|
nil
|
169
169
|
end
|
170
|
-
|
171
|
-
|
170
|
+
|
171
|
+
|
172
172
|
# Create a feature of type LinearRing.
|
173
173
|
# The given points argument should be an Enumerable of Point
|
174
174
|
# objects, or objects that can be cast to Point.
|
175
175
|
# If the first and last points are not equal, the ring is
|
176
176
|
# automatically closed by appending the first point to the end of the
|
177
177
|
# string.
|
178
|
-
#
|
178
|
+
#
|
179
179
|
# Although implementations are free to attempt to handle input
|
180
180
|
# objects that are not of this factory, strictly speaking, the
|
181
181
|
# result of building geometries from objects of the wrong factory
|
182
182
|
# is undefined.
|
183
|
-
|
183
|
+
|
184
184
|
def linear_ring(points_)
|
185
185
|
nil
|
186
186
|
end
|
187
|
-
|
188
|
-
|
187
|
+
|
188
|
+
|
189
189
|
# Create a feature of type Polygon.
|
190
190
|
# The outer_ring should be a LinearRing, or an object that can be
|
191
191
|
# cast to LinearRing.
|
192
192
|
# The inner_rings should be a possibly empty Enumerable of
|
193
193
|
# LinearRing (or objects that can be casted to LinearRing).
|
194
194
|
# You may also pass nil to indicate no inner rings.
|
195
|
-
#
|
195
|
+
#
|
196
196
|
# Although implementations are free to attempt to handle input
|
197
197
|
# objects that are not of this factory, strictly speaking, the
|
198
198
|
# result of building geometries from objects of the wrong factory
|
199
199
|
# is undefined.
|
200
|
-
|
200
|
+
|
201
201
|
def polygon(outer_ring_, inner_rings_=nil)
|
202
202
|
nil
|
203
203
|
end
|
204
|
-
|
205
|
-
|
204
|
+
|
205
|
+
|
206
206
|
# Create a feature of type GeometryCollection.
|
207
207
|
# The elems should be an Enumerable of Geometry objects.
|
208
|
-
#
|
208
|
+
#
|
209
209
|
# Although implementations are free to attempt to handle input
|
210
210
|
# objects that are not of this factory, strictly speaking, the
|
211
211
|
# result of building geometries from objects of the wrong factory
|
212
212
|
# is undefined.
|
213
|
-
|
213
|
+
|
214
214
|
def collection(elems_)
|
215
215
|
nil
|
216
216
|
end
|
217
|
-
|
218
|
-
|
217
|
+
|
218
|
+
|
219
219
|
# Create a feature of type MultiPoint.
|
220
220
|
# The elems should be an Enumerable of Point objects, or objects
|
221
221
|
# that can be cast to Point.
|
222
222
|
# Returns nil if any of the contained geometries is not a Point,
|
223
223
|
# which would break the MultiPoint contract.
|
224
|
-
#
|
224
|
+
#
|
225
225
|
# Although implementations are free to attempt to handle input
|
226
226
|
# objects that are not of this factory, strictly speaking, the
|
227
227
|
# result of building geometries from objects of the wrong factory
|
228
228
|
# is undefined.
|
229
|
-
|
229
|
+
|
230
230
|
def multi_point(elems_)
|
231
231
|
nil
|
232
232
|
end
|
233
|
-
|
234
|
-
|
233
|
+
|
234
|
+
|
235
235
|
# Create a feature of type MultiLineString.
|
236
236
|
# The elems should be an Enumerable of objects that are or can be
|
237
237
|
# cast to LineString or any of its subclasses.
|
238
238
|
# Returns nil if any of the contained geometries is not a
|
239
239
|
# LineString, which would break the MultiLineString contract.
|
240
|
-
#
|
240
|
+
#
|
241
241
|
# Although implementations are free to attempt to handle input
|
242
242
|
# objects that are not of this factory, strictly speaking, the
|
243
243
|
# result of building geometries from objects of the wrong factory
|
244
244
|
# is undefined.
|
245
|
-
|
245
|
+
|
246
246
|
def multi_line_string(elems_)
|
247
247
|
nil
|
248
248
|
end
|
249
|
-
|
250
|
-
|
249
|
+
|
250
|
+
|
251
251
|
# Create a feature of type MultiPolygon.
|
252
252
|
# The elems should be an Enumerable of objects that are or can be
|
253
253
|
# cast to Polygon or any of its subclasses.
|
@@ -255,39 +255,39 @@ module RGeo
|
|
255
255
|
# which would break the MultiPolygon contract.
|
256
256
|
# Also returns nil if any of the other assertions for MultiPolygon
|
257
257
|
# are not met, e.g. if any of the polygons overlap.
|
258
|
-
#
|
258
|
+
#
|
259
259
|
# Although implementations are free to attempt to handle input
|
260
260
|
# objects that are not of this factory, strictly speaking, the
|
261
261
|
# result of building geometries from objects of the wrong factory
|
262
262
|
# is undefined.
|
263
|
-
|
263
|
+
|
264
264
|
def multi_polygon(elems_)
|
265
265
|
nil
|
266
266
|
end
|
267
|
-
|
268
|
-
|
267
|
+
|
268
|
+
|
269
269
|
# Returns a RGeo::CoordSys::Proj4 representing the projection for
|
270
270
|
# the coordinate system of features created by this factory, or nil
|
271
271
|
# if there is no such proj4 projection.
|
272
|
-
|
272
|
+
|
273
273
|
def proj4
|
274
274
|
nil
|
275
275
|
end
|
276
|
-
|
277
|
-
|
276
|
+
|
277
|
+
|
278
278
|
# Returns the coordinate system specification for the features
|
279
279
|
# created by this factory, or nil if there is no such coordinate
|
280
280
|
# system.
|
281
|
-
#
|
281
|
+
#
|
282
282
|
# NOTE: This is a required method of the factory interface, but the
|
283
283
|
# coordinate system classes themselves are not yet available, so
|
284
284
|
# implementations should just return nil for now.
|
285
|
-
|
285
|
+
|
286
286
|
def coord_sys
|
287
287
|
nil
|
288
288
|
end
|
289
|
-
|
290
|
-
|
289
|
+
|
290
|
+
|
291
291
|
# This is an optional method that may be implemented to customize
|
292
292
|
# casting for this factory. Basically, RGeo defines standard ways
|
293
293
|
# to cast certain types of objects from one factory to another and
|
@@ -295,13 +295,13 @@ module RGeo
|
|
295
295
|
# override how things are casted TO its implementation using this
|
296
296
|
# method. It can do this to optimize certain casting cases, or
|
297
297
|
# implement special cases particular to this factory.
|
298
|
-
#
|
298
|
+
#
|
299
299
|
# This method will be called (if defined) on the destination
|
300
300
|
# factory, and will be passed the original object (which may or may
|
301
301
|
# not already be created by this factory), the SFS feature type
|
302
302
|
# (which again may or may not already be the type of the original
|
303
303
|
# object), and a hash of additional flags. These flags are:
|
304
|
-
#
|
304
|
+
#
|
305
305
|
# [<tt>:keep_subtype</tt>]
|
306
306
|
# indicates whether to keep the subtype if casting to a supertype
|
307
307
|
# of the current type
|
@@ -311,7 +311,7 @@ module RGeo
|
|
311
311
|
# [<tt>:project</tt>]
|
312
312
|
# indicates whether to project the coordinates from the source to
|
313
313
|
# the destination proj4 coordinate system, if available
|
314
|
-
#
|
314
|
+
#
|
315
315
|
# It should return either a casted result object, false, or nil.
|
316
316
|
# A nil return value indicates that casting should be forced to
|
317
317
|
# fail (and RGeo::Feature.cast will return nil).
|
@@ -319,15 +319,15 @@ module RGeo
|
|
319
319
|
# override the casting algorithm, and RGeo should use its default
|
320
320
|
# algorithm to cast the object. Therefore, by default, you should
|
321
321
|
# return false.
|
322
|
-
|
322
|
+
|
323
323
|
def override_cast(original_, type_, flags_)
|
324
324
|
false
|
325
325
|
end
|
326
|
-
|
327
|
-
|
326
|
+
|
327
|
+
|
328
328
|
end
|
329
|
-
|
330
|
-
|
329
|
+
|
330
|
+
|
331
331
|
end
|
332
|
-
|
332
|
+
|
333
333
|
end
|