Module: Geos

Includes:
GeomTypes, VersionConstants
Defined in:
lib/ffi-geos.rb,
lib/ffi-geos/point.rb,
lib/ffi-geos/tools.rb,
lib/ffi-geos/utils.rb,
lib/ffi-geos/polygon.rb,
lib/ffi-geos/strtree.rb,
lib/ffi-geos/version.rb,
lib/ffi-geos/geometry.rb,
lib/ffi-geos/interrupt.rb,
lib/ffi-geos/wkb_reader.rb,
lib/ffi-geos/wkb_writer.rb,
lib/ffi-geos/wkt_reader.rb,
lib/ffi-geos/wkt_writer.rb,
lib/ffi-geos/line_string.rb,
lib/ffi-geos/linear_ring.rb,
lib/ffi-geos/multi_point.rb,
lib/ffi-geos/buffer_params.rb,
lib/ffi-geos/multi_polygon.rb,
lib/ffi-geos/multi_line_string.rb,
lib/ffi-geos/prepared_geometry.rb,
lib/ffi-geos/coordinate_sequence.rb,
lib/ffi-geos/geometry_collection.rb

Defined Under Namespace

Modules: Constants, FFIGeos, GeomTypes, Interrupt, Tools, Utils, VersionConstants Classes: BufferParams, CoordinateSequence, Error, GEOSException, Geometry, GeometryCollection, Handle, IndexBoundsError, InvalidGeometryError, InvalidGeometryTypeError, LineString, LinearRing, MixedSRIDsError, MultiLineString, MultiPoint, MultiPolygon, NullPointerError, ParseError, Point, Polygon, PreparedGeometry, STRtree, UnexpectedBooleanResultError, WkbReader, WkbWriter, WktReader, WktWriter

Constant Summary collapse

GEOS_BASE =
File.join(File.dirname(__FILE__), 'ffi-geos')
DimensionTypes =
enum(:dimension_type, [
  :dontcare, -3,
  :non_empty, -2,
  :empty, -1,
  :point, 0,
  :curve, 1,
  :surface, 2
])
ByteOrders =
enum(:byte_order, [
  :xdr, 0, # Big Endian
  :ndr, 1 # Little Endian
])
BufferCapStyles =
enum(:buffer_cap_style, [
  :round, 1,
  :flat, 2,
  :square, 3
])
BufferJoinStyles =
enum(:buffer_join_style, [
  :round, 1,
  :mitre, 2,
  :bevel, 3
])
ValidFlags =
enum(:valid_flag, [
  :allow_selftouching_ring_forming_hole, 1
])
RelateBoundaryNodeRules =
enum(:relate_boundary_node_rule, [
  :mod2, 1,
  :ogc, 1,
  :endpoint, 2,
  :multivalent_endpoint, 3,
  :monovalent_endpoint, 4
])
GeometryTypes =
enum(:geometry_type, [
  :point, 0,
  :line_string, 1,
  :linear_ring, 2,
  :polygon, 3,
  :multi_point, 4,
  :multi_line_string, 5,
  :multi_polygon, 6,
  :geometry_collection, 7
])
PrecisionOptions =
enum(:precision_option, [
  :no_topology, 1 << 0,
  :keep_collapsed, 1 << 1
])
VERSION =
'1.2.2'.freeze

Constants included from VersionConstants

VersionConstants::GEOS_CAPI_FIRST_INTERFACE, VersionConstants::GEOS_CAPI_LAST_INTERFACE, VersionConstants::GEOS_JTS_PORT

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

Class Method Summary collapse

Class Method Details

.current_handleObject



1180
1181
1182
# File 'lib/ffi-geos.rb', line 1180

def current_handle
  Thread.current[:ffi_geos_handle] ||= Geos::Handle.new
end

.current_handle_pointerObject



1184
1185
1186
# File 'lib/ffi-geos.rb', line 1184

def current_handle_pointer
  current_handle.ptr
end

.jts_portObject



1176
1177
1178
# File 'lib/ffi-geos.rb', line 1176

def jts_port
  @jts_port ||= FFIGeos.GEOSjtsport
end

.srid_copy_policyObject



1188
1189
1190
# File 'lib/ffi-geos.rb', line 1188

def srid_copy_policy
  Thread.current[:ffi_geos_srid_copy_policy] ||= srid_copy_policy_default
end

.srid_copy_policy=(policy) ⇒ Object

Sets the SRID copying behaviour. This value can be one of the values found in Geos::Constants::SRID_COPY_POLICIES and are local to the current thread. A special value of :default can also be used, which will use a global default that can be set with srid_copy_policy_default=. Setting this value will cause all future threads to use this global default rather than the true default value which is set to :zero for the sake of backwards compatibility with

The available values for policy are:

  • :default - use the value set with srid_copy_policy_default=, which itself is :zero.

  • :zero - set all SRIDs to 0. The only exception to this is when cloning a Geometry, in which the SRID is always copied as per the previous behaviour.

  • :lenient - when copying SRIDs, use the SRID of the object that the operation is being performed on, even if operation involves multiple Geometry objects that may have different SRIDs.

  • :strict - when copying SRIDs, raise a Geos::MixedSRIDsError exception if an operation is performed on mixed SRIDs. This setting



1212
1213
1214
1215
1216
1217
1218
1219
1220
# File 'lib/ffi-geos.rb', line 1212

def srid_copy_policy=(policy)
  if policy == :default
    Thread.current[:ffi_geos_srid_copy_policy] = srid_copy_policy_default
  elsif Geos::Constants::SRID_COPY_POLICIES.include?(policy)
    Thread.current[:ffi_geos_srid_copy_policy] = policy
  else
    raise ArgumentError, "Invalid SRID policy #{policy} (must be one of #{Geos::Constants::SRID_COPY_POLICIES})"
  end
end

.srid_copy_policy_defaultObject



1222
1223
1224
# File 'lib/ffi-geos.rb', line 1222

def srid_copy_policy_default
  @srid_copy_policy_default ||= :zero
end

.srid_copy_policy_default=(policy) ⇒ Object



1226
1227
1228
1229
1230
1231
1232
1233
1234
# File 'lib/ffi-geos.rb', line 1226

def srid_copy_policy_default=(policy)
  if policy == :default
    @srid_copy_policy_default = :zero
  elsif Geos::Constants::SRID_COPY_POLICIES.include?(policy)
    @srid_copy_policy_default = policy
  else
    raise ArgumentError, "Invalid SRID policy #{policy} (must be one of #{Geos::Constants::SRID_COPY_POLICIES})"
  end
end

.versionObject



1172
1173
1174
# File 'lib/ffi-geos.rb', line 1172

def version
  @version ||= FFIGeos.GEOSversion
end