Added GtkGis::move_to.
Implemented layer's visibility (yes or not).
gtk_gis_draw
gtk_gis_get_scale
gtk_gis_set_scale
+gtk_gis_zoom_to_extent
gtk_gis_zoom_to_max
gtk_gis_zoom_to_layer
+gtk_gis_move_to
gtk_gis_get_legend
</SECTION>
gtk_gis_layer_add_geometry
gtk_gis_layer_remove_geometry
gtk_gis_layer_get_extent
+gtk_gis_layer_get_visible
+gtk_gis_layer_set_visible
gtk_gis_layer_get_editable
gtk_gis_layer_set_editable
gtk_gis_layer_get_style
GtkGis *gtkgis, GtkGisScale *scale
</FUNCTION>
<FUNCTION>
+<NAME>gtk_gis_zoom_to_extent</NAME>
+<RETURNS>void </RETURNS>
+GtkGis *gtkgis, GtkGisLayerExtent extent
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_gis_zoom_to_max</NAME>
<RETURNS>void </RETURNS>
GtkGis *gtkgis
GtkGis *gtkgis, GtkGisLayer *layer
</FUNCTION>
<FUNCTION>
+<NAME>gtk_gis_move_to</NAME>
+<RETURNS>void </RETURNS>
+GtkGis *gtkgis, gdouble x, gdouble y
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_gis_get_legend</NAME>
<RETURNS>GtkWidget *</RETURNS>
GtkGis *gtkgis
GtkGisLayer *layer
</FUNCTION>
<FUNCTION>
+<NAME>gtk_gis_layer_get_visible</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkGisLayer *layer
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_gis_layer_set_visible</NAME>
+<RETURNS>void </RETURNS>
+GtkGisLayer *layer,gboolean visible
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_gis_layer_get_editable</NAME>
<RETURNS>gboolean </RETURNS>
GtkGisLayer *layer
</FUNCTION>
<FUNCTION>
<NAME>gtk_gis_layer_source_get_geometries</NAME>
-<RETURNS>GList *</RETURNS>
+<RETURNS>GSList *</RETURNS>
GtkGisLayerSource *source,const gchar *name
</FUNCTION>
<FUNCTION>
<NAME>GtkGisLayerGeometryType</NAME>
typedef enum
{
+ LAYER_GEOMETRY_TYPE_UNKNOWN,
LAYER_GEOMETRY_TYPE_POINT,
LAYER_GEOMETRY_TYPE_LINE,
LAYER_GEOMETRY_TYPE_POLYGON,
11% symbol docs coverage.
22 symbols documented.
7 symbols incomplete.
-171 not documented.
+175 not documented.
GTK_GIS
gtk_gis_layer_get_source
gtk_gis_layer_get_style
gtk_gis_layer_get_type
+gtk_gis_layer_get_visible
gtk_gis_layer_get_xml
gtk_gis_layer_new (geometrytype, geometry_type)
gtk_gis_layer_remove_geometry
gtk_gis_layer_set_editable
+gtk_gis_layer_set_visible
gtk_gis_layer_source_get_geometries (name, name)
gtk_gis_layer_source_get_layer_extent
gtk_gis_layer_source_get_layer_geometry_type
gtk_gis_layers_group_new (source, name, geometrytype, name)
gtk_gis_layers_group_remove_layer
gtk_gis_layers_group_set_name
+gtk_gis_move_to
gtk_gis_new_from_file
gtk_gis_new_from_xml
gtk_gis_remove_group
gtk_gis_remove_layer
gtk_gis_save_to_xml
gtk_gis_set_scale
+gtk_gis_zoom_to_extent
gtk_gis_zoom_to_layer
gtk_gis_zoom_to_max
GtkGisLayersGroupClass
gtk_gis_geometry_line_get_svg_path
gtk_gis_layer_get_style
+gtk_gis_layer_get_visible
gtk_gis_layer_set_style
+gtk_gis_layer_set_visible
+gtk_gis_move_to
+gtk_gis_zoom_to_extent
</para>
+@LAYER_GEOMETRY_TYPE_UNKNOWN:
@LAYER_GEOMETRY_TYPE_POINT:
@LAYER_GEOMETRY_TYPE_LINE:
@LAYER_GEOMETRY_TYPE_POLYGON:
typedef enum
{
+ LAYER_GEOMETRY_TYPE_UNKNOWN,
LAYER_GEOMETRY_TYPE_POINT,
LAYER_GEOMETRY_TYPE_LINE,
LAYER_GEOMETRY_TYPE_POLYGON,
cur = xmlDocGetRootElement (xdoc);
if (cur != NULL)
{
- if (strcmp (cur->name, "gtkgis") == 0)
+ if (xmlStrcmp (cur->name, "gtkgis") == 0)
{
GtkGisPrivate *priv;
{
xmlNode *xml_layer;
gchar *layer_name;
+ gchar *visible;
+ gboolean is_visible;
GtkGisLayer *layer;
xml_layer = cur;
{
/* TO DO */
/* get layer source name */
- layer_name = g_strdup_printf ("layer");
+ layer_name = g_strdup ("layer");
}
+ visible = xmlGetProp (cur, (const xmlChar *)"visible");
+ if (visible == NULL ||
+ g_strcmp0 (g_strstrip (visible), "") == 0)
+ {
+ visible = g_strdup ("y");
+ }
+ is_visible = (g_strcmp0 (visible, "y") == 0);
+
/* TO DO
* don't use a cycle: first find source and then style
*/
if (layer_source != NULL)
{
layer = gtk_gis_layer_new_from_source (layer_source, layer_name);
+ if (!is_visible)
+ {
+ gtk_gis_layer_set_visible (layer, is_visible);
+ }
gtk_gis_add_layer (GTK_GIS (gtkgis), layer);
}
gdk_window_set_cursor (GTK_WIDGET (gtkgis)->window, NULL);
}
+/**
+ * gtk_gis_zoom_to_extent:
+ * @gtkgis: a #GtkGis object.
+ * @extent: a #GtkGisLayerExtent struct.
+ *
+ */
+void
+gtk_gis_zoom_to_extent (GtkGis *gtkgis, GtkGisLayerExtent extent)
+{
+ GtkGisPrivate *priv;
+ GtkGisScale *scale;
+
+ gdouble extx;
+ gdouble exty;
+
+ gdouble widget_width;
+ gdouble widget_height;
+
+ gdouble extent_width;
+ gdouble extent_height;
+
+ gdouble ratio;
+ gdouble plus;
+
+ g_return_if_fail (IS_GTK_GIS (gtkgis));
+
+ priv = GTK_GIS_GET_PRIVATE (gtkgis);
+
+ extx = 1.0;
+ exty = 1.0;
+
+ widget_width = GTK_WIDGET (gtkgis)->allocation.width;
+ widget_height = GTK_WIDGET (gtkgis)->allocation.height;
+
+ scale = g_malloc0 (sizeof (GtkGisScale));
+
+ /* must add width or height to make the max extent
+ * the same proportion of the canvas */
+ extent_width = extent.max_x - extent.min_x;
+ extent_height = extent.max_y - extent.min_y;
+
+ ratio = widget_width / widget_height;
+
+ plus = extent_width / ratio;
+
+ if (plus > extent_height)
+ {
+ plus = (plus - extent_height) / 2;
+ extent.min_y -= plus;
+ extent.max_y += plus;
+ }
+ else
+ {
+ plus = extent_height * ratio;
+ plus = (plus - extent_width) / 2;
+ extent.min_x -= plus;
+ extent.max_x += plus;
+ }
+
+ extx = extent.max_x - extent.min_x;
+ exty = extent.max_y - extent.min_y;
+
+ scale->x = widget_width / extx;
+ scale->y = widget_height / exty;
+ scale->xy = (scale->x + scale->y) / 2;
+
+ gtk_gis_set_scale (gtkgis, scale);
+}
+
/**
* gtk_gis_zoom_to_max:
* @gtkgis: a #GtkGis object.
*/
void
gtk_gis_zoom_to_layer (GtkGis *gtkgis, GtkGisLayer *layer)
+{
+ GtkGisLayerExtent *extent;
+
+ g_return_if_fail (IS_GTK_GIS (gtkgis));
+ g_return_if_fail (IS_GTK_GIS_LAYER (layer));
+
+ extent = gtk_gis_layer_get_extent (layer);
+ gtk_gis_zoom_to_extent (gtkgis, *extent);
+
+ gtk_gis_move_to (gtkgis, extent->min_x, extent->min_y);
+}
+
+/**
+ * gtk_gis_move_to:
+ * @gtkgis:
+ * @x:
+ * @y:
+ *
+ */
+void
+gtk_gis_move_to (GtkGis *gtkgis, gdouble x, gdouble y)
{
GtkGisPrivate *priv;
+ gdouble new_x;
+ gdouble new_y;
g_return_if_fail (IS_GTK_GIS (gtkgis));
priv = GTK_GIS_GET_PRIVATE (gtkgis);
+ new_x = x;
+ new_y = y;
+ goo_canvas_convert_to_pixels (GOO_CANVAS (priv->canvas), &new_x, &new_y);
+
+ gtk_layout_move (GTK_LAYOUT (priv->scroll_win), priv->canvas,
+ -new_x, -new_y);
}
static void
GtkGisScale *gtk_gis_get_scale (GtkGis *gtkgis);
void gtk_gis_set_scale (GtkGis *gtkgis, GtkGisScale *scale);
+void gtk_gis_zoom_to_extent (GtkGis *gtkgis, GtkGisLayerExtent extent);
void gtk_gis_zoom_to_max (GtkGis *gtkgis);
void gtk_gis_zoom_to_layer (GtkGis *gtkgis, GtkGisLayer *layer);
+void gtk_gis_move_to (GtkGis *gtkgis, gdouble x, gdouble y);
+
GtkWidget *gtk_gis_get_legend (GtkGis *gtkgis);
GtkGisLayerSource *source;
GooCanvasItem *layer_item;
- GList *geometries;
+ GSList *geometries;
+ gboolean visible;
gboolean editable;
GtkGisLayerStyle *style;
{
GtkGisLayerPrivate *priv = GTK_GIS_LAYER_GET_PRIVATE (gtk_gis_layer);
+ priv->visible = TRUE;
+ priv->editable = FALSE;
+
priv->style = g_malloc (sizeof (GtkGisLayerStyle));
priv->style->width = 0.5;
priv->style->stroke_color = g_strdup ("black");
GtkGisLayerSource
*gtk_gis_layer_get_source (GtkGisLayer *layer)
{
- GtkGisLayerPrivate *priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+ GtkGisLayerPrivate *priv;
+
+ g_return_val_if_fail (IS_GTK_GIS_LAYER (layer), NULL);
+
+ priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
return priv->source;
}
void
gtk_gis_layer_fill_from_source (GtkGisLayer *layer)
{
- GtkGisLayerPrivate *priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+ GtkGisLayerPrivate *priv;
+
+ 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);
}
void
gtk_gis_layer_add_geometry (GtkGisLayer *layer, GtkGisGeometry *geometry)
{
- GtkGisLayerPrivate *priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+ GtkGisLayerPrivate *priv;
+
+ g_return_if_fail (IS_GTK_GIS_LAYER (layer));
+ g_return_if_fail (IS_GTK_GIS_GEOMETRY (geometry));
+
+ priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
- priv->geometries = g_list_append (priv->geometries, geometry);
+ priv->geometries = g_slist_append (priv->geometries, geometry);
}
/**
void
gtk_gis_layer_remove_geometry (GtkGisLayer *layer, GtkGisGeometry *geometry)
{
- GtkGisLayerPrivate *priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+ GtkGisLayerPrivate *priv;
- priv->geometries = g_list_remove (priv->geometries, geometry);
+ g_return_if_fail (IS_GTK_GIS_LAYER (layer));
+ g_return_if_fail (IS_GTK_GIS_GEOMETRY (geometry));
+
+ priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+
+ priv->geometries = g_slist_remove (priv->geometries, geometry);
}
/**
GtkGisLayerExtent
*gtk_gis_layer_get_extent (GtkGisLayer *layer)
{
- GtkGisLayerPrivate *priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
-
+ GtkGisLayerPrivate *priv;
GtkGisLayerExtent *extent;
+ g_return_val_if_fail (IS_GTK_GIS_LAYER (layer), NULL);
+
+ priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+
extent = gtk_gis_layer_source_get_layer_extent (priv->source, priv->name);
return extent;
}
+/**
+ * gtk_gis_layer_get_visible:
+ * @layer: a #GtkGisLayer object.
+ *
+ * Returns: whether the layer is visible.
+ */
+gboolean
+gtk_gis_layer_get_visible (GtkGisLayer *layer)
+{
+ GtkGisLayerPrivate *priv;
+
+ g_return_val_if_fail (IS_GTK_GIS_LAYER (layer), FALSE);
+
+ priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+
+ return priv->visible;
+}
+
+/**
+ * gtk_gis_layer_set_visible:
+ * @layer: a #GtkGisLayer object.
+ * @visible:
+ */
+void
+gtk_gis_layer_set_visible (GtkGisLayer *layer,
+ gboolean visible)
+{
+ GtkGisLayerPrivate *priv;
+
+ g_return_if_fail (IS_GTK_GIS_LAYER (layer));
+
+ priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+
+ priv->visible = visible;
+}
+
/**
* gtk_gis_layer_get_editable:
* @layer: a #GtkGisLayer object.
gboolean
gtk_gis_layer_get_editable (GtkGisLayer *layer)
{
- GtkGisLayerPrivate *priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+ GtkGisLayerPrivate *priv;
+
+ g_return_val_if_fail (IS_GTK_GIS_LAYER (layer), FALSE);
+
+ priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
return priv->editable;
}
gtk_gis_layer_set_editable (GtkGisLayer *layer,
gboolean editable)
{
- GtkGisLayerPrivate *priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+ GtkGisLayerPrivate *priv;
+
+ g_return_if_fail (IS_GTK_GIS_LAYER (layer));
+
+ priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
priv->editable = editable;
}
{
GtkGisLayerPrivate *priv;
GtkGisLayerStyle new_style;
+ gchar *prop;
g_return_if_fail (IS_GTK_GIS_LAYER (layer));
{
new_style.width = priv->style->width;
}
- 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 (priv->style->stroke_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);
}
gtk_gis_layer_draw (GtkGisLayer *layer, GooCanvasItem *root, GtkGisScale *scale)
{
GtkGisLayerPrivate *priv;
- GList *cur;
+ GSList *cur;
GooCanvasItem *item;
g_return_if_fail (IS_GTK_GIS_LAYER (layer));
priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+ if (!priv->visible)
+ {
+ /* TO DO
+ * free each geometry before
+ */
+ g_free (priv->geometries);
+ priv->geometries = NULL;
+ return;
+ }
+
gtk_gis_layer_fill_from_source (layer);
priv->layer_item = goo_canvas_group_new (root, NULL);
- cur = g_list_first (priv->geometries);
+ cur = priv->geometries;
while (cur != NULL)
{
item = gtk_gis_geometry_draw ((GtkGisGeometry *)cur->data, scale, *priv->style);
goo_canvas_item_add_child (priv->layer_item, item, -1);
}
- cur = g_list_next (cur);
+ cur = g_slist_next (cur);
}
}
GtkGisLayerExtent *gtk_gis_layer_get_extent (GtkGisLayer *layer);
+gboolean gtk_gis_layer_get_visible (GtkGisLayer *layer);
+void gtk_gis_layer_set_visible (GtkGisLayer *layer,
+ gboolean visible);
+
gboolean gtk_gis_layer_get_editable (GtkGisLayer *layer);
void gtk_gis_layer_set_editable (GtkGisLayer *layer,
gboolean editable);
static void gtk_gis_layer_source_class_init (GtkGisLayerSourceClass *klass);
static void gtk_gis_layer_source_init (GtkGisLayerSource *gtk_gis_layer_source);
-static GList
+static GSList
*gtk_gis_layer_source_get_geometries_from_ogr (GtkGisLayerSource *source,
const gchar *name);
-static GList
+static GSList
*gtk_gis_layer_source_get_geometries_from_gdal (GtkGisLayerSource *source,
const gchar *name);
*
* Loads the #GtkGisLayerSource from the disk.
*
- * Returns: a #GList of #GtkGeometry objects.
+ * Returns: a #GSList of #GtkGeometry objects.
*/
-GList
+GSList
*gtk_gis_layer_source_get_geometries (GtkGisLayerSource *source,
const gchar *name)
{
- GList *geometries = NULL;
+ GSList *geometries = NULL;
GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
gtk_gis_layer_source_get_layer_geometry_type (GtkGisLayerSource *source,
const gchar *name)
{
- GtkGisLayerGeometryType type = -1;
+ GtkGisLayerGeometryType type;
OGRLayerH layer;
OGRFeatureH feature;
- GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
+ GtkGisLayerSourcePrivate *priv;
+
+ g_return_val_if_fail (IS_GTK_GIS_LAYER_SOURCE (source), LAYER_GEOMETRY_TYPE_UNKNOWN);
+ priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
+
+ type = LAYER_GEOMETRY_TYPE_UNKNOWN;
if (priv->datasource != NULL)
{
layer = OGR_DS_GetLayerByName (priv->datasource, name);
- feature = OGR_L_GetNextFeature (layer);
-
- if (feature != NULL)
+ if (layer != NULL)
{
- OGRGeometryH poGeometry;
+ feature = OGR_L_GetNextFeature (layer);
- poGeometry = OGR_F_GetGeometryRef (feature);
- if (poGeometry != NULL
- && wkbFlatten (OGR_G_GetGeometryType(poGeometry)) == wkbPoint)
- {
- type = LAYER_GEOMETRY_TYPE_POINT;
- }
- else if (poGeometry != NULL
- && wkbFlatten (OGR_G_GetGeometryType(poGeometry)) == wkbLineString)
- {
- type = LAYER_GEOMETRY_TYPE_LINE;
- }
- else if (poGeometry != NULL
- && wkbFlatten (OGR_G_GetGeometryType(poGeometry)) == wkbPolygon)
+ if (feature != NULL)
{
- type = LAYER_GEOMETRY_TYPE_POLYGON;
+ OGRGeometryH poGeometry;
+
+ poGeometry = OGR_F_GetGeometryRef (feature);
+ if (poGeometry != NULL
+ && wkbFlatten (OGR_G_GetGeometryType(poGeometry)) == wkbPoint)
+ {
+ type = LAYER_GEOMETRY_TYPE_POINT;
+ }
+ else if (poGeometry != NULL
+ && wkbFlatten (OGR_G_GetGeometryType(poGeometry)) == wkbLineString)
+ {
+ type = LAYER_GEOMETRY_TYPE_LINE;
+ }
+ else if (poGeometry != NULL
+ && wkbFlatten (OGR_G_GetGeometryType(poGeometry)) == wkbPolygon)
+ {
+ type = LAYER_GEOMETRY_TYPE_POLYGON;
+ }
}
}
}
priv->max_extent = NULL;
}
-static GList
+static GSList
*gtk_gis_layer_source_get_geometries_from_ogr (GtkGisLayerSource *source,
const gchar *name)
{
- GList *geometries = NULL;
+ GSList *geometries = NULL;
OGRLayerH layer;
OGRFeatureH feature;
}
}
- geometries = g_list_append (geometries, geometry);
+ geometries = g_slist_append (geometries, geometry);
}
return geometries;
}
-static GList
+static GSList
*gtk_gis_layer_source_get_geometries_from_gdal (GtkGisLayerSource *source,
const gchar *name)
{
- GList *geometries = NULL;
+ GSList *geometries = NULL;
GtkGisGeometry *geometry;
gdouble adfGeoTransform[6];
if (geometry != NULL)
{
- geometries = g_list_append (geometries, geometry);
+ geometries = g_slist_append (geometries, geometry);
}
}
xmlNode *gtk_gis_layer_source_get_xml (GtkGisLayerSource *source);
-GList *gtk_gis_layer_source_get_geometries (GtkGisLayerSource *source,
- const gchar *name);
+GSList *gtk_gis_layer_source_get_geometries (GtkGisLayerSource *source,
+ const gchar *name);
GtkGisLayerGeometryType gtk_gis_layer_source_get_layer_geometry_type (GtkGisLayerSource *source,
const gchar *name);
NULL);
gtkgis = gtk_gis_new_from_file (argv[1]);
+ if (gtkgis == NULL)
+ {
+ g_fprintf (stderr, "Error loading GtkGis definition file.\n");
+ return 0;
+ }
- gtk_container_add (GTK_CONTAINER (window), gtkgis);
+ gtk_container_add (GTK_CONTAINER (window), gtkgis);
gtk_widget_show_all (window);
- gtk_gis_zoom_to_max (GTK_GIS (gtkgis));
+ /*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));
+ /*scale = gtk_gis_get_scale (GTK_GIS (gtkgis));
if (scale != NULL)
{
scale->x = (scale->x * 80) / 100;
scale->y = (scale->y * 80) / 100;
scale->xy = (scale->xy * 80) / 100;
gtk_gis_set_scale (GTK_GIS (gtkgis), scale);
- }
+ }*/
gtk_gis_save_to_xml (GTK_GIS (gtkgis), "test_saved.gtkgis");
</style>
</layer>
- <layer name="rivers">
+ <layer name="rivers" visible="n">
<source>
<shape filename="tests/samples/rivers.shp" />
</source>