class RGeo::Geographic::Factory

This class implements the various factories for geography features. See methods of the RGeo::Geographic module for the API for creating geography factories.

Public Instance Methods

==(rhs_) click to toggle source
Alias for: eql?
collection(elems_) click to toggle source

See RGeo::Feature::Factory#collection

# File lib/rgeo/geographic/factory.rb, line 411
def collection(elems_)
  @geometry_collection_class.new(self, elems_) rescue nil
end
coord_sys() click to toggle source

See RGeo::Feature::Factory#coord_sys

# File lib/rgeo/geographic/factory.rb, line 446
def coord_sys
  @coord_sys
end
eql?(rhs_) click to toggle source

Equivalence test.

# File lib/rgeo/geographic/factory.rb, line 120
def eql?(rhs_)
  rhs_.is_a?(Geographic::Factory) &&
    @impl_prefix == rhs_.instance_variable_get(:@impl_prefix) &&
    @support_z == rhs_.instance_variable_get(:@support_z) &&
    @support_m == rhs_.instance_variable_get(:@support_m) &&
    @proj4 == rhs_.instance_variable_get(:@proj4)
end
Also aliased as: ==
has_projection?() click to toggle source

Returns true if this factory supports a projection.

# File lib/rgeo/geographic/factory.rb, line 269
def has_projection?
  !@projector.nil?
end
hash() click to toggle source

Standard hash code

# File lib/rgeo/geographic/factory.rb, line 132
def hash
  @hash ||= [@impl_prefix, @support_z, @support_m, @proj4].hash
end
line(start_, end_) click to toggle source

See RGeo::Feature::Factory#line

# File lib/rgeo/geographic/factory.rb, line 390
def line(start_, end_)
  @line_class.new(self, start_, end_) rescue nil
end
line_string(points_) click to toggle source

See RGeo::Feature::Factory#line_string

# File lib/rgeo/geographic/factory.rb, line 383
def line_string(points_)
  @line_string_class.new(self, points_) rescue nil
end
linear_ring(points_) click to toggle source

See RGeo::Feature::Factory#linear_ring

# File lib/rgeo/geographic/factory.rb, line 397
def linear_ring(points_)
  @linear_ring_class.new(self, points_) rescue nil
end
multi_line_string(elems_) click to toggle source

See RGeo::Feature::Factory#multi_line_string

# File lib/rgeo/geographic/factory.rb, line 425
def multi_line_string(elems_)
  @multi_line_string_class.new(self, elems_) rescue nil
end
multi_point(elems_) click to toggle source

See RGeo::Feature::Factory#multi_point

# File lib/rgeo/geographic/factory.rb, line 418
def multi_point(elems_)
  @multi_point_class.new(self, elems_) rescue nil
end
multi_polygon(elems_) click to toggle source

See RGeo::Feature::Factory#multi_polygon

# File lib/rgeo/geographic/factory.rb, line 432
def multi_polygon(elems_)
  @multi_polygon_class.new(self, elems_) rescue nil
end
parse_wkb(str_) click to toggle source

See RGeo::Feature::Factory#parse_wkb

# File lib/rgeo/geographic/factory.rb, line 369
def parse_wkb(str_)
  @wkb_parser.parse(str_)
end
parse_wkt(str_) click to toggle source

See RGeo::Feature::Factory#parse_wkt

# File lib/rgeo/geographic/factory.rb, line 362
def parse_wkt(str_)
  @wkt_parser.parse(str_)
end
point(x_, y_, *extra_) click to toggle source

See RGeo::Feature::Factory#point

# File lib/rgeo/geographic/factory.rb, line 376
def point(x_, y_, *extra_)
  @point_class.new(self, x_, y_, *extra_) rescue nil
end
polygon(outer_ring_, inner_rings_=nil) click to toggle source

See RGeo::Feature::Factory#polygon

# File lib/rgeo/geographic/factory.rb, line 404
def polygon(outer_ring_, inner_rings_=nil)
  @polygon_class.new(self, outer_ring_, inner_rings_) rescue nil
end
proj4() click to toggle source

See RGeo::Feature::Factory#proj4

# File lib/rgeo/geographic/factory.rb, line 439
def proj4
  @proj4
end
project(geometry_) click to toggle source

Projects the given geometry into the projected coordinate space, and returns the projected geometry. Returns nil if this factory does not support a projection. Raises Error::InvalidGeometry if the given geometry is not of this factory.

# File lib/rgeo/geographic/factory.rb, line 288
def project(geometry_)
  return nil unless @projector && geometry_
  unless geometry_.factory == self
    raise Error::InvalidGeometry, 'Wrong geometry type'
  end
  @projector.project(geometry_)
end
projection_factory() click to toggle source

Returns the factory for the projected coordinate space, or nil if this factory does not support a projection.

# File lib/rgeo/geographic/factory.rb, line 277
def projection_factory
  @projector ? @projector.projection_factory : nil
end
projection_limits_window() click to toggle source

Returns a ProjectedWindow specifying the limits of the domain of the projection space. Returns nil if this factory does not support a projection, or the projection limits are not known.

# File lib/rgeo/geographic/factory.rb, line 328
def projection_limits_window
  if @projector
    unless defined?(@projection_limits_window)
      @projection_limits_window = @projector.limits_window
    end
    @projection_limits_window
  else
    nil
  end
end
projection_wraps?() click to toggle source

Returns true if this factory supports a projection and the projection wraps its x (easting) direction. For example, a Mercator projection wraps, but a local projection that is valid only for a small area does not wrap. Returns nil if this factory does not support or a projection, or if it is not known whether or not it wraps.

# File lib/rgeo/geographic/factory.rb, line 318
def projection_wraps?
  @projector ? @projector.wraps? : nil
end
property(name_) click to toggle source

See RGeo::Feature::Factory#property

# File lib/rgeo/geographic/factory.rb, line 342
def property(name_)
  case name_
  when :has_z_coordinate
    @support_z
  when :has_m_coordinate
    @support_m
  when :uses_lenient_assertions
    @lenient_assertions
  when :buffer_resolution
    @buffer_resolution
  when :is_geographic
    true
  else
    nil
  end
end
srid() click to toggle source

Returns the srid reported by this factory.

# File lib/rgeo/geographic/factory.rb, line 262
def srid
  @srid
end
unproject(geometry_) click to toggle source

Reverse-projects the given geometry from the projected coordinate space into lat-long space. Raises Error::InvalidGeometry if the given geometry is not of the projection defined by this factory.

# File lib/rgeo/geographic/factory.rb, line 302
def unproject(geometry_)
  return nil unless geometry_
  unless @projector && @projector.projection_factory == geometry_.factory
    raise Error::InvalidGeometry, 'You can unproject only features that are in the projected coordinate space.'
  end
  @projector.unproject(geometry_)
end