Apache Baremaps Documentation
repository·main·Indexed 20 days ago
https://github.com/apache/incubator-baremapsA toolkit for building, publishing, and operating online maps. It provides data pipelines with live reload and services for location search, IP-to-location, and vector tile production. The ecosystem includes the baremaps-renderer for pixel-to-pixel matching integration tests and a CLI for managing workflows, databases (PostgreSQL/PostGIS), and map operations.
What's inside Apache Baremaps
- Apache Baremaps is a toolkit and infrastructure designed for creating, publishing, and operating online maps. It features a data pipeline that allows developers to build maps using various data sources with live reload capabilities. Additionally, it provides common map-related services such as location search and IP-to-location mapping.
Access OpenStreetMap Test Data
mainThebaremaps-testing/data/osm-testdatadirectory contains grid test datasets sourced from the osm-testdata repository. These datasets are intended for use in testing Baremaps components.Locate test spatial data
mainThe
baremaps-testing/datadirectory contains sample spatial data in various formats (such as.shp,.gpkg, and.fgb) used for testing and demonstration purposes.Available datasets include:
countries.fgbandcountries.gpkg(sourced from flatgeobuf)data.gpkg(sourced from geopackage-java)
Configure the tileset using SQL queries
mainThe
tileset.jsconfiguration extends the TileJSON specification. It allows you to definevector_layerswhere each layer containsqueries.Each query can specify a zoom range (
minzoom,maxzoom) and a PostGIS-dialectsqlstatement. This allows you to dynamically fetch layer content based on the current zoom level using the${zoom}variable in your SQL.{ "tilejson": "2.2.0", "tiles": [ "http://localhost:9000/tiles/{z}/{x}/{y}.mvt" ], "vector_layers": [ { "id": "aerialway", "queries": [ { "minzoom": 14, "maxzoom": 20, "sql": "SELECT id, tags, geom FROM osm_way_z${zoom} WHERE tags ? 'aerialway'" } ] } ] }Understand JavaScript-based configuration
mainIn this project, configuration files (like
tileset.jsandstyle.js) are written in JavaScript instead of static JSON.Benefits of using JS for configuration:
- Flexibility: Use JavaScript functions to programmatically generate complex configurations.
- Modularity: Supports
importstatements to reuse code across files. - Documentation: Allows the use of comments within configuration files.
- Complexity Management: Easier to manage as configuration files grow in size and complexity.
Getting started with Apache Baremaps
mainTo begin using Apache Baremaps, refer to the official getting started guide and explore additional examples available on the project website.Run integration tests with baremaps-renderer
mainTo execute tests, navigate to a directory containing a
testsfolder and use theruncommand with the-s(style URL) flag. This will generate a report attests/report.html.baremaps-renderer run -s <styleUrl>Create and serve vector tiles from contour lines
mainThis example demonstrates how to use Apache Baremaps to create and serve vector tiles specifically from contour lines data. The process involves preparing the necessary data files and configuring the environment to generate tiles from contour line geometries.
For a detailed step-by-step guide on importing contour data into PostGIS and setting up the tile server, refer to the official documentation.
Create and serve vector tiles from OpenStreetMap data
mainThis example provides the necessary configuration and files to import OpenStreetMap (OSM) data into a PostGIS database and subsequently serve it as vector tiles using Apache Baremaps.
For a detailed step-by-step guide on the import process, refer to the official documentation: Import OSM into PostGIS.
Install and build Baremaps Renderer
mainTo use
baremaps-rendereras a command line tool, install the dependencies, build the project, and link the script to your system path using npm.npm install npm run build npm linkCreate a new integration test
mainTo add a new test, create a new folder within the
tests/integrationdirectory. Inside that folder, you must include ametadata.jsonfile defining the viewport parameters.{ "width": 512, "height": 512, "center": [6.6323, 46.5197], "zoom": 14 }Update the database
mainTo keep your database current, use the update workflow. This downloads the latest changes from OpenStreetMap (
osc.xml) and applies them.Note: Refreshing materialized views is an optional and costly step. It is only necessary if you need to update low zoom levels.
# This command updates the database baremaps workflow execute --file update.js # This command refreshes the materialized views (optional) baremaps workflow execute --file refresh.js