]> saetta.ns0.it Git - libgtkgis/commitdiff
Ended initial layer's label support.
authorAndrea Zagli <azagli@libero.it>
Sun, 16 Aug 2009 13:55:37 +0000 (15:55 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 16 Aug 2009 13:55:37 +0000 (15:55 +0200)
Many bug fixes.

22 files changed:
.gitignore
INSTALL [deleted symlink]
docs/reference/libgtkgis-decl-list.txt
docs/reference/libgtkgis-decl.txt
docs/reference/libgtkgis-undeclared.txt
docs/reference/libgtkgis-undocumented.txt
docs/reference/libgtkgis-unused.txt
docs/reference/tmpl/geometryline.sgml
docs/reference/tmpl/layer.sgml
docs/reference/tmpl/libgtkgis-unused.sgml
src/geometry.c
src/geometry.h
src/geometryline.c
src/geometryline.h
src/geometrypoint.c
src/geometrypolygon.c
src/gtkgis.c
src/layer.c
src/layer.h
src/layersource.c
tests/from_xml.c
tests/test1.gtkgis

index 197a3e0e9058c79cff8d2d77c5734b13d8a88d56..3cb57fa19724ead421b8eb1567f707bbf7240833 100644 (file)
@@ -23,6 +23,7 @@ configure
 depcomp
 gtk-doc.make
 install-sh
+INSTALL
 libgtkgis.pc
 libtool
 ltmain.sh
diff --git a/INSTALL b/INSTALL
deleted file mode 120000 (symlink)
index 5bb6e7b..0000000
--- a/INSTALL
+++ /dev/null
@@ -1 +0,0 @@
-/usr/share/automake-1.10/INSTALL
\ No newline at end of file
index 93bc5b81daad2df46b443a036c178e7a8e8134bf..37d6dc3a3893b2659906f3e3dd872f941d16a5d3 100644 (file)
@@ -147,7 +147,7 @@ GTK_GIS_GEOMETRY_LINE_GET_CLASS
 GtkGisGeometryLine
 gtk_gis_geometry_line_get_type
 gtk_gis_geometry_line_new
-gtk_gis_geometry_line_new_from_list
+gtk_gis_geometry_line_new_from_points
 gtk_gis_geometry_line_add_point
 gtk_gis_geometry_line_add_point_from_coordinates
 gtk_gis_geometry_line_get_svg_path
index 2806a3719ca43fa1fbecfca34b508694bd1e6f99..7600ce706788e18eacf0ba7be8b7427817e740b0 100644 (file)
@@ -550,7 +550,7 @@ GtkGisLayer *layer
 <FUNCTION>
 <NAME>gtk_gis_layer_set_style</NAME>
 <RETURNS>void </RETURNS>
-GtkGisLayer *layer, GtkGisLayerStyle style
+GtkGisLayer *layer, GtkGisLayerStyle *style
 </FUNCTION>
 <FUNCTION>
 <NAME>gtk_gis_layer_get_label</NAME>
@@ -564,8 +564,8 @@ GtkGisLayer *layer, GtkGisLayerLabel *label
 </FUNCTION>
 <FUNCTION>
 <NAME>gtk_gis_layer_draw</NAME>
-<RETURNS>void </RETURNS>
-GtkGisLayer *layer, GooCanvasItem *root, GtkGisScale *scale
+<RETURNS>GooCanvasItem *</RETURNS>
+GtkGisLayer *layer, GtkGisScale *scale
 </FUNCTION>
 <MACRO>
 <NAME>TYPE_GTK_GIS_GEOMETRY_LINE</NAME>
@@ -622,14 +622,14 @@ void
 void
 </FUNCTION>
 <FUNCTION>
-<NAME>gtk_gis_geometry_line_new_from_list</NAME>
+<NAME>gtk_gis_geometry_line_new_from_points</NAME>
 <RETURNS>GtkGisGeometry *</RETURNS>
 GSList *points
 </FUNCTION>
 <FUNCTION>
 <NAME>gtk_gis_geometry_line_add_point</NAME>
 <RETURNS>void </RETURNS>
-GtkGisGeometryLine *line, GtkGisPoint point
+GtkGisGeometryLine *line, GtkGisPoint *point
 </FUNCTION>
 <FUNCTION>
 <NAME>gtk_gis_geometry_line_add_point_from_coordinates</NAME>
@@ -688,7 +688,7 @@ struct _GtkGisGeometryClass
 
                GooCanvasItem *(*draw) (GtkGisGeometry *geometry,
                                        GtkGisScale *scale,
-                                       GtkGisLayerStyle style);
+                                       GtkGisLayerStyle *style);
        };
 </STRUCT>
 <FUNCTION>
@@ -724,7 +724,7 @@ GtkGisGeometry *geometry
 <FUNCTION>
 <NAME>gtk_gis_geometry_draw</NAME>
 <RETURNS>GooCanvasItem *</RETURNS>
-GtkGisGeometry *geometry,GtkGisScale *scale,GtkGisLayerStyle style
+GtkGisGeometry *geometry,GtkGisScale *scale,GtkGisLayerStyle *style
 </FUNCTION>
 <MACRO>
 <NAME>TYPE_GTK_GIS_LAYER_SOURCE_POSTGIS</NAME>
index 994f2fb64238b6ebb2b211d9960ca381e6c58691..e80e9c725fe71a2bf4e82a8a733549cd34fb3fa0 100644 (file)
@@ -1,2 +1,3 @@
+gtk_gis_geometry_line_new_from_list
 gtk_gis_geometry_polygon_add_line_from_list
 gtk_gis_geometry_polygon_new_from_list
index 1aad4e22a06f6fa5b5c186150830a07defd9f185..7dfb79f4bbb94989d5d53d8ac84f99ff9b5a3011 100644 (file)
@@ -1,7 +1,7 @@
 11% symbol docs coverage.
-22 symbols documented.
+23 symbols documented.
 7 symbols incomplete.
-180 not documented.
+179 not documented.
 
 
 GTK_GIS
@@ -163,7 +163,6 @@ gtk_gis_save_to_xml
 gtk_gis_set_scale
 gtk_gis_zoom_to_extent
 gtk_gis_zoom_to_layer
-gtk_gis_zoom_to_max
 
 
 commons:Long_Description
index b02fb8657b91962b810ceb6a6b12215fdb0ec463..156933948adee10f24b1bd611d6ae68dfe266f88 100644 (file)
@@ -13,6 +13,7 @@ GtkGisLayersGroupClass
 gtk_gis_geometry_get_extent
 gtk_gis_geometry_get_label
 gtk_gis_geometry_line_get_svg_path
+gtk_gis_geometry_line_new_from_points
 gtk_gis_geometry_polygon_add_line_from_points
 gtk_gis_geometry_polygon_new_from_points
 gtk_gis_geometry_set_label
index 4d0e081978c16e156e82dff27214f9ded39628bb..88afbd6234477cb3d97403287949bfd7a33d6796 100644 (file)
@@ -86,15 +86,6 @@ GtkGisGeometryLine
 @Returns: 
 
 
-<!-- ##### FUNCTION gtk_gis_geometry_line_new_from_list ##### -->
-<para>
-
-</para>
-
-@points: 
-@Returns: 
-
-
 <!-- ##### FUNCTION gtk_gis_geometry_line_add_point ##### -->
 <para>
 
index 95f4c199dd1db417f0b2684e184df7171fd9dd52..eaf9acb39803692442c521dcfa75237d27418116 100644 (file)
@@ -195,7 +195,7 @@ GtkGisLayer
 </para>
 
 @layer: 
-@root: 
 @scale: 
+@Returns: 
 
 
index 75e4975a2655701470917a9ae4d3745e7b8c2322..17ef532584c629d40ff4df19ac4d0052dba533f4 100644 (file)
@@ -1,3 +1,11 @@
+<!-- ##### FUNCTION gtk_gis_geometry_line_new_from_list ##### -->
+<para>
+
+</para>
+
+@points: 
+@Returns: 
+
 <!-- ##### FUNCTION gtk_gis_geometry_polygon_add_line_from_list ##### -->
 <para>
 
index 49a007ef362304fdce1b0a6261ba40bac51a9467..be1058f2c5a9057d86731834ff6d7472ea1148bc 100644 (file)
@@ -70,6 +70,7 @@ gtk_gis_geometry_init (GtkGisGeometry *gtk_gis_geometry)
        GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry);
 
        priv->editable = FALSE;
+       priv->label = NULL;
 }
 
 /**
@@ -109,23 +110,33 @@ gtk_gis_geometry_set_editable (GtkGisGeometry *geometry, gboolean editable)
 
 /**
  * gtk_gis_geometry_get_label:
- * @geometry:
+ * @geometry: a #GtkGisGeometry object.
  *
+ * Returns: the field's name used as label.
  */
 const gchar
 *gtk_gis_geometry_get_label (GtkGisGeometry *geometry)
 {
        GtkGisGeometryPrivate *priv;
+       gchar *label;
        
        g_return_val_if_fail (IS_GTK_GIS_GEOMETRY (geometry), NULL);
 
-       return g_strdup (priv->label);
+       priv = GTK_GIS_GEOMETRY_GET_PRIVATE (geometry);
+
+       label = NULL;
+       if (priv->label != NULL)
+               {
+                       label = g_strdup (priv->label);
+               }
+
+       return label;
 }
 
 /**
  * gtk_gis_geometry_set_label:
- * @geometry:
- * @label:
+ * @geometry: a #GtkGisGeometry object.
+ * @label: the field's name to use as label.
  *
  */
 void
@@ -135,12 +146,21 @@ gtk_gis_geometry_set_label (GtkGisGeometry *geometry, const gchar *label)
        
        g_return_if_fail (IS_GTK_GIS_GEOMETRY (geometry));
 
-       priv->label = g_strdup (label);
+       priv = GTK_GIS_GEOMETRY_GET_PRIVATE (geometry);
+
+       if (label == NULL)
+               {
+                       priv->label = NULL;
+               }
+       else
+               {
+                       priv->label = g_strdup (label);
+               }
 }
 
 /**
  * gtk_gis_geometry_get_extent:
- * @line: a #GtkGisGeometry object.
+ * @geometry: a #GtkGisGeometry object.
  *
  */
 GtkGisExtent
@@ -159,12 +179,14 @@ GtkGisExtent
 /**
  * gtk_gis_geometry_draw:
  * @geometry: a #GtkGisGeometry object.
+ * @scale:
+ * @style:
  *
  */
 GooCanvasItem
 *gtk_gis_geometry_draw (GtkGisGeometry *geometry,
                         GtkGisScale *scale,
-                        GtkGisLayerStyle style)
+                        GtkGisLayerStyle *style)
 {
        GooCanvasItem *item = NULL;
 
index 95e53c6f47611e82d2c563558763ad431ee5d3e0..50a7ad547598a523c3f487aeb6379f47d8055e12 100644 (file)
@@ -54,7 +54,7 @@ struct _GtkGisGeometryClass
 
                GooCanvasItem *(*draw) (GtkGisGeometry *geometry,
                                        GtkGisScale *scale,
-                                       GtkGisLayerStyle style);
+                                       GtkGisLayerStyle *style);
        };
 
 GType gtk_gis_geometry_get_type (void) G_GNUC_CONST;
@@ -70,7 +70,7 @@ GtkGisExtent *gtk_gis_geometry_get_extent (GtkGisGeometry *geometry);
 
 GooCanvasItem *gtk_gis_geometry_draw (GtkGisGeometry *geometry,
                                       GtkGisScale *scale,
-                                      GtkGisLayerStyle style);
+                                      GtkGisLayerStyle *style);
 
 
 G_END_DECLS
index a11398fde580cebeecfa1ea57cb489427ec3523d..c76c7c9a6e38c0af982a35fd8937b41fdb596f60 100644 (file)
@@ -35,7 +35,7 @@ static gchar *convert_comma_to_dot (gchar *str);
 static GtkGisExtent *gtk_gis_geometry_line_get_extent (GtkGisGeometry *line);
 static GooCanvasItem *gtk_gis_geometry_line_draw (GtkGisGeometry *line,
                                                   GtkGisScale *scale,
-                                                  GtkGisLayerStyle style);
+                                                  GtkGisLayerStyle *style);
 
 static void gtk_gis_geometry_line_set_property (GObject *object,
                                      guint property_id,
@@ -101,7 +101,7 @@ GtkGisGeometry
 }
 
 /**
- * gtk_gis_geometry_line_new_from_list:
+ * gtk_gis_geometry_line_new_from_points:
  * @points: a #GSList of #GtkGisPoint to add to the line.
  *
  * Creates a new #GtkGisGeometryLine object.
@@ -109,16 +109,25 @@ GtkGisGeometry
  * Returns: the newly created #GtkGisGeometryLine object.
  */
 GtkGisGeometry
-*gtk_gis_geometry_line_new_from_list (GSList *points)
+*gtk_gis_geometry_line_new_from_points (GSList *points)
 {
        GtkGisGeometry *line = NULL;
        GtkGisGeometryLinePrivate *priv;
+       GSList *cur;
+
+       g_return_val_if_fail (points != NULL, NULL);
 
        line = gtk_gis_geometry_line_new ();
 
        priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (GTK_GIS_GEOMETRY_LINE (line));
 
-       priv->points = g_slist_copy (points);
+       cur = points;
+       while (cur != NULL)
+               {
+                       gtk_gis_geometry_line_add_point (GTK_GIS_GEOMETRY_LINE (line), (GtkGisPoint *)cur->data);
+
+                       cur = g_slist_next (cur);
+               }
 
        return line;
 }
@@ -129,7 +138,7 @@ GtkGisGeometry
  * @point: a #GtkGisPoint to add to the line.
  */
 void
-gtk_gis_geometry_line_add_point (GtkGisGeometryLine *line, GtkGisPoint point)
+gtk_gis_geometry_line_add_point (GtkGisGeometryLine *line, GtkGisPoint *point)
 {
        GtkGisGeometryLinePrivate *priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (line);
 
@@ -139,11 +148,11 @@ gtk_gis_geometry_line_add_point (GtkGisGeometryLine *line, GtkGisPoint point)
 
        gpoint = g_malloc0 (sizeof (GtkGisPoint));
 
-       gpoint->x = point.x;
-       gpoint->y = point.y;
+       gpoint->x = point->x;
+       gpoint->y = point->y;
 
        /* recalculate the new extent */
-       if (priv->extent = NULL)
+       if (priv->extent == NULL)
                {
                        priv->extent = g_malloc (sizeof (GtkGisExtent));
                        priv->extent->min_x = gpoint->x;
@@ -185,12 +194,14 @@ void
 gtk_gis_geometry_line_add_point_from_coordinates (GtkGisGeometryLine *line,
                                                   gdouble x, gdouble y)
 {
-       GtkGisPoint gpoint;
+       GtkGisPoint *gpoint;
 
        g_return_if_fail (IS_GTK_GIS_GEOMETRY_LINE (line));
 
-       gpoint.x = x;
-       gpoint.y = y;
+       gpoint = g_malloc0 (sizeof (GtkGisPoint));
+
+       gpoint->x = x;
+       gpoint->y = y;
 
        gtk_gis_geometry_line_add_point (line, gpoint);
 }
@@ -276,7 +287,7 @@ static GtkGisExtent
 static GooCanvasItem
 *gtk_gis_geometry_line_draw (GtkGisGeometry *line,
                              GtkGisScale *scale,
-                             GtkGisLayerStyle style)
+                             GtkGisLayerStyle *style)
 {
        GtkGisGeometryLinePrivate *priv;
        GooCanvasItem *item = NULL;
@@ -290,11 +301,44 @@ static GooCanvasItem
                        path = (gchar *)gtk_gis_geometry_line_get_svg_path (GTK_GIS_GEOMETRY_LINE (line));
                        if (path != NULL)
                                {
+                                       const gchar *str_label;
+
                                        item = goo_canvas_path_new (NULL,
                                                                    path,
-                                                                   "line-width", style.width / scale->xy,
-                                                                   "stroke-color", style.stroke_color,
+                                                                   "line-width", style->width / scale->xy,
+                                                                   "stroke-color", style->stroke_color,
                                                                    NULL);
+
+                                       str_label = gtk_gis_geometry_get_label (line);
+                                       if (str_label != NULL
+                                               && g_strcmp0 (str_label, "") != 0)
+                                               {
+                                                       GooCanvasItem *group;
+                                                       gdouble x;
+                                                       gdouble y;
+
+                                                       group = goo_canvas_group_new (NULL, NULL);
+
+                                                       goo_canvas_item_add_child (group, item, -1);
+
+                                                       /* center the label inside the polygon */
+
+                                                       /* TO DO
+                                                        * the label must be visible every time that the polygon is visible
+                                                        */
+
+                                                       x = priv->extent->min_x + (priv->extent->max_x - priv->extent->min_x) / 2;
+                                                       y = priv->extent->min_y + (priv->extent->max_y - priv->extent->min_y) / 2;
+
+                                                       goo_canvas_text_new (group,
+                                                                                    str_label,
+                                                                                    x, y, -1,
+                                                                                    GTK_ANCHOR_CENTER,
+                                                                                    "font", g_strdup_printf ("Sans %fpx", 12 / scale->xy),
+                                                                                    NULL);
+
+                                                       item = group;
+                                               }
                                }
                }
 
index 96a73ca9939d744cdf6a42d26c65bd97e0757e0d..80d5c46846db66d56361878309f2bb29729ade81 100644 (file)
@@ -52,9 +52,9 @@ GType gtk_gis_geometry_line_get_type (void) G_GNUC_CONST;
 
 GtkGisGeometry *gtk_gis_geometry_line_new (void);
 
-GtkGisGeometry *gtk_gis_geometry_line_new_from_list (GSList *points);
+GtkGisGeometry *gtk_gis_geometry_line_new_from_points (GSList *points);
 
-void gtk_gis_geometry_line_add_point (GtkGisGeometryLine *line, GtkGisPoint point);
+void gtk_gis_geometry_line_add_point (GtkGisGeometryLine *line, GtkGisPoint *point);
 void gtk_gis_geometry_line_add_point_from_coordinates (GtkGisGeometryLine *line,
                                                        gdouble x, gdouble y);
 
index 90b01ae0166912a02c878895fb9087bf5d1a51ae..797988449b6a97d0bd2f11ec8acfeb9232750c76 100644 (file)
@@ -33,7 +33,7 @@ static void gtk_gis_geometry_point_init (GtkGisGeometryPoint *gtk_gis_geometry_p
 static GtkGisExtent *gtk_gis_geometry_point_get_extent (GtkGisGeometry *point);
 static GooCanvasItem *gtk_gis_geometry_point_draw (GtkGisGeometry *point,
                                                    GtkGisScale *scale,
-                                                   GtkGisLayerStyle style);
+                                                   GtkGisLayerStyle *style);
 
 static void gtk_gis_geometry_point_set_property (GObject *object,
                                      guint property_id,
@@ -173,7 +173,7 @@ static GtkGisExtent
 static
 GooCanvasItem *gtk_gis_geometry_point_draw (GtkGisGeometry *point,
                                             GtkGisScale *scale,
-                                            GtkGisLayerStyle style)
+                                            GtkGisLayerStyle *style)
 {
        GooCanvasItem *item = NULL;
 
@@ -181,13 +181,35 @@ GooCanvasItem *gtk_gis_geometry_point_draw (GtkGisGeometry *point,
 
        if (priv->point != NULL)
                {
+                       const gchar *str_label;
+
                        item = goo_canvas_ellipse_new (NULL,
                                                       priv->point->x, priv->point->y,
-                                                      0.5 / scale->x, 0.5 / scale->y,
-                                                      "line-width", style.width / scale->xy,
-                                                      "stroke-color", style.stroke_color,
-                                                      "fill-color", style.fill_color,
+                                                      (style->width / 2) / scale->x, (style->width / 2) / scale->y,
+                                                      "line-width", style->width / scale->xy,
+                                                      "stroke-color", style->stroke_color,
+                                                      "fill-color", style->fill_color,
                                                       NULL);
+
+                       str_label = gtk_gis_geometry_get_label (point);
+                       if (str_label != NULL
+                           && g_strcmp0 (str_label, "") != 0)
+                               {
+                                       GooCanvasItem *group;
+
+                                       group = goo_canvas_group_new (NULL, NULL);
+
+                                       goo_canvas_item_add_child (group, item, -1);
+
+                                       goo_canvas_text_new (group,
+                                                            str_label,
+                                                            priv->point->x, priv->point->y, -1,
+                                                            GTK_ANCHOR_CENTER,
+                                                            "font", g_strdup_printf ("Sans %fpx", 12 / scale->xy),
+                                                            NULL);
+
+                                       item = group;
+                               }
                }
 
        return item;
index 38f5029c93ad816a681d2463fe5d64bdf7b77d4a..ca15d6323a15e610c9c5f3eefcab83a4415ba963 100644 (file)
@@ -33,7 +33,7 @@ static void gtk_gis_geometry_polygon_init (GtkGisGeometryPolygon *gtk_gis_geomet
 static GtkGisExtent *gtk_gis_geometry_polygon_get_extent (GtkGisGeometry *polygon);
 static GooCanvasItem *gtk_gis_geometry_polygon_draw (GtkGisGeometry *polygon,
                                                      GtkGisScale *scale,
-                                                    GtkGisLayerStyle style);
+                                                     GtkGisLayerStyle *style);
 
 static void gtk_gis_geometry_polygon_set_property (GObject *object,
                                      guint property_id,
@@ -131,7 +131,7 @@ GtkGisGeometry
        GtkGisGeometry *polygon = NULL;
        GtkGisGeometry *line = NULL;
 
-       line = gtk_gis_geometry_line_new_from_list (points);
+       line = gtk_gis_geometry_line_new_from_points (points);
 
        if (line != NULL)
                {
@@ -163,7 +163,7 @@ gtk_gis_geometry_polygon_add_line (GtkGisGeometryPolygon *polygon,
        /* recalculate the new extent */
        line_extent = gtk_gis_geometry_get_extent (GTK_GIS_GEOMETRY (line));
 
-       if (priv->extent = NULL)
+       if (priv->extent == NULL)
                {
                        priv->extent = g_malloc (sizeof (GtkGisExtent));
                        priv->extent->min_x = line_extent->min_x;
@@ -208,7 +208,7 @@ gtk_gis_geometry_polygon_add_line_from_points (GtkGisGeometryPolygon *polygon,
 
        g_return_if_fail (IS_GTK_GIS_GEOMETRY_POLYGON (polygon));
 
-       line = gtk_gis_geometry_line_new_from_list (points);
+       line = gtk_gis_geometry_line_new_from_points (points);
 
        if (line != NULL)
                {
@@ -255,7 +255,7 @@ static GtkGisExtent
 static GooCanvasItem
 *gtk_gis_geometry_polygon_draw (GtkGisGeometry *polygon,
                                 GtkGisScale *scale,
-                                GtkGisLayerStyle style)
+                                GtkGisLayerStyle *style)
 {
        GtkGisGeometryPolygonPrivate *priv;
        GooCanvasItem *item = NULL;
@@ -272,7 +272,6 @@ static GooCanvasItem
                        GtkGisGeometry *line;
 
                        const gchar *str_label;
-                       GooCanvasItem *item_label;
 
                        cur = priv->lines;
                        while (cur != NULL)
@@ -287,10 +286,10 @@ static GooCanvasItem
                                }
 
                        item = goo_canvas_path_new (NULL,
-                                                   path,
-                                                   "line-width", style.width / scale->xy,
-                                                   "stroke-color", style.stroke_color,
-                                                   "fill-color", style.fill_color,
+                                                   path + 1,
+                                                   "line-width", style->width / scale->xy,
+                                                   "stroke-color", style->stroke_color,
+                                                   "fill-color", style->fill_color,
                                                    "fill-rule", CAIRO_FILL_RULE_EVEN_ODD,
                                                    NULL);
 
@@ -298,9 +297,14 @@ static GooCanvasItem
                        if (str_label != NULL
                            && g_strcmp0 (str_label, "") != 0)
                                {
+                                       GooCanvasItem *group;
                                        gdouble x;
                                        gdouble y;
 
+                                       group = goo_canvas_group_new (NULL, NULL);
+
+                                       goo_canvas_item_add_child (group, item, -1);
+
                                        /* center the label inside the polygon */
 
                                        /* TO DO
@@ -310,12 +314,14 @@ static GooCanvasItem
                                        x = priv->extent->min_x + (priv->extent->max_x - priv->extent->min_x) / 2;
                                        y = priv->extent->min_y + (priv->extent->max_y - priv->extent->min_y) / 2;
 
-                                       item_label = goo_canvas_text_new (item,
-                                                                         str_label,
-                                                                         x, y, -1,
-                                                                         GTK_ANCHOR_CENTER,
-                                                                         "font", "Sans 12",
-                                                                         NULL);
+                                       goo_canvas_text_new (group,
+                                                            str_label,
+                                                            x, y, -1,
+                                                            GTK_ANCHOR_CENTER,
+                                                            "font", g_strdup_printf ("Sans %fpx", 12 / scale->xy),
+                                                            NULL);
+
+                                       item = group;
                                }
                }
 
index 45d1ef24b56dccea20840ef11a41a0339c2a2dba..694d07ff25221f3261d70affffcfceebbfdef662 100644 (file)
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <locale.h>
+
 #include <goocanvas.h>
 
 #include <ogr_api.h>
@@ -289,27 +291,31 @@ GtkWidget
                                                                                                && xmlStrcmp (cur->name, "style") == 0)
                                                                                                {
                                                                                                        xmlNode *xml_style;
-                                                                                                       GtkGisLayerStyle style;
+                                                                                                       GtkGisLayerStyle *style;
 
                                                                                                        xml_style = cur;
 
+                                                                                                       style = g_malloc0 (sizeof (GtkGisLayerStyle));
+                                                                                                       style->stroke_color = NULL;
+                                                                                                       style->fill_color = NULL;
+
                                                                                                        cur = cur->children;
                                                                                                        while (cur != NULL)
                                                                                                                {
                                                                                                                        if (cur->type == XML_ELEMENT_NODE
                                                                                                                                && (xmlStrcmp (cur->name, "width") == 0))
                                                                                                                                {
-                                                                                                                                       style.width = g_strtod ((gchar *)xmlNodeGetContent (cur), NULL);
+                                                                                                                                       style->width = g_strtod ((gchar *)xmlNodeGetContent (cur), NULL);
                                                                                                                                }
                                                                                                                        else if (cur->type == XML_ELEMENT_NODE
                                                                                                                                && (xmlStrcmp (cur->name, "stroke-color") == 0))
                                                                                                                                {
-                                                                                                                                       style.stroke_color = g_strdup ((gchar *)xmlNodeGetContent (cur));
+                                                                                                                                       style->stroke_color = g_strdup ((gchar *)xmlNodeGetContent (cur));
                                                                                                                                }
                                                                                                                        else if (cur->type == XML_ELEMENT_NODE
                                                                                                                                && (xmlStrcmp (cur->name, "fill-color") == 0))
                                                                                                                                {
-                                                                                                                                       style.fill_color = g_strdup ((gchar *)xmlNodeGetContent (cur));
+                                                                                                                                       style->fill_color = g_strdup ((gchar *)xmlNodeGetContent (cur));
                                                                                                                                }
                                                                                                                        cur = cur->next;
                                                                                                                }
@@ -318,6 +324,50 @@ GtkWidget
 
                                                                                                        cur = xml_style;
                                                                                                }
+                                                                                       else if (cur->type == XML_ELEMENT_NODE
+                                                                                               && xmlStrcmp (cur->name, "label") == 0)
+                                                                                               {
+                                                                                                       xmlNode *xml_label;
+                                                                                                       GtkGisLayerLabel *label;
+
+                                                                                                       xml_label = cur;
+
+                                                                                                       label = g_malloc0 (sizeof (GtkGisLayerLabel));
+                                                                                                       label->field = NULL;
+                                                                                                       label->color = NULL;
+                                                                                                       label->background_color = NULL;
+                                                                                                       label->font = NULL;
+
+                                                                                                       cur = cur->children;
+                                                                                                       while (cur != NULL)
+                                                                                                               {
+                                                                                                                       if (cur->type == XML_ELEMENT_NODE
+                                                                                                                               && (xmlStrcmp (cur->name, "field") == 0))
+                                                                                                                               {
+                                                                                                                                       label->field = g_strdup ((gchar *)xmlNodeGetContent (cur));
+                                                                                                                               }
+                                                                                                                       else if (cur->type == XML_ELEMENT_NODE
+                                                                                                                               && (xmlStrcmp (cur->name, "color") == 0))
+                                                                                                                               {
+                                                                                                                                       label->color = g_strdup ((gchar *)xmlNodeGetContent (cur));
+                                                                                                                               }
+                                                                                                                       else if (cur->type == XML_ELEMENT_NODE
+                                                                                                                               && (xmlStrcmp (cur->name, "background-color") == 0))
+                                                                                                                               {
+                                                                                                                                       label->background_color = g_strdup ((gchar *)xmlNodeGetContent (cur));
+                                                                                                                               }
+                                                                                                                       else if (cur->type == XML_ELEMENT_NODE
+                                                                                                                               && (xmlStrcmp (cur->name, "font") == 0))
+                                                                                                                               {
+                                                                                                                                       label->font = g_strdup ((gchar *)xmlNodeGetContent (cur));
+                                                                                                                               }
+                                                                                                                       cur = cur->next;
+                                                                                                               }
+
+                                                                                                       gtk_gis_layer_set_label (layer, label);
+
+                                                                                                       cur = xml_label;
+                                                                                               }
 
                                                                                        cur = cur->next;
                                                                                }
@@ -381,6 +431,9 @@ GtkWidget
 xmlDoc
 *gtk_gis_get_xml (GtkGis *gtkgis)
 {
+       gchar *locale_old;
+       gchar *locale_num;
+
        xmlDoc *xdoc = NULL;
        xmlNode *xroot;
        xmlNode *xreport;
@@ -394,6 +447,9 @@ xmlDoc
 
        priv = GTK_GIS_GET_PRIVATE (gtkgis);
 
+       locale_old = setlocale (LC_ALL, NULL);
+       locale_num = setlocale (LC_NUMERIC, "C");
+
        xdoc = xmlNewDoc ("1.0");
 
        xroot = xmlNewNode (NULL, "gtkgis");
@@ -412,6 +468,9 @@ xmlDoc
                        cur_layer = g_slist_next (cur_layer);
                }
 
+       setlocale (LC_NUMERIC, locale_num);
+       setlocale (LC_ALL, locale_old);
+
        return xdoc;
 }
 
@@ -559,6 +618,7 @@ gtk_gis_draw (GtkGis *gtkgis)
        GdkCursor *cursor;
        GSList *cur;
        GtkGisLayerSource *layer_source;
+       GooCanvasItem *item_layer;
 
        g_return_if_fail (IS_GTK_GIS (gtkgis));
 
@@ -576,7 +636,11 @@ gtk_gis_draw (GtkGis *gtkgis)
                        layer_source = gtk_gis_layer_get_source ((GtkGisLayer *)cur->data);
                        gtk_gis_layer_source_set_max_extent (layer_source, priv->extent);
 
-                       gtk_gis_layer_draw ((GtkGisLayer *)cur->data, priv->canvas_root, priv->scale);
+                       item_layer = gtk_gis_layer_draw ((GtkGisLayer *)cur->data, priv->scale);
+                       if (item_layer != NULL)
+                               {
+                                       goo_canvas_item_add_child (priv->canvas_root, item_layer, -1);
+                               }
 
                        cur = g_slist_next (cur);
                }
@@ -613,7 +677,7 @@ GtkGisScale
 /**
  * gtk_gis_set_scale:
  * @gtkgis: a #GtkGis object.
- * @scale:
+ * @scale: a #GtkGisScale struct.
  *
  */
 void
@@ -682,7 +746,7 @@ gtk_gis_zoom_to_extent (GtkGis *gtkgis, GtkGisExtent extent)
 
        scale = g_malloc0 (sizeof (GtkGisScale));
 
-       /* must add width or height to make the max extent
+       /* must add width or height to make the extent
         * the same proportion of the canvas */
        extent_width = extent.max_x - extent.min_x;
        extent_height = extent.max_y - extent.min_y;
@@ -719,6 +783,7 @@ gtk_gis_zoom_to_extent (GtkGis *gtkgis, GtkGisExtent extent)
  * gtk_gis_zoom_to_max:
  * @gtkgis: a #GtkGis object.
  *
+ * Zoom to the possible max extent.
  */
 void
 gtk_gis_zoom_to_max (GtkGis *gtkgis)
index 6f3b12af8e78afbcef4170d8e791e324f1476a3b..2deef9addb773fca17935b71810fa11a293b9a62 100644 (file)
@@ -88,7 +88,11 @@ gtk_gis_layer_init (GtkGisLayer *gtk_gis_layer)
        priv->style->stroke_color = g_strdup ("black");
        priv->style->fill_color =  g_strdup ("white");
 
-       priv->label = NULL;
+       priv->label = g_malloc (sizeof (GtkGisLayerLabel));
+       priv->label->field = NULL;
+       priv->label->color = g_strdup ("black");
+       priv->label->background_color =  g_strdup ("white");
+       priv->label->font = g_strdup ("Sans 12");
 }
 
 /**
@@ -170,7 +174,11 @@ xmlNode
                        xmlSetProp (xnode, "name", priv->name);
                }
 
-       if (!priv->visible)
+       if (priv->visible)
+               {
+                       xmlSetProp (xnode, "visible", "y");
+               }
+       else
                {
                        xmlSetProp (xnode, "visible", "n");
                }
@@ -215,6 +223,18 @@ xmlNode
                        xnode_label_prop = xmlNewNode (NULL, "field");
                        xmlNodeSetContent (xnode_label_prop, g_strdup (priv->label->field));
                        xmlAddChild (xnode_label, xnode_label_prop);
+
+                       xnode_label_prop = xmlNewNode (NULL, "color");
+                       xmlNodeSetContent (xnode_label_prop, g_strdup (priv->label->color));
+                       xmlAddChild (xnode_label, xnode_label_prop);
+
+                       xnode_label_prop = xmlNewNode (NULL, "background-color");
+                       xmlNodeSetContent (xnode_label_prop, g_strdup (priv->label->background_color));
+                       xmlAddChild (xnode_label, xnode_label_prop);
+
+                       xnode_label_prop = xmlNewNode (NULL, "font");
+                       xmlNodeSetContent (xnode_label_prop, g_strdup (priv->label->font));
+                       xmlAddChild (xnode_label, xnode_label_prop);
                }
 
        return xnode;
@@ -271,7 +291,7 @@ gtk_gis_layer_fill_from_source (GtkGisLayer *layer, GtkGisLayerLabel *label)
        priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
 
        field = NULL;
-       if (label->field != NULL && g_strcmp0 (label->field, "") != 0)
+       if (label != NULL && label->field != NULL && g_strcmp0 (label->field, "") != 0)
                {
                        field = g_strdup (label->field);
                }
@@ -452,49 +472,53 @@ GtkGisLayerStyle
  * Valid only for layers that aren't rasters.
  */
 void
-gtk_gis_layer_set_style (GtkGisLayer *layer, GtkGisLayerStyle style)
+gtk_gis_layer_set_style (GtkGisLayer *layer, GtkGisLayerStyle *style)
 {
        GtkGisLayerPrivate *priv;
-       GtkGisLayerStyle new_style;
+       GtkGisLayerStyle *new_style;
        gchar *prop;
 
        g_return_if_fail (IS_GTK_GIS_LAYER (layer));
 
+       if (style == NULL) return;
+
        priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
 
-       if (style.width != 0)
+       new_style = g_malloc0 (sizeof (GtkGisLayerStyle));
+
+       if (style->width != 0)
                {
-                       new_style.width = style.width;
+                       new_style->width = style->width;
                }
        else
                {
-                       new_style.width = priv->style->width;
+                       new_style->width = priv->style->width;
                }
 
-       prop = g_strdup (style.stroke_color);
-       if (style.stroke_color != NULL &&
+       prop = g_strdup (style->stroke_color);
+       if (style->stroke_color != NULL &&
            g_strcmp0 (g_strstrip (prop), "") != 0)
                {
-                       new_style.stroke_color = g_strdup (style.stroke_color);
+                       new_style->stroke_color = g_strdup (prop);
                }
        else
                {
-                       new_style.stroke_color = g_strdup (priv->style->stroke_color);
+                       new_style->stroke_color = g_strdup (priv->style->stroke_color);
                }
 
-       prop = g_strdup (style.fill_color);
-       if (style.fill_color != NULL &&
+       prop = g_strdup (style->fill_color);
+       if (style->fill_color != NULL &&
            g_strcmp0 (g_strstrip (prop), "") != 0)
                {
-                       new_style.fill_color = g_strdup (style.fill_color);
+                       new_style->fill_color = g_strdup (prop);
                }
        else
                {
-                       new_style.fill_color = g_strdup (priv->style->fill_color);
+                       new_style->fill_color = g_strdup (priv->style->fill_color);
                }
 
        g_free (priv->style);
-       priv->style = g_memdup (&new_style, sizeof (GtkGisLayerStyle));
+       priv->style = new_style;
 }
 
 /**
@@ -523,28 +547,80 @@ void
 gtk_gis_layer_set_label (GtkGisLayer *layer, GtkGisLayerLabel *label)
 {
        GtkGisLayerPrivate *priv;
+       GtkGisLayerLabel *new_label;
+       gchar *prop;
 
        g_return_if_fail (IS_GTK_GIS_LAYER (layer));
 
-       priv->label = g_memdup (label, sizeof (GtkGisLayerLabel));
+       if (label == NULL) return;
+
+       priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+
+       new_label = g_malloc0 (sizeof (GtkGisLayerLabel));
+
+       prop = g_strdup (label->field);
+       if (label->field != NULL &&
+           g_strcmp0 (g_strstrip (prop), "") != 0)
+               {
+                       new_label->field = g_strdup (prop);
+               }
+       else
+               {
+                       new_label->field = g_strdup (priv->label->field);
+               }
+
+       prop = g_strdup (label->color);
+       if (label->color != NULL &&
+           g_strcmp0 (g_strstrip (prop), "") != 0)
+               {
+                       new_label->color = g_strdup (prop);
+               }
+       else
+               {
+                       new_label->color = g_strdup (priv->label->color);
+               }
+
+       prop = g_strdup (label->background_color);
+       if (label->background_color != NULL &&
+           g_strcmp0 (g_strstrip (prop), "") != 0)
+               {
+                       new_label->background_color = g_strdup (prop);
+               }
+       else
+               {
+                       new_label->background_color = g_strdup (priv->label->background_color);
+               }
+
+       prop = g_strdup (label->font);
+       if (label->font != NULL &&
+           g_strcmp0 (g_strstrip (prop), "") != 0)
+               {
+                       new_label->font = g_strdup (prop);
+               }
+       else
+               {
+                       new_label->font = g_strdup (priv->label->font);
+               }
+
+       g_free (priv->label);
+       priv->label = new_label;
 }
 
 /**
  * gtk_gis_layer_draw:
  * @layer: a #GtkGisLayer object.
- * @root:
  * @scale:
  *
+ * Returns: the #GooCanvasItem object with the layer's content draw.
  */
-void
-gtk_gis_layer_draw (GtkGisLayer *layer, GooCanvasItem *root, GtkGisScale *scale)
+GooCanvasItem
+*gtk_gis_layer_draw (GtkGisLayer *layer, GtkGisScale *scale)
 {
        GtkGisLayerPrivate *priv;
        GSList *cur;
        GooCanvasItem *item;
 
        g_return_if_fail (IS_GTK_GIS_LAYER (layer));
-       g_return_if_fail (GOO_IS_CANVAS_ITEM (root));
 
        priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
 
@@ -560,12 +636,12 @@ gtk_gis_layer_draw (GtkGisLayer *layer, GooCanvasItem *root, GtkGisScale *scale)
 
        gtk_gis_layer_fill_from_source (layer, priv->label);
 
-       priv->layer_item = goo_canvas_group_new (root, NULL);
+       priv->layer_item = goo_canvas_group_new (NULL, NULL);
 
        cur = priv->geometries;
        while (cur != NULL)
                {
-                       item = gtk_gis_geometry_draw ((GtkGisGeometry *)cur->data, scale, *priv->style);
+                       item = gtk_gis_geometry_draw ((GtkGisGeometry *)cur->data, scale, priv->style);
                        if (item != NULL)
                                {
                                        goo_canvas_item_add_child (priv->layer_item, item, -1);
@@ -573,6 +649,8 @@ gtk_gis_layer_draw (GtkGisLayer *layer, GooCanvasItem *root, GtkGisScale *scale)
 
                        cur = g_slist_next (cur);
                }
+
+       return priv->layer_item;
 }
 
 static void
index 08ee2a3a8bbc423d437397d9630709d6ea443d11..1ff0dcafb8f50a937013e2b149d3e5f101380da5 100644 (file)
@@ -92,12 +92,12 @@ void gtk_gis_layer_set_editable (GtkGisLayer *layer,
                                  gboolean editable);
 
 GtkGisLayerStyle *gtk_gis_layer_get_style (GtkGisLayer *layer);
-void gtk_gis_layer_set_style (GtkGisLayer *layer, GtkGisLayerStyle style);
+void gtk_gis_layer_set_style (GtkGisLayer *layer, GtkGisLayerStyle *style);
 
 GtkGisLayerLabel *gtk_gis_layer_get_label (GtkGisLayer *layer);
 void gtk_gis_layer_set_label (GtkGisLayer *layer, GtkGisLayerLabel *label);
 
-void gtk_gis_layer_draw (GtkGisLayer *layer, GooCanvasItem *root, GtkGisScale *scale);
+GooCanvasItem *gtk_gis_layer_draw (GtkGisLayer *layer, GtkGisScale *scale);
 
 
 G_END_DECLS
index 6eff09e6c590a5bba80c2ae7dfc1f2e335570404..1fa8a584c68c0f5c71fbef8d80c42d5a8a0f907b 100644 (file)
@@ -384,7 +384,7 @@ static GSList
                                                        gpoints = g_slist_append (gpoints, gpoint);
                                                }
 
-                                       geometry = gtk_gis_geometry_line_new_from_list (gpoints);
+                                       geometry = gtk_gis_geometry_line_new_from_points (gpoints);
                                }
                        else if (poGeometry != NULL
                                && wkbFlatten (OGR_G_GetGeometryType (poGeometry)) == wkbPolygon)
index fb7d49a59fbd34ae5e92a454c154e3da7d6cb85b..5bec20dd048cb7550bf56bc88937da03ec1f9b17 100644 (file)
@@ -26,9 +26,9 @@ main (int argc, char *argv[])
 
        gtk_widget_show_all (window);
 
-       /*gtk_gis_zoom_to_max (GTK_GIS (gtkgis));*/
-       gtk_gis_zoom_to_layer (GTK_GIS (gtkgis),
-                              gtk_gis_get_layer_by_name (GTK_GIS (gtkgis), "railroads"));
+       gtk_gis_zoom_to_max (GTK_GIS (gtkgis));
+       /*gtk_gis_zoom_to_layer (GTK_GIS (gtkgis),
+                              gtk_gis_get_layer_by_name (GTK_GIS (gtkgis), "railroads"));*/
        gtk_gis_draw (GTK_GIS (gtkgis));
 
        /*scale = gtk_gis_get_scale (GTK_GIS (gtkgis));
index 33d044e4df2383b0814208ce5e3edd687eda16e4..e717e18ccc10e2ff59fa769c8fd5c0eb5f51a184 100644 (file)
                <source>
                        <shape filename="tests/samples/airports.shp" />
                </source>
+               <style>
+                       <stroke-color>red</stroke-color>
+               </style>
+               <!--<label>
+                       <field>NAME</field>
+               </label>-->
        </layer>
 
-       <layer name="railroads">
+       <!--<layer name="railroads">
                <source>
                        <shape filename="tests/samples/railroads.shp" />
                </source>
                <style>
                        <stroke-color>red</stroke-color>
                </style>
-       </layer>
+       </layer>-->
 
-       <layer name="rivers" visible="n">
+       <layer name="rivers">
                <source>
                        <shape filename="tests/samples/rivers.shp" />
                </source>
                <style>
                        <stroke-color>blue</stroke-color>
                </style>
+               <!--<label>
+                       <field>NAM</field>
+               </label>-->
        </layer>
 
 </gtkgis>