[gnome-maps/wip/jonasdn/vector-tiles] mapcss: Use @import
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/jonasdn/vector-tiles] mapcss: Use @import
- Date: Tue, 12 May 2015 18:18:21 +0000 (UTC)
commit db3c94b5ae8fb5d5c83dc22aae758a56448dbb20
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Tue May 12 20:15:28 2015 +0200
mapcss: Use @import
data/Makefile.am | 6 +-
data/buildings.mapcss | 24 ++++
data/gnome-maps.mapcss | 308 ++----------------------------------------
data/landuse.mapcss | 52 +++++++
data/nodes.mapcss | 30 ++++
data/roads.mapcss | 194 ++++++++++++++++++++++++++
lib/maps-mapbox-renderer.c | 3 +
lib/maps-mapbox-renderer.h | 1 +
lib/maps-mapbox-text-layer.c | 3 +-
src/mapView.js | 3 +-
10 files changed, 323 insertions(+), 301 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 9c7511e..2288982 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -14,7 +14,11 @@ org.gnome.Maps.data.gresource: org.gnome.Maps.data.gresource.xml $(app_resource_
resourcedir = $(pkgdatadir)
resource_DATA = \
org.gnome.Maps.data.gresource \
- gnome-maps.mapcss
+ gnome-maps.mapcss \
+ roads.mapcss \
+ buildings.mapcss \
+ landuse.mapcss \
+ nodes.mapcss
appsdir = $(datadir)/applications
apps_DATA = org.gnome.Maps.desktop
diff --git a/data/buildings.mapcss b/data/buildings.mapcss
new file mode 100644
index 0000000..001a80d
--- /dev/null
+++ b/data/buildings.mapcss
@@ -0,0 +1,24 @@
+area|z17-19[building!=apartments],
+area|z17-19[building!=residential],
+area|z17-19[building!=house],
+area|z17-19[building!=detached],
+area|z17-19[building!=dormitory]
+{
+ text: name;
+ text-color: #222233;
+ text-halo-color: white;
+ text-halo-radius: 1;
+ font-size: 8;
+ font-family: cantarell;
+}
+
+
+area|z13-16[building] {
+ color: #C7B8A4;
+ fill-color: #C7B8A4;
+}
+
+area|z17[building] {
+ color: #777777;
+ fill-color: #C7B8A4;
+}
diff --git a/data/gnome-maps.mapcss b/data/gnome-maps.mapcss
index b7f7b5c..09b2544 100644
--- a/data/gnome-maps.mapcss
+++ b/data/gnome-maps.mapcss
@@ -1,324 +1,36 @@
-node {
- font-size: 10;
- font-weight: bold;
- font-variant: small-caps;
- font-family: cantarell;
-}
-
-node|z5-10[place=country] {
- text-color: #4A90D9;
- text: name;
- text-halo-radius: 2;
- text-halo-color: white;
-}
-
-node|z5-10[place=sea] {
- text-color: #770000;
- text: name;
- text-halo-radius: 2;
- text-halo-color: white;
-}
-
-node|z5-13[place=city] {
- font-family: cantarell;
- font-weight: bold;
- text-color: #000000;
- font-size: 14;
- text: name;
- text-halo-radius: 2;
- text-halo-color: white;
-}
-
/* This applies to the Map as a whole, renders first */
canvas {
fill-color: #FAEBD7;
}
-/* Roads */
-
-/* Generic style for all roads */
-way|z8-17[highway] {
- color: #d2ccc3;
- casing-color: #c7b8a4;
- casing-width: 1;
-}
-
-way|z8-17[highway][is_bridge=yes] {
- casing-color: #b0a696;
-}
-
-/* type specific way overrides*/
-way|z8-17[highway=motorway],
-way|z8-17[highway=motorway_link] {
- color: #ffaf60;
- casing-color: #f57900;
- z-index: 7;
-}
-
-way|z8-17[highway=motorway][is_bridge=yes] {
- casing-color: #cc6500;
-}
-
-way|z9-17[highway=trunk],
-way|z9-17[highway=trunk_link],
-way|z9-17[highway=primary],
-way|z9-17[highway=primary_link] {
- color: #ffea40;
- casing-color: #c4af00;
- z-index: 6;
-}
-
-way|z9-17[highway=trunk][is_bridge=yes],
-way|z9-17[highway=primary][is_bridge=yes] {
- casing-color: #d3bc00;
-}
-
-/* Grow roads on zoom */
-way|z9[highway=trunk],
-way|z9[highway=primary] {
- width: 1;
-}
-
-way|z9[highway=motorway],
-way|z10[motorway_link],
-way|z10[highway=trunk],
-way|z10[highway=primary],
-way|z11[highway=trunk_link],
-way|z11[highway=primary_link] {
- width: 2;
-}
-
-way|z10[highway=motorway],
-way|z11[highway=motorway_link],
-way|z11[highway=trunk],
-way|z11[highway=primary],
-way|z12[highway=trunk_link],
-way|z12[highway=primary_link] {
- width: 3;
-}
-
-way|z11-17[highway=motorway],
-way|z12-17[highway=motorway_link],
-way|z12-17[highway=trunk],
-way|z12[highway=primary],
-way|z13-17[highway=trunk_link],
-way|z13-17[highway=primary_link] {
- width: 7;
- text: name;
- text-color: #222233;
- text-halo-color: white;
- text-halo-radius: 1;
- font-size: 6;
- font-family: cantarell;
-
-}
-
-way|z10[highway=secondary],
-way|z11[highway=tertiary],
-way|z12[highway=unclassified],
-way|z12[highway=road],
-way|z12-13[highway=residential],
-way|z15[highway=service],
-way|z15[highway=footway],
-way|z15[highway=cycleway],
-way|z15[highway=path],
-way|z15[highway=pedestrian],
-way|z15[highway=track],
-way|z15[highway=living_street],
-way|z15[highway=steps] {
- width: 1;
- casing-width: 0;
- z-index: 1;
-}
-
-way|z11[highway=secondary],
-way|z12[highway=tertiary],
-way|z13[highway=unclassified],
-way|z13[highway=road],
-way|z14[highway=residential],
-way|z16[highway=service],
-way|z16[highway=footway],
-way|z16[highway=cycleway],
-way|z16[highway=path],
-way|z16[highway=pedestrian],
-way|z16[highway=track],
-way|z16[highway=living_street],
-way|z16[highway=steps] {
- width: 1;
- color: white;
- casing-width: 1;
- z-index: 2;
-}
-
-way|z12[highway=secondary],
-way|z13[highway=tertiary],
-way|z14[highway=unclassified],
-way|z14[highway=road],
-way|z15[highway=residential],
-way|z17[highway=service],
-way|z17[highway=footway],
-way|z17[highway=cycleway],
-way|z17[highway=path],
-way|z17[highway=track],
-way|z17[highway=living_street],
-way|z17[highway=steps] {
- width: 3;
- color: white;
- z-index: 3;
-}
-
-way|z17[highway=pedestrian] {
- width: 4;
- color: #dddddd;
- z-index: 3;
-}
-
-way|z13[highway=secondary],
-way|z14[highway=tertiary],
-way|z15[highway=unclassified],
-way|z15[highway=road],
-way|z16[highway=residential] {
- width: 4;
- color: white;
- z-index: 4;
-}
-
-way|z14-17[highway=secondary],
-way|z15-17[highway=tertiary],
-way|z16-17[highway=unclassified],
-way|z16[highway=road],
-way|z17[highway=residential] {
- width: 7;
- color: white;
- z-index: 5;
-}
-
-way|z11-12[highway=residential] {
- opacity: 0;
-}
-
-way|z17[highway=residential] {
- text: name;
- text-color: #222233;
- text-halo-color: white;
- text-halo-radius: 1;
- font-size: 6;
- font-family: cantarell;
-}
-
+/* Generic area */
area {
color: #000000;
fill-color: #FAEBD7;
width: 1;
}
-area|z17-19[building!=apartments],
-area|z17-19[building!=residential],
-area|z17-19[building!=house],
-area|z17-19[building!=detached],
-area|z17-19[building!=dormitory]
-{
- text: name;
- text-color: #222233;
- text-halo-color: white;
- text-halo-radius: 1;
- font-size: 8;
- font-family: cantarell;
-}
+/* Roads */
+ import("roads.mapcss");
-area|z16-19[landuse!=residential] {
- text: name;
- text-color: #222233;
- text-halo-color: white;
- text-halo-radius: 1;
- font-size: 8;
- font-family: cantarell;
-}
+/* Buildings */
+ import("buildings.mapcss");
-area[landuse=park], area[landuse=playground], area[landuse=pitch],
-area[leisure=park], area[leasure=playground], area[leisure=pitch],
-area[landuse=grass], area[landuse=garden], area[landuse=golf_course],
-area[landuse=cemetery], area[landuse=meadow], area[landuse=common],
-area[landuse=sports_centre], area[landuse=farmland], area[landuse=farm],
-area[landuse=farmyard], area[landuse=allotments], area[landuse=village_green] {
- fill-color: #cfe1bd;
- color: #cfe1bd;
- z-index: 1;
-}
+/* Landuse */
+ import("landuse.mapcss");
-area[landuse=forest], area[landuse=wood], area[landuse=scrub],
-area[natural=wood], area[landuse=nature_reserve] {
- fill-color: #ABCA8a;
- color: #ABCA8a;
- z-index: 1; /* z-index 0 is baseline */
-}
+/* Nodes */
+ import("nodes.mapcss");
-area[landuse=wetland] {
- fill-color: #7BB26A;
-}
+/* Misc */
area[water], way[water], area[natural=water] {
color: #4A90D9;
fill-color: #4A90D9;
}
-area|z13-16[building] {
- color: #C7B8A4;
- fill-color: #C7B8A4;
-}
-
-area|z17[building] {
- color: #777777;
- fill-color: #C7B8A4;
-}
-
-area[landuse=parking] {
- color: #fff59f;
- fill-color: #fff59f;
- z-index: 1;
-}
-
-area[landuse=residential], area[landuse=industrial] {
- fill-color: #e6dbcb;
- color: #e6dbcb;
-}
-
-area[landuse=quarry] {
- fill-color: #cdcbcb;
- color: #cdcbcb;
-}
-
-area[amenity=parking] {
- color: #ffff77;
- fill-color: #C7B8A4;
-}
-
area[highway=pedestrian], area[landuse=pedestrian] {
color: #dddddd;
fill-color: #dddddd;
z-index: 1;
}
-
-way[is_tunnel=yes] {
- color: #EEEEEC;
- width: 2;
- dashes: 3, 3;
-}
-
-/* Railways */
-way[railway=rail] {
- color: white;
- width: 2;
- casing-color: #777777;
- casing-width: 1;
- dashes: 7, 10;
-}
-/*
-way[railway=tram], way[railway=lightrail] {
- color: #888a85;
- casing-color: #888a85;
- casing-width: 1.5;
- casing-dashes: 1, 6;
- width: 2;
-}
-*/
diff --git a/data/landuse.mapcss b/data/landuse.mapcss
new file mode 100644
index 0000000..cfec927
--- /dev/null
+++ b/data/landuse.mapcss
@@ -0,0 +1,52 @@
+area|z16-19[landuse!=residential] {
+ text: name;
+ text-color: #222233;
+ text-halo-color: white;
+ text-halo-radius: 1;
+ font-size: 8;
+ font-family: cantarell;
+}
+
+area[landuse=park], area[landuse=playground], area[landuse=pitch],
+area[leisure=park], area[leasure=playground], area[leisure=pitch],
+area[landuse=grass], area[landuse=garden], area[landuse=golf_course],
+area[landuse=cemetery], area[landuse=meadow], area[landuse=common],
+area[landuse=sports_centre], area[landuse=farmland], area[landuse=farm],
+area[landuse=farmyard], area[landuse=allotments], area[landuse=village_green] {
+ fill-color: #cfe1bd;
+ color: #cfe1bd;
+ z-index: 1;
+}
+
+area[landuse=forest], area[landuse=wood], area[landuse=scrub],
+area[natural=wood], area[landuse=nature_reserve] {
+ fill-color: #ABCA8a;
+ color: #ABCA8a;
+ z-index: 1; /* z-index 0 is baseline */
+}
+
+area[landuse=wetland] {
+ fill-color: #7BB26A;
+}
+
+area[landuse=parking] {
+ color: #fff59f;
+ fill-color: #fff59f;
+ z-index: 1;
+}
+
+area[landuse=residential], area[landuse=industrial] {
+ fill-color: #e6dbcb;
+ color: #e6dbcb;
+}
+
+area[landuse=quarry] {
+ fill-color: #cdcbcb;
+ color: #cdcbcb;
+}
+
+area[amenity=parking] {
+ color: #ffff77;
+ fill-color: #C7B8A4;
+}
+
diff --git a/data/nodes.mapcss b/data/nodes.mapcss
new file mode 100644
index 0000000..36c428a
--- /dev/null
+++ b/data/nodes.mapcss
@@ -0,0 +1,30 @@
+node {
+ font-size: 10;
+ font-weight: bold;
+ font-variant: small-caps;
+ font-family: cantarell;
+}
+
+node|z5-10[place=country] {
+ text-color: #4A90D9;
+ text: name;
+ text-halo-radius: 2;
+ text-halo-color: white;
+}
+
+node|z5-10[place=sea] {
+ text-color: #770000;
+ text: name;
+ text-halo-radius: 2;
+ text-halo-color: white;
+}
+
+node|z5-13[place=city] {
+ font-family: cantarell;
+ font-weight: bold;
+ text-color: #000000;
+ font-size: 14;
+ text: name;
+ text-halo-radius: 2;
+ text-halo-color: white;
+}
diff --git a/data/roads.mapcss b/data/roads.mapcss
new file mode 100644
index 0000000..ae4d3ea
--- /dev/null
+++ b/data/roads.mapcss
@@ -0,0 +1,194 @@
+/* Generic style for all roads */
+way|z8-17[highway] {
+ color: #d2ccc3;
+ casing-color: #c7b8a4;
+ casing-width: 1;
+}
+
+way|z8-17[highway][is_bridge=yes] {
+ casing-color: #b0a696;
+}
+
+/* type specific way overrides*/
+way|z8-17[highway=motorway],
+way|z8-17[highway=motorway_link] {
+ color: #ffaf60;
+ casing-color: #f57900;
+ z-index: 7;
+}
+
+way|z8-17[highway=motorway][is_bridge=yes] {
+ casing-color: #cc6500;
+}
+
+way|z9-17[highway=trunk],
+way|z9-17[highway=trunk_link],
+way|z9-17[highway=primary],
+way|z9-17[highway=primary_link] {
+ color: #ffea40;
+ casing-color: #c4af00;
+ z-index: 6;
+}
+
+way|z9-17[highway=trunk][is_bridge=yes],
+way|z9-17[highway=primary][is_bridge=yes] {
+ casing-color: #d3bc00;
+}
+
+/* Grow roads on zoom */
+way|z9[highway=trunk],
+way|z9[highway=primary] {
+ width: 1;
+}
+
+way|z9[highway=motorway],
+way|z10[motorway_link],
+way|z10[highway=trunk],
+way|z10[highway=primary],
+way|z11[highway=trunk_link],
+way|z11[highway=primary_link] {
+ width: 2;
+}
+
+way|z10[highway=motorway],
+way|z11[highway=motorway_link],
+way|z11[highway=trunk],
+way|z11[highway=primary],
+way|z12[highway=trunk_link],
+way|z12[highway=primary_link] {
+ width: 3;
+}
+
+way|z11-17[highway=motorway],
+way|z12-17[highway=motorway_link],
+way|z12-17[highway=trunk],
+way|z12[highway=primary],
+way|z13-17[highway=trunk_link],
+way|z13-17[highway=primary_link] {
+ width: 7;
+ text: name;
+ text-color: #222233;
+ text-halo-color: white;
+ text-halo-radius: 1;
+ font-size: 6;
+ font-family: cantarell;
+
+}
+
+way|z10[highway=secondary],
+way|z11[highway=tertiary],
+way|z12[highway=unclassified],
+way|z12[highway=road],
+way|z12-13[highway=residential],
+way|z15[highway=service],
+way|z15[highway=footway],
+way|z15[highway=cycleway],
+way|z15[highway=path],
+way|z15[highway=pedestrian],
+way|z15[highway=track],
+way|z15[highway=living_street],
+way|z15[highway=steps] {
+ width: 1;
+ casing-width: 0;
+ z-index: 1;
+}
+
+way|z11[highway=secondary],
+way|z12[highway=tertiary],
+way|z13[highway=unclassified],
+way|z13[highway=road],
+way|z14[highway=residential],
+way|z16[highway=service],
+way|z16[highway=footway],
+way|z16[highway=cycleway],
+way|z16[highway=path],
+way|z16[highway=pedestrian],
+way|z16[highway=track],
+way|z16[highway=living_street],
+way|z16[highway=steps] {
+ width: 1;
+ color: white;
+ casing-width: 1;
+ z-index: 2;
+}
+
+way|z12[highway=secondary],
+way|z13[highway=tertiary],
+way|z14[highway=unclassified],
+way|z14[highway=road],
+way|z15[highway=residential],
+way|z17[highway=service],
+way|z17[highway=footway],
+way|z17[highway=cycleway],
+way|z17[highway=path],
+way|z17[highway=track],
+way|z17[highway=living_street],
+way|z17[highway=steps] {
+ width: 3;
+ color: white;
+ z-index: 3;
+}
+
+way|z17[highway=pedestrian] {
+ width: 4;
+ color: #dddddd;
+ z-index: 3;
+}
+
+way|z13[highway=secondary],
+way|z14[highway=tertiary],
+way|z15[highway=unclassified],
+way|z15[highway=road],
+way|z16[highway=residential] {
+ width: 4;
+ color: white;
+ z-index: 4;
+}
+
+way|z14-17[highway=secondary],
+way|z15-17[highway=tertiary],
+way|z16-17[highway=unclassified],
+way|z16[highway=road],
+way|z17[highway=residential] {
+ width: 7;
+ color: white;
+ z-index: 5;
+}
+
+way|z11-12[highway=residential] {
+ opacity: 0;
+}
+
+way|z17[highway=residential] {
+ text: name;
+ text-color: #222233;
+ text-halo-color: white;
+ text-halo-radius: 1;
+ font-size: 6;
+ font-family: cantarell;
+}
+
+way[is_tunnel=yes] {
+ color: #EEEEEC;
+ width: 2;
+ dashes: 3, 3;
+}
+
+/* Railways */
+way[railway=rail] {
+ color: white;
+ width: 2;
+ casing-color: #777777;
+ casing-width: 1;
+ dashes: 7, 10;
+}
+
+/*
+way[railway=tram], way[railway=lightrail] {
+ color: #888a85;
+ casing-color: #888a85;
+ casing-width: 1.5;
+ casing-dashes: 1, 6;
+ width: 2;
+}
+*/
diff --git a/lib/maps-mapbox-renderer.c b/lib/maps-mapbox-renderer.c
index a3b13cf..b116af4 100644
--- a/lib/maps-mapbox-renderer.c
+++ b/lib/maps-mapbox-renderer.c
@@ -170,12 +170,14 @@ on_stylesheet_changed (GFileMonitor *monitor,
void
maps_mapbox_renderer_load_css (MapsMapboxRenderer *renderer,
const char *filename,
+ const char *search_path,
GError **error)
{
GFile *file;
GFileMonitor *monitor;
renderer->priv->stylesheet = vtile_mapcss_new ();
+ vtile_mapcss_set_search_path (renderer->priv->stylesheet, search_path);
vtile_mapcss_load (renderer->priv->stylesheet, filename, error);
file = g_file_new_for_path (filename);
@@ -235,6 +237,7 @@ on_canvas_draw (ClutterCanvas *canvas,
for (l = texts; l != NULL; l = l->next) {
maps_mapbox_text_layer_add_text (data->layer, data->tile, l->data);
}
+ g_list_free (texts);
champlain_tile_set_content (data->tile, actor);
g_signal_emit_by_name (data->tile, "render-complete",
diff --git a/lib/maps-mapbox-renderer.h b/lib/maps-mapbox-renderer.h
index 7995f75..c5dba01 100644
--- a/lib/maps-mapbox-renderer.h
+++ b/lib/maps-mapbox-renderer.h
@@ -72,6 +72,7 @@ MapsMapboxRenderer *maps_mapbox_renderer_new_with_view (ChamplainView *view);
void maps_mapbox_renderer_load_css (MapsMapboxRenderer *renderer,
const char *filename,
+ const char *search_path,
GError **error);
void maps_mapbox_renderer_set_view (MapsMapboxRenderer *renderer,
diff --git a/lib/maps-mapbox-text-layer.c b/lib/maps-mapbox-text-layer.c
index 8c6d107..744cce4 100644
--- a/lib/maps-mapbox-text-layer.c
+++ b/lib/maps-mapbox-text-layer.c
@@ -93,6 +93,7 @@ on_text_draw (ClutterCanvas *canvas,
cairo_paint (cr);
surface = cairo_get_target (cr);
g_signal_handlers_disconnect_by_func (canvas, on_text_draw, text);
+ vtile_mapbox_text_free (text);
return TRUE;
}
@@ -139,7 +140,7 @@ maps_mapbox_text_layer_add_text (MapsMapboxTextLayer *layer,
ClutterActor *actor;
gfloat tile_x, tile_y;
- if (g_hash_table_lookup (layer->priv->objects, text->uid))
+ if (!text->uid || g_hash_table_lookup (layer->priv->objects, text->uid))
return;
clutter_actor_get_position ((ClutterActor *) tile, &tile_x, &tile_y);
diff --git a/src/mapView.js b/src/mapView.js
index f85b691..63afea9 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -157,7 +157,8 @@ const MapView = new Lang.Class({
try {
renderer.load_css(GLib.build_filenamev([pkg.pkgdatadir,
- 'gnome-maps.mapcss']));
+ 'gnome-maps.mapcss']),
+ pkg.pkgdatadir);
} catch(e) {
Application.notificationManager.showMessage(e.message);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]