rgeo-dschee 0.5.4
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.
- checksums.yaml +7 -0
- data/LICENSE.txt +29 -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 +43 -0
- data/ext/geos_c_impl/factory.c +995 -0
- data/ext/geos_c_impl/factory.h +238 -0
- data/ext/geos_c_impl/geometry.c +1093 -0
- data/ext/geos_c_impl/geometry.h +23 -0
- data/ext/geos_c_impl/geometry_collection.c +757 -0
- data/ext/geos_c_impl/geometry_collection.h +46 -0
- data/ext/geos_c_impl/line_string.c +675 -0
- data/ext/geos_c_impl/line_string.h +32 -0
- data/ext/geos_c_impl/main.c +40 -0
- data/ext/geos_c_impl/point.c +236 -0
- data/ext/geos_c_impl/point.h +30 -0
- data/ext/geos_c_impl/polygon.c +359 -0
- data/ext/geos_c_impl/polygon.h +43 -0
- data/ext/geos_c_impl/preface.h +38 -0
- data/ext/proj4_c_impl/extconf.rb +62 -0
- data/ext/proj4_c_impl/main.c +315 -0
- data/lib/rgeo.rb +89 -0
- data/lib/rgeo/cartesian.rb +25 -0
- data/lib/rgeo/cartesian/analysis.rb +77 -0
- data/lib/rgeo/cartesian/bounding_box.rb +398 -0
- data/lib/rgeo/cartesian/calculations.rb +113 -0
- data/lib/rgeo/cartesian/factory.rb +347 -0
- data/lib/rgeo/cartesian/feature_classes.rb +100 -0
- data/lib/rgeo/cartesian/feature_methods.rb +88 -0
- data/lib/rgeo/cartesian/interface.rb +135 -0
- data/lib/rgeo/coord_sys.rb +43 -0
- data/lib/rgeo/coord_sys/cs/entities.rb +1315 -0
- data/lib/rgeo/coord_sys/cs/factories.rb +148 -0
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +272 -0
- data/lib/rgeo/coord_sys/proj4.rb +293 -0
- data/lib/rgeo/coord_sys/srs_database/interface.rb +115 -0
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +140 -0
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +62 -0
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +63 -0
- data/lib/rgeo/error.rb +27 -0
- data/lib/rgeo/feature.rb +54 -0
- data/lib/rgeo/feature/curve.rb +111 -0
- data/lib/rgeo/feature/factory.rb +278 -0
- data/lib/rgeo/feature/factory_generator.rb +96 -0
- data/lib/rgeo/feature/geometry.rb +624 -0
- data/lib/rgeo/feature/geometry_collection.rb +95 -0
- data/lib/rgeo/feature/line.rb +26 -0
- data/lib/rgeo/feature/line_string.rb +60 -0
- data/lib/rgeo/feature/linear_ring.rb +26 -0
- data/lib/rgeo/feature/mixins.rb +143 -0
- data/lib/rgeo/feature/multi_curve.rb +71 -0
- data/lib/rgeo/feature/multi_line_string.rb +26 -0
- data/lib/rgeo/feature/multi_point.rb +33 -0
- data/lib/rgeo/feature/multi_polygon.rb +57 -0
- data/lib/rgeo/feature/multi_surface.rb +73 -0
- data/lib/rgeo/feature/point.rb +84 -0
- data/lib/rgeo/feature/polygon.rb +97 -0
- data/lib/rgeo/feature/surface.rb +79 -0
- data/lib/rgeo/feature/types.rb +284 -0
- data/lib/rgeo/geographic.rb +40 -0
- data/lib/rgeo/geographic/factory.rb +450 -0
- data/lib/rgeo/geographic/interface.rb +489 -0
- data/lib/rgeo/geographic/proj4_projector.rb +58 -0
- data/lib/rgeo/geographic/projected_feature_classes.rb +107 -0
- data/lib/rgeo/geographic/projected_feature_methods.rb +212 -0
- data/lib/rgeo/geographic/projected_window.rb +383 -0
- data/lib/rgeo/geographic/simple_mercator_projector.rb +110 -0
- data/lib/rgeo/geographic/spherical_feature_classes.rb +100 -0
- data/lib/rgeo/geographic/spherical_feature_methods.rb +134 -0
- data/lib/rgeo/geographic/spherical_math.rb +188 -0
- data/lib/rgeo/geos.rb +89 -0
- data/lib/rgeo/geos/capi_factory.rb +470 -0
- data/lib/rgeo/geos/capi_feature_classes.rb +129 -0
- data/lib/rgeo/geos/ffi_factory.rb +592 -0
- data/lib/rgeo/geos/ffi_feature_classes.rb +83 -0
- data/lib/rgeo/geos/ffi_feature_methods.rb +574 -0
- data/lib/rgeo/geos/interface.rb +202 -0
- data/lib/rgeo/geos/utils.rb +74 -0
- data/lib/rgeo/geos/zm_factory.rb +405 -0
- data/lib/rgeo/geos/zm_feature_classes.rb +80 -0
- data/lib/rgeo/geos/zm_feature_methods.rb +344 -0
- data/lib/rgeo/impl_helper.rb +19 -0
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +185 -0
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +61 -0
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +146 -0
- data/lib/rgeo/impl_helper/basic_point_methods.rb +104 -0
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +87 -0
- data/lib/rgeo/impl_helper/math.rb +14 -0
- data/lib/rgeo/impl_helper/utils.rb +29 -0
- data/lib/rgeo/version.rb +3 -0
- data/lib/rgeo/wkrep.rb +37 -0
- data/lib/rgeo/wkrep/wkb_generator.rb +201 -0
- data/lib/rgeo/wkrep/wkb_parser.rb +251 -0
- data/lib/rgeo/wkrep/wkt_generator.rb +207 -0
- data/lib/rgeo/wkrep/wkt_parser.rb +415 -0
- data/lib/rgeo/yaml.rb +23 -0
- data/test/cartesian_analysis_test.rb +65 -0
- data/test/cartesian_bbox_test.rb +123 -0
- data/test/common/factory_tests.rb +78 -0
- data/test/common/geometry_collection_tests.rb +237 -0
- data/test/common/line_string_tests.rb +330 -0
- data/test/common/multi_line_string_tests.rb +182 -0
- data/test/common/multi_point_tests.rb +200 -0
- data/test/common/multi_polygon_tests.rb +191 -0
- data/test/common/point_tests.rb +370 -0
- data/test/common/polygon_tests.rb +261 -0
- data/test/coord_sys/ogc_cs_test.rb +342 -0
- data/test/coord_sys/proj4_srs_data_test.rb +41 -0
- data/test/coord_sys/proj4_test.rb +150 -0
- data/test/coord_sys/sr_org_test.rb +32 -0
- data/test/coord_sys/url_reader_test.rb +42 -0
- data/test/geos_capi/factory_test.rb +31 -0
- data/test/geos_capi/geometry_collection_test.rb +24 -0
- data/test/geos_capi/line_string_test.rb +24 -0
- data/test/geos_capi/misc_test.rb +116 -0
- data/test/geos_capi/multi_line_string_test.rb +24 -0
- data/test/geos_capi/multi_point_test.rb +24 -0
- data/test/geos_capi/multi_polygon_test.rb +39 -0
- data/test/geos_capi/parsing_unparsing_test.rb +40 -0
- data/test/geos_capi/point_test.rb +72 -0
- data/test/geos_capi/polygon_test.rb +154 -0
- data/test/geos_capi/zmfactory_test.rb +57 -0
- data/test/geos_ffi/factory_test.rb +31 -0
- data/test/geos_ffi/geometry_collection_test.rb +24 -0
- data/test/geos_ffi/line_string_test.rb +24 -0
- data/test/geos_ffi/misc_test.rb +63 -0
- data/test/geos_ffi/multi_line_string_test.rb +24 -0
- data/test/geos_ffi/multi_point_test.rb +24 -0
- data/test/geos_ffi/multi_polygon_test.rb +33 -0
- data/test/geos_ffi/parsing_unparsing_test.rb +41 -0
- data/test/geos_ffi/point_test.rb +77 -0
- data/test/geos_ffi/polygon_test.rb +46 -0
- data/test/geos_ffi/zmfactory_test.rb +58 -0
- data/test/mixins_test.rb +141 -0
- data/test/oneoff_test.rb +26 -0
- data/test/projected_geographic/factory_test.rb +25 -0
- data/test/projected_geographic/geometry_collection_test.rb +24 -0
- data/test/projected_geographic/line_string_test.rb +24 -0
- data/test/projected_geographic/multi_line_string_test.rb +26 -0
- data/test/projected_geographic/multi_point_test.rb +30 -0
- data/test/projected_geographic/multi_polygon_test.rb +25 -0
- data/test/projected_geographic/point_test.rb +51 -0
- data/test/projected_geographic/polygon_test.rb +24 -0
- data/test/simple_cartesian/calculations_test.rb +99 -0
- data/test/simple_cartesian/factory_test.rb +27 -0
- data/test/simple_cartesian/geometry_collection_test.rb +30 -0
- data/test/simple_cartesian/line_string_test.rb +31 -0
- data/test/simple_cartesian/multi_line_string_test.rb +28 -0
- data/test/simple_cartesian/multi_point_test.rb +31 -0
- data/test/simple_cartesian/multi_polygon_test.rb +31 -0
- data/test/simple_cartesian/point_test.rb +50 -0
- data/test/simple_cartesian/polygon_test.rb +28 -0
- data/test/simple_mercator/factory_test.rb +25 -0
- data/test/simple_mercator/geometry_collection_test.rb +24 -0
- data/test/simple_mercator/line_string_test.rb +24 -0
- data/test/simple_mercator/multi_line_string_test.rb +26 -0
- data/test/simple_mercator/multi_point_test.rb +29 -0
- data/test/simple_mercator/multi_polygon_test.rb +25 -0
- data/test/simple_mercator/point_test.rb +55 -0
- data/test/simple_mercator/polygon_test.rb +24 -0
- data/test/simple_mercator/window_test.rb +173 -0
- data/test/spherical_geographic/calculations_test.rb +167 -0
- data/test/spherical_geographic/factory_test.rb +27 -0
- data/test/spherical_geographic/geometry_collection_test.rb +31 -0
- data/test/spherical_geographic/line_string_test.rb +31 -0
- data/test/spherical_geographic/multi_line_string_test.rb +29 -0
- data/test/spherical_geographic/multi_point_test.rb +31 -0
- data/test/spherical_geographic/multi_polygon_test.rb +31 -0
- data/test/spherical_geographic/point_test.rb +78 -0
- data/test/spherical_geographic/polygon_test.rb +28 -0
- data/test/types_test.rb +42 -0
- data/test/wkrep/wkb_generator_test.rb +185 -0
- data/test/wkrep/wkb_parser_test.rb +293 -0
- data/test/wkrep/wkt_generator_test.rb +294 -0
- data/test/wkrep/wkt_parser_test.rb +412 -0
- metadata +386 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# Curve feature interface
|
|
4
|
+
#
|
|
5
|
+
# -----------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
module RGeo
|
|
8
|
+
module Feature
|
|
9
|
+
# == SFS 1.1 Description
|
|
10
|
+
#
|
|
11
|
+
# A Curve is a 1-dimensional geometric object usually stored as a
|
|
12
|
+
# sequence of Points, with the subtype of Curve specifying the form of
|
|
13
|
+
# the interpolation between Points. This part of ISO 19125 defines only
|
|
14
|
+
# one subclass of Curve, LineString, which uses linear interpolation
|
|
15
|
+
# between Points.
|
|
16
|
+
#
|
|
17
|
+
# A Curve is a 1-dimensional geometric object that is the homeomorphic
|
|
18
|
+
# image of a real, closed interval D=[a,b] under a mapping f:[a,b]->R2.
|
|
19
|
+
#
|
|
20
|
+
# A Curve is simple if it does not pass through the same Point twice.
|
|
21
|
+
#
|
|
22
|
+
# A Curve is closed if its start Point is equal to its end Point.
|
|
23
|
+
#
|
|
24
|
+
# The boundary of a closed Curve is empty.
|
|
25
|
+
#
|
|
26
|
+
# A Curve that is simple and closed is a Ring.
|
|
27
|
+
#
|
|
28
|
+
# The boundary of a non-closed Curve consists of its two end Points.
|
|
29
|
+
#
|
|
30
|
+
# A Curve is defined as topologically closed.
|
|
31
|
+
#
|
|
32
|
+
# == Notes
|
|
33
|
+
#
|
|
34
|
+
# Curve is defined as a module and is provided primarily
|
|
35
|
+
# for the sake of documentation. Implementations need not necessarily
|
|
36
|
+
# include this module itself. Therefore, you should not depend on the
|
|
37
|
+
# kind_of? method to check type. Instead, use the provided check_type
|
|
38
|
+
# class method (or === operator) defined in the Type module.
|
|
39
|
+
#
|
|
40
|
+
# Some implementations may support higher dimensional points.
|
|
41
|
+
|
|
42
|
+
module Curve
|
|
43
|
+
include Geometry
|
|
44
|
+
extend Type
|
|
45
|
+
|
|
46
|
+
# === SFS 1.1 Description
|
|
47
|
+
#
|
|
48
|
+
# The length of this Curve in its associated spatial reference.
|
|
49
|
+
#
|
|
50
|
+
# === Notes
|
|
51
|
+
#
|
|
52
|
+
# Returns a floating-point scalar value.
|
|
53
|
+
|
|
54
|
+
def length
|
|
55
|
+
raise Error::UnsupportedOperation, "Method Curve#length not defined."
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# === SFS 1.1 Description
|
|
59
|
+
#
|
|
60
|
+
# The start Point of this Curve.
|
|
61
|
+
#
|
|
62
|
+
# === Notes
|
|
63
|
+
#
|
|
64
|
+
# Returns an object that supports the Point interface.
|
|
65
|
+
|
|
66
|
+
def start_point
|
|
67
|
+
raise Error::UnsupportedOperation, "Method Curve#start_point not defined."
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# === SFS 1.1 Description
|
|
71
|
+
#
|
|
72
|
+
# The end Point of this Curve.
|
|
73
|
+
#
|
|
74
|
+
# === Notes
|
|
75
|
+
#
|
|
76
|
+
# Returns an object that supports the Point interface.
|
|
77
|
+
|
|
78
|
+
def end_point
|
|
79
|
+
raise Error::UnsupportedOperation, "Method Curve#end_point not defined."
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# === SFS 1.1 Description
|
|
83
|
+
#
|
|
84
|
+
# Returns true if this Curve is closed [StartPoint() = EndPoint()].
|
|
85
|
+
#
|
|
86
|
+
# === Notes
|
|
87
|
+
#
|
|
88
|
+
# Returns a boolean value. Note that this is different from the SFS
|
|
89
|
+
# specification, which stipulates an integer return value.
|
|
90
|
+
|
|
91
|
+
def is_closed?
|
|
92
|
+
raise Error::UnsupportedOperation, "Method Curve#is_closed? not defined."
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# === SFS 1.1 Description
|
|
96
|
+
#
|
|
97
|
+
# Returns true if this Curve is closed [StartPoint() = EndPoint()]
|
|
98
|
+
# and this Curve is simple (does not pass through the same Point
|
|
99
|
+
# more than once).
|
|
100
|
+
#
|
|
101
|
+
# === Notes
|
|
102
|
+
#
|
|
103
|
+
# Returns a boolean value. Note that this is different from the SFS
|
|
104
|
+
# specification, which stipulates an integer return value.
|
|
105
|
+
|
|
106
|
+
def is_ring?
|
|
107
|
+
raise Error::UnsupportedOperation, "Method Curve#is_ring? not defined."
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# Feature factory interface
|
|
4
|
+
#
|
|
5
|
+
# -----------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
module RGeo
|
|
8
|
+
module Feature
|
|
9
|
+
# This is a standard interface for factories of features.
|
|
10
|
+
# Generally, each Feature implementation will implement these
|
|
11
|
+
# methods as a standard way to create features.
|
|
12
|
+
#
|
|
13
|
+
# If the implementation is unable to create the given feature,
|
|
14
|
+
# it should generally return nil. Implementations may also choose to
|
|
15
|
+
# raise an exception on failure.
|
|
16
|
+
#
|
|
17
|
+
# Some implementations may extend this interface to provide facilities
|
|
18
|
+
# for creating additional objects according to the capabilities
|
|
19
|
+
# provided by that implementation. Examples might include
|
|
20
|
+
# higher-dimensional coordinates or additional subclasses not
|
|
21
|
+
# explicitly required by the Simple Features Specification.
|
|
22
|
+
#
|
|
23
|
+
# Factory is defined as a module and is provided primarily for the
|
|
24
|
+
# sake of documentation. Implementations need not necessarily include
|
|
25
|
+
# this module itself. Therefore, you should not depend on the result
|
|
26
|
+
# of <tt>is_a?(Factory)</tt> to check type. However, to support
|
|
27
|
+
# testing for factory-ness, the <tt>Factory::Instance</tt> submodule
|
|
28
|
+
# is provided. All factory implementation classes MUST include
|
|
29
|
+
# <tt>Factory::Instance</tt>, and you may use it in <tt>is_a?</tt>,
|
|
30
|
+
# <tt>===</tt>, and case-when constructs.
|
|
31
|
+
|
|
32
|
+
module Factory
|
|
33
|
+
# All factory implementations MUST include this submodule.
|
|
34
|
+
# This serves as a marker that may be used to test an object for
|
|
35
|
+
# factory-ness.
|
|
36
|
+
|
|
37
|
+
module Instance
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Returns meta-information about this factory, by key. This
|
|
41
|
+
# information may involve support for optional functionality,
|
|
42
|
+
# properties of the coordinate system, or other characteristics.
|
|
43
|
+
#
|
|
44
|
+
# Each property has a symbolic name. Names that have no periods are
|
|
45
|
+
# considered well-known names and are reserved for use by RGeo. If
|
|
46
|
+
# you want to define your own properties, use a name that is
|
|
47
|
+
# namespaced with periods, such as <tt>:'mycompany.myprop'</tt>.
|
|
48
|
+
#
|
|
49
|
+
# Property values are dependent on the individual property.
|
|
50
|
+
# Generally, properties that involve testing for functionality
|
|
51
|
+
# should return true if the functionality is support, or false or
|
|
52
|
+
# nil if not. A property value could also invlove different values
|
|
53
|
+
# indicating different levels of support. In any case, the factory
|
|
54
|
+
# should return nil for property names it does not recognize. This
|
|
55
|
+
# value is considered the "default" or "no value" value.
|
|
56
|
+
#
|
|
57
|
+
# Currently defined well-known properties are:
|
|
58
|
+
#
|
|
59
|
+
# [<tt>:has_z_coordinate</tt>]
|
|
60
|
+
# Set to true if geometries created by this factory include a Z
|
|
61
|
+
# coordinate, and the Point#z method is available.
|
|
62
|
+
# [<tt>:has_m_coordinate</tt>]
|
|
63
|
+
# Set to true if geometries created by this factory include a M
|
|
64
|
+
# coordinate, and the Point#m method is available.
|
|
65
|
+
# [<tt>:is_cartesian</tt>]
|
|
66
|
+
# Set to true if this Factory guarantees that it operates in
|
|
67
|
+
# Cartesian geometry. If false or nil, no such guarantee is made,
|
|
68
|
+
# though it is possible the geometries may still be Cartesian.
|
|
69
|
+
# [<tt>:is_geographic</tt>]
|
|
70
|
+
# Set to true if this Factory's coordinate system is meant to be
|
|
71
|
+
# interpreted as x=longitude and y=latitude. If false or nil, no
|
|
72
|
+
# information is present about whether the coordinate system is
|
|
73
|
+
# meant to be so interpreted.
|
|
74
|
+
|
|
75
|
+
def property(_name_)
|
|
76
|
+
nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Parse the given string in well-known-text format and return the
|
|
80
|
+
# resulting feature. Returns nil if the string couldn't be parsed.
|
|
81
|
+
|
|
82
|
+
def parse_wkt(_str_)
|
|
83
|
+
nil
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Parse the given string in well-known-binary format and return the
|
|
87
|
+
# resulting feature. Returns nil if the string couldn't be parsed.
|
|
88
|
+
|
|
89
|
+
def parse_wkb(_str_)
|
|
90
|
+
nil
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Create a feature of type Point.
|
|
94
|
+
# The x and y parameters should be Float values.
|
|
95
|
+
#
|
|
96
|
+
# The extra parameters should be the Z and/or M coordinates, if
|
|
97
|
+
# supported. If both Z and M coordinates are supported, Z should
|
|
98
|
+
# be passed first.
|
|
99
|
+
|
|
100
|
+
def point(_x_, _y_, *_extra_)
|
|
101
|
+
nil
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Create a feature of type LineString.
|
|
105
|
+
# The given points argument should be an Enumerable of Point
|
|
106
|
+
# objects, or objects that can be cast to Point.
|
|
107
|
+
#
|
|
108
|
+
# Although implementations are free to attempt to handle input
|
|
109
|
+
# objects that are not of this factory, strictly speaking, the
|
|
110
|
+
# result of building geometries from objects of the wrong factory
|
|
111
|
+
# is undefined.
|
|
112
|
+
|
|
113
|
+
def line_string(_points_)
|
|
114
|
+
nil
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Create a feature of type Line.
|
|
118
|
+
# The given point arguments should be Point objects, or objects
|
|
119
|
+
# that can be cast to Point.
|
|
120
|
+
#
|
|
121
|
+
# Although implementations are free to attempt to handle input
|
|
122
|
+
# objects that are not of this factory, strictly speaking, the
|
|
123
|
+
# result of building geometries from objects of the wrong factory
|
|
124
|
+
# is undefined.
|
|
125
|
+
|
|
126
|
+
def line(_start_, _end_)
|
|
127
|
+
nil
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Create a feature of type LinearRing.
|
|
131
|
+
# The given points argument should be an Enumerable of Point
|
|
132
|
+
# objects, or objects that can be cast to Point.
|
|
133
|
+
# If the first and last points are not equal, the ring is
|
|
134
|
+
# automatically closed by appending the first point to the end of the
|
|
135
|
+
# string.
|
|
136
|
+
#
|
|
137
|
+
# Although implementations are free to attempt to handle input
|
|
138
|
+
# objects that are not of this factory, strictly speaking, the
|
|
139
|
+
# result of building geometries from objects of the wrong factory
|
|
140
|
+
# is undefined.
|
|
141
|
+
|
|
142
|
+
def linear_ring(_points_)
|
|
143
|
+
nil
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Create a feature of type Polygon.
|
|
147
|
+
# The outer_ring should be a LinearRing, or an object that can be
|
|
148
|
+
# cast to LinearRing.
|
|
149
|
+
# The inner_rings should be a possibly empty Enumerable of
|
|
150
|
+
# LinearRing (or objects that can be casted to LinearRing).
|
|
151
|
+
# You may also pass nil to indicate no inner rings.
|
|
152
|
+
#
|
|
153
|
+
# Although implementations are free to attempt to handle input
|
|
154
|
+
# objects that are not of this factory, strictly speaking, the
|
|
155
|
+
# result of building geometries from objects of the wrong factory
|
|
156
|
+
# is undefined.
|
|
157
|
+
|
|
158
|
+
def polygon(_outer_ring_, _inner_rings_ = nil)
|
|
159
|
+
nil
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Create a feature of type GeometryCollection.
|
|
163
|
+
# The elems should be an Enumerable of Geometry objects.
|
|
164
|
+
#
|
|
165
|
+
# Although implementations are free to attempt to handle input
|
|
166
|
+
# objects that are not of this factory, strictly speaking, the
|
|
167
|
+
# result of building geometries from objects of the wrong factory
|
|
168
|
+
# is undefined.
|
|
169
|
+
|
|
170
|
+
def collection(_elems_)
|
|
171
|
+
nil
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Create a feature of type MultiPoint.
|
|
175
|
+
# The elems should be an Enumerable of Point objects, or objects
|
|
176
|
+
# that can be cast to Point.
|
|
177
|
+
# Returns nil if any of the contained geometries is not a Point,
|
|
178
|
+
# which would break the MultiPoint contract.
|
|
179
|
+
#
|
|
180
|
+
# Although implementations are free to attempt to handle input
|
|
181
|
+
# objects that are not of this factory, strictly speaking, the
|
|
182
|
+
# result of building geometries from objects of the wrong factory
|
|
183
|
+
# is undefined.
|
|
184
|
+
|
|
185
|
+
def multi_point(_elems_)
|
|
186
|
+
nil
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Create a feature of type MultiLineString.
|
|
190
|
+
# The elems should be an Enumerable of objects that are or can be
|
|
191
|
+
# cast to LineString or any of its subclasses.
|
|
192
|
+
# Returns nil if any of the contained geometries is not a
|
|
193
|
+
# LineString, which would break the MultiLineString contract.
|
|
194
|
+
#
|
|
195
|
+
# Although implementations are free to attempt to handle input
|
|
196
|
+
# objects that are not of this factory, strictly speaking, the
|
|
197
|
+
# result of building geometries from objects of the wrong factory
|
|
198
|
+
# is undefined.
|
|
199
|
+
|
|
200
|
+
def multi_line_string(_elems_)
|
|
201
|
+
nil
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Create a feature of type MultiPolygon.
|
|
205
|
+
# The elems should be an Enumerable of objects that are or can be
|
|
206
|
+
# cast to Polygon or any of its subclasses.
|
|
207
|
+
# Returns nil if any of the contained geometries is not a Polygon,
|
|
208
|
+
# which would break the MultiPolygon contract.
|
|
209
|
+
# Also returns nil if any of the other assertions for MultiPolygon
|
|
210
|
+
# are not met, e.g. if any of the polygons overlap.
|
|
211
|
+
#
|
|
212
|
+
# Although implementations are free to attempt to handle input
|
|
213
|
+
# objects that are not of this factory, strictly speaking, the
|
|
214
|
+
# result of building geometries from objects of the wrong factory
|
|
215
|
+
# is undefined.
|
|
216
|
+
|
|
217
|
+
def multi_polygon(_elems_)
|
|
218
|
+
nil
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# Returns a RGeo::CoordSys::Proj4 representing the projection for
|
|
222
|
+
# the coordinate system of features created by this factory, or nil
|
|
223
|
+
# if there is no such proj4 projection.
|
|
224
|
+
|
|
225
|
+
def proj4
|
|
226
|
+
nil
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Returns the coordinate system specification for the features
|
|
230
|
+
# created by this factory, or nil if there is no such coordinate
|
|
231
|
+
# system.
|
|
232
|
+
#
|
|
233
|
+
# NOTE: This is a required method of the factory interface, but the
|
|
234
|
+
# coordinate system classes themselves are not yet available, so
|
|
235
|
+
# implementations should just return nil for now.
|
|
236
|
+
|
|
237
|
+
def coord_sys
|
|
238
|
+
nil
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# This is an optional method that may be implemented to customize
|
|
242
|
+
# casting for this factory. Basically, RGeo defines standard ways
|
|
243
|
+
# to cast certain types of objects from one factory to another and
|
|
244
|
+
# one SFS type to another. However, a factory may choose to
|
|
245
|
+
# override how things are casted TO its implementation using this
|
|
246
|
+
# method. It can do this to optimize certain casting cases, or
|
|
247
|
+
# implement special cases particular to this factory.
|
|
248
|
+
#
|
|
249
|
+
# This method will be called (if defined) on the destination
|
|
250
|
+
# factory, and will be passed the original object (which may or may
|
|
251
|
+
# not already be created by this factory), the SFS feature type
|
|
252
|
+
# (which again may or may not already be the type of the original
|
|
253
|
+
# object), and a hash of additional flags. These flags are:
|
|
254
|
+
#
|
|
255
|
+
# [<tt>:keep_subtype</tt>]
|
|
256
|
+
# indicates whether to keep the subtype if casting to a supertype
|
|
257
|
+
# of the current type
|
|
258
|
+
# [<tt>:force_new</tt>]
|
|
259
|
+
# indicates whether to force the creation of a new object even if
|
|
260
|
+
# the original is already of the desired factory and type
|
|
261
|
+
# [<tt>:project</tt>]
|
|
262
|
+
# indicates whether to project the coordinates from the source to
|
|
263
|
+
# the destination proj4 coordinate system, if available
|
|
264
|
+
#
|
|
265
|
+
# It should return either a casted result object, false, or nil.
|
|
266
|
+
# A nil return value indicates that casting should be forced to
|
|
267
|
+
# fail (and RGeo::Feature.cast will return nil).
|
|
268
|
+
# A false return value indicates that this method declines to
|
|
269
|
+
# override the casting algorithm, and RGeo should use its default
|
|
270
|
+
# algorithm to cast the object. Therefore, by default, you should
|
|
271
|
+
# return false.
|
|
272
|
+
|
|
273
|
+
def override_cast(_original_, _type_, _flags_)
|
|
274
|
+
false
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# Feature factory interface
|
|
4
|
+
#
|
|
5
|
+
# -----------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
module RGeo
|
|
8
|
+
module Feature
|
|
9
|
+
# A FactoryGenerator is a callable object (usually a Proc) that
|
|
10
|
+
# takes a configuration as a hash and returns a factory. These are
|
|
11
|
+
# often used, e.g., by parsers to determine what factory the parsed
|
|
12
|
+
# geometry should have.
|
|
13
|
+
#
|
|
14
|
+
# See the call method for a list of common configuration parameters.
|
|
15
|
+
# Different generators will support different parameters. There is
|
|
16
|
+
# no mechanism defined to reflect on the parameters understood by a
|
|
17
|
+
# factory generator.
|
|
18
|
+
#
|
|
19
|
+
# Many of the implementations provide a factory method for creating
|
|
20
|
+
# factories. For example, RGeo::Cartesian.preferred_factory can be
|
|
21
|
+
# called to create a factory using the preferred Cartesian
|
|
22
|
+
# implementation. Thus, to get a corresponding factory generator,
|
|
23
|
+
# you can use the <tt>method</tt> method. e.g.
|
|
24
|
+
#
|
|
25
|
+
# factory_generator = ::RGeo::Cartesian.method(:preferred_factory)
|
|
26
|
+
#
|
|
27
|
+
# FactoryGenerator is defined as a module and is provided
|
|
28
|
+
# primarily for the sake of documentation. Implementations need not
|
|
29
|
+
# necessarily include this module itself. Therefore, you should not
|
|
30
|
+
# depend on the kind_of? method to determine if an object is a
|
|
31
|
+
# factory generator.
|
|
32
|
+
|
|
33
|
+
module FactoryGenerator
|
|
34
|
+
# Generate a factory given a configuration as a hash.
|
|
35
|
+
#
|
|
36
|
+
# If the generator does not recognize or does not support a given
|
|
37
|
+
# configuration value, the behavior is usually determined by the
|
|
38
|
+
# <tt>:strict</tt> configuration element. If <tt>strict</tt> is
|
|
39
|
+
# set to true, the generator should fail fast by returning nil or
|
|
40
|
+
# raising an exception. If it is set to false, the generator should
|
|
41
|
+
# attempt to do the best it can, even if it means returning a
|
|
42
|
+
# factory that does not match the requested configuration.
|
|
43
|
+
#
|
|
44
|
+
# Common parameters are as follows. These are intended as a
|
|
45
|
+
# recommendation only. There is no hard requirement for any
|
|
46
|
+
# particular factory generator to support them.
|
|
47
|
+
#
|
|
48
|
+
# [<tt>:strict</tt>]
|
|
49
|
+
# If true, return nil or raise an exception if any configuration
|
|
50
|
+
# was not recognized or not supportable. Otherwise, if false,
|
|
51
|
+
# the generator should attempt to do its best to return some
|
|
52
|
+
# viable factory, even if it does not strictly match the
|
|
53
|
+
# requested configuration. Default is usually false.
|
|
54
|
+
# [<tt>:srid</tt>]
|
|
55
|
+
# The SRID for the factory and objects it creates.
|
|
56
|
+
# Default is usually 0.
|
|
57
|
+
# [<tt>:proj4</tt>]
|
|
58
|
+
# The coordinate system in Proj4 format, either as a
|
|
59
|
+
# CoordSys::Proj4 object or as a string or hash representing the
|
|
60
|
+
# proj4 format. This is usually an optional parameter; the default
|
|
61
|
+
# is usually nil.
|
|
62
|
+
# [<tt>:coord_sys</tt>]
|
|
63
|
+
# The coordinate system in OGC form, either as a subclass of
|
|
64
|
+
# CoordSys::CS::CoordinateSystem, or as a string in WKT format.
|
|
65
|
+
# This is usually an optional parameter; the default is usually
|
|
66
|
+
# nil.
|
|
67
|
+
# [<tt>:srs_database</tt>]
|
|
68
|
+
# If provided, look up the Proj4 and OGC coordinate systems from
|
|
69
|
+
# the given database and SRID.
|
|
70
|
+
# [<tt>:has_z_coordinate</tt>]
|
|
71
|
+
# Support Z coordinates. Default is usually false.
|
|
72
|
+
# [<tt>:has_m_coordinate</tt>]
|
|
73
|
+
# Support M coordinates. Default is usually false.
|
|
74
|
+
|
|
75
|
+
def call(_config_ = {})
|
|
76
|
+
nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Return a new FactoryGenerator that always returns the given
|
|
80
|
+
# factory.
|
|
81
|
+
|
|
82
|
+
def self.single(factory_)
|
|
83
|
+
::Proc.new { |_c_| factory_ }
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Return a new FactoryGenerator that calls the given delegate, but
|
|
87
|
+
# modifies the configuration passed to it. You can provide defaults
|
|
88
|
+
# for configuration values not explicitly specified, and you can
|
|
89
|
+
# force certain values to override the given configuration.
|
|
90
|
+
|
|
91
|
+
def self.decorate(delegate_, default_config_ = {}, force_config_ = {})
|
|
92
|
+
::Proc.new { |c_| delegate_.call(default_config_.merge(c_).merge(force_config_)) }
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|