Browse Source

room-history: switch to vector tiles for maps

merge-requests/1579/merge
Alexandre Franke 2 years ago
parent
commit
7df7dcffc0
  1. 37
      .gitlab-ci/org.gnome.Fractal.CiTest.json
  2. 35
      build-aux/org.gnome.Fractal.Devel.json
  3. 39
      data/resources/mapstyle/osm-liberty/LICENSE.md
  4. 14
      data/resources/mapstyle/osm-liberty/README.md
  5. 1689
      data/resources/mapstyle/osm-liberty/sprites.json
  6. BIN
      data/resources/mapstyle/osm-liberty/sprites.png
  7. 1689
      data/resources/mapstyle/osm-liberty/sprites@2x.json
  8. BIN
      data/resources/mapstyle/osm-liberty/sprites@2x.png
  9. 1660
      data/resources/mapstyle/osm-liberty/style.json
  10. 5
      data/resources/resources.gresource.xml
  11. 28
      src/components/location_viewer.rs

37
.gitlab-ci/org.gnome.Fractal.CiTest.json

@ -22,19 +22,48 @@
"append-path": "/usr/lib/sdk/llvm16/bin:/usr/lib/sdk/rust-stable/bin"
},
"modules": [
{
"name" : "protobuf",
"buildsystem" : "autotools",
"config-opts": [ "DIST_LANG=cpp" ],
"cleanup" : [
"/bin/protoc*",
"/lib/libprotoc*",
"/lib/libprotobuf-lite*"
],
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz",
"sha256" : "77ad26d3f65222fd96ccc18b055632b0bfedf295cb748b712a98ba1ac0b704b2"
}
]
},
{
"name" : "protobuf-c",
"buildsystem" : "autotools",
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/protobuf-c/protobuf-c/releases/download/v1.4.0/protobuf-c-1.4.0.tar.gz",
"sha256" : "26d98ee9bf18a6eba0d3f855ddec31dbe857667d269bc0b6017335572f85bbcb"
}
]
},
{
"name": "libshumate",
"buildsystem": "meson",
"config-opts": [
"-Dgir=false",
"-Dvapi=false",
"-Dgtk_doc=false"
"-Dgtk_doc=false",
"-Dvector_renderer=true"
],
"sources": [
{
"type": "archive",
"url": "https://download.gnome.org/sources/libshumate/1.1/libshumate-1.1.0.tar.xz",
"sha256": "b3b7c4c2d3002f37b951c9ca99b09275d0aa82265c69f53374ce12faefd3b14e"
"url": "https://download.gnome.org/sources/libshumate/1.1/libshumate-1.1.2.tar.xz",
"sha256": "8f094f6e7e256ab192800516ff96617abeec2363b054aad6aeb17e0088c1fb2c"
}
]
},
@ -50,4 +79,4 @@
]
}
]
}
}

35
build-aux/org.gnome.Fractal.Devel.json

@ -37,19 +37,48 @@
]
},
"modules": [
{
"name" : "protobuf",
"buildsystem" : "autotools",
"config-opts": [ "DIST_LANG=cpp" ],
"cleanup" : [
"/bin/protoc*",
"/lib/libprotoc*",
"/lib/libprotobuf-lite*"
],
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz",
"sha256" : "77ad26d3f65222fd96ccc18b055632b0bfedf295cb748b712a98ba1ac0b704b2"
}
]
},
{
"name" : "protobuf-c",
"buildsystem" : "autotools",
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/protobuf-c/protobuf-c/releases/download/v1.4.0/protobuf-c-1.4.0.tar.gz",
"sha256" : "26d98ee9bf18a6eba0d3f855ddec31dbe857667d269bc0b6017335572f85bbcb"
}
]
},
{
"name": "libshumate",
"buildsystem": "meson",
"config-opts": [
"-Dgir=false",
"-Dvapi=false",
"-Dgtk_doc=false"
"-Dgtk_doc=false",
"-Dvector_renderer=true"
],
"sources": [
{
"type": "archive",
"url": "https://download.gnome.org/sources/libshumate/1.1/libshumate-1.1.0.tar.xz",
"sha256": "b3b7c4c2d3002f37b951c9ca99b09275d0aa82265c69f53374ce12faefd3b14e"
"url": "https://download.gnome.org/sources/libshumate/1.1/libshumate-1.1.2.tar.xz",
"sha256": "8f094f6e7e256ab192800516ff96617abeec2363b054aad6aeb17e0088c1fb2c"
}
]
},

39
data/resources/mapstyle/osm-liberty/LICENSE.md

@ -0,0 +1,39 @@
## Code License
The Mapbox GL Style JSON file is originally derived from [OSM Bright from Mapbox Open Styles](https://github.com/mapbox/mapbox-gl-styles/blob/master/LICENSE.md). The modified Mapbox GL Style JSON retains the same BSD license.
> Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
> * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Mapbox nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## Design License
The look and feel of the OSM liberty map design is also derived (although heavily altered) from [OSM Bright from Mapbox Open Styles](https://github.com/mapbox/mapbox-gl-styles/blob/master/LICENSE.md) which is licensed under the Creative Commons Attribution 3.0 license.
The map is displaying and styling the data from [OpenMapTiles](https://openmaptiles.org/) with [CC-BY 4.0 design license](https://github.com/openmaptiles/openmaptiles/blob/master/LICENSE.md).
The products or services using this map style need to visibly credit "OpenMapTiles.org" or reference "OpenMapTiles" with a link to http://openmaptiles.org/. For a browsable electronic map based on OpenMapTiles and OpenStreetMap data, the credit should appear in the corner of the map. For example:
[© OpenMapTiles](https://openmaptiles.org/)
[© OpenStreetMap contributors](https://www.openstreetmap.org/copyright)
For printed and static maps a similar attribution should be made in a textual description near the image, in the same fashion as if you cite a photograph.
## Icons
OSM Liberty is using the [Maki POI icon set](https://github.com/mapbox/maki/blob/master/LICENSE.txt) which is licensed under CC0 1.0 Universal.
The right arrow was derived from [Wikipedia][wiki_arrow] which is in the public domain.
[wiki_arrow]: https://commons.wikimedia.org/wiki/File:Arrowright.svg
## Fonts
OSM Liberty is using the Roboto font family (Copyright 2011 Google).
Roboto is licensed under the [Apache License, Version 2.0](https://github.com/google/roboto/blob/master/LICENSE).

14
data/resources/mapstyle/osm-liberty/README.md

@ -0,0 +1,14 @@
# OSM Liberty style
This is the vector style currently used in Maps. It is taken from
<https://github.com/maputnik/osm-liberty> at commit [539d0525](https://github.com/maputnik/osm-liberty/commit/539d0525421eb5be901ede630c49947dfe5a343f),
with a few modifications:
- Removed the Natural Earth raster layer, since libshumate doesn't support that
yet
- Removed the 3D buildings layer, since libshumate doesn't support fill-extrusion
layers yet
- Changed the tile source URL
OSM Liberty is covered by several licenses. See LICENSE.md, which is copied
from the upstream repository.

1689
data/resources/mapstyle/osm-liberty/sprites.json

File diff suppressed because it is too large Load Diff

BIN
data/resources/mapstyle/osm-liberty/sprites.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

1689
data/resources/mapstyle/osm-liberty/sprites@2x.json

File diff suppressed because it is too large Load Diff

BIN
data/resources/mapstyle/osm-liberty/sprites@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

1660
data/resources/mapstyle/osm-liberty/style.json

File diff suppressed because it is too large Load Diff

5
data/resources/resources.gresource.xml

@ -60,6 +60,11 @@
<file preprocess="xml-stripblanks">icons/scalable/status/verified-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/status/video-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/status/warning-symbolic.svg</file>
<file preprocess="json-stripblanks">mapstyle/osm-liberty/sprites.json</file>
<file>mapstyle/osm-liberty/sprites.png</file>
<file preprocess="json-stripblanks">mapstyle/osm-liberty/sprites@2x.json</file>
<file>mapstyle/osm-liberty/sprites@2x.png</file>
<file>mapstyle/osm-liberty/style.json</file>
<file compressed="true">sas-emoji/ar.json</file>
<file compressed="true">sas-emoji/bg.json</file>
<file compressed="true">sas-emoji/ca.json</file>

28
src/components/location_viewer.rs

@ -1,6 +1,6 @@
use adw::{prelude::*, subclass::prelude::*};
use geo_uri::GeoUri;
use gtk::{glib, CompositeTemplate};
use gtk::{gdk_pixbuf, gio, glib, CompositeTemplate};
use shumate::prelude::*;
use crate::i18n::gettext_f;
@ -48,8 +48,30 @@ mod imp {
fn constructed(&self) {
self.marker.set_child(Some(&*self.marker_img));
let registry = shumate::MapSourceRegistry::with_defaults();
let source = registry.by_id(shumate::MAP_SOURCE_OSM_MAPNIK).unwrap();
let style = gio::resources_lookup_data(
"/org/gnome/Fractal/mapstyle/osm-liberty/style.json",
gio::ResourceLookupFlags::NONE,
)
.expect("Failed to load map style");
let source =
shumate::VectorRenderer::new("vector-tiles", &String::from_utf8_lossy(&style))
.expect("Failed to read map style");
source.set_license("© OpenMapTiles © OpenStreetMap contributors");
source.set_license_uri("https://www.openstreetmap.org/copyright");
let spritepixbuf = gdk_pixbuf::Pixbuf::from_resource(
"/org/gnome/Fractal/mapstyle/osm-liberty/sprites.png",
)
.expect("Failed to load map sprites");
let spritejson = gio::resources_lookup_data(
"/org/gnome/Fractal/mapstyle/osm-liberty/sprites.json",
gio::ResourceLookupFlags::NONE,
)
.expect("Failed to load map sprite sheet");
source
.set_sprite_sheet_data(&spritepixbuf, &String::from_utf8_lossy(&spritejson))
.expect("Failed to set map sprite sheet");
self.map.set_map_source(Some(&source));
let viewport = self.map.viewport().unwrap();

Loading…
Cancel
Save