Module: Geos::Tools
Constant Summary
Constants included
from GeomTypes
GeomTypes::GEOS_GEOMETRYCOLLECTION, GeomTypes::GEOS_LINEARRING, GeomTypes::GEOS_LINESTRING, GeomTypes::GEOS_MULTILINESTRING, GeomTypes::GEOS_MULTIPOINT, GeomTypes::GEOS_MULTIPOLYGON, GeomTypes::GEOS_POINT, GeomTypes::GEOS_POLYGON
Instance Method Summary
collapse
Instance Method Details
#bool_result(r) ⇒ Object
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/ffi-geos/tools.rb', line 79
def bool_result(r)
case r
when 1
true
when 0
false
else
raise RuntimeError.new("Unexpected boolean result: #{r}")
end
end
|
#cast_geometry_ptr(geom_ptr, options = {}) ⇒ Object
#check_enum_value(enum, value) ⇒ Object
90
91
92
93
|
# File 'lib/ffi-geos/tools.rb', line 90
def check_enum_value(enum, value)
enum[value] or
raise TypeError.new("Couldn't find valid #{enum.tag} value: #{value}")
end
|
#check_geometry(geom) ⇒ Object
50
51
52
|
# File 'lib/ffi-geos/tools.rb', line 50
def check_geometry(geom)
raise TypeError.new("Expected Geos::Geometry") unless geom.is_a?(Geos::Geometry)
end
|
#pick_srid_according_to_policy(srid, policy = Geos.srid_copy_policy) ⇒ Object
69
70
71
72
73
74
75
76
77
|
# File 'lib/ffi-geos/tools.rb', line 69
def pick_srid_according_to_policy(srid, policy = Geos.srid_copy_policy)
policy = Geos.srid_copy_policy_default if policy == :default
if srid != 0 && policy != :zero
srid
else
0
end
end
|
#pick_srid_from_geoms(srid_a, srid_b, policy = Geos.srid_copy_policy) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/ffi-geos/tools.rb', line 54
def pick_srid_from_geoms(srid_a, srid_b, policy = Geos.srid_copy_policy)
policy = Geos.srid_copy_policy_default if policy == :default
case policy
when :zero
0
when :lenient
srid_a
when :strict
raise Geos::MixedSRIDsError.new(srid_a, srid_b)
else
raise ArgumentError.new("Unexpected policy value: #{policy}")
end
end
|
#symbol_for_enum(enum, value) ⇒ Object
95
96
97
98
99
100
101
|
# File 'lib/ffi-geos/tools.rb', line 95
def symbol_for_enum(enum, value)
if value.is_a?(Symbol)
value
else
enum[value]
end
end
|