Class: Geos::GeoJSONReader
- Inherits:
-
Object
- Object
- Geos::GeoJSONReader
- Includes:
- Tools
- Defined in:
- lib/ffi-geos/geojson_reader.rb
Defined Under Namespace
Classes: ParseError
Constant Summary
Constants included from GeomTypes
Geos::GeomTypes::GEOS_GEOMETRYCOLLECTION, Geos::GeomTypes::GEOS_LINEARRING, Geos::GeomTypes::GEOS_LINESTRING, Geos::GeomTypes::GEOS_MULTILINESTRING, Geos::GeomTypes::GEOS_MULTIPOINT, Geos::GeomTypes::GEOS_MULTIPOLYGON, Geos::GeomTypes::GEOS_POINT, Geos::GeomTypes::GEOS_POLYGON
Instance Attribute Summary collapse
-
#ptr ⇒ Object
readonly
Returns the value of attribute ptr.
Class Method Summary collapse
-
.release(ptr) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#initialize(*args) ⇒ GeoJSONReader
constructor
A new instance of GeoJSONReader.
- #read(json, options = {}) ⇒ Object
Methods included from Tools
#bool_result, #bool_to_int, #cast_geometry_ptr, #check_enum_value, #check_geometry, #extract_options!, #pick_srid_according_to_policy, #pick_srid_from_geoms, #symbol_for_enum
Constructor Details
#initialize(*args) ⇒ GeoJSONReader
Returns a new instance of GeoJSONReader.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ffi-geos/geojson_reader.rb', line 12 def initialize(*args) ptr = if args.first.is_a?(FFI::Pointer) args.first else FFIGeos.GEOSGeoJSONReader_create_r(Geos.current_handle_pointer, *args) end @ptr = FFI::AutoPointer.new( ptr, self.class.method(:release) ) end |
Instance Attribute Details
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
7 8 9 |
# File 'lib/ffi-geos/geojson_reader.rb', line 7 def ptr @ptr end |
Class Method Details
.release(ptr) ⇒ Object
:nodoc:
31 32 33 |
# File 'lib/ffi-geos/geojson_reader.rb', line 31 def self.release(ptr) # :nodoc: FFIGeos.GEOSGeoJSONReader_destroy_r(Geos.current_handle_pointer, ptr) end |
Instance Method Details
#read(json, options = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/ffi-geos/geojson_reader.rb', line 25 def read(json, = {}) cast_geometry_ptr(FFIGeos.GEOSGeoJSONReader_readGeometry_r(Geos.current_handle_pointer, ptr, json), srid: [:srid]) rescue Geos::GEOSException => e raise ParseError, e end |