GeoSQL.PostGIS.VectorTiles (GeoSQL v1.2.0)
View SourceIn addition to support for functions related to Mapbox vector tiles, this module also
provides support for generating complete tiles via generate/6
.
The generate/6
function takes a list of GeoSQL.PostGIS.VectorTiles.Layer
structs along
with the tile coordinates and an Ecto.Repo
:
use GeoSQL.PostGIS
def tile(zoom, x, y) do
layers = [
%PostGIS.VectorTiles.Layer{
name: "pois",
source: "nodes",
columns: %{geometry: :geom, id: :node_id, tags: :tags}
},
%PostGIS.VectorTiles.Layer{
name: "buildings",
source: "buildings",
columns: %{geometry: :footprint, id: :id, tags: :tags}
}
]
PostGIS.VectorTiles.generate(MyApp.Repo, zoom, x, y, layers)
end
The resulting data can be loaded directly into map renderers such as MapLibre
or OpenLayers
with the MVT
vector tile layer format.
Database prefixes ("schemas" in PostgreSQL) are also supported both on the whole tile query as well as per-layer.
For non-trivial tables, ensure that a GIST
index exists on the geometry columns used.
Summary
SQL Functions
Tile Generation
@spec generate( repo :: Ecto.Repo.t(), zoom :: non_neg_integer(), x :: non_neg_integer(), y :: non_neg_integer(), layers :: [GeoSQL.PostGIS.VectorTiles.Layer.t()], db_prefix :: String.t() | nil ) :: term()