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, 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
])
VERSION =
"1.1.0"

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



1089
1090
1091
1092
# File 'lib/ffi-geos.rb', line 1089

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

.jts_portObject



1085
1086
1087
# File 'lib/ffi-geos.rb', line 1085

def jts_port
  @jts_port ||= FFIGeos.GEOSjtsport
end

.srid_copy_policyObject



1094
1095
1096
# File 'lib/ffi-geos.rb', line 1094

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



1118
1119
1120
1121
1122
1123
1124
1125
1126
# File 'lib/ffi-geos.rb', line 1118

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.new("Invalid SRID policy #{policy} (must be one of #{Geos::Constants::SRID_COPY_POLICIES})")
  end
end

.srid_copy_policy_defaultObject



1128
1129
1130
# File 'lib/ffi-geos.rb', line 1128

def srid_copy_policy_default
  @srid_copy_policy_default ||= :zero
end

.srid_copy_policy_default=(policy) ⇒ Object



1132
1133
1134
1135
1136
1137
1138
1139
1140
# File 'lib/ffi-geos.rb', line 1132

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.new("Invalid SRID policy #{policy} (must be one of #{Geos::Constants::SRID_COPY_POLICIES})")
  end
end

.versionObject



1081
1082
1083
# File 'lib/ffi-geos.rb', line 1081

def version
  @version ||= FFIGeos.GEOSversion
end