Added samples data.
Added test test1.
src/.deps/
src/.libs/
stamp-h1
+tests/.deps
# temporarily
TODO.tasks
# Checks for libraries.
PKG_CHECK_MODULES([GTKGIS], [gtk+-2.0 >= 2.10.0
+ libxml-2.0 >= 2.7.0
goocanvas >= 0.13])
AC_SUBST(GTKGIS_CFLAGS)
src/Makefile
data/Makefile
tests/Makefile
+ tests/samples/Makefile
])
AC_OUTPUT
-<!ELEMENT gtkgis (layer*)>
+<!ELEMENT gtkgis (group*, layer*)>
+
+<!ELEMENT group (layer*)>
<!ELEMENT layer (source)>
<!ATTLIST layer
name CDATA #REQUIRED
+ visible (y | n) "y"
>
<!ELEMENT source (shape | postgis)>
libgtkgis_la_SOURCES = \
gtkgis.c \
+ layersgroup.c \
layer.c \
layersource.c \
layersourceshp.c \
libgtkgis.h \
gtkgis.h \
layer.h \
+ layersgroup.h \
layersource.h \
layersourceshp.h \
layersourcepostgis.h \
GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry);
}
-/**
- * gtk_gis_geometry_new:
- *
- * Creates a new #GtkGisGeometry object.
- *
- * Returns: the newly created #GtkGisGeometry object.
- */
-GtkGisGeometry
-*gtk_gis_geometry_new ()
-{
- GtkGisGeometry *gtk_gis_geometry;
-
- gtk_gis_geometry = GTK_GIS_GEOMETRY (g_object_new (gtk_gis_geometry_get_type (), NULL));
-
- return gtk_gis_geometry;
-}
-
static void
gtk_gis_geometry_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
GType gtk_gis_geometry_get_type (void) G_GNUC_CONST;
-GtkGisGeometry *gtk_gis_geometry_new (void);
-
gboolean gtk_gis_geometry_get_editable (GtkGisGeometry *geometry);
void gtk_gis_geometry_set_editable (GtkGisGeometry *geometry, gboolean editable);
typedef struct _GtkGisGeometryLinePrivate GtkGisGeometryLinePrivate;
struct _GtkGisGeometryLinePrivate
{
+ GPtrArray *points;
};
GType
gtk_gis_geometry_line_init (GtkGisGeometryLine *gtk_gis_geometry_line)
{
GtkGisGeometryLinePrivate *priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (gtk_gis_geometry_line);
+
+ priv->points = g_ptr_array_new ();
}
/**
return gtk_gis_geometry_line;
}
+/**
+ * gtk_gis_geometry_line_new_from_array:
+ * @points:
+ *
+ * Creates a new #GtkGisGeometryLine object.
+ *
+ * Returns: the newly created #GtkGisGeometryLine object.
+ */
+GtkGisGeometryLine
+*gtk_gis_geometry_line_new_from_array (GPtrArray *points)
+{
+ GtkGisGeometryLine *gtk_gis_geometry_line;
+ GtkGisGeometryLinePrivate *priv;
+
+ gtk_gis_geometry_line = gtk_gis_geometry_line_new ();
+
+ priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (gtk_gis_geometry_line);
+
+ priv->points = points;
+
+ return gtk_gis_geometry_line;
+}
+
+/**
+ * gtk_gis_geomtry_line_add_point:
+ * @line:
+ * @point:
+ */
+void
+gtk_gis_geomtry_line_add_point (GtkGisGeometryLine *line, GtkGisGeometryPoint *point)
+{
+ GtkGisGeometryLinePrivate *priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (gtk_gis_geometry_line);
+
+ g_ptr_array_add (priv->points, point);
+}
+
+/**
+ * gtk_gis_geometry_line_add_point_from_coordinates:
+ * @line:
+ * @x:
+ * @y:
+ *
+ */
+void
+gtk_gis_geomtry_line_add_point_from_coordinates (GtkGisGeometryLine *line,
+ gdouble x, gdouble y)
+{
+ GtkGisGeometryPoint *point;
+
+ point = gtk_gis_geometry_point_new (x, y);
+
+ gtk_gis_geometry_line_add_point (line, point);
+}
+
static void
gtk_gis_geometry_line_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
#define __GTK_GIS_GEOMETRY_LINE_H__
#include "geometry.h"
+#include "geometrypoint.h"
G_BEGIN_DECLS
GtkGisGeometryLine *gtk_gis_geometry_line_new (void);
+GtkGisGeometryLine *gtk_gis_geometry_line_new_from_array (GPtrArray *points);
+
+void gtk_gis_geomtry_line_add_point (GtkGisGeometryLine *line, GtkGisGeometryPoint *point);
+void gtk_gis_geomtry_line_add_point_from_coordinates (GtkGisGeometryLine *line,
+ gdouble x, gdouble y);
+
+
G_END_DECLS
typedef struct _GtkGisGeometryPointPrivate GtkGisGeometryPointPrivate;
struct _GtkGisGeometryPointPrivate
{
+ gdouble x;
+ gdouble y;
};
GType
/**
* gtk_gis_geometry_point_new:
+ * @x:
+ * @y:
*
* Creates a new #GtkGisGeometryPoint object.
*
* Returns: the newly created #GtkGisGeometryPoint object.
*/
GtkGisGeometryPoint
-*gtk_gis_geometry_point_new ()
+*gtk_gis_geometry_point_new (gdouble x, gdouble y)
{
GtkGisGeometryPoint *gtk_gis_geometry_point;
+ GtkGisGeometryPointPrivate *priv;
gtk_gis_geometry_point = GTK_GIS_GEOMETRY_POINT (g_object_new (gtk_gis_geometry_point_get_type (), NULL));
+ priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (gtk_gis_geometry_point);
+
+ priv->x = x;
+ priv->y = y;
+
return gtk_gis_geometry_point;
}
+gdouble
+gtk_gis_geometry_get_x (GtkGisGeometryPoint *point)
+{
+ GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (gtk_gis_geometry_point);
+
+ return priv->x;
+}
+
+gdouble
+gtk_gis_geometry_get_y (GtkGisGeometryPoint *point)
+{
+ GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (gtk_gis_geometry_point);
+
+ return priv->y;
+}
+
static void
gtk_gis_geometry_point_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
GType gtk_gis_geometry_point_get_type (void) G_GNUC_CONST;
-GtkGisGeometryPoint *gtk_gis_geometry_point_new (void);
+GtkGisGeometryPoint *gtk_gis_geometry_point_new (gdouble x, gdouble y);
+
+gdouble gtk_gis_geometry_get_x (GtkGisGeometryPoint *point);
+gdouble gtk_gis_geometry_get_y (GtkGisGeometryPoint *point);
G_END_DECLS
return gtk_gis_geometry_polygon;
}
+/**
+ * gtk_gis_geometry_polygon_new_from_array:
+ * @points:
+ *
+ * Creates a new #GtkGisGeometryPolygon object.
+ *
+ * Returns: the newly created #GtkGisGeometryPolygon object.
+ */
+GtkGisGeometryPolygon
+*gtk_gis_geometry_polygon_new_from_array (GPtrArray *points)
+{
+ GtkGisGeometryPolygon *gtk_gis_geometry_polygon;
+
+ gtk_gis_geometry_polygon = gtk_gis_geometry_line_new_from_array (points);
+
+ return gtk_gis_geometry_polygon;
+}
+
static void
gtk_gis_geometry_polygon_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
#ifndef __GTK_GIS_GEOMETRY_POLYGON_H__
#define __GTK_GIS_GEOMETRY_POLYGON_H__
-#include "geometry.h"
+#include "geometryline.h"
G_BEGIN_DECLS
struct _GtkGisGeometryPolygon
{
- GtkGisGeometry parent;
+ GtkGisGeometryLine parent;
};
struct _GtkGisGeometryPolygonClass
{
- GtkGisGeometryClass parent_class;
+ GtkGisGeometryClassLine parent_class;
};
GType gtk_gis_geometry_polygon_get_type (void) G_GNUC_CONST;
GtkGisGeometryPolygon *gtk_gis_geometry_polygon_new (void);
+GtkGisGeometryPolygon *gtk_gis_geometry_polygon_new_from_array (GPtrArray *points);
+
G_END_DECLS
GtkWidget *canvas;
GooCanvasItem *canvas_root;
+ GList *layer_groups;
GList *layers;
};
return gtk_gis;
}
+/**
+ * gtk_gis_new_from_xml:
+ * @xdoc:
+ *
+ * Returns: the newly created #GtkGis object.
+ */
+GtkGis
+*gtk_gis_new_from_xml (xmlDoc *xdoc)
+{
+ GtkGis *gtkgis = NULL;
+ xmlNode *cur;
+
+ cur = xmlDocGetRootElement (xdoc);
+ if (cur != NULL)
+ {
+ if (strcmp (cur->name, "gtkgis") == 0)
+ {
+ GtkGisPrivate *priv;
+
+ gtkgis = gtk_gis_new ();
+
+ priv = GTK_GIS_GET_PRIVATE (gtkgis);
+
+ cur = cur->children;
+ while (cur != NULL)
+ {
+ if (cur->type == XML_ELEMENT_NODE
+ && xmlStrcmp (cur->name, "layer") == 0)
+ {
+ xmlNode *xml_layer;
+ gchar *layer_name;
+
+ xml_layer = cur;
+
+ layer_name = xmlGetProp (cur, (const xmlChar *)"name");
+ if (layer_name != NULL)
+ {
+ /* TO DO */
+ /* get layer source name */
+ layer_name = g_strdup_printf ("layer");
+ }
+
+ cur = cur->children;
+ if (cur != NULL
+ && cur->type == XML_ELEMENT_NODE
+ && xmlStrcmp (cur->name, "source") == 0)
+ {
+ xmlNode *xml_source;
+
+ xml_source = cur;
+
+ if (cur != NULL
+ && cur->type == XML_ELEMENT_NODE
+ && (xmlStrcmp (cur->name, "shape") == 0
+ || xmlStrcmp (cur->name, "postgis") == 0))
+ {
+ xmlNode *xml_source_spec;
+ GtkGisLayer *layer = NULL;
+ GtkGisLayerSource *layer_source = NULL;
+
+ xml_source_spec = cur;
+
+ if (xmlStrcmp (cur->name, "shape") == 0)
+ {
+ gchar *filename;
+
+ filename = xmlGetProp (cur, (const xmlChar *)"filename");
+ if (filename != NULL)
+ {
+ layer_source = gtk_gis_layer_source_shp_new (filename);
+ }
+ }
+ else if (xmlStrcmp (cur->name, "postgis") == 0)
+ {
+ /* TO DO */
+ }
+
+ if (layer_source != NULL)
+ {
+ layer = gtk_gis_layer_new_from_source (layer_source, layer_name);
+ gtk_gis_add_layer (gtkgis, layer);
+ }
+
+ cur = xml_source_spec;
+ }
+
+ cur = xml_source;
+ }
+
+ cur = xml_layer;
+ }
+
+ cur = cur->next;
+ }
+ }
+ else
+ {
+ /* TO DO */
+ g_error ("Node \"gtkgis\" is missing.");
+ }
+ }
+ else
+ {
+ /* TO DO */
+ g_warning ("The file is not a valid gtkgis file.");
+ }
+
+ return gtkgis;
+}
+
/**
* gtk_gis_new_from_file:
* @filename:
* Returns: the newly created #GtkGis object.
*/
GtkGis
-*gtk_gis_new_from_file (gchar *filename)
+*gtk_gis_new_from_file (const gchar *filename)
{
+ GtkGis *gtkgis = NULL;
+
+ xmlDoc *xdoc = xmlParseFile (filename);
+ if (xdoc != NULL)
+ {
+ gtkgis = gtk_gis_new_from_xml (xdoc);
+ }
+
+ return gtkgis;
}
/**
- * gtk_gis_save_to_file:
+ * gtk_gis_save_to_xml:
* @gtkgis:
* @filename:
*/
void
-*gtk_gis_save_to_file (GtkGis *gtkgis, gchar *filename)
+*gtk_gis_save_to_xml (GtkGis *gtkgis, const gchar *filename)
{
}
#define __GTK_GIS_H__
#include <gtk/gtkwidget.h>
+#include <libxml/tree.h>
+#include "layersgroup.h"
#include "layer.h"
G_BEGIN_DECLS
GtkGis *gtk_gis_new (void);
+GtkGis *gtk_gis_new_from_xml (xmlDoc *xdoc);
GtkGis *gtk_gis_new_from_file (gchar *filename);
-void *gtk_gis_save_to_file (GtkGis *gtkgis, gchar *filename);
+void *gtk_gis_save_to_xml (GtkGis *gtkgis, const gchar *filename);
+
+void gtk_gis_add_group (GtkGis *gtkgis, GtkGisLayersGroup *group);
+void gtk_gis_remove_group (GtkGis *gtkgis, GtkGisLayersGroup *group);
void gtk_gis_add_layer (GtkGis *gtkgis, GtkGisLayer *layer);
void gtk_gis_remove_layer (GtkGis *gtkgis, GtkGisLayer *layer);
layer = gtk_gis_layer_new (source, name, type);
+ gtk_gis_layer_source_fill_layer (source, layer);
+
return layer;
}
void gtk_gis_layer_set_editable (GtkGisLayer *layer,
gboolean editable);
-void gtk_gis_layer_draw (GtkGisLayer *layer
+void gtk_gis_layer_draw (GtkGisLayer *layer,
GooCanvasItem *canvas_root);
--- /dev/null
+/*
+ * Copyright (C) 2009 Andrea Zagli <azagli@libero.it>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include "layersgroup.h"
+
+static void gtk_gis_layers_group_class_init (GtkGisLayersGroupClass *klass);
+static void gtk_gis_layers_group_init (GtkGisLayersGroup *gtk_gis_layers_group);
+
+static void gtk_gis_layers_group_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gtk_gis_layers_group_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+
+#define GTK_GIS_LAYERS_GROUP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_GIS_LAYERS_GROUP, GtkGisLayersGroupPrivate))
+
+typedef struct _GtkGisLayersGroupPrivate GtkGisLayersGroupPrivate;
+struct _GtkGisLayersGroupPrivate
+ {
+ gchar *name;
+
+ gboolean visible;
+
+ GList *layers;
+ };
+
+GType
+gtk_gis_layers_group_get_type (void)
+{
+ static GType gtk_gis_layers_group_type = 0;
+
+ if (!gtk_gis_layers_group_type)
+ {
+ static const GTypeInfo gtk_gis_layers_group_info =
+ {
+ sizeof (GtkGisLayersGroupClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_gis_layers_group_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkGisLayersGroup),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_gis_layers_group_init,
+ NULL
+ };
+
+ gtk_gis_layers_group_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisLayersGroup",
+ >k_gis_layers_group_info, 0);
+ }
+
+ return gtk_gis_layers_group_type;
+}
+
+static void
+gtk_gis_layers_group_class_init (GtkGisLayersGroupClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof (GtkGisLayersGroupPrivate));
+
+ object_class->set_property = gtk_gis_layers_group_set_property;
+ object_class->get_property = gtk_gis_layers_group_get_property;
+}
+
+static void
+gtk_gis_layers_group_init (GtkGisLayersGroup *gtk_gis_layers_group)
+{
+ GtkGisLayersGroupPrivate *priv = GTK_GIS_LAYERS_GROUP_GET_PRIVATE (gtk_gis_layers_group);
+}
+
+/**
+ * gtk_gis_layers_group_new:
+ * @source:
+ * @name:
+ * @geometrytype:
+ *
+ * Creates a new empty #GtkGisLayersGroup object.
+ *
+ * Returns: the newly created #GtkGisLayersGroup object.
+ */
+GtkGisLayersGroup
+*gtk_gis_layers_group_new (const gchar *name)
+{
+ GtkGisLayersGroup *gtk_gis_layers_group;
+ GtkGisLayersGroupPrivate *priv;
+
+ gtk_gis_layers_group = GTK_GIS_LAYERS_GROUP (g_object_new (gtk_gis_layers_group_get_type (), NULL));
+
+ priv = GTK_GIS_LAYERS_GROUP_GET_PRIVATE (layers_group);
+
+ priv->name = g_strdup (name);
+
+ return gtk_gis_layers_group;
+}
+
+/**
+ * gtk_gis_layers_group_get_name:
+ * @layers_group:
+ *
+ * Returns: the #GtkGisLayersGroup's name.
+ */
+gchar
+*gtk_gis_layers_group_get_name (GtkGisLayersGroup *layers_group)
+{
+ GtkGisLayersGroupPrivate *priv = GTK_GIS_LAYERS_GROUP_GET_PRIVATE (layers_group);
+
+ return g_strdup (priv->name);
+}
+
+/**
+ * gtk_gis_layers_group_set_name:
+ * @layers_group:
+ * @name:
+ */
+void
+gtk_gis_layers_group_set_name (GtkGisLayersGroup *layers_group,
+ const gchar *name)
+{
+ GtkGisLayersGroupPrivate *priv = GTK_GIS_LAYERS_GROUP_GET_PRIVATE (layers_group);
+
+ priv->name = g_strdup (name);
+}
+
+/**
+ * gtk_gis_layers_group_add_layer:
+ * @layers_group:
+ * @layer:
+ */
+void
+gtk_gis_layers_group_add_geometry (GtkGisLayersGroup *layers_group, GtkGisLayer *layer)
+{
+ GtkGisLayersGroupPrivate *priv = GTK_GIS_LAYERS_GROUP_GET_PRIVATE (layers_group);
+
+ priv->layers = g_list_append (priv->layers, layer);
+}
+
+/**
+ * gtk_gis_layers_group_remove_layer:
+ * @layers_group:
+ * @layer:
+ */
+void
+gtk_gis_layers_group_remove_layer (GtkGisLayersGroup *layers_group, GtkGisLayer *layer)
+{
+ GtkGisLayersGroupPrivate *priv = GTK_GIS_LAYERS_GROUP_GET_PRIVATE (layers_group);
+
+ priv->layers = g_list_remove (priv->layers, layer);
+}
+
+static void
+gtk_gis_layers_group_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+ GtkGisLayersGroup *layers_group = GTK_GIS_LAYERS_GROUP (object);
+
+ GtkGisLayersGroupPrivate *priv = GTK_GIS_LAYERS_GROUP_GET_PRIVATE (layers_group);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_gis_layers_group_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+ GtkGisLayersGroup *layers_group = GTK_GIS_LAYERS_GROUP (object);
+
+ GtkGisLayersGroupPrivate *priv = GTK_GIS_LAYERS_GROUP_GET_PRIVATE (layers_group);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2009 Andrea Zagli <azagli@libero.it>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __GTK_GIS_LAYERS_GROUP_H__
+#define __GTK_GIS_LAYERS_GROUP_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "layer.h"
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_GIS_LAYERS_GROUP (gtk_gis_layers_group_get_type ())
+#define GTK_GIS_LAYERS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_GIS_LAYERS_GROUP, GtkGisLayersGroup))
+#define GTK_GIS_LAYERS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_GIS_LAYERS_GROUP, GtkGisLayersGroupClass))
+#define IS_GTK_GIS_LAYERS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_GIS_LAYERS_GROUP))
+#define IS_GTK_GIS_LAYERS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_GIS_LAYERS_GROUP))
+#define GTK_GIS_LAYERS_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_GIS_LAYERS_GROUP, GtkGisLayersGroupClass))
+
+
+typedef struct _GtkGisLayersGroup GtkGisLayersGroup;
+typedef struct _GtkGisLayersGroupClass GtkGisLayersGroupClass;
+
+struct _GtkGisLayersGroup
+ {
+ GObject parent;
+ };
+
+struct _GtkGisLayersGroupClass
+ {
+ GObjectClass parent_class;
+ };
+
+GType gtk_gis_layers_group_get_type (void) G_GNUC_CONST;
+
+
+GtkGisLayersGroup *gtk_gis_layers_group_new (const gchar *name);
+
+void gtk_gis_layers_group_add_layer (GtkGisLayersGroup *layers_group,
+ GtkGisLayer *layer);
+void gtk_gis_layers_group_remove_layer (GtkGisLayersGroup *layers_group,
+ GtkGisLayer *layer);
+
+const gchar *gtk_gis_layers_group_get_name (GtkGisLayersGroup *layers_group);
+void gtk_gis_layers_group_set_name (GtkGisLayersGroup *layers_group,
+ const gchar *name);
+
+
+G_END_DECLS
+
+#endif /* __GTK_GIS_LAYERS_GROUP_H__ */
}
/**
- * gtk_gis_layer_source_new:
- *
- * Creates a new #GtkGisLayerSource object.
- *
- * Returns: the newly created #GtkGisLayerSource object.
- */
-GtkGisLayerSource
-*gtk_gis_layer_source_new ()
-{
- GtkGisLayerSource *gtk_gis_layer_source;
-
- gtk_gis_layer_source = GTK_GIS_LAYER_SOURCE (g_object_new (gtk_gis_layer_source_get_type (), NULL));
-
- return gtk_gis_layer_source;
-}
-
-/**
- * gtk_gis_layer_source_load:
+ * gtk_gis_layer_source_fill_layer:
* @source:
* @layer:
*
GObjectClass parent_class;
gboolean (*fill_layer) (GtkGisLayerSource *source,
- GtkGisLayer *layer);
+ GtkGisLayer *layer);
GtkGisLayerGeometryType (*get_layer_geometry_type) (GtkGisLayerSource *source,
- gchar *name);
+ gchar *name);
};
GType gtk_gis_layer_source_get_type (void) G_GNUC_CONST;
-GtkGisLayerSource *gtk_gis_layer_source_new (void);
-
gboolean gtk_gis_layer_source_fill_layer (GtkGisLayerSource *source,
GtkGisLayer *layer);
#include <ogr_core.h>
#include "layersourceshp.h"
+#include "geomtryline.h"
+#include "geomtrypoint.h"
+#include "geomtrypolygon.h"
static void gtk_gis_layer_source_shp_class_init (GtkGisLayerSourceShpClass *klass);
static void gtk_gis_layer_source_shp_init (GtkGisLayerSourceShp *gtk_gis_layer_source_shp);
/* TO DO */
ret = FALSE;
}
+ else
+ {
+ gint numLayers;
+ gint i;
+
+ OGRLayerH layer;
+ OGRFeatureDefnH layerDefn;
+
+ gchar *name = gtk_gis_layer_get_name (layer);
+
+ GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (gtk_gis_layer_source);
+
+ numLayers = OGR_DS_GetLayerCount (priv->datasource);
+ for (i = 0; i < numLayers; i++)
+ {
+ layer = OGR_DS_GetLayer (priv->datasource, i);
+ layerDefn = OGR_L_GetLayerDefn (layer);
+
+ if (strcmp (name, OGR_FD_GetName(layerDefn)) == 0)
+ {
+ OGRFeatureH feature;
+ OGRGeometryH poGeometry;
+ GtkGisGeometry *geometry;
+
+ while ((feature = OGR_L_GetNextFeature (layer)) != NULL)
+ {
+ poGeometry = OGR_F_GetGeometryRef (feature);
+ if (poGeometry != NULL
+ && wkbFlatten(OGR_G_GetGeometryType (poGeometry)) == wkbPoint)
+ {
+ geometry = gtk_gis_geometry_point_new (OGR_G_GetX (poGeometry, 0), OGR_G_GetY (poGeometry, 0));
+ }
+ else if (poGeometry != NULL
+ && wkbFlatten(OGR_G_GetGeometryType (poGeometry)) == wkbLineString)
+ {
+ }
+ else if (poGeometry != NULL
+ && wkbFlatten(OGR_G_GetGeometryType (poGeometry)) == wkbPolygon)
+ {
+ }
+ }
+
+ break;
+ }
+ }
+ }
return ret;
}
+SUBDIRS = samples
+
LIBS = $(GTKGIS_LIBS)
AM_CPPFLAGS = $(GTKGIS_CFLAGS) \
libgtkgis = $(top_builddir)/src/libgtkgis.la
-noinst_PROGRAMS =
+noinst_PROGRAMS = from_xml
LDADD = $(libgtgkis)
-EXTRA_DIST =
+EXTRA_DIST = test1.gtkgis
--- /dev/null
+EXTRA_DIST = \
+ airports.dbf \
+ airports.prj \
+ airports.shp \
+ airports.shx \
+ alaska.dbf \
+ alaska.prj \
+ alaska.shp \
+ alaska.shx \
+ railroads.dbf \
+ railroads.prj \
+ railroads.shp \
+ railroads.shx \
+ rivers.dbf \
+ rivers.prj \
+ rivers.shp \
+ rivers.shx
--- /dev/null
+PROJCS["Albers",GEOGCS["GCS_North_American_1927",DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.978698213898]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Albers"],PARAMETER["standard_parallel_1",55],PARAMETER["standard_parallel_2",65],PARAMETER["latitude_of_origin",50],PARAMETER["central_meridian",-154],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Foot_US",0.30480060960121924]]
\ No newline at end of file
--- /dev/null
+PROJCS["Albers Equal Area",GEOGCS["clark66",DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Albers"],PARAMETER["standard_parallel_1",55],PARAMETER["standard_parallel_2",65],PARAMETER["latitude_of_origin",50],PARAMETER["central_meridian",-154],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Foot_US",0.30480060960121924]]
\ No newline at end of file
--- /dev/null
+PROJCS["Albers",GEOGCS["GCS_North_American_1927",DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.978698213898]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Albers"],PARAMETER["standard_parallel_1",55],PARAMETER["standard_parallel_2",65],PARAMETER["latitude_of_origin",50],PARAMETER["central_meridian",-154],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Foot_US",0.30480060960121924]]
\ No newline at end of file
--- /dev/null
+PROJCS["Albers Equal Area",GEOGCS["clark66",DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Albers"],PARAMETER["standard_parallel_1",55],PARAMETER["standard_parallel_2",65],PARAMETER["latitude_of_origin",50],PARAMETER["central_meridian",-154],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Foot_US",0.30480060960121924]]
\ No newline at end of file
--- /dev/null
+<gtkgis>
+
+ <layer name="alaska">
+ <source>
+ <shape filename="samples\alaska.shp" />
+ </source>
+ </layer>
+
+ <layer name="airports">
+ <source>
+ <shape filename="samples\airports.shp" />
+ </source>
+ </layer>
+
+ <layer name="railroads">
+ <source>
+ <shape filename="samples\railroads.shp" />
+ </source>
+ </layer>
+
+ <layer name="rivers">
+ <source>
+ <shape filename="samples\rivers.shp" />
+ </source>
+ </layer>
+
+</gtkgis>