<!ELEMENT group (layer*)>
-<!ELEMENT layer (source, style?)>
+<!ELEMENT layer (source, style?, label?)>
<!ATTLIST layer
name CDATA #REQUIRED
visible (y | n) "y"
<!ELEMENT width (#PCDATA)>
<!ELEMENT stroke-color (#PCDATA)>
<!ELEMENT fill-color (#PCDATA)>
+
+<!ELEMENT label (field, color?, background-color?, font?)>
+
+<!ELEMENT field (#PCDATA) />
+<!ELEMENT color (#PCDATA) />
+<!ELEMENT background-color (#PCDATA) />
+<!ELEMENT font (#PCDATA) />
gtk_gis_layer_set_editable
gtk_gis_layer_get_style
gtk_gis_layer_set_style
+gtk_gis_layer_get_label
+gtk_gis_layer_set_label
gtk_gis_layer_draw
</SECTION>
gtk_gis_geometry_get_type
gtk_gis_geometry_get_editable
gtk_gis_geometry_set_editable
+gtk_gis_geometry_get_label
+gtk_gis_geometry_set_label
gtk_gis_geometry_draw
</SECTION>
<FUNCTION>
<NAME>gtk_gis_layer_fill_from_source</NAME>
<RETURNS>void </RETURNS>
-GtkGisLayer *layer
+GtkGisLayer *layer, GtkGisLayerLabel *label
</FUNCTION>
<FUNCTION>
<NAME>gtk_gis_layer_save</NAME>
GtkGisLayer *layer, GtkGisLayerStyle style
</FUNCTION>
<FUNCTION>
+<NAME>gtk_gis_layer_get_label</NAME>
+<RETURNS>GtkGisLayerLabel *</RETURNS>
+GtkGisLayer *layer
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_gis_layer_set_label</NAME>
+<RETURNS>void </RETURNS>
+GtkGisLayer *layer, GtkGisLayerLabel *label
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_gis_layer_draw</NAME>
<RETURNS>void </RETURNS>
GtkGisLayer *layer, GooCanvasItem *root, GtkGisScale *scale
GtkGisGeometry *geometry, gboolean editable
</FUNCTION>
<FUNCTION>
+<NAME>gtk_gis_geometry_get_label</NAME>
+<RETURNS>const gchar *</RETURNS>
+GtkGisGeometry *geometry
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_gis_geometry_set_label</NAME>
+<RETURNS>void </RETURNS>
+GtkGisGeometry *geometry, const gchar *label
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_gis_geometry_draw</NAME>
<RETURNS>GooCanvasItem *</RETURNS>
GtkGisGeometry *geometry,GtkGisScale *scale,GtkGisLayerStyle style
<FUNCTION>
<NAME>gtk_gis_layer_source_get_geometries</NAME>
<RETURNS>GSList *</RETURNS>
-GtkGisLayerSource *source,const gchar *name
+GtkGisLayerSource *source,const gchar *name,const gchar *label_fieldname
</FUNCTION>
<FUNCTION>
<NAME>gtk_gis_layer_source_get_layer_geometry_type</NAME>
11% symbol docs coverage.
22 symbols documented.
7 symbols incomplete.
-175 not documented.
+179 not documented.
GTK_GIS
gtk_gis_draw
gtk_gis_geometry_draw
gtk_gis_geometry_get_editable
+gtk_gis_geometry_get_label
gtk_gis_geometry_get_point
gtk_gis_geometry_get_type
gtk_gis_geometry_line_add_point
gtk_gis_geometry_raster_get_type
gtk_gis_geometry_raster_new_from_pixbuf (x, y, width, height, x, y, width, height)
gtk_gis_geometry_set_editable
+gtk_gis_geometry_set_label
gtk_gis_get_layer_by_name
gtk_gis_get_legend
gtk_gis_get_scale
gtk_gis_layer_draw
gtk_gis_layer_get_editable
gtk_gis_layer_get_extent
+gtk_gis_layer_get_label
gtk_gis_layer_get_name
gtk_gis_layer_get_source
gtk_gis_layer_get_style
gtk_gis_layer_new (geometrytype, geometry_type)
gtk_gis_layer_remove_geometry
gtk_gis_layer_set_editable
+gtk_gis_layer_set_label
gtk_gis_layer_set_visible
-gtk_gis_layer_source_get_geometries (name, name)
+gtk_gis_layer_source_get_geometries (name, name, label_fieldname)
gtk_gis_layer_source_get_layer_extent
gtk_gis_layer_source_get_layer_geometry_type
gtk_gis_layer_source_get_type
GtkGisLayerSourceRasterClass
GtkGisLayerSourceShpClass
GtkGisLayersGroupClass
+gtk_gis_geometry_get_label
gtk_gis_geometry_line_get_svg_path
+gtk_gis_geometry_set_label
+gtk_gis_layer_get_label
gtk_gis_layer_get_style
gtk_gis_layer_get_visible
+gtk_gis_layer_set_label
gtk_gis_layer_set_style
gtk_gis_layer_set_visible
gtk_gis_move_to
</para>
@layer:
+@label:
<!-- ##### FUNCTION gtk_gis_layer_save ##### -->
@source:
@name:
+@label_fieldname:
@Returns:
gchar *fill_color;
} GtkGisLayerStyle;
+typedef struct
+ {
+ gchar *field;
+ gchar *color;
+ gchar *background_color;
+ gchar *font;
+ } GtkGisLayerLabel;
+
typedef enum
{
LAYER_GEOMETRY_TYPE_UNKNOWN,
struct _GtkGisGeometryPrivate
{
gboolean editable;
+
+ gchar *label;
};
G_DEFINE_TYPE (GtkGisGeometry, gtk_gis_geometry, G_TYPE_OBJECT)
gboolean
gtk_gis_geometry_get_editable (GtkGisGeometry *geometry)
{
- GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (geometry);
+ GtkGisGeometryPrivate *priv;
+
+ g_return_val_if_fail (IS_GTK_GIS_GEOMETRY (geometry), FALSE);
+
+ priv = GTK_GIS_GEOMETRY_GET_PRIVATE (geometry);
return priv->editable;
}
void
gtk_gis_geometry_set_editable (GtkGisGeometry *geometry, gboolean editable)
{
- GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (geometry);
+ GtkGisGeometryPrivate *priv;
+
+ g_return_if_fail (IS_GTK_GIS_GEOMETRY (geometry));
+
+ priv = GTK_GIS_GEOMETRY_GET_PRIVATE (geometry);
priv->editable = editable;
}
+/**
+ * gtk_gis_geometry_get_label:
+ * @geometry:
+ *
+ */
+const gchar
+*gtk_gis_geometry_get_label (GtkGisGeometry *geometry)
+{
+ GtkGisGeometryPrivate *priv;
+
+ g_return_val_if_fail (IS_GTK_GIS_GEOMETRY (geometry), NULL);
+
+ return g_strdup (priv->label);
+}
+
+/**
+ * gtk_gis_geometry_set_label:
+ * @geometry:
+ * @label:
+ *
+ */
+void
+gtk_gis_geometry_set_label (GtkGisGeometry *geometry, const gchar *label)
+{
+ GtkGisGeometryPrivate *priv;
+
+ g_return_if_fail (IS_GTK_GIS_GEOMETRY (geometry));
+
+ priv->label = g_strdup (label);
+}
+
/**
* gtk_gis_geometry_draw:
* @geometry: a #GtkGisGeometry object.
gboolean gtk_gis_geometry_get_editable (GtkGisGeometry *geometry);
void gtk_gis_geometry_set_editable (GtkGisGeometry *geometry, gboolean editable);
+const gchar *gtk_gis_geometry_get_label (GtkGisGeometry *geometry);
+void gtk_gis_geometry_set_label (GtkGisGeometry *geometry, const gchar *label);
+
GooCanvasItem *gtk_gis_geometry_draw (GtkGisGeometry *geometry,
GtkGisScale *scale,
GtkGisLayerStyle style);
gboolean editable;
GtkGisLayerStyle *style;
+
+ GtkGisLayerLabel *label;
};
G_DEFINE_TYPE (GtkGisLayer, gtk_gis_layer, G_TYPE_OBJECT)
priv->style->width = 0.5;
priv->style->stroke_color = g_strdup ("black");
priv->style->fill_color = g_strdup ("white");
+
+ priv->label = NULL;
}
/**
xmlSetProp (xnode, "name", priv->name);
}
+ if (!priv->visible)
+ {
+ xmlSetProp (xnode, "visible", "n");
+ }
+
if (priv->source != NULL)
{
xmlNode *xnode_source;
xmlAddChild (xnode, xnode_source);
}
+ if (priv->style != NULL)
+ {
+ xmlNode *xnode_style;
+ xmlNode *xnode_style_prop;
+
+ xnode_style = xmlNewNode (NULL, "style");
+ xmlAddChild (xnode, xnode_style);
+
+ xnode_style_prop = xmlNewNode (NULL, "width");
+ xmlNodeSetContent (xnode_style_prop, g_strdup_printf ("%f", priv->style->width));
+ xmlAddChild (xnode_style, xnode_style_prop);
+
+ xnode_style_prop = xmlNewNode (NULL, "stroke-color");
+ xmlNodeSetContent (xnode_style_prop, g_strdup (priv->style->stroke_color));
+ xmlAddChild (xnode_style, xnode_style_prop);
+
+ xnode_style_prop = xmlNewNode (NULL, "fill-color");
+ xmlNodeSetContent (xnode_style_prop, g_strdup (priv->style->fill_color));
+ xmlAddChild (xnode_style, xnode_style_prop);
+ }
+
+ if (priv->label != NULL)
+ {
+ xmlNode *xnode_label;
+ xmlNode *xnode_label_prop;
+
+ xnode_label = xmlNewNode (NULL, "label");
+ xmlAddChild (xnode, xnode_label);
+
+ xnode_label_prop = xmlNewNode (NULL, "field");
+ xmlNodeSetContent (xnode_label_prop, g_strdup (priv->label->field));
+ xmlAddChild (xnode_label, xnode_label_prop);
+ }
+
return xnode;
}
/**
* gtk_gis_layer_fill_from_source:
* @layer: a #GtkGisLayer object.
+ * @label: a pointer to a #GtkGisLayerLabel struct.
*
* Loads the #GtkGisLayer's content from the associated #GtkGisLayerSource.
* Contents loaded before will be lost.
*/
void
-gtk_gis_layer_fill_from_source (GtkGisLayer *layer)
+gtk_gis_layer_fill_from_source (GtkGisLayer *layer, GtkGisLayerLabel *label)
{
GtkGisLayerPrivate *priv;
+ gchar *field;
g_return_if_fail (IS_GTK_GIS_LAYER (layer));
priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
- priv->geometries = gtk_gis_layer_source_get_geometries (priv->source, priv->name);
+ field = NULL;
+ if (label->field != NULL && g_strcmp0 (label->field, "") != 0)
+ {
+ field = g_strdup (label->field);
+ }
+
+ priv->geometries = gtk_gis_layer_source_get_geometries (priv->source, priv->name, field);
}
/**
priv->style = g_memdup (&new_style, sizeof (GtkGisLayerStyle));
}
+/**
+ * gtk_gis_layer_get_label:
+ * @layer: a #GtkGisLayer object.
+ *
+ */
+GtkGisLayerLabel
+*gtk_gis_layer_get_label (GtkGisLayer *layer)
+{
+ GtkGisLayerPrivate *priv;
+ GtkGisLayerLabel *label;
+
+ g_return_val_if_fail (IS_GTK_GIS_LAYER (layer), NULL);
+
+ return label;
+}
+
+/**
+ * gtk_gis_layer_set_label:
+ * @layer: a #GtkGisLayer object.
+ * @label:
+ *
+ */
+void
+gtk_gis_layer_set_label (GtkGisLayer *layer, GtkGisLayerLabel *label)
+{
+ GtkGisLayerPrivate *priv;
+
+ g_return_if_fail (IS_GTK_GIS_LAYER (layer));
+
+ priv->label = g_memdup (label, sizeof (GtkGisLayerLabel));
+}
+
/**
* gtk_gis_layer_draw:
* @layer: a #GtkGisLayer object.
return;
}
- gtk_gis_layer_fill_from_source (layer);
+ gtk_gis_layer_fill_from_source (layer, priv->label);
priv->layer_item = goo_canvas_group_new (root, NULL);
while (cur != NULL)
{
item = gtk_gis_geometry_draw ((GtkGisGeometry *)cur->data, scale, *priv->style);
-
if (item != NULL)
{
goo_canvas_item_add_child (priv->layer_item, item, -1);
GtkGisLayerSource *gtk_gis_layer_get_source (GtkGisLayer *layer);
-void gtk_gis_layer_fill_from_source (GtkGisLayer *layer);
+void gtk_gis_layer_fill_from_source (GtkGisLayer *layer, GtkGisLayerLabel *label);
void gtk_gis_layer_save (GtkGisLayer *layer,
GtkGisLayerSource *source);
GtkGisLayerStyle *gtk_gis_layer_get_style (GtkGisLayer *layer);
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);
static GSList
*gtk_gis_layer_source_get_geometries_from_ogr (GtkGisLayerSource *source,
- const gchar *name);
+ const gchar *name,
+ const gchar *label_fieldname);
static GSList
*gtk_gis_layer_source_get_geometries_from_gdal (GtkGisLayerSource *source,
const gchar *name);
*/
GSList
*gtk_gis_layer_source_get_geometries (GtkGisLayerSource *source,
- const gchar *name)
+ const gchar *name,
+ const gchar *label_fieldname)
{
GSList *geometries = NULL;
if (priv->datasource != NULL)
{
- geometries = gtk_gis_layer_source_get_geometries_from_ogr (source, name);
+ geometries = gtk_gis_layer_source_get_geometries_from_ogr (source, name, label_fieldname);
}
else if (priv->dataset != NULL)
{
static GSList
*gtk_gis_layer_source_get_geometries_from_ogr (GtkGisLayerSource *source,
- const gchar *name)
+ const gchar *name,
+ const gchar *label_fieldname)
{
GSList *geometries = NULL;
OGRGeometryH poGeometry;
GtkGisGeometry *geometry;
+ gint field_index;
+
gdouble fixy;
GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
fixy = priv->max_extent->max_y + priv->max_extent->min_y;
//}
+ field_index = -1;
while ((feature = OGR_L_GetNextFeature (layer)) != NULL)
{
poGeometry = OGR_F_GetGeometryRef (feature);
}
}
+ if (geometry != NULL
+ && label_fieldname != NULL
+ && g_strcmp0 (label_fieldname, "") != 0)
+ {
+ field_index = OGR_F_GetFieldIndex (feature, label_fieldname);
+ if (field_index > -1)
+ {
+ gtk_gis_geometry_set_label (geometry, OGR_F_GetFieldAsString (feature, field_index));
+ }
+ }
+
geometries = g_slist_append (geometries, geometry);
}
xmlNode *gtk_gis_layer_source_get_xml (GtkGisLayerSource *source);
GSList *gtk_gis_layer_source_get_geometries (GtkGisLayerSource *source,
- const gchar *name);
+ const gchar *name,
+ const gchar *label_fieldname);
GtkGisLayerGeometryType gtk_gis_layer_source_get_layer_geometry_type (GtkGisLayerSource *source,
const gchar *name);