]> saetta.ns0.it Git - libgtkgis/commitdiff
Continued base classes.
authorAndrea Zagli <azagli@libero.it>
Sun, 28 Jun 2009 15:06:48 +0000 (17:06 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 28 Jun 2009 15:06:48 +0000 (17:06 +0200)
Implemented geometry classes.
Moved LayerSourceShp::get_geometry_type and LayerSourceShp::get_geometries funtions to LayerSource.

24 files changed:
.gitignore
src/geometry.h
src/geometryline.c
src/geometryline.h
src/geometrypoint.c
src/geometrypoint.h
src/geometrypolygon.c
src/geometrypolygon.h
src/geometryraster.c
src/geometryraster.h
src/gtkgis.c
src/gtkgis.h
src/layer.c
src/layer.h
src/layersgroup.c
src/layersource.c
src/layersource.h
src/layersourcepostgis.c
src/layersourcepostgis.h
src/layersourceshp.c
src/layersourceshp.h
tests/Makefile.am
tests/from_xml.c
tests/test1.gtkgis

index 095b9a409fe70863f0061066543cd463381d2c07..0cdb086e9986d3ff077ed7597fb51a447073649c 100644 (file)
@@ -27,6 +27,7 @@ src/.deps/
 src/.libs/
 stamp-h1
 tests/.deps
+tests/.libs
 tests/from_xml
 
 # temporarily
index f0c756789928e088231a1f5df7b429f68561feae..ec5994703aaaaf03c3e8e0c0c9e18276b43f8595 100644 (file)
@@ -50,6 +50,13 @@ struct _GtkGisGeometryClass
 GType gtk_gis_geometry_get_type (void) G_GNUC_CONST;
 
 
+typedef struct
+       {
+               gdouble x;
+               gdouble y;
+       } GtkGisPoint;
+
+
 gboolean gtk_gis_geometry_get_editable (GtkGisGeometry *geometry);
 void gtk_gis_geometry_set_editable (GtkGisGeometry *geometry, gboolean editable);
 
index 3cc42a207c50f8b9bc1ba00fcf4f47f90c527523..11fdebafb07fb613f62d341ab71952d19cca1346 100644 (file)
@@ -48,33 +48,7 @@ struct _GtkGisGeometryLinePrivate
                GPtrArray *points;
        };
 
-GType
-gtk_gis_geometry_line_get_type (void)
-{
-       static GType gtk_gis_geometry_line_type = 0;
-
-       if (!gtk_gis_geometry_line_type)
-               {
-                       static const GTypeInfo gtk_gis_geometry_line_info =
-                       {
-                               sizeof (GtkGisGeometryLineClass),
-                               NULL,   /* base_init */
-                               NULL,   /* base_finalize */
-                               (GClassInitFunc) gtk_gis_geometry_line_class_init,
-                               NULL,   /* class_finalize */
-                               NULL,   /* class_data */
-                               sizeof (GtkGisGeometryLine),
-                               0,      /* n_preallocs */
-                               (GInstanceInitFunc) gtk_gis_geometry_line_init,
-                               NULL
-                       };
-
-                       gtk_gis_geometry_line_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisGeometryLine",
-                                                                 &gtk_gis_geometry_line_info, 0);
-               }
-
-       return gtk_gis_geometry_line_type;
-}
+G_DEFINE_TYPE (GtkGisGeometryLine, gtk_gis_geometry_line, TYPE_GTK_GIS_GEOMETRY)
 
 static void
 gtk_gis_geometry_line_class_init (GtkGisGeometryLineClass *klass)
@@ -102,12 +76,12 @@ gtk_gis_geometry_line_init (GtkGisGeometryLine *gtk_gis_geometry_line)
  *
  * Returns: the newly created #GtkGisGeometryLine object.
  */
-GtkGisGeometryLine
+GtkGisGeometry
 *gtk_gis_geometry_line_new ()
 {
-       GtkGisGeometryLine *gtk_gis_geometry_line;
+       GtkGisGeometry *gtk_gis_geometry_line;
 
-       gtk_gis_geometry_line = GTK_GIS_GEOMETRY_LINE (g_object_new (gtk_gis_geometry_line_get_type (), NULL));
+       gtk_gis_geometry_line = g_object_new (gtk_gis_geometry_line_get_type (), NULL);
 
        return gtk_gis_geometry_line;
 }
@@ -120,32 +94,39 @@ GtkGisGeometryLine
  *
  * Returns: the newly created #GtkGisGeometryLine object.
  */
-GtkGisGeometryLine
+GtkGisGeometry
 *gtk_gis_geometry_line_new_from_array (GPtrArray *points)
 {
-       GtkGisGeometryLine *gtk_gis_geometry_line;
+       GtkGisGeometry *line;
        GtkGisGeometryLinePrivate *priv;
 
-       gtk_gis_geometry_line = gtk_gis_geometry_line_new ();
+       line = gtk_gis_geometry_line_new ();
 
-       priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (gtk_gis_geometry_line);
+       priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (GTK_GIS_GEOMETRY_LINE (line));
 
        priv->points = points;
 
-       return gtk_gis_geometry_line;
+       return line;
 }
 
 /**
- * gtk_gis_geomtry_line_add_point:
+ * gtk_gis_geometry_line_add_point:
  * @line:
  * @point:
  */
 void
-gtk_gis_geomtry_line_add_point (GtkGisGeometryLine *line, GtkGisGeometryPoint *point)
+gtk_gis_geometry_line_add_point (GtkGisGeometryLine *line, GtkGisPoint point)
 {
        GtkGisGeometryLinePrivate *priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (line);
 
-       g_ptr_array_add (priv->points, point);
+       GtkGisPoint *gpoint;
+
+       gpoint = g_malloc0 (sizeof (GtkGisPoint));
+
+       gpoint->x = point.x;
+       gpoint->y = point.y;
+
+       g_ptr_array_add (priv->points, gpoint);
 }
 
 /**
@@ -156,22 +137,23 @@ gtk_gis_geomtry_line_add_point (GtkGisGeometryLine *line, GtkGisGeometryPoint *p
  *
  */
 void
-gtk_gis_geomtry_line_add_point_from_coordinates (GtkGisGeometryLine *line,
-                                                 gdouble x, gdouble y)
+gtk_gis_geometry_line_add_point_from_coordinates (GtkGisGeometryLine *line,
+                                                  gdouble x, gdouble y)
 {
-       GtkGisGeometryPoint *point;
+       GtkGisPoint gpoint;
 
-       point = gtk_gis_geometry_point_new (x, y);
+       gpoint.x = x;
+       gpoint.y = y;
 
-       gtk_gis_geometry_line_add_point (line, point);
+       gtk_gis_geometry_line_add_point (line, gpoint);
 }
 
 static void
 gtk_gis_geometry_line_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
-       GtkGisGeometryLine *gtk_gis_geometry_line = GTK_GIS_GEOMETRY_LINE (object);
+       GtkGisGeometryLine *line = GTK_GIS_GEOMETRY_LINE (object);
 
-       GtkGisGeometryLinePrivate *priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (gtk_gis_geometry_line);
+       GtkGisGeometryLinePrivate *priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (line);
 
        switch (property_id)
                {
@@ -184,9 +166,9 @@ gtk_gis_geometry_line_set_property (GObject *object, guint property_id, const GV
 static void
 gtk_gis_geometry_line_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
 {
-       GtkGisGeometryLine *gtk_gis_geometry_line = GTK_GIS_GEOMETRY_LINE (object);
+       GtkGisGeometryLine *line = GTK_GIS_GEOMETRY_LINE (object);
 
-       GtkGisGeometryLinePrivate *priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (gtk_gis_geometry_line);
+       GtkGisGeometryLinePrivate *priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (line);
 
        switch (property_id)
                {
index 63a1f10291fbcc85c902d4ce5556a048610237a9..97d3d52e872060f6f7b3932e59dba3c6496a25ff 100644 (file)
@@ -50,13 +50,13 @@ struct _GtkGisGeometryLineClass
 GType gtk_gis_geometry_line_get_type (void) G_GNUC_CONST;
 
 
-GtkGisGeometryLine *gtk_gis_geometry_line_new (void);
+GtkGisGeometry *gtk_gis_geometry_line_new (void);
 
-GtkGisGeometryLine *gtk_gis_geometry_line_new_from_array (GPtrArray *points);
+GtkGisGeometry *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);
+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 f9b9611bfa5ce60bad93d19d8d6b621b37a2b0e9..f35226749cbbd5b3a078f2dfd7e1450fe46df85e 100644 (file)
@@ -45,8 +45,7 @@ static void gtk_gis_geometry_point_get_property (GObject *object,
 typedef struct _GtkGisGeometryPointPrivate GtkGisGeometryPointPrivate;
 struct _GtkGisGeometryPointPrivate
        {
-               gdouble x;
-               gdouble y;
+               GtkGisPoint point;
        };
 
 GType
@@ -70,7 +69,7 @@ gtk_gis_geometry_point_get_type (void)
                                NULL
                        };
 
-                       gtk_gis_geometry_point_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisGeometryPoint",
+                       gtk_gis_geometry_point_type = g_type_register_static (TYPE_GTK_GIS_GEOMETRY, "GtkGisGeometryPoint",
                                                                  &gtk_gis_geometry_point_info, 0);
                }
 
@@ -96,51 +95,81 @@ gtk_gis_geometry_point_init (GtkGisGeometryPoint *gtk_gis_geometry_point)
 
 /**
  * gtk_gis_geometry_point_new:
- * @x:
- * @y:
+ * @point:
  *
  * Creates a new #GtkGisGeometryPoint object.
  *
  * Returns: the newly created #GtkGisGeometryPoint object.
  */
-GtkGisGeometryPoint
-*gtk_gis_geometry_point_new (gdouble x, gdouble y)
+GtkGisGeometry
+*gtk_gis_geometry_point_new (GtkGisPoint point)
 {
-       GtkGisGeometryPoint *gtk_gis_geometry_point;
+       GtkGisGeometry *gpoint;
        GtkGisGeometryPointPrivate *priv;
 
-       gtk_gis_geometry_point = GTK_GIS_GEOMETRY_POINT (g_object_new (gtk_gis_geometry_point_get_type (), NULL));
+       gpoint = g_object_new (gtk_gis_geometry_point_get_type (), NULL);
 
-       priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (gtk_gis_geometry_point);
+       priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (GTK_GIS_GEOMETRY_POINT (gpoint));
 
-       priv->x = x;
-       priv->y = y;
+       priv->point.x = point.x;
+       priv->point.y = point.y;
 
-       return gtk_gis_geometry_point;
+       return gpoint;
 }
 
+/**
+ * gtk_gis_geometry_get_point:
+ * @point:
+ *
+ * Returns:
+ */
+GtkGisPoint
+*gtk_gis_geometry_get_point (GtkGisGeometryPoint *point)
+{
+       GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (point);
+
+       GtkGisPoint *gpoint;
+
+       gpoint = g_malloc0 (sizeof (GtkGisPoint));
+
+       gpoint->x = priv->point.x;
+       gpoint->y = priv->point.y;
+
+       return gpoint;
+}
+
+/**
+ * gtk_gis_geometry_point_get_x:
+ * @point:
+ *
+ */
 gdouble
-gtk_gis_geometry_get_x (GtkGisGeometryPoint *point)
+gtk_gis_geometry_point_get_x (GtkGisGeometryPoint *point)
 {
        GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (point);
 
-       return priv->x;
+       return priv->point.x;
 }
 
+/**
+ * gtk_gis_geometry_point_get_y:
+ * @point:
+ *
+ */
 gdouble
-gtk_gis_geometry_get_y (GtkGisGeometryPoint *point)
+gtk_gis_geometry_point_get_y (GtkGisGeometryPoint *point)
 {
        GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (point);
 
-       return priv->y;
+       return priv->point.y;
 }
 
 static void
 gtk_gis_geometry_point_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
-       GtkGisGeometryPoint *gtk_gis_geometry_point = GTK_GIS_GEOMETRY_POINT (object);
+       GtkGisGeometryPoint *point = GTK_GIS_GEOMETRY_POINT (object);
 
-       GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (gtk_gis_geometry_point);
+       GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (point);
 
        switch (property_id)
                {
@@ -153,9 +182,9 @@ gtk_gis_geometry_point_set_property (GObject *object, guint property_id, const G
 static void
 gtk_gis_geometry_point_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
 {
-       GtkGisGeometryPoint *gtk_gis_geometry_point = GTK_GIS_GEOMETRY_POINT (object);
+       GtkGisGeometryPoint *point = GTK_GIS_GEOMETRY_POINT (object);
 
-       GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (gtk_gis_geometry_point);
+       GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (point);
 
        switch (property_id)
                {
index 12e899b79ceb1be80a4ad33467abbc8e5a9788b2..63add2acf0faedc882a16e97b2f1c239674f2070 100644 (file)
@@ -49,10 +49,12 @@ struct _GtkGisGeometryPointClass
 GType gtk_gis_geometry_point_get_type (void) G_GNUC_CONST;
 
 
-GtkGisGeometryPoint *gtk_gis_geometry_point_new (gdouble x, gdouble y);
+GtkGisGeometry *gtk_gis_geometry_point_new (GtkGisPoint point);
 
-gdouble gtk_gis_geometry_get_x (GtkGisGeometryPoint *point);
-gdouble gtk_gis_geometry_get_y (GtkGisGeometryPoint *point);
+GtkGisPoint *gtk_gis_geometry_get_point (GtkGisGeometryPoint *point);
+
+gdouble gtk_gis_geometry_point_get_x (GtkGisGeometryPoint *point);
+gdouble gtk_gis_geometry_point_get_y (GtkGisGeometryPoint *point);
 
 
 G_END_DECLS
index 4dad0b287339e4ded514accc171033ef56b47ebf..6d79aa85c1c70bdbce8fbd387ed54fa51d7912c5 100644 (file)
@@ -45,35 +45,10 @@ static void gtk_gis_geometry_polygon_get_property (GObject *object,
 typedef struct _GtkGisGeometryPolygonPrivate GtkGisGeometryPolygonPrivate;
 struct _GtkGisGeometryPolygonPrivate
        {
+               GList *lines;
        };
 
-GType
-gtk_gis_geometry_polygon_get_type (void)
-{
-       static GType gtk_gis_geometry_polygon_type = 0;
-
-       if (!gtk_gis_geometry_polygon_type)
-               {
-                       static const GTypeInfo gtk_gis_geometry_polygon_info =
-                       {
-                               sizeof (GtkGisGeometryPolygonClass),
-                               NULL,   /* base_init */
-                               NULL,   /* base_finalize */
-                               (GClassInitFunc) gtk_gis_geometry_polygon_class_init,
-                               NULL,   /* class_finalize */
-                               NULL,   /* class_data */
-                               sizeof (GtkGisGeometryPolygon),
-                               0,      /* n_preallocs */
-                               (GInstanceInitFunc) gtk_gis_geometry_polygon_init,
-                               NULL
-                       };
-
-                       gtk_gis_geometry_polygon_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisGeometryPolygon",
-                                                                 &gtk_gis_geometry_polygon_info, 0);
-               }
-
-       return gtk_gis_geometry_polygon_type;
-}
+G_DEFINE_TYPE (GtkGisGeometryPolygon, gtk_gis_geometry_polygon, TYPE_GTK_GIS_GEOMETRY)
 
 static void
 gtk_gis_geometry_polygon_class_init (GtkGisGeometryPolygonClass *klass)
@@ -99,14 +74,34 @@ gtk_gis_geometry_polygon_init (GtkGisGeometryPolygon *gtk_gis_geometry_polygon)
  *
  * Returns: the newly created #GtkGisGeometryPolygon object.
  */
-GtkGisGeometryPolygon
+GtkGisGeometry
 *gtk_gis_geometry_polygon_new ()
 {
-       GtkGisGeometryPolygon *gtk_gis_geometry_polygon;
+       GtkGisGeometry *polygon;
+
+       polygon = g_object_new (gtk_gis_geometry_polygon_get_type (), NULL);
+
+       return polygon;
+}
+
+/**
+ * gtk_gis_geometry_polygon_new_from_line:
+ * @line: a #GtkGisGeometryLine object
+ *
+ * Creates a new #GtkGisGeometryPolygon object.
+ *
+ * Returns: the newly created #GtkGisGeometryPolygon object.
+ */
+GtkGisGeometry
+*gtk_gis_geometry_polygon_new_from_line (GtkGisGeometryLine *line)
+{
+       GtkGisGeometry *polygon;
+
+       polygon = gtk_gis_geometry_polygon_new ();
 
-       gtk_gis_geometry_polygon = GTK_GIS_GEOMETRY_POLYGON (g_object_new (gtk_gis_geometry_polygon_get_type (), NULL));
+       gtk_gis_geometry_polygon_add_line (GTK_GIS_GEOMETRY_POLYGON (polygon), line);
 
-       return gtk_gis_geometry_polygon;
+       return polygon;
 }
 
 /**
@@ -117,22 +112,55 @@ GtkGisGeometryPolygon
  *
  * Returns: the newly created #GtkGisGeometryPolygon object.
  */
-GtkGisGeometryPolygon
+GtkGisGeometry
 *gtk_gis_geometry_polygon_new_from_array (GPtrArray *points)
 {
-       GtkGisGeometryPolygon *gtk_gis_geometry_polygon;
+       GtkGisGeometry *polygon;
+       GtkGisGeometry *line;
 
-       gtk_gis_geometry_polygon = gtk_gis_geometry_line_new_from_array (points);
+       line = gtk_gis_geometry_line_new_from_array (points);
 
-       return gtk_gis_geometry_polygon;
+       gtk_gis_geometry_polygon_add_line (GTK_GIS_GEOMETRY_POLYGON (polygon), GTK_GIS_GEOMETRY_LINE (line));
+
+       return polygon;
+}
+
+/**
+ * gtk_gis_geometry_polygon_add_line:
+ * @polygon:
+ * @line:
+ *
+ */
+void
+gtk_gis_geometry_polygon_add_line (GtkGisGeometryPolygon *polygon,
+                                   GtkGisGeometryLine *line)
+{
+       GtkGisGeometryPolygonPrivate *priv = GTK_GIS_GEOMETRY_POLYGON_GET_PRIVATE (polygon);
+
+       priv->lines = g_list_append (priv->lines, line);
+}
+
+/**
+ * gtk_gis_geometry_polygon_remove_line:
+ * @polygon:
+ * @line:
+ *
+ */
+void
+gtk_gis_geometry_polygon_remove_line (GtkGisGeometryPolygon *polygon,
+                                      GtkGisGeometryLine *line)
+{
+       GtkGisGeometryPolygonPrivate *priv = GTK_GIS_GEOMETRY_POLYGON_GET_PRIVATE (polygon);
+
+       priv->lines = g_list_remove (priv->lines, line);
 }
 
 static void
 gtk_gis_geometry_polygon_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
-       GtkGisGeometryPolygon *gtk_gis_geometry_polygon = GTK_GIS_GEOMETRY_POLYGON (object);
+       GtkGisGeometryPolygon *polygon = GTK_GIS_GEOMETRY_POLYGON (object);
 
-       GtkGisGeometryPolygonPrivate *priv = GTK_GIS_GEOMETRY_POLYGON_GET_PRIVATE (gtk_gis_geometry_polygon);
+       GtkGisGeometryPolygonPrivate *priv = GTK_GIS_GEOMETRY_POLYGON_GET_PRIVATE (polygon);
 
        switch (property_id)
                {
@@ -145,9 +173,9 @@ gtk_gis_geometry_polygon_set_property (GObject *object, guint property_id, const
 static void
 gtk_gis_geometry_polygon_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
 {
-       GtkGisGeometryPolygon *gtk_gis_geometry_polygon = GTK_GIS_GEOMETRY_POLYGON (object);
+       GtkGisGeometryPolygon *polygon = GTK_GIS_GEOMETRY_POLYGON (object);
 
-       GtkGisGeometryPolygonPrivate *priv = GTK_GIS_GEOMETRY_POLYGON_GET_PRIVATE (gtk_gis_geometry_polygon);
+       GtkGisGeometryPolygonPrivate *priv = GTK_GIS_GEOMETRY_POLYGON_GET_PRIVATE (polygon);
 
        switch (property_id)
                {
index 2309170fa05b8123ddfa7b710ed49c3248731946..a1ecbd84e66bb2425f6bfd806652f4477083cebf 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef __GTK_GIS_GEOMETRY_POLYGON_H__
 #define __GTK_GIS_GEOMETRY_POLYGON_H__
 
+#include "geometry.h"
 #include "geometryline.h"
 
 G_BEGIN_DECLS
@@ -38,20 +39,24 @@ typedef struct _GtkGisGeometryPolygonClass GtkGisGeometryPolygonClass;
 
 struct _GtkGisGeometryPolygon
        {
-               GtkGisGeometryLine parent;
+               GtkGisGeometry parent;
        };
 
 struct _GtkGisGeometryPolygonClass
        {
-               GtkGisGeometryLineClass parent_class;
+               GtkGisGeometryClass parent_class;
        };
 
 GType gtk_gis_geometry_polygon_get_type (void) G_GNUC_CONST;
 
 
-GtkGisGeometryPolygon *gtk_gis_geometry_polygon_new (void);
+GtkGisGeometry *gtk_gis_geometry_polygon_new (void);
 
-GtkGisGeometryPolygon *gtk_gis_geometry_polygon_new_from_array (GPtrArray *points);
+GtkGisGeometry *gtk_gis_geometry_polygon_new_from_line (GtkGisGeometryLine *line);
+GtkGisGeometry *gtk_gis_geometry_polygon_new_from_array (GPtrArray *points);
+
+void gtk_gis_geometry_polygon_add_line (GtkGisGeometryPolygon *polygon, GtkGisGeometryLine *line);
+void gtk_gis_geometry_polygon_remove_line (GtkGisGeometryPolygon *polygon, GtkGisGeometryLine *line);
 
 
 G_END_DECLS
index 4fe3800815775475108d26b1b0aa7ad49e8622de..9979a0c075b8e3c1da5d05c2219bd14616b28811 100644 (file)
@@ -68,7 +68,7 @@ gtk_gis_geometry_raster_get_type (void)
                                NULL
                        };
 
-                       gtk_gis_geometry_raster_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisGeometryRaster",
+                       gtk_gis_geometry_raster_type = g_type_register_static (TYPE_GTK_GIS_GEOMETRY, "GtkGisGeometryRaster",
                                                                  &gtk_gis_geometry_raster_info, 0);
                }
 
@@ -99,22 +99,22 @@ gtk_gis_geometry_raster_init (GtkGisGeometryRaster *gtk_gis_geometry_raster)
  *
  * Returns: the newly created #GtkGisGeometryRaster object.
  */
-GtkGisGeometryRaster
+GtkGisGeometry
 *gtk_gis_geometry_raster_new ()
 {
-       GtkGisGeometryRaster *gtk_gis_geometry_raster;
+       GtkGisGeometry *raster;
 
-       gtk_gis_geometry_raster = GTK_GIS_GEOMETRY_RASTER (g_object_new (gtk_gis_geometry_raster_get_type (), NULL));
+       raster = g_object_new (gtk_gis_geometry_raster_get_type (), NULL);
 
-       return gtk_gis_geometry_raster;
+       return raster;
 }
 
 static void
 gtk_gis_geometry_raster_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
-       GtkGisGeometryRaster *gtk_gis_geometry_raster = GTK_GIS_GEOMETRY_RASTER (object);
+       GtkGisGeometryRaster *raster = GTK_GIS_GEOMETRY_RASTER (object);
 
-       GtkGisGeometryRasterPrivate *priv = GTK_GIS_GEOMETRY_RASTER_GET_PRIVATE (gtk_gis_geometry_raster);
+       GtkGisGeometryRasterPrivate *priv = GTK_GIS_GEOMETRY_RASTER_GET_PRIVATE (raster);
 
        switch (property_id)
                {
@@ -127,9 +127,9 @@ gtk_gis_geometry_raster_set_property (GObject *object, guint property_id, const
 static void
 gtk_gis_geometry_raster_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
 {
-       GtkGisGeometryRaster *gtk_gis_geometry_raster = GTK_GIS_GEOMETRY_RASTER (object);
+       GtkGisGeometryRaster *raster = GTK_GIS_GEOMETRY_RASTER (object);
 
-       GtkGisGeometryRasterPrivate *priv = GTK_GIS_GEOMETRY_RASTER_GET_PRIVATE (gtk_gis_geometry_raster);
+       GtkGisGeometryRasterPrivate *priv = GTK_GIS_GEOMETRY_RASTER_GET_PRIVATE (raster);
 
        switch (property_id)
                {
index e8ac4e9834a9e505e549ec2ef2c8f9d8a6a64dc9..38a9683166033e7cc33597ec9cb0eaceb5ee23ef 100644 (file)
@@ -49,7 +49,7 @@ struct _GtkGisGeometryRasterClass
 GType gtk_gis_geometry_raster_get_type (void) G_GNUC_CONST;
 
 
-GtkGisGeometryRaster *gtk_gis_geometry_raster_new (void);
+GtkGisGeometry *gtk_gis_geometry_raster_new (void);
 
 
 G_END_DECLS
index cc0f8421cc6e4de2a2933629b0cd7979bfb55b04..0740a3917264ec3518246c88151c1c140b4d9b7a 100644 (file)
 #endif
 
 #include "gtkgis.h"
+#include "layer.h"
+#include "layersource.h"
+#include "layersourceshp.h"
+#include "layersourcepostgis.h"
 
 static void gtk_gis_class_init (GtkGisClass *klass);
 static void gtk_gis_init (GtkGis *gtk_gis);
 
+static void gtk_gis_add (GtkContainer *container,
+                         GtkWidget *widget);
+
 static void gtk_gis_set_property (GObject *object,
                                      guint property_id,
                                      const GValue *value,
@@ -45,56 +52,46 @@ static void gtk_gis_get_property (GObject *object,
 typedef struct _GtkGisPrivate GtkGisPrivate;
 struct _GtkGisPrivate
        {
+               GtkWidget *scroll_win;
+
                GtkWidget *canvas;
                GooCanvasItem *canvas_root;
 
                GList *layer_groups;
                GList *layers;
-       };
 
-GType
-gtk_gis_get_type (void)
-{
-       static GType gtk_gis_type = 0;
-
-       if (!gtk_gis_type)
-               {
-                       static const GTypeInfo gtk_gis_info =
-                       {
-                               sizeof (GtkGisClass),
-                               NULL,   /* base_init */
-                               NULL,   /* base_finalize */
-                               (GClassInitFunc) gtk_gis_class_init,
-                               NULL,   /* class_finalize */
-                               NULL,   /* class_data */
-                               sizeof (GtkGis),
-                               0,      /* n_preallocs */
-                               (GInstanceInitFunc) gtk_gis_init,
-                               NULL
-                       };
-
-                       gtk_gis_type = g_type_register_static (G_TYPE_OBJECT, "GtkGis",
-                                                                 &gtk_gis_info, 0);
-               }
+               GtkGisLayerExtent extent;
+       };
 
-       return gtk_gis_type;
-}
+G_DEFINE_TYPE (GtkGis, gtk_gis, GTK_TYPE_BIN)
 
 static void
 gtk_gis_class_init (GtkGisClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
+       GtkContainerClass *container_class = (GtkContainerClass*) klass;
 
        g_type_class_add_private (object_class, sizeof (GtkGisPrivate));
 
        object_class->set_property = gtk_gis_set_property;
        object_class->get_property = gtk_gis_get_property;
+
+       container_class->add = gtk_gis_add;
 }
 
 static void
 gtk_gis_init (GtkGis *gtk_gis)
 {
        GtkGisPrivate *priv = GTK_GIS_GET_PRIVATE (gtk_gis);
+
+       priv->scroll_win = gtk_scrolled_window_new (NULL, NULL);
+    gtk_container_add (GTK_CONTAINER (gtk_gis), priv->scroll_win);
+
+       priv->canvas = goo_canvas_new ();
+    gtk_container_add (GTK_CONTAINER (priv->scroll_win), priv->canvas);
+  
+    priv->canvas_root = goo_canvas_get_root_item (GOO_CANVAS (priv->canvas));
 }
 
 /**
@@ -104,12 +101,15 @@ gtk_gis_init (GtkGis *gtk_gis)
  *
  * Returns: the newly created #GtkGis object.
  */
-GtkGis
+GtkWidget
 *gtk_gis_new ()
 {
-       GtkGis *gtk_gis;
+       GtkWidget *gtk_gis;
+       GtkGisPrivate *priv;
 
-       gtk_gis = GTK_GIS (g_object_new (gtk_gis_get_type (), NULL));
+       gtk_gis = g_object_new (gtk_gis_get_type (), NULL);
+
+       priv = GTK_GIS_GET_PRIVATE (GTK_GIS (gtk_gis));
 
        return gtk_gis;
 }
@@ -120,10 +120,10 @@ GtkGis
  *
  * Returns: the newly created #GtkGis object.
  */
-GtkGis
+GtkWidget
 *gtk_gis_new_from_xml (xmlDoc *xdoc)
 {
-       GtkGis *gtkgis = NULL;
+       GtkWidget *gtkgis = NULL;
        xmlNode *cur;
 
        cur = xmlDocGetRootElement (xdoc);
@@ -135,7 +135,7 @@ GtkGis
 
                                        gtkgis = gtk_gis_new ();
 
-                                       priv = GTK_GIS_GET_PRIVATE (gtkgis);
+                                       priv = GTK_GIS_GET_PRIVATE (GTK_GIS (gtkgis));
 
                                        cur = cur->children;
                                        while (cur != NULL)
@@ -149,7 +149,7 @@ GtkGis
                                                                        xml_layer = cur;
 
                                                                        layer_name = xmlGetProp (cur, (const xmlChar *)"name");
-                                                                       if (layer_name != NULL)
+                                                                       if (layer_name == NULL)
                                                                                {
                                                                                        /* TO DO */
                                                                                        /* get layer source name */
@@ -157,55 +157,62 @@ GtkGis
                                                                                }
 
                                                                        cur = cur->children;
-                                                                       if (cur != NULL
-                                                                           && cur->type == XML_ELEMENT_NODE
-                                                                           && xmlStrcmp (cur->name, "source") == 0)
+                                                                       while (cur != NULL)
                                                                                {
-                                                                                       xmlNode *xml_source;
-
-                                                                                       xml_source = cur;
-
-                                                                                       if (cur != NULL
-                                                                                           && cur->type == XML_ELEMENT_NODE
-                                                                                           && (xmlStrcmp (cur->name, "shape") == 0
-                                                                                           || xmlStrcmp (cur->name, "postgis") == 0))
+                                                                                       if (cur->type == XML_ELEMENT_NODE
+                                                                                               && xmlStrcmp (cur->name, "source") == 0)
                                                                                                {
-                                                                                                       xmlNode *xml_source_spec;
-                                                                                                       GtkGisLayer *layer = NULL;
-                                                                                                       GtkGisLayerSource *layer_source = NULL;
+                                                                                                       xmlNode *xml_source;
 
-                                                                                                       xml_source_spec = cur;
+                                                                                                       xml_source = cur;
 
-                                                                                                       if (xmlStrcmp (cur->name, "shape") == 0)
+                                                                                                       cur = cur->children;
+                                                                                                       while (cur != NULL)
                                                                                                                {
-                                                                                                                       gchar *filename;
-
-                                                                                                                       filename = xmlGetProp (cur, (const xmlChar *)"filename");
-                                                                                                                       if (filename != NULL)
+                                                                                                                       if (cur->type == XML_ELEMENT_NODE
+                                                                                                                               && (xmlStrcmp (cur->name, "shape") == 0
+                                                                                                                               || xmlStrcmp (cur->name, "postgis") == 0))
                                                                                                                                {
-                                                                                                                                       layer_source = GTK_GIS_LAYER_SOURCE (gtk_gis_layer_source_shp_new (filename));
+                                                                                                                                       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 ((const gchar *)filename);
+                                                                                                                                                               }
+                                                                                                                                               }
+                                                                                                                                       else if (xmlStrcmp (cur->name, "postgis") == 0)
+                                                                                                                                               {
+                                                                                                                                                       layer_source = gtk_gis_layer_source_postgis_new (xmlGetProp (cur, (const xmlChar *)"host"),
+                                                                                 atol (xmlGetProp (cur, (const xmlChar *)"port")),
+                                                                                 xmlGetProp (cur, (const xmlChar *)"username"),
+                                                                                 xmlGetProp (cur, (const xmlChar *)"password"));
+                                                                                                                                               }
+
+                                                                                                                                       if (layer_source != NULL)
+                                                                                                                                               {
+                                                                                                                                                       layer = gtk_gis_layer_new_from_source (layer_source, layer_name);
+                                                                                                                                                       gtk_gis_add_layer (GTK_GIS (gtkgis), layer);
+                                                                                                                                               }
+
+                                                                                                                                       cur = xml_source_spec;
                                                                                                                                }
+                                                                                                                       cur = cur->next;
                                                                                                                }
-                                                                                                       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_source;
+                                                                                       cur = cur->next;
                                                                                }
-
                                                                        cur = xml_layer;
                                                                }
-
                                                        cur = cur->next;
                                                }
                                }
@@ -230,10 +237,10 @@ GtkGis
  *
  * Returns: the newly created #GtkGis object.
  */
-GtkGis
+GtkWidget
 *gtk_gis_new_from_file (const gchar *filename)
 {
-       GtkGis *gtkgis = NULL;
+       GtkWidget *gtkgis = NULL;
 
        xmlDoc *xdoc = xmlParseFile (filename);
        if (xdoc != NULL)
@@ -262,9 +269,37 @@ void
 void
 gtk_gis_add_layer (GtkGis *gtkgis, GtkGisLayer *layer)
 {
-       GtkGisPrivate *priv = GTK_GIS_GET_PRIVATE (gtkgis);
+       GtkGisPrivate *priv;
+       GtkGisLayerExtent extent;
+
+       priv = GTK_GIS_GET_PRIVATE (gtkgis);
 
        priv->layers = g_list_append (priv->layers, layer);
+
+       extent = gtk_gis_layer_get_extent (layer);
+
+       if (extent.min_x < priv->extent.min_x)
+               {
+                       priv->extent.min_x = extent.min_x;
+               }
+       if (extent.min_y < priv->extent.min_y)
+               {
+                       priv->extent.min_y = extent.min_y;
+               }
+       if (extent.max_x > priv->extent.max_x)
+               {
+                       priv->extent.max_x = extent.max_x;
+               }
+       if (extent.max_y > priv->extent.max_y)
+               {
+                       priv->extent.max_y = extent.max_y;
+               }
+
+       goo_canvas_set_bounds (GOO_CANVAS (priv->canvas),
+                              priv->extent.min_x,
+                              priv->extent.min_y,
+                              priv->extent.max_x,
+                              priv->extent.max_y);
 }
 
 /**
@@ -280,6 +315,22 @@ gtk_gis_remove_layer (GtkGis *gtkgis, GtkGisLayer *layer)
        priv->layers = g_list_remove (priv->layers, layer);
 }
 
+static void
+gtk_gis_add (GtkContainer *container,
+                        GtkWidget *child)
+{
+       GtkGis *gtkgis;
+       GtkBin *bin;
+
+       bin = GTK_BIN (container);
+       g_return_if_fail (bin->child == NULL);
+
+       gtkgis = GTK_GIS (container);
+
+       bin->child = child;
+       gtk_widget_set_parent (child, GTK_WIDGET (bin));
+}
+
 static void
 gtk_gis_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
index bc1a1f16207708d181ceb41ac6fff9c935a8f0e7..9bb0e7bf9bb4212f1eb82d88360b51be727dc9bd 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef __GTK_GIS_H__
 #define __GTK_GIS_H__
 
-#include <gtk/gtkwidget.h>
+#include <gtk/gtk.h>
 #include <libxml/tree.h>
 
 #include "layersgroup.h"
@@ -42,21 +42,21 @@ typedef struct _GtkGisClass GtkGisClass;
 
 struct _GtkGis
        {
-               GtkWidget parent;
+               GtkBin parent;
        };
 
 struct _GtkGisClass
        {
-               GtkWidgetClass parent_class;
+               GtkBinClass parent_class;
        };
 
 GType gtk_gis_get_type (void) G_GNUC_CONST;
 
 
-GtkGis *gtk_gis_new (void);
+GtkWidget *gtk_gis_new (void);
 
-GtkGis *gtk_gis_new_from_xml (xmlDoc *xdoc);
-GtkGis *gtk_gis_new_from_file (const gchar *filename);
+GtkWidget *gtk_gis_new_from_xml (xmlDoc *xdoc);
+GtkWidget *gtk_gis_new_from_file (const gchar *filename);
 
 void *gtk_gis_save_to_xml (GtkGis *gtkgis, const gchar *filename);
 
index c7bc950497f30bdecf532455b9e042803700663e..9f7b42dde411977578a6d256e7c16843283c0cd1 100644 (file)
@@ -153,7 +153,7 @@ GtkGisLayer
 
        layer = gtk_gis_layer_new (source, name, type);
 
-       gtk_gis_layer_source_fill_layer (source, layer);
+       gtk_gis_layer_fill_from_source (layer);
 
        return layer;
 }
@@ -198,7 +198,7 @@ gtk_gis_layer_fill_from_source (GtkGisLayer *layer)
 {
        GtkGisLayerPrivate *priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
 
-       gtk_gis_layer_source_fill_layer (priv->source, layer);
+       priv->geometries = gtk_gis_layer_source_get_geometries (priv->source, priv->name);
 }
 
 /**
@@ -241,6 +241,23 @@ gtk_gis_layer_remove_geometry (GtkGisLayer *layer, GtkGisGeometry *geometry)
        priv->geometries = g_list_remove (priv->geometries, geometry);
 }
 
+/**
+ * gtk_gis_layer_get_extent:
+ * @layer:
+ *
+ */
+GtkGisLayerExtent
+gtk_gis_layer_get_extent (GtkGisLayer *layer)
+{
+       GtkGisLayerPrivate *priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+
+       GtkGisLayerExtent extent;
+
+       extent = gtk_gis_layer_source_get_layer_extent (priv->source, priv->name);
+
+       return extent;
+}
+
 /**
  * gtk_gis_layer_get_editable:
  * @layer:
index b39d6c882c95b81ff8bb79290351689f2c43a5c5..5e9f3f684a6e14a62122412080a109689bbd5425 100644 (file)
@@ -76,6 +76,8 @@ void gtk_gis_layer_add_geometry (GtkGisLayer *layer,
 void gtk_gis_layer_remove_geometry (GtkGisLayer *layer,
                                     GtkGisGeometry *geometry);
 
+GtkGisLayerExtent gtk_gis_layer_get_extent (GtkGisLayer *layer);
+
 gboolean gtk_gis_layer_get_editable (GtkGisLayer *layer);
 void gtk_gis_layer_set_editable (GtkGisLayer *layer,
                                  gboolean editable);
index 024540dcfc6579f5a57c6ecc8d23c434ebf0fab8..1a4b236dfc756dfef7036f5b4d14083476c884a3 100644 (file)
@@ -105,16 +105,16 @@ gtk_gis_layers_group_init (GtkGisLayersGroup *gtk_gis_layers_group)
 GtkGisLayersGroup
 *gtk_gis_layers_group_new (const gchar *name)
 {
-       GtkGisLayersGroup *gtk_gis_layers_group;
+       GtkGisLayersGroup *group;
        GtkGisLayersGroupPrivate *priv;
 
-       gtk_gis_layers_group = GTK_GIS_LAYERS_GROUP (g_object_new (gtk_gis_layers_group_get_type (), NULL));
+       group = GTK_GIS_LAYERS_GROUP (g_object_new (gtk_gis_layers_group_get_type (), NULL));
 
-       priv = GTK_GIS_LAYERS_GROUP_GET_PRIVATE (gtk_gis_layers_group);
+       priv = GTK_GIS_LAYERS_GROUP_GET_PRIVATE (group);
 
        priv->name = g_strdup (name);
 
-       return gtk_gis_layers_group;
+       return group;
 }
 
 /**
index 571d2693ceffecf4518936666d4505d39cd51ff5..91a88abc0d433cd617cb5531a7670f0e3794f3d5 100644 (file)
 #include <ogr_core.h>
 
 #include "layersource.h"
+#include "geometryline.h"
+#include "geometrypoint.h"
+#include "geometrypolygon.h"
 
 static void gtk_gis_layer_source_class_init (GtkGisLayerSourceClass *klass);
 static void gtk_gis_layer_source_init (GtkGisLayerSource *gtk_gis_layer_source);
 
+static void
+gtk_gis_layer_source_set_ogr_datasource (GtkGisLayerSource *source,
+                                          OGRDataSourceH datasource);
+
 static void gtk_gis_layer_source_set_property (GObject *object,
                                      guint property_id,
                                      const GValue *value,
@@ -46,33 +53,7 @@ struct _GtkGisLayerSourcePrivate
                OGRDataSourceH datasource;
        };
 
-GType
-gtk_gis_layer_source_get_type (void)
-{
-       static GType gtk_gis_layer_source_type = 0;
-
-       if (!gtk_gis_layer_source_type)
-               {
-                       static const GTypeInfo gtk_gis_layer_source_info =
-                       {
-                               sizeof (GtkGisLayerSourceClass),
-                               NULL,   /* base_init */
-                               NULL,   /* base_finalize */
-                               (GClassInitFunc) gtk_gis_layer_source_class_init,
-                               NULL,   /* class_finalize */
-                               NULL,   /* class_data */
-                               sizeof (GtkGisLayerSource),
-                               0,      /* n_preallocs */
-                               (GInstanceInitFunc) gtk_gis_layer_source_init,
-                               NULL
-                       };
-
-                       gtk_gis_layer_source_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisLayerSource",
-                                                                 &gtk_gis_layer_source_info, 0);
-               }
-
-       return gtk_gis_layer_source_type;
-}
+G_DEFINE_TYPE (GtkGisLayerSource, gtk_gis_layer_source, G_TYPE_OBJECT)
 
 static void
 gtk_gis_layer_source_class_init (GtkGisLayerSourceClass *klass)
@@ -81,6 +62,8 @@ gtk_gis_layer_source_class_init (GtkGisLayerSourceClass *klass)
 
        g_type_class_add_private (object_class, sizeof (GtkGisLayerSourcePrivate));
 
+       klass->set_ogr_datasource = gtk_gis_layer_source_set_ogr_datasource;
+
        object_class->set_property = gtk_gis_layer_source_set_property;
        object_class->get_property = gtk_gis_layer_source_get_property;
 }
@@ -91,20 +74,129 @@ gtk_gis_layer_source_init (GtkGisLayerSource *gtk_gis_layer_source)
        GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (gtk_gis_layer_source);
 }
 
+static void
+gtk_gis_layer_source_set_ogr_datasource (GtkGisLayerSource *source,
+                                          OGRDataSourceH datasource)
+{
+       GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
+
+       priv->datasource = datasource;
+}
+
+
 /**
  * gtk_gis_layer_source_get_geometries:
  * @source:
+ * @name:
+ *
+ * Loads the #GtkGisLayerSource from the disk.
  *
+ * Returns: .
  */
 GList
 *gtk_gis_layer_source_get_geometries (GtkGisLayerSource *source,
                                       const gchar *name)
 {
-       GList *geometries;
+       GList *geometries = NULL;
 
-       if (IS_GTK_GIS_LAYER_SOURCE_OBJECT (source) && GTK_GIS_LAYER_SOURCE_GET_CLASS (source)->get_geometries != NULL)
+       GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
+
+    if (priv->datasource == NULL)
+           {
+                       /* TO DO */
+               }
+       else
                {
-                       geometries = GTK_GIS_LAYER_SOURCE_GET_CLASS (source)->get_geometries (source, name);
+                       OGRLayerH layer;
+                       OGRFeatureDefnH layerDefn;
+                       OGRFeatureH feature;
+                       OGRGeometryH poGeometry;
+                       GtkGisGeometry *geometry;
+
+                       layer = OGR_DS_GetLayerByName (priv->datasource, name);
+
+                       layerDefn = OGR_L_GetLayerDefn (layer);
+
+                       while ((feature = OGR_L_GetNextFeature (layer)) != NULL)
+                               {
+                                       poGeometry = OGR_F_GetGeometryRef (feature);
+
+                                       if (poGeometry != NULL
+                                               && wkbFlatten(OGR_G_GetGeometryType (poGeometry)) == wkbPoint)
+                                               {
+                                                       GtkGisPoint gpoint;
+
+                                                       gpoint.x = OGR_G_GetX (poGeometry, 0);
+                                                       gpoint.y = OGR_G_GetY (poGeometry, 0);
+
+                                                       geometry = gtk_gis_geometry_point_new (gpoint);
+                                               }
+                                       else if (poGeometry != NULL
+                                               && wkbFlatten(OGR_G_GetGeometryType (poGeometry)) == wkbLineString)
+                                               {
+                                                       gint points;
+                                                       gint point;
+                                                       GPtrArray *gar_points;
+
+                                                       GtkGisPoint *gpoint;
+
+                                                       gar_points = g_ptr_array_new ();
+
+                                                       points = OGR_G_GetPointCount (poGeometry);
+
+                                                       for (point = 0; point < points; point++)
+                                                               {
+                                                                       gpoint = g_malloc0 (sizeof (GtkGisPoint));
+
+                                                                       gpoint->x = OGR_G_GetX (poGeometry, point);
+                                                                       gpoint->y = OGR_G_GetY (poGeometry, point);
+
+                                                                       g_ptr_array_add (gar_points, gpoint);
+                                                               }
+
+                                                       geometry = gtk_gis_geometry_line_new_from_array (gar_points);
+                                               }
+                                       else if (poGeometry != NULL
+                                               && wkbFlatten(OGR_G_GetGeometryType (poGeometry)) == wkbPolygon)
+                                               {
+                                                       gint num_geometries;
+                                                       gint i_geometry;
+
+                                                       OGRGeometryH poGeometryIns;
+
+                                                       num_geometries = OGR_G_GetGeometryCount (poGeometry);
+
+                                                       for (i_geometry = 0; i_geometry < num_geometries; i_geometry++)
+                                                               {
+
+                                                                       gint points;
+                                                                       gint point;
+                                                                       GPtrArray *gar_points;
+
+                                                                       GtkGisPoint *gpoint;
+
+                                                                       poGeometryIns = OGR_G_GetGeometryRef (poGeometry, i_geometry);
+
+                                                                       gar_points = g_ptr_array_new ();
+
+                                                                       points = OGR_G_GetPointCount (poGeometry);
+
+                                                                       for (point = 0; point < points; point++)
+                                                                               {
+                                                                                       gpoint = g_malloc0 (sizeof (GtkGisPoint));
+
+                                                                                       gpoint->x = OGR_G_GetX (poGeometry, point);
+                                                                                       gpoint->y = OGR_G_GetY (poGeometry, point);
+
+                                                                                       g_ptr_array_add (gar_points, gpoint);
+                                                                               }
+
+                                                                       geometry = gtk_gis_geometry_polygon_new_from_array (gar_points);
+                                                               }
+                                               }
+
+                                       geometries = g_list_append (geometries, geometry);
+                               }
                }
 
        return geometries;
@@ -119,24 +211,79 @@ GList
  */
 GtkGisLayerGeometryType
 gtk_gis_layer_source_get_layer_geometry_type (GtkGisLayerSource *source,
-                                              gchar *name)
+                                              const gchar *name)
 {
        GtkGisLayerGeometryType type = -1;
 
-       if (IS_GTK_GIS_LAYER_SOURCE_OBJECT (source) && GTK_GIS_LAYER_SOURCE_GET_CLASS (source)->get_layer_geometry_type != NULL)
+       OGRLayerH layer;
+       OGRFeatureH feature;
+
+       GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
+
+       layer = OGR_DS_GetLayerByName (priv->datasource, name);
+
+       feature = OGR_L_GetNextFeature (layer);
+
+       if (feature != NULL)
                {
-                       type = GTK_GIS_LAYER_SOURCE_GET_CLASS (source)->get_layer_geometry_type (source, name);
+                       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;
+                               }
                }
 
        return type;
 }
 
+/**
+ * gtk_gis_layer_source_get_layer_extent:
+ * @source:
+ * @name:
+ *
+ * Returns:
+ */
+GtkGisLayerExtent
+gtk_gis_layer_source_get_layer_extent (GtkGisLayerSource *source,
+                                       const gchar *name)
+{
+       OGRLayerH layer;
+       OGREnvelope psExtent;
+       GtkGisLayerExtent extent;
+
+       GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
+
+       layer = OGR_DS_GetLayerByName (priv->datasource, name);
+
+       OGR_L_GetExtent (layer, &psExtent, 1);
+
+       extent.min_x = psExtent.MinX;
+       extent.min_y = psExtent.MinY;
+       extent.max_x = psExtent.MaxX;
+       extent.max_y = psExtent.MaxY;
+
+       return extent;
+}
+
 static void
 gtk_gis_layer_source_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
-       GtkGisLayerSource *gtk_gis_layer_source = GTK_GIS_LAYER_SOURCE (object);
+       GtkGisLayerSource *source = GTK_GIS_LAYER_SOURCE (object);
 
-       GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (gtk_gis_layer_source);
+       GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
 
        switch (property_id)
                {
@@ -149,9 +296,9 @@ gtk_gis_layer_source_set_property (GObject *object, guint property_id, const GVa
 static void
 gtk_gis_layer_source_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
 {
-       GtkGisLayerSource *gtk_gis_layer_source = GTK_GIS_LAYER_SOURCE (object);
+       GtkGisLayerSource *source = GTK_GIS_LAYER_SOURCE (object);
 
-       GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (gtk_gis_layer_source);
+       GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
 
        switch (property_id)
                {
index 7c91002462e7f31931bcc5f0e65ef5cafe774ef6..5a72e54712fd6267e4adab620811e96138223df1 100644 (file)
@@ -23,6 +23,9 @@
 #include <glib.h>
 #include <glib-object.h>
 
+#include <ogr_api.h>
+#include <ogr_core.h>
+
 #include "geometry.h"
 
 G_BEGIN_DECLS
@@ -37,12 +40,20 @@ G_BEGIN_DECLS
 
 
 typedef enum
-{
-       LAYER_GEOMETRY_TYPE_POINT,
-       LAYER_GEOMETRY_TYPE_LINE,
-       LAYER_GEOMETRY_TYPE_POLYGON,
-       LAYER_GEOMETRY_TYPE_RASTER
-} GtkGisLayerGeometryType;
+       {
+               LAYER_GEOMETRY_TYPE_POINT,
+               LAYER_GEOMETRY_TYPE_LINE,
+               LAYER_GEOMETRY_TYPE_POLYGON,
+               LAYER_GEOMETRY_TYPE_RASTER
+       } GtkGisLayerGeometryType;
+
+typedef struct
+       {
+               gdouble min_x;
+               gdouble min_y;
+               gdouble max_x;
+               gdouble max_y;
+       } GtkGisLayerExtent;
 
 
 typedef struct _GtkGisLayerSource GtkGisLayerSource;
@@ -57,10 +68,8 @@ struct _GtkGisLayerSourceClass
        {
                GObjectClass parent_class;
 
-               GList *(*get_geometries) (GtkGisLayerSource *source, const gchar *name);
-
-               GtkGisLayerGeometryType (*get_layer_geometry_type) (GtkGisLayerSource *source,
-                                                                   gchar *name);
+               void (*set_ogr_datasource) (GtkGisLayerSource *source,
+                                           OGRDataSourceH datasource);
        };
 
 GType gtk_gis_layer_source_get_type (void) G_GNUC_CONST;
@@ -70,7 +79,10 @@ GList *gtk_gis_layer_source_get_geometries (GtkGisLayerSource *source,
                                             const gchar *name);
 
 GtkGisLayerGeometryType gtk_gis_layer_source_get_layer_geometry_type (GtkGisLayerSource *source,
-                                                                      gchar *name);
+                                                                      const gchar *name);
+
+GtkGisLayerExtent gtk_gis_layer_source_get_layer_extent (GtkGisLayerSource *source,
+                                                         const gchar *name);
 
 
 G_END_DECLS
index b6afb77d8bfcfe8026f33e026e551efe4ff57e37..b0ce11301ab44175b64a125a8bc56dc5cd612ac6 100644 (file)
@@ -67,7 +67,7 @@ gtk_gis_layer_source_postgis_get_type (void)
                                NULL
                        };
 
-                       gtk_gis_layer_source_postgis_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisLayerSourcePostgis",
+                       gtk_gis_layer_source_postgis_type = g_type_register_static (TYPE_GTK_GIS_LAYER_SOURCE, "GtkGisLayerSourcePostgis",
                                                                  &gtk_gis_layer_source_postgis_info, 0);
                }
 
@@ -102,33 +102,33 @@ gtk_gis_layer_source_postgis_init (GtkGisLayerSourcePostgis *gtk_gis_layer_sourc
  *
  * Returns: the newly created #GtkGisLayerSourcePostgis object.
  */
-GtkGisLayerSourcePostgis
+GtkGisLayerSource
 *gtk_gis_layer_source_postgis_new (gchar *host,
                                    gint port,
                                    gchar *username,
                                    gchar *password)
 {
-       GtkGisLayerSourcePostgis *gtk_gis_layer_source_postgis;
+       GtkGisLayerSource *source;
        GtkGisLayerSourcePostgisPrivate *priv;
 
-       gtk_gis_layer_source_postgis = GTK_GIS_LAYER_SOURCE_POSTGIS (g_object_new (gtk_gis_layer_source_postgis_get_type (), NULL));
+       source = g_object_new (gtk_gis_layer_source_postgis_get_type (), NULL);
 
-       priv = GTK_GIS_LAYER_SOURCE_POSTGIS_GET_PRIVATE (gtk_gis_layer_source_postgis);
+       priv = GTK_GIS_LAYER_SOURCE_POSTGIS_GET_PRIVATE (GTK_GIS_LAYER_SOURCE_POSTGIS (source));
 
        priv->host = g_strdup (host == NULL ? "localhost" : host);
        priv->port = (port == 0 ? 5432 : port);
        priv->username = g_strdup (username == NULL ? "" : username);
        priv->password = g_strdup (password == NULL ? "" : password);
 
-       return gtk_gis_layer_source_postgis;
+       return source;
 }
 
 static void
 gtk_gis_layer_source_postgis_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
-       GtkGisLayerSourcePostgis *gtk_gis_layer_source_postgis = GTK_GIS_LAYER_SOURCE_POSTGIS (object);
+       GtkGisLayerSourcePostgis *source = GTK_GIS_LAYER_SOURCE_POSTGIS (object);
 
-       GtkGisLayerSourcePostgisPrivate *priv = GTK_GIS_LAYER_SOURCE_POSTGIS_GET_PRIVATE (gtk_gis_layer_source_postgis);
+       GtkGisLayerSourcePostgisPrivate *priv = GTK_GIS_LAYER_SOURCE_POSTGIS_GET_PRIVATE (source);
 
        switch (property_id)
                {
@@ -141,9 +141,9 @@ gtk_gis_layer_source_postgis_set_property (GObject *object, guint property_id, c
 static void
 gtk_gis_layer_source_postgis_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
 {
-       GtkGisLayerSourcePostgis *gtk_gis_layer_source_postgis = GTK_GIS_LAYER_SOURCE_POSTGIS (object);
+       GtkGisLayerSourcePostgis *source = GTK_GIS_LAYER_SOURCE_POSTGIS (object);
 
-       GtkGisLayerSourcePostgisPrivate *priv = GTK_GIS_LAYER_SOURCE_POSTGIS_GET_PRIVATE (gtk_gis_layer_source_postgis);
+       GtkGisLayerSourcePostgisPrivate *priv = GTK_GIS_LAYER_SOURCE_POSTGIS_GET_PRIVATE (source);
 
        switch (property_id)
                {
index a9bd32b4a015fbf69fb5a7f906d486a194518637..ccba260ce73f9d0b53543deb2a6fb4427435b6ee 100644 (file)
@@ -49,10 +49,10 @@ struct _GtkGisLayerSourcePostgisClass
 GType gtk_gis_layer_source_postgis_get_type (void) G_GNUC_CONST;
 
 
-GtkGisLayerSourcePostgis *gtk_gis_layer_source_postgis_new (gchar *host,
-                                                            gint port,
-                                                            gchar *username,
-                                                            gchar *password);
+GtkGisLayerSource *gtk_gis_layer_source_postgis_new (gchar *host,
+                                                     gint port,
+                                                     gchar *username,
+                                                     gchar *password);
 
 
 G_END_DECLS
index e51ecdd49ae9a7a91db737b8be789266d5b1596f..5132a51488da463e7a769bbf5fe64e698212424f 100644 (file)
 #include <ogr_core.h>
 
 #include "layersourceshp.h"
-#include "geometryline.h"
-#include "geometrypoint.h"
-#include "geometrypolygon.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);
 
-static OGRDataSourceH gtk_gis_layer_source_get_ogr_datasource (GtkGisLayerSource *source);
+static void
+gtk_gis_layer_source_shp_set_ogr_datasource (GtkGisLayerSource *source,
+                                             OGRDataSourceH datasource);
 
 static void gtk_gis_layer_source_shp_set_property (GObject *object,
                                      guint property_id,
@@ -49,8 +48,6 @@ typedef struct _GtkGisLayerSourceShpPrivate GtkGisLayerSourceShpPrivate;
 struct _GtkGisLayerSourceShpPrivate
        {
                gchar *filename;
-
-               OGRDataSourceH datasource;
        };
 
 GType
@@ -74,7 +71,7 @@ gtk_gis_layer_source_shp_get_type (void)
                                NULL
                        };
 
-                       gtk_gis_layer_source_shp_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisLayerSourceShp",
+                       gtk_gis_layer_source_shp_type = g_type_register_static (TYPE_GTK_GIS_LAYER_SOURCE, "GtkGisLayerSourceShp",
                                                                  &gtk_gis_layer_source_shp_info, 0);
                }
 
@@ -91,9 +88,6 @@ gtk_gis_layer_source_shp_class_init (GtkGisLayerSourceShpClass *klass)
 
        object_class->set_property = gtk_gis_layer_source_shp_set_property;
        object_class->get_property = gtk_gis_layer_source_shp_get_property;
-
-       gtkgislayersource_class->get_geometries = gtk_gis_layer_source_shp_get_geometries;
-       gtkgislayersource_class->get_layer_geometry_type = gtk_gis_layer_source_shp_get_layer_geometry_type;
 }
 
 static void
@@ -110,14 +104,15 @@ gtk_gis_layer_source_shp_init (GtkGisLayerSourceShp *gtk_gis_layer_source_shp)
  *
  * Returns: the newly created #GtkGisLayerSourceShp object.
  */
-GtkGisLayerSourceShp
-*gtk_gis_layer_source_shp_new (gchar *filename)
+GtkGisLayerSource
+*gtk_gis_layer_source_shp_new (const gchar *filename)
 {
-       GtkGisLayerSourceShp *gtk_gis_layer_source_shp;
+       GtkGisLayerSource *source;
+       GtkGisLayerSourceShpPrivate *priv;
 
-       gtk_gis_layer_source_shp = GTK_GIS_LAYER_SOURCE_SHP (g_object_new (gtk_gis_layer_source_shp_get_type (), NULL));
+       source = g_object_new (gtk_gis_layer_source_shp_get_type (), NULL);
 
-       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (gtk_gis_layer_source_shp);
+       priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (GTK_GIS_LAYER_SOURCE_SHP (source));
 
        priv->filename = g_strdup (filename);
 
@@ -125,9 +120,10 @@ GtkGisLayerSourceShp
        OGRRegisterAll ();
 
        /* Open data source */
-       priv->datasource = OGROpen (priv->filename, 0 /* bUpdate */, NULL);
+       gtk_gis_layer_source_shp_set_ogr_datasource (source,
+                                                    OGROpen (priv->filename, 0 /* bUpdate */, NULL));
 
-       return gtk_gis_layer_source_shp;
+       return source;
 }
 
 /**
@@ -144,144 +140,22 @@ gchar
        return g_strdup (priv->filename);
 }
 
-/**
- * gtk_gis_layer_source_shp_get_geometries:
- * @source:
- * @name:
- *
- * Loads the #GtkGisLayerSource from the disk.
- *
- * Returns: .
- */
-GList
-*gtk_gis_layer_source_shp_get_geometries (GtkGisLayerSource *source,
-                                          const gchar *name)
+static void
+gtk_gis_layer_source_shp_set_ogr_datasource (GtkGisLayerSource *source,
+                                             OGRDataSourceH datasource)
 {
-       GList *geometries = NULL;
-
-       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (source);
-
-    if (priv->datasource == NULL)
-           {
-                       /* TO DO */
-               }
-       else
+       if (IS_GTK_GIS_LAYER_SOURCE (source) && GTK_GIS_LAYER_SOURCE_GET_CLASS (source)->set_ogr_datasource != NULL)
                {
-                       gint numLayers;
-                       gint i;
-
-                       OGRLayerH layer;
-                       OGRFeatureDefnH layerDefn;
-
-                       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (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 (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)
-                                                                               {
-                                                                               }
-
-                                                                       geometries = g_list_append (geometries, geometry);
-                                                               }
-
-                                                       break;
-                                               }
-                               }
-               }
-
-       return geometries;
-}
-
-/**
- * gtk_gis_layer_source_shp_get_layer_geometry_type:
- * @source:
- * @name:
- *
- * Returns: a #GtkGisLayerGeometryType or -1 on error.
- */
-GtkGisLayerGeometryType
-gtk_gis_layer_source_shp_get_layer_geometry_type (GtkGisLayerSource *source,
-                                                  gchar *name)
-{
-       GtkGisLayerGeometryType type = -1;
-       gint numLayers;
-       gint i;
-
-    OGRLayerH layer;
-    OGRFeatureDefnH layerDefn;
-
-       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (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;
-
-                                       feature = OGR_L_GetNextFeature (layer);
-
-                                       if (feature != NULL)
-                                               {
-                                                       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;
-                                                               }
-                                               }
-
-                                       break;
-                               }
+                       GTK_GIS_LAYER_SOURCE_GET_CLASS (source)->set_ogr_datasource (source, datasource);
                }
-
-       return type;
 }
 
 static void
 gtk_gis_layer_source_shp_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
-       GtkGisLayerSourceShp *gtk_gis_layer_source_shp = GTK_GIS_LAYER_SOURCE_SHP (object);
+       GtkGisLayerSourceShp *source = GTK_GIS_LAYER_SOURCE_SHP (object);
 
-       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (gtk_gis_layer_source_shp);
+       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (source);
 
        switch (property_id)
                {
@@ -294,9 +168,9 @@ gtk_gis_layer_source_shp_set_property (GObject *object, guint property_id, const
 static void
 gtk_gis_layer_source_shp_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
 {
-       GtkGisLayerSourceShp *gtk_gis_layer_source_shp = GTK_GIS_LAYER_SOURCE_SHP (object);
+       GtkGisLayerSourceShp *source = GTK_GIS_LAYER_SOURCE_SHP (object);
 
-       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (gtk_gis_layer_source_shp);
+       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (source);
 
        switch (property_id)
                {
index fba66294386d1aa6dc8fdd2c59eddab73801ace4..efe82e76e66f5e6fc031c5f898bb5eb9b0cb6517 100644 (file)
@@ -49,15 +49,10 @@ struct _GtkGisLayerSourceShpClass
 GType gtk_gis_layer_source_shp_get_type (void) G_GNUC_CONST;
 
 
-GtkGisLayerSourceShp *gtk_gis_layer_source_shp_new (gchar *filename);
+GtkGisLayerSource *gtk_gis_layer_source_shp_new (const gchar *filename);
 
 gchar *gtk_gis_layer_get_filename (GtkGisLayerSourceShp *source);
 
-GList *gtk_gis_layer_source_shp_get_geometries (GtkGisLayerSource *source, const gchar *name);
-
-GtkGisLayerGeometryType gtk_gis_layer_source_shp_get_layer_geometry_type (GtkGisLayerSource *source,
-                                                                          gchar *name);
-
 
 G_END_DECLS
 
index a6fb6c560c2102ec7447d19f9ba9a31fafb8d58a..1a40d6aa5bc24e2426fe26205fa421d80f70187c 100644 (file)
@@ -1,14 +1,16 @@
 SUBDIRS = samples
 
-LIBS = $(GTKGIS_LIBS)
+LIBS = $(GTKGIS_LIBS) \
+       $(GDAL_LIBS)
 
 AM_CPPFLAGS = $(GTKGIS_CFLAGS) \
+              $(GDAL_CFLAGS) \
               -I$(top_srcdir)/src
 
 libgtkgis = $(top_builddir)/src/libgtkgis.la
 
-noinst_PROGRAMS = from_xml
+LDADD = $(libgtkgis)
 
-LDADD = $(libgtgkis)
+noinst_PROGRAMS = from_xml
 
 EXTRA_DIST = test1.gtkgis
index f7107fc21be5ad0c4632ce54166168d1cad57fbb..afa64c73ea10237e346b322eefb5196645191dac 100644 (file)
@@ -3,5 +3,24 @@
 int
 main (int argc, char *argv[])
 {
+       GtkWidget *window;
+       GtkWidget *gtkgis;
+
+       gtk_init (&argc, &argv);
+
+       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+       gtk_window_set_default_size (GTK_WINDOW (window), 640, 600);
+
+    g_signal_connect (window, "delete_event", (GtkSignalFunc) gtk_main_quit,
+                      NULL);
+
+       gtkgis = gtk_gis_new_from_file (argv[1]);
+
+    gtk_container_add (GTK_CONTAINER (window), gtkgis);
+
+       gtk_widget_show_all (window);
+
+       gtk_main ();
+
        return 0;
 }
index 9fd53c6db5d06b28278cb073b76a70c6f0c33b4a..bf96191aaca97617f73d274dc19df96508c2c39c 100644 (file)
@@ -2,26 +2,26 @@
 
        <layer name="alaska">
                <source>
-                       <shape filename="samples\alaska.shp" />
+                       <shape filename="/home/andreaz/files/c/libgtkgis/tests/samples/alaska.shp" />
                </source>
        </layer>
 
-       <layer name="airports">
+       <!--<layer name="airports">
                <source>
-                       <shape filename="samples\airports.shp" />
+                       <shape filename="samples/airports.shp" />
                </source>
        </layer>
 
        <layer name="railroads">
                <source>
-                       <shape filename="samples\railroads.shp" />
+                       <shape filename="samples/railroads.shp" />
                </source>
        </layer>
 
        <layer name="rivers">
                <source>
-                       <shape filename="samples\rivers.shp" />
+                       <shape filename="samples/rivers.shp" />
                </source>
-       </layer>
+       </layer>-->
 
 </gtkgis>