class GeoRuby::SimpleFeatures::Circle

Represents a point. It is in 3D if the Z coordinate is not nil.

Attributes

c[RW]
center[RW]
r[RW]
radius[RW]

Public Class Methods

from_coordinates(center, r, srid = DEFAULT_SRID) click to toggle source
# File lib/geo_ruby/simple_features/circle.rb, line 50
def from_coordinates(center, r, srid = DEFAULT_SRID)
  circle = new(srid)
  circle.center = Point.from_coordinates(center)
  circle.radius = r
  circle
end
from_x_y_r(x, y, r, srid = DEFAULT_SRID) click to toggle source
# File lib/geo_ruby/simple_features/circle.rb, line 43
def from_x_y_r(x, y, r, srid = DEFAULT_SRID)
  circle = new(srid)
  circle.center = Point.from_x_y(x, y, srid)
  circle.radius = r
  circle
end
new(srid = DEFAULT_SRID, with_z = false, with_m = false) click to toggle source
Calls superclass method
# File lib/geo_ruby/simple_features/circle.rb, line 9
def initialize(srid = DEFAULT_SRID, with_z = false, with_m = false)
  super(srid, with_z, with_m)
end

Public Instance Methods

==(other) click to toggle source
# File lib/geo_ruby/simple_features/circle.rb, line 26
def ==(other)
  return false unless other.is_a?(Circle)
  @center == other.center && @radius == other.radius
end
as_geojson(options = {})
Alias for: to_json
bounding_box() click to toggle source
# File lib/geo_ruby/simple_features/circle.rb, line 13
def bounding_box
  [Point.from_x_y(@center.x - @r, @center.y - @r),
   Point.from_x_y(@center.x + @r, @center.y + @r)]
end
contains_point?(_point) click to toggle source
# File lib/geo_ruby/simple_features/circle.rb, line 38
def contains_point?(_point)
  fail NotImplementedError
end
diameter() click to toggle source
# File lib/geo_ruby/simple_features/circle.rb, line 18
def diameter
  radius * 2
end
m_range() click to toggle source
# File lib/geo_ruby/simple_features/circle.rb, line 22
def m_range
  fail NotImplementedError
end
to_json(options = {}) click to toggle source
# File lib/geo_ruby/simple_features/circle.rb, line 31
def to_json(options = {})
  { type: 'Circle',
    coordinates: @center.to_coordinates,
    radius: @radius }.to_json(options)
end
Also aliased as: as_geojson