Class: OvertureMaps::FeaturesController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- OvertureMaps::FeaturesController
- Defined in:
- app/controllers/overture_maps/features_controller.rb
Overview
Read-only access to imported Overture data.
GET /overture/places?bbox=-122.4,47.5,-122.2,47.7&category=cafe&limit=50
GET /overture/places?near=47.6,-122.3,1000&format=geojson
GET /overture/buildings/<gers-id>
Collections paginate by keyset: pass meta.next_cursor back as ?after=. ?format=geojson (or Accept: application/geo+json) returns GeoJSON.
Constant Summary collapse
- RESOURCES =
{ "places" => Models::Place, "buildings" => Models::Building, "addresses" => Models::Address, "divisions" => Models::Division, "segments" => Models::Segment, "connectors" => Models::Connector, "base_features" => Models::BaseFeature }.freeze
- MAX_RADIUS_METERS =
100_000
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/overture_maps/features_controller.rb', line 25 def index scope = apply_filters(model.all) scope = scope.where("id > ?", params[:after].to_s) if params[:after].present? records = scope.order(:id).limit(page_size).to_a if geojson? render json: { type: "FeatureCollection", features: records.map(&:to_geojson) } else render json: { data: records.map { |record| serialize(record) }, meta: { count: records.length, next_cursor: records.length == page_size ? records.last&.id : nil } } end end |
#show ⇒ Object
46 47 48 49 50 51 |
# File 'app/controllers/overture_maps/features_controller.rb', line 46 def show record = model.find_by(id: params[:id]) return render json: { error: "not found" }, status: :not_found unless record render json: geojson? ? record.to_geojson : serialize(record) end |