Class: MapnikLegendary::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/mapnik_legendary/feature.rb

Overview

A feature has a name, description, and one or more parts holding geometries, tags and layers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature, zoom, map, extra_tags) ⇒ Feature

Returns a new instance of Feature.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mapnik_legendary/feature.rb', line 10

def initialize(feature, zoom, map, extra_tags)
  @name = feature['name']
  @description = feature.key?('description') ? feature['description'] : @name.capitalize
  @parts = []
  if feature.key? 'parts'
    feature['parts'].each do |part|
      @parts << Part.new(part, zoom, map, extra_tags)
    end
  else
    @parts << Part.new(feature, zoom, map, extra_tags)
  end
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/mapnik_legendary/feature.rb', line 8

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/mapnik_legendary/feature.rb', line 8

def name
  @name
end

#partsObject (readonly)

Returns the value of attribute parts.



8
9
10
# File 'lib/mapnik_legendary/feature.rb', line 8

def parts
  @parts
end

Instance Method Details

#envelopeObject



23
24
25
# File 'lib/mapnik_legendary/feature.rb', line 23

def envelope
  @parts.first.geom.envelope
end