Class: OvertureMaps::Models::Category
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- OvertureMaps::Models::Category
- Defined in:
- lib/overture_maps/models/category.rb
Overview
Overture places category taxonomy (no geometry — plain lookup table).
Class Method Summary collapse
-
.expand(names) ⇒ Object
Expands taxonomy groups to the leaf categories beneath them, at any depth ("eat_and_drink" or "restaurant" → every *_restaurant leaf).
- .primary_categories ⇒ Object
Class Method Details
.expand(names) ⇒ Object
Expands taxonomy groups to the leaf categories beneath them, at any depth ("eat_and_drink" or "restaurant" → every *_restaurant leaf). Names that aren't groups pass through unchanged, so mixed input like ["eat_and_drink", "museum"] works.
23 24 25 26 27 28 29 |
# File 'lib/overture_maps/models/category.rb', line 23 def self.(names) names = Array(names).map(&:to_s) leaves = names.flat_map do |group| where("taxonomy @> ?", [group].to_json).pluck(:name) end (names + leaves).uniq end |
.primary_categories ⇒ Object
15 16 17 |
# File 'lib/overture_maps/models/category.rb', line 15 def self.primary_categories distinct.where.not(primary_category: nil).pluck(:primary_category).sort end |