Class: Underpass::Feature

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

Overview

Wraps an RGeo geometry with OSM metadata (tags, id, type).

Returned by QL::Query.perform and Matcher#matches for each matched element in the Overpass API response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(geometry:, properties: {}, id: nil, type: nil) ⇒ Feature

Creates a new Feature.

Parameters:

  • geometry (RGeo::Feature::Geometry)

    the RGeo geometry

  • properties (Hash) (defaults to: {})

    the OSM tags

  • id (Integer, nil) (defaults to: nil)

    the OSM element ID

  • type (String, nil) (defaults to: nil)

    the OSM element type



27
28
29
30
31
32
# File 'lib/underpass/feature.rb', line 27

def initialize(geometry:, properties: {}, id: nil, type: nil)
  @geometry = geometry
  @properties = properties
  @id = id
  @type = type
end

Instance Attribute Details

#geometryRGeo::Feature::Geometry (readonly)

Returns the RGeo geometry object.

Returns:

  • (RGeo::Feature::Geometry)

    the RGeo geometry object



10
11
12
# File 'lib/underpass/feature.rb', line 10

def geometry
  @geometry
end

#idInteger? (readonly)

Returns the OSM element ID.

Returns:

  • (Integer, nil)

    the OSM element ID



16
17
18
# File 'lib/underpass/feature.rb', line 16

def id
  @id
end

#propertiesHash{Symbol => String} (readonly)

Returns the OSM tags for this element.

Returns:

  • (Hash{Symbol => String})

    the OSM tags for this element



13
14
15
# File 'lib/underpass/feature.rb', line 13

def properties
  @properties
end

#typeString? (readonly)

Returns the OSM element type (“node”, “way”, or “relation”).

Returns:

  • (String, nil)

    the OSM element type (“node”, “way”, or “relation”)



19
20
21
# File 'lib/underpass/feature.rb', line 19

def type
  @type
end