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
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Well-known binary generator 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,24 +35,24 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module RGeo
|
38
|
-
|
38
|
+
|
39
39
|
module WKRep
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
# This class provides the functionality of serializing a geometry as
|
43
43
|
# WKB (well-known binary) format. You may also customize the
|
44
44
|
# serializer to generate PostGIS EWKB extensions to the output, or to
|
45
45
|
# follow the Simple Features Specification 1.2 extensions for Z and M
|
46
46
|
# coordinates.
|
47
|
-
#
|
47
|
+
#
|
48
48
|
# To use this class, create an instance with the desired settings and
|
49
49
|
# customizations, and call the generate method.
|
50
|
-
#
|
50
|
+
#
|
51
51
|
# === Configuration options
|
52
|
-
#
|
52
|
+
#
|
53
53
|
# The following options are recognized. These can be passed to the
|
54
54
|
# constructor, or set on the object afterwards.
|
55
|
-
#
|
55
|
+
#
|
56
56
|
# [<tt>:type_format</tt>]
|
57
57
|
# The format for type codes. Possible values are <tt>:wkb11</tt>,
|
58
58
|
# indicating SFS 1.1 WKB (i.e. no Z or M values); <tt>:ewkb</tt>,
|
@@ -70,10 +70,10 @@ module RGeo
|
|
70
70
|
# [<tt>:little_endian</tt>]
|
71
71
|
# If true, output little endian (NDR) byte order. If false, output
|
72
72
|
# big endian (XDR), or network byte order. Default is false.
|
73
|
-
|
73
|
+
|
74
74
|
class WKBGenerator
|
75
|
-
|
76
|
-
|
75
|
+
|
76
|
+
|
77
77
|
# :stopdoc:
|
78
78
|
TYPE_CODES = {
|
79
79
|
Feature::Point => 1,
|
@@ -87,42 +87,42 @@ module RGeo
|
|
87
87
|
Feature::GeometryCollection => 7,
|
88
88
|
}.freeze
|
89
89
|
# :startdoc:
|
90
|
-
|
91
|
-
|
90
|
+
|
91
|
+
|
92
92
|
# Create and configure a WKB generator. See the WKBGenerator
|
93
93
|
# documentation for the options that can be passed.
|
94
|
-
|
94
|
+
|
95
95
|
def initialize(opts_={})
|
96
96
|
@type_format = opts_[:type_format] || :wkb11
|
97
97
|
@emit_ewkb_srid = opts_[:emit_ewkb_srid] ? true : false if @type_format == :ewkb
|
98
98
|
@hex_format = opts_[:hex_format] ? true : false
|
99
99
|
@little_endian = opts_[:little_endian] ? true : false
|
100
100
|
end
|
101
|
-
|
102
|
-
|
101
|
+
|
102
|
+
|
103
103
|
# Returns the format for type codes. See WKBGenerator for details.
|
104
104
|
def type_format
|
105
105
|
@type_format
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
# Returns whether SRID is embedded. See WKBGenerator for details.
|
109
109
|
def emit_ewkb_srid?
|
110
110
|
@emit_ewkb_srid
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
# Returns whether output is converted to hex.
|
114
114
|
# See WKBGenerator for details.
|
115
115
|
def hex_format?
|
116
116
|
@hex_format
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
# Returns whether output is little-endian (NDR).
|
120
120
|
# See WKBGenerator for details.
|
121
121
|
def little_endian?
|
122
122
|
@little_endian
|
123
123
|
end
|
124
|
-
|
125
|
-
|
124
|
+
|
125
|
+
|
126
126
|
def _properties # :nodoc:
|
127
127
|
{
|
128
128
|
:type_format => @type_format,
|
@@ -131,11 +131,11 @@ module RGeo
|
|
131
131
|
:little_endian => @little_endian,
|
132
132
|
}
|
133
133
|
end
|
134
|
-
|
135
|
-
|
134
|
+
|
135
|
+
|
136
136
|
# Generate and return the WKB format for the given geometry object,
|
137
137
|
# according to the current settings.
|
138
|
-
|
138
|
+
|
139
139
|
def generate(obj_)
|
140
140
|
factory_ = obj_.factory
|
141
141
|
if @type_format == :ewkb || @type_format == :wkb12
|
@@ -150,8 +150,8 @@ module RGeo
|
|
150
150
|
_generate_feature(obj_, true)
|
151
151
|
_finish_emitter
|
152
152
|
end
|
153
|
-
|
154
|
-
|
153
|
+
|
154
|
+
|
155
155
|
def _generate_feature(obj_, toplevel_=false) # :nodoc:
|
156
156
|
_emit_byte(@little_endian ? 1 : 0)
|
157
157
|
type_ = obj_.geometry_type
|
@@ -200,8 +200,8 @@ module RGeo
|
|
200
200
|
obj_.each{ |g_| _generate_feature(g_) }
|
201
201
|
end
|
202
202
|
end
|
203
|
-
|
204
|
-
|
203
|
+
|
204
|
+
|
205
205
|
def _point_coords(obj_, array_=[]) # :nodoc:
|
206
206
|
array_ << obj_.x
|
207
207
|
array_ << obj_.y
|
@@ -209,46 +209,46 @@ module RGeo
|
|
209
209
|
array_ << obj_.m if @cur_has_m
|
210
210
|
array_
|
211
211
|
end
|
212
|
-
|
213
|
-
|
212
|
+
|
213
|
+
|
214
214
|
def _emit_line_string_coords(obj_) # :nodoc:
|
215
215
|
array_ = []
|
216
216
|
obj_.points.each{ |p_| _point_coords(p_, array_) }
|
217
217
|
_emit_integer(obj_.num_points)
|
218
218
|
_emit_doubles(array_)
|
219
219
|
end
|
220
|
-
|
221
|
-
|
220
|
+
|
221
|
+
|
222
222
|
def _start_emitter # :nodoc:
|
223
223
|
@cur_array = []
|
224
224
|
end
|
225
|
-
|
226
|
-
|
225
|
+
|
226
|
+
|
227
227
|
def _emit_byte(value_) # :nodoc:
|
228
228
|
@cur_array << [value_].pack("C")
|
229
229
|
end
|
230
|
-
|
231
|
-
|
230
|
+
|
231
|
+
|
232
232
|
def _emit_integer(value_) # :nodoc:
|
233
233
|
@cur_array << [value_].pack(@little_endian ? 'V' : 'N')
|
234
234
|
end
|
235
|
-
|
236
|
-
|
235
|
+
|
236
|
+
|
237
237
|
def _emit_doubles(array_) # :nodoc:
|
238
238
|
@cur_array << array_.pack(@little_endian ? 'E*' : 'G*')
|
239
239
|
end
|
240
|
-
|
241
|
-
|
240
|
+
|
241
|
+
|
242
242
|
def _finish_emitter # :nodoc:
|
243
243
|
str_ = @cur_array.join
|
244
244
|
@cur_array = nil
|
245
245
|
@hex_format ? str_.unpack("H*")[0] : str_
|
246
246
|
end
|
247
|
-
|
248
|
-
|
247
|
+
|
248
|
+
|
249
249
|
end
|
250
|
-
|
251
|
-
|
250
|
+
|
251
|
+
|
252
252
|
end
|
253
|
-
|
253
|
+
|
254
254
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Well-known binary parser 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
|
-
|
38
|
+
|
39
39
|
module WKRep
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
# This class provides the functionality of parsing a geometry from
|
43
43
|
# WKB (well-known binary) format. You may also customize the parser
|
44
44
|
# to recognize PostGIS EWKB extensions to the input, or Simple
|
45
45
|
# Features Specification 1.2 extensions for Z and M coordinates.
|
46
|
-
#
|
46
|
+
#
|
47
47
|
# To use this class, create an instance with the desired settings and
|
48
48
|
# customizations, and call the parse method.
|
49
|
-
#
|
49
|
+
#
|
50
50
|
# === Configuration options
|
51
|
-
#
|
51
|
+
#
|
52
52
|
# You must provide each parser with an RGeo::Feature::FactoryGenerator.
|
53
53
|
# It should understand the configuration options <tt>:srid</tt>,
|
54
54
|
# <tt>:has_z_coordinate</tt>, and <tt>:has_m_coordinate</tt>.
|
55
55
|
# You may also pass a specific RGeo::Feature::Factory, or nil to
|
56
56
|
# specify the default Cartesian FactoryGenerator.
|
57
|
-
#
|
57
|
+
#
|
58
58
|
# The following additional options are recognized. These can be passed
|
59
59
|
# to the constructor, or set on the object afterwards.
|
60
|
-
#
|
60
|
+
#
|
61
61
|
# [<tt>:support_ewkb</tt>]
|
62
62
|
# Activate support for PostGIS EWKB type codes, which use high
|
63
63
|
# order bits in the type code to signal the presence of Z, M, and
|
@@ -73,13 +73,13 @@ module RGeo
|
|
73
73
|
# [<tt>:default_srid</tt>]
|
74
74
|
# A SRID to pass to the factory generator if no SRID is present in
|
75
75
|
# the input. Defaults to nil (i.e. don't specify a SRID).
|
76
|
-
|
76
|
+
|
77
77
|
class WKBParser
|
78
|
-
|
79
|
-
|
78
|
+
|
79
|
+
|
80
80
|
# Create and configure a WKB parser. See the WKBParser
|
81
81
|
# documentation for the options that can be passed.
|
82
|
-
|
82
|
+
|
83
83
|
def initialize(factory_generator_=nil, opts_={})
|
84
84
|
if factory_generator_.kind_of?(Feature::Factory::Instance)
|
85
85
|
@factory_generator = Feature::FactoryGenerator.single(factory_generator_)
|
@@ -96,38 +96,38 @@ module RGeo
|
|
96
96
|
@ignore_extra_bytes = opts_[:ignore_extra_bytes] ? true : false
|
97
97
|
@default_srid = opts_[:default_srid]
|
98
98
|
end
|
99
|
-
|
100
|
-
|
99
|
+
|
100
|
+
|
101
101
|
# Returns the factory generator. See WKBParser for details.
|
102
102
|
def factory_generator
|
103
103
|
@factory_generator
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
# If this parser was given an exact factory, returns it; otherwise
|
107
107
|
# returns nil.
|
108
108
|
def exact_factory
|
109
109
|
@exact_factory
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
# Returns true if this parser supports EWKB.
|
113
113
|
# See WKBParser for details.
|
114
114
|
def support_ewkb?
|
115
115
|
@support_ewkb
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
# Returns true if this parser supports SFS 1.2 extensions.
|
119
119
|
# See WKBParser for details.
|
120
120
|
def support_wkb12?
|
121
121
|
@support_wkb12
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
# Returns true if this parser ignores extra bytes.
|
125
125
|
# See WKBParser for details.
|
126
126
|
def ignore_extra_bytes?
|
127
127
|
@ignore_extra_bytes
|
128
128
|
end
|
129
|
-
|
130
|
-
|
129
|
+
|
130
|
+
|
131
131
|
def _properties # :nodoc:
|
132
132
|
{
|
133
133
|
:support_ewkb => @support_ewkb,
|
@@ -136,14 +136,14 @@ module RGeo
|
|
136
136
|
:default_srid => @default_srid,
|
137
137
|
}
|
138
138
|
end
|
139
|
-
|
140
|
-
|
139
|
+
|
140
|
+
|
141
141
|
# Parse the given binary data or hexadecimal string, and return a
|
142
142
|
# geometry object.
|
143
|
-
#
|
143
|
+
#
|
144
144
|
# The #parse_hex method is a synonym, present for historical
|
145
145
|
# reasons but deprecated. Use #parse instead.
|
146
|
-
|
146
|
+
|
147
147
|
def parse(data_)
|
148
148
|
if data_[0,1] =~ /[0-9a-fA-F]/
|
149
149
|
data_ = [data_].pack('H*')
|
@@ -168,8 +168,8 @@ module RGeo
|
|
168
168
|
obj_
|
169
169
|
end
|
170
170
|
alias_method :parse_hex, :parse
|
171
|
-
|
172
|
-
|
171
|
+
|
172
|
+
|
173
173
|
def _parse_object(contained_) # :nodoc:
|
174
174
|
endian_value_ = _get_byte
|
175
175
|
case endian_value_
|
@@ -243,32 +243,32 @@ module RGeo
|
|
243
243
|
raise Error::ParseError, "Unknown type value: #{type_code_}."
|
244
244
|
end
|
245
245
|
end
|
246
|
-
|
247
|
-
|
246
|
+
|
247
|
+
|
248
248
|
def _parse_line_string(little_endian_) # :nodoc:
|
249
249
|
count_ = _get_integer(little_endian_)
|
250
250
|
coords_ = _get_doubles(little_endian_, @cur_dims * count_)
|
251
251
|
@cur_factory.line_string((0...count_).map{ |i_| @cur_factory.point(*coords_[@cur_dims*i_,@cur_dims]) })
|
252
252
|
end
|
253
|
-
|
254
|
-
|
253
|
+
|
254
|
+
|
255
255
|
def _start_scanner(data_) # :nodoc:
|
256
256
|
@_data = data_
|
257
257
|
@_len = data_.length
|
258
258
|
@_pos = 0
|
259
259
|
end
|
260
|
-
|
261
|
-
|
260
|
+
|
261
|
+
|
262
262
|
def _clean_scanner # :nodoc:
|
263
263
|
@_data = nil
|
264
264
|
end
|
265
|
-
|
266
|
-
|
265
|
+
|
266
|
+
|
267
267
|
def _bytes_remaining # :nodoc:
|
268
268
|
@_len - @_pos
|
269
269
|
end
|
270
|
-
|
271
|
-
|
270
|
+
|
271
|
+
|
272
272
|
def _get_byte # :nodoc:
|
273
273
|
if @_pos + 1 > @_len
|
274
274
|
raise Error::ParseError, "Not enough bytes left to fulfill 1 byte"
|
@@ -277,8 +277,8 @@ module RGeo
|
|
277
277
|
@_pos += 1
|
278
278
|
str_.unpack("C").first
|
279
279
|
end
|
280
|
-
|
281
|
-
|
280
|
+
|
281
|
+
|
282
282
|
def _get_integer(little_endian_) # :nodoc:
|
283
283
|
if @_pos + 4 > @_len
|
284
284
|
raise Error::ParseError, "Not enough bytes left to fulfill 1 integer"
|
@@ -287,8 +287,8 @@ module RGeo
|
|
287
287
|
@_pos += 4
|
288
288
|
str_.unpack("#{little_endian_ ? 'V' : 'N'}").first
|
289
289
|
end
|
290
|
-
|
291
|
-
|
290
|
+
|
291
|
+
|
292
292
|
def _get_doubles(little_endian_, count_) # :nodoc:
|
293
293
|
len_ = 8 * count_
|
294
294
|
if @_pos + len_ > @_len
|
@@ -298,11 +298,11 @@ module RGeo
|
|
298
298
|
@_pos += len_
|
299
299
|
str_.unpack("#{little_endian_ ? 'E' : 'G'}*")
|
300
300
|
end
|
301
|
-
|
302
|
-
|
301
|
+
|
302
|
+
|
303
303
|
end
|
304
|
-
|
305
|
-
|
304
|
+
|
305
|
+
|
306
306
|
end
|
307
|
-
|
307
|
+
|
308
308
|
end
|