gtk_gis_geometry_polygon_get_type
gtk_gis_geometry_polygon_new
gtk_gis_geometry_polygon_new_from_line
-gtk_gis_geometry_polygon_new_from_list
+gtk_gis_geometry_polygon_new_from_points
gtk_gis_geometry_polygon_add_line
-gtk_gis_geometry_polygon_add_line_from_list
+gtk_gis_geometry_polygon_add_line_from_points
gtk_gis_geometry_polygon_remove_line
</SECTION>
gtk_gis_geometry_set_editable
gtk_gis_geometry_get_label
gtk_gis_geometry_set_label
+gtk_gis_geometry_get_extent
gtk_gis_geometry_draw
</SECTION>
GtkGisGeometryLine *line
</FUNCTION>
<FUNCTION>
-<NAME>gtk_gis_geometry_polygon_new_from_list</NAME>
+<NAME>gtk_gis_geometry_polygon_new_from_points</NAME>
<RETURNS>GtkGisGeometry *</RETURNS>
GSList *points
</FUNCTION>
GtkGisGeometryPolygon *polygon, GtkGisGeometryLine *line
</FUNCTION>
<FUNCTION>
-<NAME>gtk_gis_geometry_polygon_add_line_from_list</NAME>
+<NAME>gtk_gis_geometry_polygon_add_line_from_points</NAME>
<RETURNS>void </RETURNS>
GtkGisGeometryPolygon *polygon, GSList *points
</FUNCTION>
<FUNCTION>
<NAME>gtk_gis_zoom_to_extent</NAME>
<RETURNS>void </RETURNS>
-GtkGis *gtkgis, GtkGisLayerExtent extent
+GtkGis *gtkgis, GtkGisExtent extent
</FUNCTION>
<FUNCTION>
<NAME>gtk_gis_zoom_to_max</NAME>
</FUNCTION>
<FUNCTION>
<NAME>gtk_gis_layer_get_extent</NAME>
-<RETURNS>GtkGisLayerExtent *</RETURNS>
+<RETURNS>GtkGisExtent *</RETURNS>
GtkGisLayer *layer
</FUNCTION>
<FUNCTION>
{
GObjectClass parent_class;
+ GtkGisExtent *(*get_extent) (GtkGisGeometry *geometry);
+
GooCanvasItem *(*draw) (GtkGisGeometry *geometry,
GtkGisScale *scale,
GtkGisLayerStyle style);
GtkGisGeometry *geometry, const gchar *label
</FUNCTION>
<FUNCTION>
+<NAME>gtk_gis_geometry_get_extent</NAME>
+<RETURNS>GtkGisExtent *</RETURNS>
+GtkGisGeometry *geometry
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_gis_geometry_draw</NAME>
<RETURNS>GooCanvasItem *</RETURNS>
GtkGisGeometry *geometry,GtkGisScale *scale,GtkGisLayerStyle style
</FUNCTION>
<FUNCTION>
<NAME>gtk_gis_layer_source_get_layer_extent</NAME>
-<RETURNS>GtkGisLayerExtent *</RETURNS>
+<RETURNS>GtkGisExtent *</RETURNS>
GtkGisLayerSource *source,const gchar *name
</FUNCTION>
<FUNCTION>
<NAME>gtk_gis_layer_source_set_max_extent</NAME>
<RETURNS>void </RETURNS>
-GtkGisLayerSource *source,GtkGisLayerExtent *extent
+GtkGisLayerSource *source,GtkGisExtent *extent
</FUNCTION>
<ENUM>
<NAME>GtkGisLayerGeometryType</NAME>
+gtk_gis_geometry_polygon_add_line_from_list
+gtk_gis_geometry_polygon_new_from_list
11% symbol docs coverage.
22 symbols documented.
7 symbols incomplete.
-179 not documented.
+180 not documented.
GTK_GIS
gtk_gis_draw
gtk_gis_geometry_draw
gtk_gis_geometry_get_editable
+gtk_gis_geometry_get_extent
gtk_gis_geometry_get_label
gtk_gis_geometry_get_point
gtk_gis_geometry_get_type
gtk_gis_geometry_point_get_x
gtk_gis_geometry_point_get_y
gtk_gis_geometry_polygon_add_line
-gtk_gis_geometry_polygon_add_line_from_list
+gtk_gis_geometry_polygon_add_line_from_points
gtk_gis_geometry_polygon_get_type
gtk_gis_geometry_polygon_remove_line
gtk_gis_geometry_raster_get_type
GtkGisLayerSourceRasterClass
GtkGisLayerSourceShpClass
GtkGisLayersGroupClass
+gtk_gis_geometry_get_extent
gtk_gis_geometry_get_label
gtk_gis_geometry_line_get_svg_path
+gtk_gis_geometry_polygon_add_line_from_points
+gtk_gis_geometry_polygon_new_from_points
gtk_gis_geometry_set_label
gtk_gis_layer_get_label
gtk_gis_layer_get_style
@Returns:
-<!-- ##### FUNCTION gtk_gis_geometry_polygon_new_from_list ##### -->
-<para>
-
-</para>
-
-@points:
-@Returns:
-
-
<!-- ##### FUNCTION gtk_gis_geometry_polygon_add_line ##### -->
<para>
@line:
-<!-- ##### FUNCTION gtk_gis_geometry_polygon_add_line_from_list ##### -->
-<para>
-
-</para>
-
-@polygon:
-@points:
-
-
<!-- ##### FUNCTION gtk_gis_geometry_polygon_remove_line ##### -->
<para>
+<!-- ##### FUNCTION gtk_gis_geometry_polygon_add_line_from_list ##### -->
+<para>
+
+</para>
+
+@polygon:
+@points:
+
+<!-- ##### FUNCTION gtk_gis_geometry_polygon_new_from_list ##### -->
+<para>
+
+</para>
+
+@points:
+@Returns:
+
gdouble min_y;
gdouble max_x;
gdouble max_y;
- } GtkGisLayerExtent;
+ } GtkGisExtent;
typedef struct
{
priv->label = g_strdup (label);
}
+/**
+ * gtk_gis_geometry_get_extent:
+ * @line: a #GtkGisGeometry object.
+ *
+ */
+GtkGisExtent
+*gtk_gis_geometry_get_extent (GtkGisGeometry *geometry)
+{
+ GtkGisExtent *extent = NULL;
+
+ if (IS_GTK_GIS_GEOMETRY (geometry) && GTK_GIS_GEOMETRY_GET_CLASS (geometry)->get_extent != NULL)
+ {
+ extent = GTK_GIS_GEOMETRY_GET_CLASS (geometry)->get_extent (geometry);
+ }
+
+ return extent;
+}
+
/**
* gtk_gis_geometry_draw:
* @geometry: a #GtkGisGeometry object.
{
GObjectClass parent_class;
+ GtkGisExtent *(*get_extent) (GtkGisGeometry *geometry);
+
GooCanvasItem *(*draw) (GtkGisGeometry *geometry,
GtkGisScale *scale,
GtkGisLayerStyle style);
const gchar *gtk_gis_geometry_get_label (GtkGisGeometry *geometry);
void gtk_gis_geometry_set_label (GtkGisGeometry *geometry, const gchar *label);
+GtkGisExtent *gtk_gis_geometry_get_extent (GtkGisGeometry *geometry);
+
GooCanvasItem *gtk_gis_geometry_draw (GtkGisGeometry *geometry,
GtkGisScale *scale,
GtkGisLayerStyle style);
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);
struct _GtkGisGeometryLinePrivate
{
GSList *points;
+
+ GtkGisExtent *extent;
};
G_DEFINE_TYPE (GtkGisGeometryLine, gtk_gis_geometry_line, TYPE_GTK_GIS_GEOMETRY)
object_class->set_property = gtk_gis_geometry_line_set_property;
object_class->get_property = gtk_gis_geometry_line_get_property;
+ geometry_class->get_extent = gtk_gis_geometry_line_get_extent;
geometry_class->draw = gtk_gis_geometry_line_draw;
}
GtkGisGeometryLinePrivate *priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (gtk_gis_geometry_line);
priv->points = NULL;
+ priv->extent = NULL;
}
/**
gpoint->x = point.x;
gpoint->y = point.y;
+ /* recalculate the new extent */
+ if (priv->extent = NULL)
+ {
+ priv->extent = g_malloc (sizeof (GtkGisExtent));
+ priv->extent->min_x = gpoint->x;
+ priv->extent->min_y = gpoint->y;
+ priv->extent->max_x = gpoint->x;
+ priv->extent->max_y = gpoint->y;
+ }
+ else
+ {
+ if (gpoint->x < priv->extent->min_x)
+ {
+ priv->extent->min_x = gpoint->x;
+ }
+ if (gpoint->y < priv->extent->min_y)
+ {
+ priv->extent->min_y = gpoint->y;
+ }
+ if (gpoint->x > priv->extent->max_x)
+ {
+ priv->extent->max_x = gpoint->x;
+ }
+ if (gpoint->y > priv->extent->max_y)
+ {
+ priv->extent->max_y = gpoint->y;
+ }
+ }
+
priv->points = g_slist_append (priv->points, gpoint);
}
return ret;
}
+static GtkGisExtent
+*gtk_gis_geometry_line_get_extent (GtkGisGeometry *line)
+{
+ GtkGisGeometryLinePrivate *priv;
+
+ g_return_val_if_fail (IS_GTK_GIS_GEOMETRY_LINE (line), NULL);
+
+ priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (GTK_GIS_GEOMETRY_LINE (line));
+
+ return g_memdup (priv->extent, sizeof (GtkGisExtent));
+}
+
static GooCanvasItem
*gtk_gis_geometry_line_draw (GtkGisGeometry *line,
GtkGisScale *scale,
static void gtk_gis_geometry_point_class_init (GtkGisGeometryPointClass *klass);
static void gtk_gis_geometry_point_init (GtkGisGeometryPoint *gtk_gis_geometry_point);
+static GtkGisExtent *gtk_gis_geometry_point_get_extent (GtkGisGeometry *point);
static GooCanvasItem *gtk_gis_geometry_point_draw (GtkGisGeometry *point,
GtkGisScale *scale,
GtkGisLayerStyle style);
object_class->set_property = gtk_gis_geometry_point_set_property;
object_class->get_property = gtk_gis_geometry_point_get_property;
+ geometry_class->get_extent = gtk_gis_geometry_point_get_extent;
geometry_class->draw = gtk_gis_geometry_point_draw;
}
return priv->point->y;
}
+static GtkGisExtent
+*gtk_gis_geometry_point_get_extent (GtkGisGeometry *point)
+{
+ GtkGisGeometryPointPrivate *priv;
+ GtkGisExtent *extent;
+
+ g_return_val_if_fail (IS_GTK_GIS_GEOMETRY_POINT (point), NULL);
+
+ priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (GTK_GIS_GEOMETRY_POINT (point));
+
+ extent = g_malloc (sizeof (GtkGisExtent));
+ extent->min_x = priv->point->x;
+ extent->min_y = priv->point->y;
+ extent->max_x = priv->point->x;
+ extent->max_y = priv->point->y;
+
+ return extent;
+}
+
static
GooCanvasItem *gtk_gis_geometry_point_draw (GtkGisGeometry *point,
GtkGisScale *scale,
static void gtk_gis_geometry_polygon_class_init (GtkGisGeometryPolygonClass *klass);
static void gtk_gis_geometry_polygon_init (GtkGisGeometryPolygon *gtk_gis_geometry_polygon);
+static GtkGisExtent *gtk_gis_geometry_polygon_get_extent (GtkGisGeometry *polygon);
static GooCanvasItem *gtk_gis_geometry_polygon_draw (GtkGisGeometry *polygon,
GtkGisScale *scale,
GtkGisLayerStyle style);
struct _GtkGisGeometryPolygonPrivate
{
GSList *lines;
+
+ GtkGisExtent *extent;
};
G_DEFINE_TYPE (GtkGisGeometryPolygon, gtk_gis_geometry_polygon, TYPE_GTK_GIS_GEOMETRY)
object_class->set_property = gtk_gis_geometry_polygon_set_property;
object_class->get_property = gtk_gis_geometry_polygon_get_property;
+ geometry_class->get_extent = gtk_gis_geometry_polygon_get_extent;
geometry_class->draw = gtk_gis_geometry_polygon_draw;
}
}
/**
- * gtk_gis_geometry_polygon_new_from_list:
+ * gtk_gis_geometry_polygon_new_from_points:
* @points: a #GSList og #GtkGisPoint to add to the polygon.
*
* Creates a new #GtkGisGeometryPolygon object.
* Returns: the newly created #GtkGisGeometryPolygon object.
*/
GtkGisGeometry
-*gtk_gis_geometry_polygon_new_from_list (GSList *points)
+*gtk_gis_geometry_polygon_new_from_points (GSList *points)
{
GtkGisGeometry *polygon = NULL;
GtkGisGeometry *line = NULL;
GtkGisGeometryLine *line)
{
GtkGisGeometryPolygonPrivate *priv;
+ GtkGisExtent *line_extent;
g_return_if_fail (IS_GTK_GIS_GEOMETRY_POLYGON (polygon));
g_return_if_fail (IS_GTK_GIS_GEOMETRY_LINE (line));
priv = GTK_GIS_GEOMETRY_POLYGON_GET_PRIVATE (polygon);
+ /* recalculate the new extent */
+ line_extent = gtk_gis_geometry_get_extent (GTK_GIS_GEOMETRY (line));
+
+ if (priv->extent = NULL)
+ {
+ priv->extent = g_malloc (sizeof (GtkGisExtent));
+ priv->extent->min_x = line_extent->min_x;
+ priv->extent->min_y = line_extent->min_y;
+ priv->extent->max_x = line_extent->max_x;
+ priv->extent->max_y = line_extent->max_y;
+ }
+ else
+ {
+ if (line_extent->min_x < priv->extent->min_x)
+ {
+ priv->extent->min_x = line_extent->min_x;
+ }
+ if (line_extent->min_y < priv->extent->min_y)
+ {
+ priv->extent->min_y = line_extent->min_y;
+ }
+ if (line_extent->max_x > priv->extent->max_x)
+ {
+ priv->extent->max_x = line_extent->max_x;
+ }
+ if (line_extent->max_y > priv->extent->max_y)
+ {
+ priv->extent->max_y = line_extent->max_y;
+ }
+ }
+
priv->lines = g_slist_append (priv->lines, line);
}
/**
- * gtk_gis_geometry_polygon_add_line_from_list:
+ * gtk_gis_geometry_polygon_add_line_from_points:
* @polygon: a #GtkGisGeometryPolygon object.
* @points:
*
*/
void
-gtk_gis_geometry_polygon_add_line_from_list (GtkGisGeometryPolygon *polygon,
- GSList *points)
+gtk_gis_geometry_polygon_add_line_from_points (GtkGisGeometryPolygon *polygon,
+ GSList *points)
{
GtkGisGeometry *line;
priv = GTK_GIS_GEOMETRY_POLYGON_GET_PRIVATE (polygon);
+ /* TO DO
+ * recalculate the new extent
+ */
+
priv->lines = g_slist_remove (priv->lines, line);
}
+static GtkGisExtent
+*gtk_gis_geometry_polygon_get_extent (GtkGisGeometry *polygon)
+{
+ GtkGisGeometryPolygonPrivate *priv;
+
+ g_return_val_if_fail (IS_GTK_GIS_GEOMETRY_POLYGON (polygon), NULL);
+
+ priv = GTK_GIS_GEOMETRY_POLYGON_GET_PRIVATE (GTK_GIS_GEOMETRY_POLYGON (polygon));
+
+ return g_memdup (priv->extent, sizeof (GtkGisExtent));
+}
+
static GooCanvasItem
*gtk_gis_geometry_polygon_draw (GtkGisGeometry *polygon,
GtkGisScale *scale,
GSList *cur;
GtkGisGeometry *line;
+ const gchar *str_label;
+ GooCanvasItem *item_label;
+
cur = priv->lines;
while (cur != NULL)
{
"fill-color", style.fill_color,
"fill-rule", CAIRO_FILL_RULE_EVEN_ODD,
NULL);
+
+ str_label = gtk_gis_geometry_get_label (polygon);
+ if (str_label != NULL
+ && g_strcmp0 (str_label, "") != 0)
+ {
+ gdouble x;
+ gdouble y;
+
+ /* 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;
+
+ item_label = goo_canvas_text_new (item,
+ str_label,
+ x, y, -1,
+ GTK_ANCHOR_CENTER,
+ "font", "Sans 12",
+ NULL);
+ }
}
return item;
GtkGisGeometry *gtk_gis_geometry_polygon_new (void);
GtkGisGeometry *gtk_gis_geometry_polygon_new_from_line (GtkGisGeometryLine *line);
-GtkGisGeometry *gtk_gis_geometry_polygon_new_from_list (GSList *points);
+GtkGisGeometry *gtk_gis_geometry_polygon_new_from_points (GSList *points);
void gtk_gis_geometry_polygon_add_line (GtkGisGeometryPolygon *polygon, GtkGisGeometryLine *line);
-void gtk_gis_geometry_polygon_add_line_from_list (GtkGisGeometryPolygon *polygon, GSList *points);
+void gtk_gis_geometry_polygon_add_line_from_points (GtkGisGeometryPolygon *polygon, GSList *points);
void gtk_gis_geometry_polygon_remove_line (GtkGisGeometryPolygon *polygon, GtkGisGeometryLine *line);
GSList *layers_groups;
GSList *layers;
- GtkGisLayerExtent *extent;
+ GtkGisExtent *extent;
GtkGisScale *scale;
GtkGisPoint *sel_start;
gtk_gis_add_layer (GtkGis *gtkgis, GtkGisLayer *layer)
{
GtkGisPrivate *priv;
- GtkGisLayerExtent *extent;
+ GtkGisExtent *extent;
g_return_if_fail (IS_GTK_GIS (gtkgis));
{
if (priv->extent == NULL)
{
- priv->extent = g_malloc (sizeof (GtkGisLayerExtent));
+ priv->extent = g_malloc (sizeof (GtkGisExtent));
priv->extent->min_x = extent->min_x;
priv->extent->max_x = extent->max_x;
priv->extent->min_y = extent->min_y;
/**
* gtk_gis_zoom_to_extent:
* @gtkgis: a #GtkGis object.
- * @extent: a #GtkGisLayerExtent struct.
+ * @extent: a #GtkGisExtent struct.
*
*/
void
-gtk_gis_zoom_to_extent (GtkGis *gtkgis, GtkGisLayerExtent extent)
+gtk_gis_zoom_to_extent (GtkGis *gtkgis, GtkGisExtent extent)
{
GtkGisPrivate *priv;
GtkGisScale *scale;
void
gtk_gis_zoom_to_layer (GtkGis *gtkgis, GtkGisLayer *layer)
{
- GtkGisLayerExtent *extent;
+ GtkGisExtent *extent;
g_return_if_fail (IS_GTK_GIS (gtkgis));
g_return_if_fail (IS_GTK_GIS_LAYER (layer));
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_extent (GtkGis *gtkgis, GtkGisExtent extent);
void gtk_gis_zoom_to_max (GtkGis *gtkgis);
void gtk_gis_zoom_to_layer (GtkGis *gtkgis, GtkGisLayer *layer);
* @layer: a #GtkGisLayer object.
*
*/
-GtkGisLayerExtent
+GtkGisExtent
*gtk_gis_layer_get_extent (GtkGisLayer *layer)
{
GtkGisLayerPrivate *priv;
- GtkGisLayerExtent *extent;
+ GtkGisExtent *extent;
g_return_val_if_fail (IS_GTK_GIS_LAYER (layer), NULL);
void gtk_gis_layer_remove_geometry (GtkGisLayer *layer,
GtkGisGeometry *geometry);
-GtkGisLayerExtent *gtk_gis_layer_get_extent (GtkGisLayer *layer);
+GtkGisExtent *gtk_gis_layer_get_extent (GtkGisLayer *layer);
gboolean gtk_gis_layer_get_visible (GtkGisLayer *layer);
void gtk_gis_layer_set_visible (GtkGisLayer *layer,
OGRDataSourceH datasource;
GDALDatasetH dataset;
- GtkGisLayerExtent *max_extent;
+ GtkGisExtent *max_extent;
};
G_DEFINE_TYPE (GtkGisLayerSource, gtk_gis_layer_source, G_TYPE_OBJECT)
*
* Returns:
*/
-GtkGisLayerExtent
+GtkGisExtent
*gtk_gis_layer_source_get_layer_extent (GtkGisLayerSource *source,
const gchar *name)
{
- GtkGisLayerExtent *extent = NULL;
+ GtkGisExtent *extent = NULL;
GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
if (layer != NULL)
{
- extent = g_malloc0 (sizeof (GtkGisLayerExtent));
+ extent = g_malloc0 (sizeof (GtkGisExtent));
OGR_L_GetExtent (layer, &psExtent, 1);
if (GDALGetGeoTransform (priv->dataset, adfGeoTransform) == CE_None)
{
- extent = g_malloc0 (sizeof (GtkGisLayerExtent));
+ extent = g_malloc0 (sizeof (GtkGisExtent));
extent->min_x = adfGeoTransform[0];
extent->max_x = extent->min_x + GDALGetRasterXSize (priv->dataset);
*/
void
gtk_gis_layer_source_set_max_extent (GtkGisLayerSource *source,
- GtkGisLayerExtent *extent)
+ GtkGisExtent *extent)
{
GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
if (priv->max_extent == NULL)
{
- priv->max_extent = g_malloc0 (sizeof (GtkGisLayerExtent));
+ priv->max_extent = g_malloc0 (sizeof (GtkGisExtent));
}
priv->max_extent->min_x = extent->min_x;
if (i_geometry == 0)
{
- geometry = gtk_gis_geometry_polygon_new_from_list (gpoints);
+ geometry = gtk_gis_geometry_polygon_new_from_points (gpoints);
}
else
{
- gtk_gis_geometry_polygon_add_line_from_list (GTK_GIS_GEOMETRY_POLYGON (geometry), gpoints);
+ gtk_gis_geometry_polygon_add_line_from_points (GTK_GIS_GEOMETRY_POLYGON (geometry), gpoints);
}
}
}
GtkGisLayerGeometryType gtk_gis_layer_source_get_layer_geometry_type (GtkGisLayerSource *source,
const gchar *name);
-GtkGisLayerExtent *gtk_gis_layer_source_get_layer_extent (GtkGisLayerSource *source,
- const gchar *name);
+GtkGisExtent *gtk_gis_layer_source_get_layer_extent (GtkGisLayerSource *source,
+ const gchar *name);
void gtk_gis_layer_source_set_max_extent (GtkGisLayerSource *source,
- GtkGisLayerExtent *extent);
+ GtkGisExtent *extent);
G_END_DECLS