Skip to content

How to add properties to a Feature #57

@viktorsmari

Description

@viktorsmari

How can I add more items to a Feature property Hash?
Using merge! does not seem to work

irb(main):001:0> ff = RGeo::GeoJSON.decode(Scenario.find(11).polygon)
=> #<RGeo::GeoJSON::FeatureCollection:0x724c>

irb(main):002:0> ff[0].properties
=> {"myType"=>"base_area"}

irb(main):005:0> ff[0].properties.merge!("k"=>"22")
=> {"myType"=>"base_area", "k"=>"22"}

irb(main):006:0> ff[0].properties
=> {"myType"=>"base_area"}

Which works in a 'normal' Hash

nn = Hash.new
=> {}

irb(main):041:0> nn.merge!("k"=>"22")
=> {"k"=>"22"}

irb(main):042:0> nn
=> {"k"=>"22"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions