Skip to content

Commit

Permalink
Map View and GeoPoints archetype (#6561)
Browse files Browse the repository at this point in the history
### What

Map Space View for GNSS/GPS data logged through new GPS Coordinates
archetype.


https://github.com/rerun-io/rerun/assets/82426/86b13ba3-97af-47d2-9422-7052d7064265


- Added a new `re_space_view_map` crate for visualizing `Points3D` with
gps coordinates.
- `map_visualizer_system.rs` implements the `VisualizerSystem` trait. It
has only one meaningful function, that takes the `Positions3D`
components and turns into `vec<MapEntry>` array along with optional
`Color` and `Radius` components. This `vec<MapEntry>` is the only field
of the `MapVisualizerSystem`.
- `map_space_view.rs` is where the magic happens. It uses `walkers`
slippy map implementation to show an OpenStreetMap or Mapbox map. On the
`selection_ui ` you can change the map providers. To view Mapbox maps,
you need to set mapbox tokens (you can get free tokens from Mapbox's
site) and pass it via the env variable (`MAPBOX_ACCESS_TOKEN`) or via
the blueprint
- `map_windows.rs` is a small helper to show the zoom controls and
acknowledgment on the UIs.
- For blueprints I made `MapProvider` component (enum with
providers+styles), and a `MapOptions` archetype.

The logging of data is performed as follows:

```rust
//! Log some GPS coordinates

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let rec = rerun::RecordingStreamBuilder::new("rerun_example_gps_coordinates").spawn()?;

    rec.log(
        "points",
        &rerun::Points3D::new([(47.6344, 19.1397, 0.0), (47.6344, 19.1399, 1.0)]),
    )?;

    Ok(())
}
```

The blueprint is defined as follows:

```python
"""Use a blueprint to show a map."""

import rerun as rr
import rerun.blueprint as rrb

rr.init("rerun_example_gps_coordinates", spawn=True)

rr.log("points", Points3D([[47.6344, 19.1397, 0], [47.6334, 19.1399, 1]]))

# Create a map view to display the chart.
blueprint = rrb.Blueprint(
    rrb.MapView(
        origin="points",
        name="MapView",
        map_options=rrb.archetypes.MapOptions(provider=rrb.components.MapProvider.MapboxStreets),
    ),
    collapse_panels=True,
)

rr.send_blueprint(blueprint)
```

The PR is not perfect, but the view is usable.  

Please review the changes and evaluate their potential utility for your
needs. If you don't like, prefer not to merge just close it - no hard
feelings.

### To be discussed

* Check with you guys to see if the name is right at all. Maybe instead
of GPS we can go with something better
* Position3D is limited to `f32` instead of `f64`. This makes it less
precise than `/NavSatFix`


### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
  * Using my own lame demo app which is not part of the PR. 
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG


- [PR Build Summary](https://build.rerun.io/pr/6561)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.

---------

Co-authored-by: Antoine Beyeler <[email protected]>
  • Loading branch information
tfoldi and abey79 authored Oct 26, 2024
1 parent 42175df commit 3af2270
Show file tree
Hide file tree
Showing 128 changed files with 4,832 additions and 59 deletions.
12 changes: 6 additions & 6 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,14 @@ Of course, this will only take us so far. In the future we plan on caching queri
Here is an overview of the crates included in the project:

<picture>
<img src="https://static.rerun.io/crates/4f5569b318a5b8d7b0e9ab6e34e672c58ac5c63e/full.png" alt="">
<source media="(max-width: 480px)" srcset="https://static.rerun.io/crates/4f5569b318a5b8d7b0e9ab6e34e672c58ac5c63e/480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/crates/4f5569b318a5b8d7b0e9ab6e34e672c58ac5c63e/768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/crates/4f5569b318a5b8d7b0e9ab6e34e672c58ac5c63e/1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/crates/4f5569b318a5b8d7b0e9ab6e34e672c58ac5c63e/1200w.png">
<img src="https://static.rerun.io/crates/3bdd323e2f9c8f6561cfc0696e7362190918d0fc/full.png" alt="">
<source media="(max-width: 480px)" srcset="https://static.rerun.io/crates/3bdd323e2f9c8f6561cfc0696e7362190918d0fc/480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/crates/3bdd323e2f9c8f6561cfc0696e7362190918d0fc/768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/crates/3bdd323e2f9c8f6561cfc0696e7362190918d0fc/1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/crates/3bdd323e2f9c8f6561cfc0696e7362190918d0fc/1200w.png">
</picture>



<!-- !!! IMPORTANT!!!
This image must be updated each time a crate is added/removed/updated.
Expand Down Expand Up @@ -135,6 +134,7 @@ Update instructions:
| re_space_view | Types & utilities for defining Space View classes and communicating with the Viewport. |
| re_space_view_bar_chart | A Space View that shows a single bar chart. |
| re_space_view_dataframe | A Space View that shows the data contained in entities in a table. |
| re_space_view_map | A Space View that shows geospatial data on a map. |
| re_space_view_spatial | Space Views that show entities in a 2D or 3D spatial relationship. |
| re_space_view_tensor | A Space View dedicated to visualizing tensors with arbitrary dimensionality. |
| re_space_view_text_document | A simple Space View that shows a single text box. |
Expand Down
Loading

0 comments on commit 3af2270

Please sign in to comment.