Class: GeoRuby::SimpleFeatures::UnpackStructure

Inherits:
Object
  • Object
show all
Defined in:
lib/geo_ruby/simple_features/ewkb_parser.rb

Overview

:nodoc:

Constant Summary collapse

NDR =
1
XDR =
0

Instance Method Summary collapse

Constructor Details

#initialize(ewkb) ⇒ UnpackStructure

Returns a new instance of UnpackStructure.



170
171
172
173
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 170

def initialize(ewkb)
  @position = 0
  @ewkb = ewkb
end

Instance Method Details

#doneObject

Raises:



175
176
177
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 175

def done
  raise EWKBFormatError::new("Trailing data") if @position != @ewkb.length
end

#endianness=(byte_order) ⇒ Object



207
208
209
210
211
212
213
214
215
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 207

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_byteObject

Raises:



200
201
202
203
204
205
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 200

def read_byte
  i = @position
  @position += 1
  raise EWKBFormatError::new("Truncated data") if @ewkb.length < @position
  @ewkb.unpack("@#{i}C@*").first
end

#read_doubleObject

Raises:



186
187
188
189
190
191
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 186

def read_double
  i = @position
  @position += 8
  raise EWKBFormatError::new("Truncated data") if @ewkb.length < @position
  @ewkb.unpack("@#{i}#@double_mark@*").first
end

#read_pointObject

Raises:



179
180
181
182
183
184
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 179

def read_point
  i = @position
  @position += 16
  raise EWKBFormatError::new("Truncated data") if @ewkb.length < @position
  @ewkb.unpack("@#{i}#@double_mark#@double_mark@*")
end

#read_uintObject

Raises:



193
194
195
196
197
198
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 193

def read_uint
  i = @position
  @position += 4
  raise EWKBFormatError::new("Truncated data") if @ewkb.length < @position
  @ewkb.unpack("@#{i}#@uint_mark@*").first
end