Apache Baremaps Documentation

repository·main·Indexed 20 days ago

https://github.com/apache/incubator-baremaps

A 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.

Tokens
9.4K
Snippets
46
Records
64
Agent score
69%

What's inside Apache Baremaps

  1. Overview of Apache Baremaps

    main
    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.
  2. Configure the tileset using SQL queries

    main

    The tileset.js configuration extends the TileJSON specification. It allows you to define vector_layers where each layer contains queries.

    Each query can specify a zoom range (minzoom, maxzoom) and a PostGIS-dialect sql statement. 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'"
            }
          ]
        }
      ]
    }
  3. Understand JavaScript-based configuration

    main

    In this project, configuration files (like tileset.js and style.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 import statements 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.
  4. Create and serve vector tiles from contour lines

    main

    This 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.

  5. Update the database

    main

    To 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