Class: MapnikLegendary::Part

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

Overview

A part is a combination of tags, geometry and layers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h, zoom, map, extra_tags) ⇒ Part

Returns a new instance of Part.



11
12
13
14
15
16
17
18
19
# File 'lib/mapnik_legendary/part.rb', line 11

def initialize(h, zoom, map, extra_tags)
  @tags = Tags.merge_nulls(h['tags'], extra_tags)
  @geom = Geometry.new(h['type'], zoom, map)
  if h['layer']
    @layers = [h['layer']]
  else
    @layers = h['layers']
  end
end

Instance Attribute Details

#geomObject (readonly)

Returns the value of attribute geom.



9
10
11
# File 'lib/mapnik_legendary/part.rb', line 9

def geom
  @geom
end

#layersObject (readonly)

Returns the value of attribute layers.



9
10
11
# File 'lib/mapnik_legendary/part.rb', line 9

def layers
  @layers
end

#tagsObject (readonly)

Returns the value of attribute tags.



9
10
11
# File 'lib/mapnik_legendary/part.rb', line 9

def tags
  @tags
end

Instance Method Details

#to_csvObject



21
22
23
24
25
# File 'lib/mapnik_legendary/part.rb', line 21

def to_csv
  csv = ''
  csv << @tags.keys.push('wkt').join(',') + "\n"
  csv << @tags.values.push(@geom.to_csv).join(',') + "\n"
end