Crate galileo

source ·
Expand description

Galileo is a cross-platform map rendering engine. It supports raster and vector layers, custom and flexible styling, working with different coordinate systems and projects.

§Quick start

You can create a simple interactive map with two layers by this code:

use galileo::{MapBuilder, TileSchema };
use galileo::layer::FeatureLayer;
use galileo::symbol::CirclePointSymbol;
use galileo::galileo_types::latlon;
use galileo_types::geo::Crs;
use galileo::Color;

MapBuilder::new()
    .center(latlon!(37.566, 126.9784))
    .resolution(TileSchema::web(18).lod_resolution(8).unwrap())
    .with_raster_tiles(|index| {
        format!(
            "https://tile.openstreetmap.org/{}/{}/{}.png",
            index.z, index.x, index.y
        )},
        TileSchema::web(18))
    .with_layer(FeatureLayer::new(
        vec![latlon!(37.566, 126.9784)],
        CirclePointSymbol::new(Color::BLUE, 5.0),
        Crs::WGS84,
    ))
    .build()
    .await
    .run();

This will show a map with Open Street Maps base and one blue circle in the center of the map. Map builder takes care of creating a window, setting up GPU context and configuring user interactions to control the map position with mouse or touch.

Calling .run() starts winit event loop, which will run until the user closes the window.

Running the map in a dedicated window is quite straightforward, but to integrate Galileo map into your application and interact with it you will need some understanding of what happens under the hood of the MapBuilder.

§Main components of Galileo

As surprising as it is, everything in a mapping library revolves around

  • Map struct, which is quite simple by itself and contains only currently displayed MapView, inner state, such as animation parameters, and a set of
  • layers that actually contain data and know how it should be displayed. There are different types of layers depending on what kind of data they use (images, vector tiles, geometric features etc) and on their capabilities for transforming that data into what a user wants to see. To render the data layers use
  • renderer, which is responsible for converting primitives into the images the user sees.

As you have probably noticed nothing of the above deals with user interactions or events. You can think of the map (with its layers) as a map you hang on your wall. It just shows some geo-data and does nothing else. So if you create a console utility, server or some kind of presentation application, these three would be all you need.

In case a user is supposed to interact with the map in your application, you would also need

  • EventProcessor to convert raw system event into some intermediate representation, more convenient to deal with, and some
  • controls that actually change state of the map or layers based on the user input.

Re-exports§

Modules§

  • This module contains traits and structs that provide interactivity of a Galileo map.
  • Error types used by the crate.
  • Layers specify a data source and the way the data should be rendered to the map.
  • Rendering backends for a map.
  • TileSchema is used by tile layers to calculate tile indices needed for a given [‘MapView’].
  • Types that help using Galileo with winit.

Structs§

  • Color representation.
  • Empty struct used for generic disambiguation.
  • Convenience struct holding all necessary parts of a interactive map, including window handle and an event loop.
  • Collection of layers with some meta-information.
  • Level of detail of a layer or map.
  • Map specifies a set of layers, and the view that should be rendered.
  • Builder for a GalileoMap.
  • Map view specifies the area of the map that should be drawn. In other words, it sets the position of “camera” that looks at the map.

Traits§

  • Messenger used to notifiy application when the map requires update.