Class: GeoRuby::SimpleFeatures::UnpackStructure
- Inherits:
-
Object
- Object
- GeoRuby::SimpleFeatures::UnpackStructure
- Defined in:
- lib/geo_ruby/simple_features/ewkb_parser.rb
Overview
:nodoc:
Constant Summary collapse
- NDR =
1
- XDR =
0
Instance Method Summary collapse
- #done ⇒ Object
- #endianness=(byte_order) ⇒ Object
-
#initialize(ewkb) ⇒ UnpackStructure
constructor
A new instance of UnpackStructure.
- #read_byte ⇒ Object
- #read_double ⇒ Object
- #read_uint ⇒ Object
Constructor Details
#initialize(ewkb) ⇒ UnpackStructure
Returns a new instance of UnpackStructure.
177 178 179 180 |
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 177 def initialize(ewkb) @position=0 @ewkb=ewkb end |
Instance Method Details
#done ⇒ Object
181 182 183 |
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 181 def done raise EWKBFormatError::new("Trailing data") if @position != @ewkb.length end |
#endianness=(byte_order) ⇒ Object
205 206 207 208 209 210 211 212 213 |
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 205 def endianness=(byte_order) if(byte_order == NDR) @uint_mark="V" @double_mark="E" elsif(byte_order == XDR) @uint_mark="N" @double_mark="G" end end |
#read_byte ⇒ Object
198 199 200 201 202 203 204 |
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 198 def read_byte i = @position @position += 1 packed_byte = @ewkb[i...@position] raise EWKBFormatError::new("Truncated data") if packed_byte.nil? or packed_byte.length < 1 packed_byte.unpack("C")[0] end |
#read_double ⇒ Object
184 185 186 187 188 189 190 |
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 184 def read_double i=@position @position += 8 packed_double = @ewkb[i...@position] raise EWKBFormatError::new("Truncated data") if packed_double.nil? or packed_double.length < 8 packed_double.unpack(@double_mark)[0] end |
#read_uint ⇒ Object
191 192 193 194 195 196 197 |
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 191 def read_uint i=@position @position += 4 packed_uint = @ewkb[i...@position] raise EWKBFormatError::new("Truncated data") if packed_uint.nil? or packed_uint.length < 4 packed_uint.unpack(@uint_mark)[0] end |