Class: RegionExtractor::Region

Inherits:
Object
  • Object
show all
Defined in:
lib/region_extractor/region.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Region

Returns a new instance of Region.



4
5
6
7
8
9
# File 'lib/region_extractor/region.rb', line 4

def initialize(options = {})
  @points = options[:points]
  @zone   = options[:zone]
  @projection = Proj4::Projection.new( :proj => 'utm', :datum => "NAD83", :zone => @zone)
  @holes = []
end

Instance Attribute Details

#holesObject

Returns the value of attribute holes.



3
4
5
# File 'lib/region_extractor/region.rb', line 3

def holes
  @holes
end

#pointsObject

Returns the value of attribute points.



3
4
5
# File 'lib/region_extractor/region.rb', line 3

def points
  @points
end

#zoneObject

Returns the value of attribute zone.



3
4
5
# File 'lib/region_extractor/region.rb', line 3

def zone
  @zone
end

Instance Method Details

#add_hole(region) ⇒ Object



19
20
21
# File 'lib/region_extractor/region.rb', line 19

def add_hole(region)
  @holes << region
end

#coordinates(output_projection = Proj4::Projection.new( :proj => 'latlong', :datum => 'WGS84' )) ⇒ Object



15
16
17
# File 'lib/region_extractor/region.rb', line 15

def coordinates(output_projection = Proj4::Projection.new( :proj => 'latlong', :datum => 'WGS84' ))
  transformed_points(output_projection).map{|p|"#{p.x},#{p.y},0.000000"}.join("\n")
end

#transformed_points(output_projection = Proj4::Projection.new( :proj => 'latlong', :datum => 'WGS84' )) ⇒ Object



11
12
13
# File 'lib/region_extractor/region.rb', line 11

def transformed_points(output_projection = Proj4::Projection.new( :proj => 'latlong', :datum => 'WGS84' ))
  @points.map{|p| Point.tranform_point(p, @projection, output_projection) }
end