Class: OGR::Geocoder
- Inherits:
-
Object
- Object
- OGR::Geocoder
- Defined in:
- lib/ogr/geocoder.rb
Overview
Geocode things! www.gdal.org/ogr__geocoding_8h.html
Instance Attribute Summary collapse
-
#c_pointer ⇒ FFI::Pointer
readonly
C pointer to the C geocoding session.
Class Method Summary collapse
Instance Method Summary collapse
- #destroy! ⇒ Object
- #geocode(query, **options) ⇒ OGR::Layer?
-
#initialize(**options) ⇒ Geocoder
constructor
A new instance of Geocoder.
- #reverse_geocode(lon, lat, **options) ⇒ OGR::Layer
Constructor Details
#initialize(**options) ⇒ Geocoder
Returns a new instance of Geocoder.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ogr/geocoder.rb', line 38 def initialize(**) = .each_with_object({}) do |(k, v), obj| key = "OGR_GEOCODE_#{k.to_s.upcase}" obj[key] = v end = GDAL::Options.pointer() pointer = FFI::GDAL::GDAL.OGRGeocodeCreateSession() @c_pointer = FFI::AutoPointer.new(pointer, Geocoder.method(:release)) end |
Instance Attribute Details
#c_pointer ⇒ FFI::Pointer (readonly)
Returns C pointer to the C geocoding session.
16 17 18 |
# File 'lib/ogr/geocoder.rb', line 16 def c_pointer @c_pointer end |
Class Method Details
Instance Method Details
#destroy! ⇒ Object
50 51 52 53 54 |
# File 'lib/ogr/geocoder.rb', line 50 def destroy! Geocoder.release(@c_pointer) @c_pointer = nil end |
#geocode(query, **options) ⇒ OGR::Layer?
68 69 70 71 72 73 74 75 |
# File 'lib/ogr/geocoder.rb', line 68 def geocode(query, **) = GDAL::Options.pointer() layer_ptr = FFI::GDAL::GDAL.OGRGeocode(@c_pointer, query, nil, ) return nil if layer_ptr.null? OGR::Layer.new(layer_ptr) end |
#reverse_geocode(lon, lat, **options) ⇒ OGR::Layer
85 86 87 88 89 90 91 92 |
# File 'lib/ogr/geocoder.rb', line 85 def reverse_geocode(lon, lat, **) = GDAL::Options.pointer() layer_ptr = FFI::GDAL::GDAL.OGRGeocodeReverse(@c_pointer, lon, lat, ) return nil if layer_ptr.null? OGR::Layer.new(layer_ptr) end |