Class: Charta::Polygon

Inherits:
Geometry show all
Defined in:
lib/charta/polygon.rb

Overview

Represent a Geometry with contains only polygons

Instance Method Summary collapse

Methods inherited from Geometry

#!=, #==, #area, #bounding_box, #buffer, #centroid, #collection?, #convert_to, #difference, #empty?, #ewkt, factory, feature, #feature, #feature=, #find_srid, #flatten_multi, from_ewkt, from_rgeo, #initialize, #inspect, #intersection, #intersects?, #merge, #method_missing, #point_on_surface, #respond_to_missing?, #srid, srs_database, #surface?, #to_binary, #to_ewkt, #to_geojson, #to_json_feature, #to_json_object, #to_rgeo, #to_svg, #to_svg_path, #to_text, #transform, #type

Constructor Details

This class inherits a constructor from Charta::Geometry

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Charta::Geometry

Instance Method Details

#distance(point) ⇒ Object



12
13
14
15
# File 'lib/charta/polygon.rb', line 12

def distance(point)
  polygon_centroid = Charta.new_point(*centroid, 4326)
  polygon_centroid.distance(point)
end

#exterior_ringObject



4
5
6
7
8
9
10
# File 'lib/charta/polygon.rb', line 4

def exterior_ring
  unless defined? @exterior_ring
    generator = RGeo::WKRep::WKTGenerator.new(tag_format: :ewkt, emit_ewkt_srid: true)
    @exterior_ring = Charta.new_geometry(generator.generate(feature.exterior_ring))
  end
  @exterior_ring
end