Class: OvertureMaps::TilesController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- OvertureMaps::TilesController
- Defined in:
- app/controllers/overture_maps/tiles_controller.rb
Overview
Mapbox Vector Tiles straight from PostGIS:
GET /overture/tiles/places/14/2620/5723.mvt
MapLibre/Leaflet can render imported data with no separate tile server:
map.addSource("places", { type: "vector",
tiles: ["https://app.example.com/overture/tiles/places/{z}/{x}/{y}.mvt"] })
Constant Summary collapse
- LAYERS =
FeaturesController::RESOURCES
- PROPERTY_COLUMNS =
{ "places" => %w[name primary_category confidence country], "buildings" => %w[name subtype building_class height num_floors], "addresses" => %w[number street locality postcode], "divisions" => %w[name subtype country], "segments" => %w[name subtype segment_class], "connectors" => %w[], "base_features" => %w[name feature_type subtype feature_class] }.freeze
- MAX_ZOOM =
22- TILE_EXTENT =
4096- TILE_BUFFER =
64- ENVELOPE_MARGIN =
Half a buffer's worth of envelope margin so buffered geometries at the tile edge are included.
TILE_BUFFER.to_f / TILE_EXTENT
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/overture_maps/tiles_controller.rb', line 31 def show layer = params[:layer] model = LAYERS[layer] return render json: { error: "unknown layer" }, status: :not_found unless model z, x, y = tile_coordinates tile = build_tile(model, layer, z, x, y) expires_in 1.hour, public: true send_data tile, type: "application/vnd.mapbox-vector-tile", disposition: "inline" end |