[cairo-commit] roadster/src layers.c, 1.7, 1.8 layers.h, 1.3, 1.4 main.c, 1.8, 1.9 map.c, 1.13, 1.14

Nathan Fredrickson commit at pdx.freedesktop.org
Wed Mar 2 22:45:11 PST 2005


Committed by: nrf

Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv562/src

Modified Files:
	layers.c layers.h main.c map.c 
Log Message:
    * data/Makefile.am:
    * configure.ac: Add dependency on libxml-2.0.
    * data/layers.xml: Map layer styles defined in XML.
    * src/main.c:
    * src/map.c:
    * src/layers.h:
    * src/layers.c: Load map layer styles from an XML file.


Index: layers.c
===================================================================
RCS file: /cvs/cairo/roadster/src/layers.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- layers.c	1 Mar 2005 19:48:21 -0000	1.7
+++ layers.c	3 Mar 2005 06:45:09 -0000	1.8
@@ -1,8 +1,9 @@
 /***************************************************************************
  *            layers.c
  *
- *  Copyright  2005  Ian McIntosh
- *  ian_mcintosh at linuxadvocate.org
+ *  Copyright 2005
+ *  Ian McIntosh <ian_mcintosh at linuxadvocate.org>
+ *  Nathan Fredrickson <nathan at silverorange.com>
  ****************************************************************************/
 
 /*
@@ -21,9 +22,15 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <config.h>
+
 #include <cairo.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
 #include "layers.h"
 
+layer_t * g_aLayers[NUM_LAYERS+1];
+
 gdouble pDash_Solid[] = {10};
 gdouble pDash_10_10[] = {1, 14};
 
@@ -32,150 +39,313 @@
 	{pDash_10_10, 2},
 };
 
-layer_t g_aLayers[NUM_LAYERS + 1] = {
-/* 0 */	{0, "UNUSED LAYER",
-			{{
-			/* line widths @ zooms	  	  						 color 									  dash, join, cap	*/
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0/255.0, 0/255.0, 0/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT},
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0/255.0, 0/255.0, 0/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
-			}},
-			
-			{{0,0,0,0,0,0,0,0,0,0}, /* font size */
- 			 {0,0,0,0,0,0,0,0,0,0},	/* bold */
-			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
-			 {0,0,0,0}}
-			},
+static void layers_load_style(const gchar * file);
+static layer_t* layers_new(gint index, gchar *name);
 
-/* 1 */	{LAYER_MINORSTREET, "Minor Roads",
-			{{
-			/* line widths @ zooms	  	  						 color 									  dash, join, cap	*/
-			{{0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 5.0, 12.0, 18.0,36.0}, {169/255.0, 159/255.0, 157/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND},
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.5, 10.0, 16.0,32.0}, {255/255.0, 251/255.0, 255/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND}
-			}},
+static void layers_parse_layers(xmlDocPtr doc, xmlNodePtr node);
+static void layers_parse_layer(xmlDocPtr doc, xmlNodePtr node);
+static void layers_parse_sublayer(xmlDocPtr doc, sublayerstyle_t *sublayer, xmlNodePtr node);
+static void layers_parse_sublayer_property(xmlDocPtr doc, sublayerstyle_t *sublayer, xmlNodePtr node);
+static void layers_parse_label(xmlDocPtr doc, textlabelstyle_t *label_style, xmlNodePtr node);
+static void layers_parse_label_property(xmlDocPtr doc, textlabelstyle_t *label_style, xmlNodePtr node);
+static void layers_parse_color(color_t *color, gchar *value);
 
-			{{0,0,0,0,0,0,0,10,14,32}, /* font size */
-	 		 {0,0,0,0,0,0,0,0,0,0}, /* bold */
-			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
-			 {0,0,0,0}}
-			},
+static void layers_print_layer(layer_t *layer);
+static void layers_print_sublayer(sublayerstyle_t *sublayer);
+static void layers_print_color(color_t *color);
 
-/* 2 */	{LAYER_MAJORSTREET, "Major Roads",
-			{{
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 12.0, 17.0, 24.0, 36.0}, {173/255.0, 162/255.0, 140/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND},
-			{{0.0, 0.0, 1.8, 2.5, 3.3, 6.0, 10.0, 14.5, 22.0, 32.5}, {255/255.0, 251/255.0, 115/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND}
-			}},
 
-			{{0,0,0,0,0,8,10,12,20,34}, /* font size */
-			 {0,0,0,0,0,0,0,0,1,1}, /* bold */
-			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
-			 {0,0,0,0}}
-			},
+void
+layers_init(void)
+{
+	g_aLayers[LAYER_NONE] = layers_new(LAYER_NONE, "unused");
+	g_aLayers[LAYER_MINORSTREET] = layers_new(LAYER_MINORSTREET, "minor-roads");
+	g_aLayers[LAYER_MAJORSTREET] = layers_new(LAYER_MAJORSTREET, "major-roads");
+	g_aLayers[LAYER_MINORHIGHWAY] = layers_new(LAYER_MINORHIGHWAY, "minor-highways");
+	g_aLayers[LAYER_MINORHIGHWAY_RAMP] = layers_new(LAYER_MINORHIGHWAY_RAMP, "minor-highway-ramps");
+	g_aLayers[LAYER_MAJORHIGHWAY] = layers_new(LAYER_MAJORHIGHWAY, "major-highways");
+	g_aLayers[LAYER_MAJORHIGHWAY_RAMP] = layers_new(LAYER_MAJORHIGHWAY_RAMP, "major-highway-ramps");
+	g_aLayers[LAYER_RAILROAD] = layers_new(LAYER_RAILROAD, "railroad");
+	g_aLayers[LAYER_PARK] = layers_new(LAYER_PARK, "parks");
+	g_aLayers[LAYER_RIVER] = layers_new(LAYER_RIVER, "rivers");
+	g_aLayers[LAYER_LAKE] = layers_new(LAYER_LAKE, "lakes");
+	g_aLayers[LAYER_MISC_AREA] = layers_new(LAYER_MISC_AREA, "misc-area");
 
-/* 3 */	{LAYER_MINORHIGHWAY, "Minor Highways",
-			{{
-			{{0.0, 0.0, 4.0, 5.0, 8.0, 9.0, 17.0,22.0,28.0,36.0}, {173/255.0, 142/255.0, 33/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND},
-			{{0.0, 0.0, 2.5, 3.1, 6.5, 7.0, 15.0,19.5,25.0,33.0}, {247/255.0, 223/255.0, 74/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND}
-			}},													// 255/255.0, 202/255.0, 58/255.0
-			
-			{{0,0,0,0,0,6,12,16,18,26}, /* font size */
-			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
-			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
-			 {0,0,0,0}}
-			},
+	/* init libxml */
+	LIBXML_TEST_VERSION
 
-/* 4 */	{LAYER_MINORHIGHWAY_RAMP, "Minor Highway Ramps",
-			{{
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 5.0,8.0,10.0}, {173/255.0, 142/255.0, 33/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND},
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.5, 3.5,6.0,8.0}, {247/255.0, 223/255.0, 74/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND}
-			}},
-			
-			{{0,0,0,0,0,0,0,0,0,0}, /* font size */
-			 {0,0,0,0,0,0,0,0,0,0}, /* bold */
-			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
-			 {0,0,0,0}}
-			},
+	layers_load_style(PACKAGE_SOURCE_DIR"/data/styles/road.xml");
 
-/* 5 */	{LAYER_MAJORHIGHWAY, "Major Highways",
-			{{
-			{{0.0, 0.0, 4.0, 10.0, 12.0, 16.0, 22.0,28.0,34.0,38.0}, {173/255.0, 162/255.0, 140/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT},
-			{{0.0, 0.0, 2.0, 8.5,  10.0, 14.0, 20.0,26.0,32.0,36.0}, {239/255.0, 190/255.0, 33/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
-			}},
-			
-			{{0,0,0,0,0,6,8,10,16,26}, /* font size */
-			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
-			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
-			 {0,0,0,0}}
-			},
+	xmlCleanupParser();
+}
 
-/* 6 */	{LAYER_MAJORHIGHWAY_RAMP, "Major Highway Ramps",
-			{{
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 7.0,16.0}, {173/255.0, 162/255.0, 140/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT},
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 5.5,14.0}, {0/255.0, 190/255.0, 0/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
-			}},
+void 
+layers_deinit(void)
+{
 
-			{{0,0,0,0,0,0,0,0,0,0}, /* font size */
-			 {0,0,0,0,0,0,0,0,0,0}, /* bold */
-			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
-			 {0,0,0,0}}
-			},
+}
+
+static layer_t*
+layers_new(gint index, gchar *name)
+{
+	layer_t *layer;
+
+	layer = g_new0(layer_t, 1);
+	layer->nLayerIndex = index;
+	layer->m_pszName = name;
+
+	return layer;
+}
+
+static void
+layers_load_style(const gchar * file)
+{
+	xmlDocPtr doc = NULL;
+	xmlNodePtr root_element = NULL;
+	//int i;
+
+	// Load style definition file
+	doc = xmlReadFile(PACKAGE_DATA_DIR"/data/layers.xml", NULL, 0);
+	if(doc == NULL) {
+		// try source directory if user hasn't done a 'make install' (good for development, too!)
+		doc = xmlReadFile(PACKAGE_SOURCE_DIR"/data/layers.xml", NULL, 0);
+
+		if(doc == NULL) {
+			g_message("cannot load file layers.xml\n");
+			gtk_exit(0);
+		}
+	}
+
+	root_element = xmlDocGetRootElement(doc);
+
+	layers_parse_layers(doc, root_element);
+
+	/*
+	for (i = 1; i <= MAX_ZOOMLEVEL; i++)
+		layers_print_layer(g_aLayers[i]);
+	*/
+
+	xmlFreeDoc(doc);
+}
+
+
+/*****************************************************************
+ * layers_parse_* functions for parsing the xml 
+ *****************************************************************/
+static void
+layers_parse_layers(xmlDocPtr doc, xmlNodePtr node)
+{
+	xmlNodePtr cur_node = NULL;
+
+	if (node->type == XML_ELEMENT_NODE && strcmp(node->name, "roadster-layers") == 0) {
+		for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
+			if (cur_node->type == XML_ELEMENT_NODE && strcmp(cur_node->name, "layer") == 0) {
+				layers_parse_layer(doc, cur_node);
+			}
+		}
+	}
+}
+
+static void
+layers_parse_layer(xmlDocPtr doc, xmlNodePtr node)
+{
+	xmlNodePtr cur_node = NULL;
+	xmlAttrPtr cur_attr = NULL;
+	gchar *layer_name;
+	layer_t *layer = NULL;
+	gint i;
+
+	for (cur_attr = node->properties; cur_attr; cur_attr = cur_attr->next) {
+		if (!strcmp(cur_attr->name, "name")) {
+			layer_name = xmlNodeListGetString(doc, cur_attr->xmlChildrenNode, 1);
+			printf("parsing layer: %s\n", layer_name);
+			for (i = 0; i <= NUM_LAYERS; i++) {
+				if (!strcmp(g_aLayers[i]->m_pszName, layer_name))
+					layer = g_aLayers[i];
+			}
+		}
+	}
+
+	if (layer) {
+		i = 0;
+		for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
+			if (cur_node->type == XML_ELEMENT_NODE && strcmp(cur_node->name, "sublayer") == 0) {
+				if (i < 2)
+					layers_parse_sublayer(doc, &(layer->m_Style.m_aSubLayers[i]), cur_node);
+				i++;
+			} else if (cur_node->type == XML_ELEMENT_NODE && strcmp(cur_node->name, "label") == 0) {
+				layers_parse_label(doc, &(layer->m_TextLabelStyle), cur_node);
+			}
+		}
+	}
+}
+
+static void
+layers_parse_sublayer(xmlDocPtr doc, sublayerstyle_t *sublayer, xmlNodePtr node)
+{
+	xmlNodePtr cur_node = NULL;
+
+	for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
+		if (cur_node->type == XML_ELEMENT_NODE && strcmp(cur_node->name, "property") == 0) {
+			layers_parse_sublayer_property(doc, sublayer, cur_node);
+		}
+	}
+}
+
+static void
+layers_parse_sublayer_property(xmlDocPtr doc, sublayerstyle_t *sublayer, xmlNodePtr node)
+{
+	xmlAttrPtr cur_attr = NULL;
+	gchar *name = NULL;
+	gchar *levelstr = NULL;
+	gchar *value = NULL;
+
+	for (cur_attr = node->properties; cur_attr; cur_attr = cur_attr->next) {
+		if (!strcmp(cur_attr->name, "name"))
+			name = xmlNodeListGetString(doc, cur_attr->xmlChildrenNode, 1);
+		else if (!strcmp(cur_attr->name, "level"))
+			levelstr = xmlNodeListGetString(doc, cur_attr->xmlChildrenNode, 1);
+		else if (!strcmp(cur_attr->name, "value"))
+			value = xmlNodeListGetString(doc, cur_attr->xmlChildrenNode, 1);
+	}
+
+	if (name && value) {
+		gdouble width;
+		gint i, level;
+
+		level = (levelstr? atoi(levelstr): 0);
+
+		if (!strcmp(name, "width")) {
+			for (i = level-1; i < MAX_ZOOMLEVEL; i++)
+				sublayer->m_afLineWidths[i] = (gdouble)atof(value);
+
+		} else if (!strcmp(name, "color")) {
+			layers_parse_color(&(sublayer->m_clrColor), value);
+
+		} else if (!strcmp(name, "join-style")) {
+			if (!strcmp(value, "mitre"))
+				sublayer->m_nJoinStyle = CAIRO_LINE_JOIN_MITER;
+			else if (!strcmp(value, "round"))
+				sublayer->m_nJoinStyle = CAIRO_LINE_JOIN_ROUND;
+
+		} else if (!strcmp(name, "cap-style")) {
+			if (!strcmp(value, "butt"))
+				sublayer->m_nCapStyle = CAIRO_LINE_CAP_BUTT;
+			else if (!strcmp(value, "round"))
+				sublayer->m_nCapStyle = CAIRO_LINE_CAP_ROUND;
+
+		}
+	}
+}
+
+static void
+layers_parse_label(xmlDocPtr doc, textlabelstyle_t *label_style, xmlNodePtr node)
+{
+	xmlNodePtr cur_node = NULL;
+
+	for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
+		if (cur_node->type == XML_ELEMENT_NODE && strcmp(cur_node->name, "property") == 0) {
+			layers_parse_label_property(doc, label_style, cur_node);
+		}
+	}
+}
+
+static void
+layers_parse_label_property(xmlDocPtr doc, textlabelstyle_t *label_style, xmlNodePtr node)
+{
+	xmlAttrPtr cur_attr = NULL;
+	gchar *name = NULL;
+	gchar *levelstr = NULL;
+	gchar *value = NULL;
+
+	for (cur_attr = node->properties; cur_attr; cur_attr = cur_attr->next) {
+		if (!strcmp(cur_attr->name, "name"))
+			name = xmlNodeListGetString(doc, cur_attr->xmlChildrenNode, 1);
+		else if (!strcmp(cur_attr->name, "level"))
+			levelstr = xmlNodeListGetString(doc, cur_attr->xmlChildrenNode, 1);
+		else if (!strcmp(cur_attr->name, "value"))
+			value = xmlNodeListGetString(doc, cur_attr->xmlChildrenNode, 1);
+	}
+
+	if (name && value) {
+		gint i, level;
+
+		level = (levelstr? atoi(levelstr): 0);
+
+		if (!strcmp(name, "font-size")) {
+			for (i = level-1; i < MAX_ZOOMLEVEL; i++)
+				label_style->m_afFontSizeAtZoomLevel[i] = (gdouble)atof(value);
 			
-/* 7 */	{LAYER_RAILROAD, "Railroads",
-			{{
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.6, 0.6, 0.6, 1.2}, {80/255.0, 80/255.0, 110/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT},
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 4.0, 7.0}, {80/255.0, 80/255.0, 110/255.0, 1.00}, 1, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
-			}},
+		} else if (!strcmp(name, "bold")) {
+			for (i = level-1; i < MAX_ZOOMLEVEL; i++)
+				label_style->m_abBoldAtZoomLevel[i] = (strcmp(value, "yes")? 0: 1);
 			
-			{{0,0,0,0,0,0,10,10,10,10}, /* font size */
-			 {0,0,0,0,0,0,0,0,0,0}, /* bold */
-			 {0,0,0,0,0,0,4,4,4,4}, /* halo */
-			 {0,0,0,0}}
-			},
-
-/* 8 */	{LAYER_PARK, "Parks",
-			{{
-			{{0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, {173/255.0, 202/255.0, 148/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT},
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {135/255.0, 172/255.0, 126/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
-			}},
+		} else if (!strcmp(name, "halo")) {
+			for (i = level-1; i < MAX_ZOOMLEVEL; i++)
+				label_style->m_afHaloAtZoomLevel[i] = (gdouble)atof(value);
 			
-			{{0,0,0,0,0,0,10,12,12,14}, /* font size */
-			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
-			 {0,0,0,0,0,0,3,3,3,3}, /* halo */
-			 {0.1,0.1,0.1, 1.0}}
-			},
+		} else if (!strcmp(name, "color")) {
+			layers_parse_color(&(label_style->m_clrColor), value);
 
-/* 9 */{LAYER_RIVER, "Rivers",
-			{{
-			{{0.0, 0.0, 0.0, 0.0, 1.0, 4.0, 6.0, 10.0, 14.0, 18.0}, {148/255.0, 178/255.0, 197/255.0, 1.00}, 0, CAIRO_LINE_JOIN_ROUND, CAIRO_LINE_CAP_ROUND},
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0/255.0, 0/255.0, 0/255.0, 1.00}, 0, CAIRO_LINE_JOIN_ROUND, CAIRO_LINE_CAP_ROUND}
-			}},
-			
-			{{0,0,0,0,0,0,10,12,12,14}, /* font size */
-			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
-			 {0,0,0,0,0,0,3,3,3,3}, /* halo */
-			 {128/255.0, 158/255.0, 180/255.0, 1.0}}
-			},
+		}
+	}
+}
 
-/* 10 */{LAYER_LAKE, "Lakes",
-			{{
-			{{0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, {148/255.0, 178/255.0, 197/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT},
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0/255.0, 0/255.0, 0/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
-			}},
-			
-			{{0,0,0,0,0,0,10,12,12,14}, /* font size */
-			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
-			 {0,0,0,0,0,0,3,3,3,3}, /* halo */
-			 {0.1,0.1,0.1, 1.0}}
-			},
+static void
+layers_parse_color(color_t *color, gchar *value)
+{
+	gchar *ptr;
+
+	ptr = value;
+	if (*ptr == '#') ptr++;
+
+	if (strlen(ptr) < 8)
+		return;
+
+	ptr += 6;
+	color->m_fAlpha = (gfloat)strtol(ptr, NULL, 16)/255.0;
+	*ptr = '\0';
+	ptr -= 2;
+	color->m_fBlue = (gfloat)strtol(ptr, NULL, 16)/255.0;
+	*ptr = '\0';
+	ptr -= 2;
+	color->m_fGreen = (gfloat)strtol(ptr, NULL, 16)/255.0;
+	*ptr = '\0';
+	ptr -= 2;
+	color->m_fRed = (gfloat)strtol(ptr, NULL, 16)/255.0;
+}
+
+
+/******************************************************************
+ * layers_print_* functions for debugging
+ *****************************************************************/
+static void
+layers_print_layer(layer_t *layer)
+{
+	printf("---------------\nlayer: %s (%d)\n", layer->m_pszName, layer->nLayerIndex);
+	layers_print_sublayer(&(layer->m_Style.m_aSubLayers[0]));
+	layers_print_sublayer(&(layer->m_Style.m_aSubLayers[1]));
+	//layers_print_labelstyle(&(layer->m_TextLabelStyle));
+}
+
+static void
+layers_print_sublayer(sublayerstyle_t *sublayer)
+{
+	int i;
+
+	printf("line widths: ");
+	for(i = MIN_ZOOMLEVEL; i <= MAX_ZOOMLEVEL; i++) printf(" %2.2f", sublayer->m_afLineWidths[i]);
+	printf("\n");
+
+	layers_print_color(&(sublayer->m_clrColor));
+	
+	printf("join style: %d\n", sublayer->m_nJoinStyle);
+	printf("cap style: %d\n", sublayer->m_nCapStyle);
+}
+
+static void
+layers_print_color(color_t *color)
+{
+	printf("color: %3.2f, %3.2f, %3.2f, %3.2f\n", color->m_fRed, color->m_fGreen, color->m_fBlue, color->m_fAlpha);
+}
 
-/* 11 */{LAYER_MISC_AREA, "Misc Areas",
-			{{
-			{{0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, {155/255.0, 155/255.0, 155/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT},
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0/255.0, 0/255.0, 0/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
-			}},
-			
-			{{0,0,0,0,0,0,10,12,12,14}, /* font size */
-			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
-			 {0,0,0,0,0,0,3,3,3,3}, /* halo */
-			 {0.25,0.25,0.25,1.0}}
-			},
-};

Index: layers.h
===================================================================
RCS file: /cvs/cairo/roadster/src/layers.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- layers.h	1 Mar 2005 19:48:21 -0000	1.3
+++ layers.h	3 Mar 2005 06:45:09 -0000	1.4
@@ -1,8 +1,9 @@
 /***************************************************************************
  *            layers.h
  *
- *  Copyright  2005  Ian McIntosh
- *  ian_mcintosh at linuxadvocate.org
+ *  Copyright 2005
+ *  Ian McIntosh <ian_mcintosh at linuxadvocate.org>
+ *  Nathan Fredrickson <nathan at silverorange.com>
  ****************************************************************************/
 
 /*
@@ -95,7 +96,10 @@
 	textlabelstyle_t m_TextLabelStyle;
 } layer_t;
 
-extern layer_t g_aLayers[NUM_LAYERS+1];
+extern layer_t * g_aLayers[NUM_LAYERS+1];
+
+void layers_init(void);
+void layers_deinit(void);
 
 #ifdef __cplusplus
 }

Index: main.c
===================================================================
RCS file: /cvs/cairo/roadster/src/main.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- main.c	1 Mar 2005 19:48:21 -0000	1.8
+++ main.c	3 Mar 2005 06:45:09 -0000	1.9
@@ -83,6 +83,8 @@
 	pointstring_init();
 	g_print("initializing tracks\n");
 	track_init();
+	g_print("initializing layers\n");
+	layers_init();
 	g_print("initializing glyphs\n");
 	glyph_init();
 	g_print("initializing map\n");

Index: map.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- map.c	2 Mar 2005 06:25:48 -0000	1.13
+++ map.c	3 Mar 2005 06:45:09 -0000	1.14
@@ -807,8 +807,8 @@
 			layerdraworder[i].pFunc(pMap, pCairo,
 						pRenderMetrics,
 				/* geometry */ 	pMap->m_apLayerData[nLayer]->m_pPointStringsArray,
-				/* style */ 	&g_aLayers[nLayer].m_Style.m_aSubLayers[nSubLayer],
-						&g_aLayers[nLayer].m_TextLabelStyle
+				/* style */ 	&(g_aLayers[nLayer]->m_Style.m_aSubLayers[nSubLayer]),
+						&(g_aLayers[nLayer]->m_TextLabelStyle)
 						);
 		}
 	TIMER_END(maptimer, "END RENDER MAP");
@@ -1125,8 +1125,8 @@
 	gint nActiveLayerCount = 0;
 	gint i;
 	for(i=LAYER_FIRST ; i <= LAYER_LAST ;i++) {
-		if(g_aLayers[i].m_Style.m_aSubLayers[0].m_afLineWidths[nZoomLevel-1] != 0.0 ||
-		   g_aLayers[i].m_Style.m_aSubLayers[1].m_afLineWidths[nZoomLevel-1] != 0.0)
+		if(g_aLayers[i]->m_Style.m_aSubLayers[0].m_afLineWidths[nZoomLevel-1] != 0.0 ||
+		   g_aLayers[i]->m_Style.m_aSubLayers[1].m_afLineWidths[nZoomLevel-1] != 0.0)
 		{
 			gchar azLayerNumber[10];
 




More information about the cairo-commit mailing list