]> saetta.ns0.it Git - libgtkgis/commitdiff
Continued base classes: now it compiles
authorAndrea Zagli <azagli@libero.it>
Wed, 24 Jun 2009 20:34:48 +0000 (22:34 +0200)
committerAndrea Zagli <azagli@libero.it>
Wed, 24 Jun 2009 20:34:48 +0000 (22:34 +0200)
16 files changed:
.gitignore
src/geometryline.c
src/geometrypoint.c
src/geometrypolygon.h
src/gtkgis.c
src/gtkgis.h
src/layer.c
src/layer.h
src/layersgroup.c
src/layersgroup.h
src/layersource.c
src/layersource.h
src/layersourcepostgis.c
src/layersourceshp.c
src/layersourceshp.h
tests/from_xml.c

index 1fc33800ea9f2f50f77a4e7ba4c9210301f7ebd6..095b9a409fe70863f0061066543cd463381d2c07 100644 (file)
@@ -27,6 +27,7 @@ src/.deps/
 src/.libs/
 stamp-h1
 tests/.deps
+tests/from_xml
 
 # temporarily
 TODO.tasks
index eaa91d79ec06ee31d57f4f0c64ba2dd7e9e0c103..3cc42a207c50f8b9bc1ba00fcf4f47f90c527523 100644 (file)
@@ -143,7 +143,7 @@ GtkGisGeometryLine
 void
 gtk_gis_geomtry_line_add_point (GtkGisGeometryLine *line, GtkGisGeometryPoint *point)
 {
-       GtkGisGeometryLinePrivate *priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (gtk_gis_geometry_line);
+       GtkGisGeometryLinePrivate *priv = GTK_GIS_GEOMETRY_LINE_GET_PRIVATE (line);
 
        g_ptr_array_add (priv->points, point);
 }
index ad18bb4e61dd85c4eb510e30b27637574b03aa50..f9b9611bfa5ce60bad93d19d8d6b621b37a2b0e9 100644 (file)
@@ -122,7 +122,7 @@ GtkGisGeometryPoint
 gdouble
 gtk_gis_geometry_get_x (GtkGisGeometryPoint *point)
 {
-       GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (gtk_gis_geometry_point);
+       GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (point);
 
        return priv->x;
 }
@@ -130,7 +130,7 @@ gtk_gis_geometry_get_x (GtkGisGeometryPoint *point)
 gdouble
 gtk_gis_geometry_get_y (GtkGisGeometryPoint *point)
 {
-       GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (gtk_gis_geometry_point);
+       GtkGisGeometryPointPrivate *priv = GTK_GIS_GEOMETRY_POINT_GET_PRIVATE (point);
 
        return priv->y;
 }
index 97e9a9da02dfedcfcefb870dc93c0d14be84cfc2..2309170fa05b8123ddfa7b710ed49c3248731946 100644 (file)
@@ -43,7 +43,7 @@ struct _GtkGisGeometryPolygon
 
 struct _GtkGisGeometryPolygonClass
        {
-               GtkGisGeometryClassLine parent_class;
+               GtkGisGeometryLineClass parent_class;
        };
 
 GType gtk_gis_geometry_polygon_get_type (void) G_GNUC_CONST;
index c2ef0092d55c884fff85c6609e8965b43eb95afd..cc0f8421cc6e4de2a2933629b0cd7979bfb55b04 100644 (file)
@@ -183,7 +183,7 @@ GtkGis
                                                                                                                        filename = xmlGetProp (cur, (const xmlChar *)"filename");
                                                                                                                        if (filename != NULL)
                                                                                                                                {
-                                                                                                                                       layer_source = gtk_gis_layer_source_shp_new (filename);
+                                                                                                                                       layer_source = GTK_GIS_LAYER_SOURCE (gtk_gis_layer_source_shp_new (filename));
                                                                                                                                }
                                                                                                                }
                                                                                                        else if (xmlStrcmp (cur->name, "postgis") == 0)
index a45abf9074c7c1aa81d6f5aafed9359e48484e5a..bc1a1f16207708d181ceb41ac6fff9c935a8f0e7 100644 (file)
@@ -56,7 +56,7 @@ GType gtk_gis_get_type (void) G_GNUC_CONST;
 GtkGis *gtk_gis_new (void);
 
 GtkGis *gtk_gis_new_from_xml (xmlDoc *xdoc);
-GtkGis *gtk_gis_new_from_file (gchar *filename);
+GtkGis *gtk_gis_new_from_file (const gchar *filename);
 
 void *gtk_gis_save_to_xml (GtkGis *gtkgis, const gchar *filename);
 
index 3634bf0da6bd8925da318d257c7e88a02e598103..c7bc950497f30bdecf532455b9e042803700663e 100644 (file)
@@ -121,7 +121,7 @@ GtkGisLayer
 
        gtk_gis_layer = GTK_GIS_LAYER (g_object_new (gtk_gis_layer_get_type (), NULL));
 
-       priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
+       priv = GTK_GIS_LAYER_GET_PRIVATE (gtk_gis_layer);
 
        priv->source = source;
        priv->name = g_strdup (name);
@@ -276,13 +276,13 @@ gtk_gis_layer_set_editable (GtkGisLayer *layer,
  *
  */
 void
-gtk_gis_layer_draw (GtkGisLayer *layer
+gtk_gis_layer_draw (GtkGisLayer *layer,
                     GooCanvasItem *canvas_root)
 {
-       if (IS_GTK_GIS_LAYER_OBJECT (layer) && GTK_GIS_LAYER_GET_CLASS (layer)->draw != NULL)
+       /*if (IS_GTK_GIS_LAYER_OBJECT (layer) && GTK_GIS_LAYER_GET_CLASS (layer)->draw != NULL)
                {
                        GTK_GIS_LAYER_GET_CLASS (layer)->draw (layer, canvas_root);
-               }
+               }*/
 }
 
 static void
index a00a71e755660165020070e322b7815913dc4977..b39d6c882c95b81ff8bb79290351689f2c43a5c5 100644 (file)
@@ -55,14 +55,6 @@ struct _GtkGisLayerClass
 GType gtk_gis_layer_get_type (void) G_GNUC_CONST;
 
 
-typedef enum
-{
-       LAYER_GEOMETRY_TYPE_POINT,
-       LAYER_GEOMETRY_TYPE_LINE,
-       LAYER_GEOMETRY_TYPE_POLYGON,
-       LAYER_GEOMETRY_TYPE_RASTER
-} GtkGisLayerGeometryType;
-
 GtkGisLayer *gtk_gis_layer_new (GtkGisLayerSource *source,
                                 gchar *name,
                                 GtkGisLayerGeometryType geometry_type);
index 389f28c912890427ba49a0368f1479bd72dc843b..024540dcfc6579f5a57c6ecc8d23c434ebf0fab8 100644 (file)
@@ -110,7 +110,7 @@ GtkGisLayersGroup
 
        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 = GTK_GIS_LAYERS_GROUP_GET_PRIVATE (gtk_gis_layers_group);
 
        priv->name = g_strdup (name);
 
index beb141df96584b0b0b5644dd19c3c2fe284274e1..2c213d0df9ec55cd7e2a21b925b014a318a71489 100644 (file)
@@ -59,7 +59,7 @@ void gtk_gis_layers_group_add_layer (GtkGisLayersGroup *layers_group,
 void gtk_gis_layers_group_remove_layer (GtkGisLayersGroup *layers_group,
                                         GtkGisLayer *layer);
 
-const gchar *gtk_gis_layers_group_get_name (GtkGisLayersGroup *layers_group);
+gchar *gtk_gis_layers_group_get_name (GtkGisLayersGroup *layers_group);
 void gtk_gis_layers_group_set_name (GtkGisLayersGroup *layers_group,
                                     const gchar *name);
 
index 3c7222bbb59a811eb0d23329947e804da6721c50..571d2693ceffecf4518936666d4505d39cd51ff5 100644 (file)
@@ -92,23 +92,22 @@ gtk_gis_layer_source_init (GtkGisLayerSource *gtk_gis_layer_source)
 }
 
 /**
- * gtk_gis_layer_source_fill_layer:
+ * gtk_gis_layer_source_get_geometries:
  * @source:
- * @layer:
  *
  */
-gboolean
-gtk_gis_layer_source_fill_layer (GtkGisLayerSource *source,
-                                 GtkGisLayer *layer)
+GList
+*gtk_gis_layer_source_get_geometries (GtkGisLayerSource *source,
+                                      const gchar *name)
 {
-       gboolean ret = FALSE;
+       GList *geometries;
 
-       if (IS_GTK_GIS_LAYER_SOURCE_OBJECT (source) && GTK_GIS_LAYER_SOURCE_GET_CLASS (source)->load != NULL)
+       if (IS_GTK_GIS_LAYER_SOURCE_OBJECT (source) && GTK_GIS_LAYER_SOURCE_GET_CLASS (source)->get_geometries != NULL)
                {
-                       ret = GTK_GIS_LAYER_SOURCE_GET_CLASS (source)->fill_layer (source, layer);
+                       geometries = GTK_GIS_LAYER_SOURCE_GET_CLASS (source)->get_geometries (source, name);
                }
 
-       return ret;
+       return geometries;
 }
 
 /**
index 480ffc072dc4244f42f53b2b372c782705f6280d..7c91002462e7f31931bcc5f0e65ef5cafe774ef6 100644 (file)
@@ -23,7 +23,7 @@
 #include <glib.h>
 #include <glib-object.h>
 
-#include "layer.h"
+#include "geometry.h"
 
 G_BEGIN_DECLS
 
@@ -36,6 +36,15 @@ G_BEGIN_DECLS
 #define GTK_GIS_LAYER_SOURCE_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_GIS_LAYER_SOURCE, GtkGisLayerSourceClass))
 
 
+typedef enum
+{
+       LAYER_GEOMETRY_TYPE_POINT,
+       LAYER_GEOMETRY_TYPE_LINE,
+       LAYER_GEOMETRY_TYPE_POLYGON,
+       LAYER_GEOMETRY_TYPE_RASTER
+} GtkGisLayerGeometryType;
+
+
 typedef struct _GtkGisLayerSource GtkGisLayerSource;
 typedef struct _GtkGisLayerSourceClass GtkGisLayerSourceClass;
 
@@ -48,8 +57,7 @@ struct _GtkGisLayerSourceClass
        {
                GObjectClass parent_class;
 
-               gboolean (*fill_layer) (GtkGisLayerSource *source,
-                                       GtkGisLayer *layer);
+               GList *(*get_geometries) (GtkGisLayerSource *source, const gchar *name);
 
                GtkGisLayerGeometryType (*get_layer_geometry_type) (GtkGisLayerSource *source,
                                                                    gchar *name);
@@ -58,8 +66,8 @@ struct _GtkGisLayerSourceClass
 GType gtk_gis_layer_source_get_type (void) G_GNUC_CONST;
 
 
-gboolean gtk_gis_layer_source_fill_layer (GtkGisLayerSource *source,
-                                          GtkGisLayer *layer);
+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);
index 6ec132665cd3e130674ba5f828858ed7c067094f..b6afb77d8bfcfe8026f33e026e551efe4ff57e37 100644 (file)
@@ -40,6 +40,10 @@ static void gtk_gis_layer_source_postgis_get_property (GObject *object,
 typedef struct _GtkGisLayerSourcePostgisPrivate GtkGisLayerSourcePostgisPrivate;
 struct _GtkGisLayerSourcePostgisPrivate
        {
+               gchar *host;
+               gint port;
+               gchar *username;
+               gchar *password;
        };
 
 GType
index 3b718cf83a5875146296f4ce979cf1753553c9af..e51ecdd49ae9a7a91db737b8be789266d5b1596f 100644 (file)
@@ -24,9 +24,9 @@
 #include <ogr_core.h>
 
 #include "layersourceshp.h"
-#include "geomtryline.h"
-#include "geomtrypoint.h"
-#include "geomtrypolygon.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);
@@ -92,7 +92,7 @@ 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->fill_layer = gtk_gis_layer_source_shp_fill_layer;
+       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;
 }
 
@@ -145,26 +145,25 @@ gchar
 }
 
 /**
- * gtk_gis_layer_source_shp_fill_layer:
+ * gtk_gis_layer_source_shp_get_geometries:
  * @source:
- * @layer:
+ * @name:
  *
  * Loads the #GtkGisLayerSource from the disk.
  *
- * Returns: FALSE on error.
+ * Returns: .
  */
-gboolean
-gtk_gis_layer_source_shp_fill_layer (GtkGisLayerSource *source,
-                                     GtkGisLayer *layer)
+GList
+*gtk_gis_layer_source_shp_get_geometries (GtkGisLayerSource *source,
+                                          const gchar *name)
 {
-       gboolean ret = TRUE;
+       GList *geometries = NULL;
 
-       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (gtk_gis_layer_source);
+       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (source);
 
     if (priv->datasource == NULL)
            {
                        /* TO DO */
-                       ret = FALSE;
                }
        else
                {
@@ -174,9 +173,7 @@ gtk_gis_layer_source_shp_fill_layer (GtkGisLayerSource *source,
                        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);
+                       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (source);
 
                        numLayers = OGR_DS_GetLayerCount (priv->datasource);
                        for (i = 0; i < numLayers; i++)
@@ -196,7 +193,7 @@ gtk_gis_layer_source_shp_fill_layer (GtkGisLayerSource *source,
                                                                        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));
+                                                                                       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)
@@ -206,6 +203,8 @@ gtk_gis_layer_source_shp_fill_layer (GtkGisLayerSource *source,
                                                                                && wkbFlatten(OGR_G_GetGeometryType (poGeometry)) == wkbPolygon)
                                                                                {
                                                                                }
+
+                                                                       geometries = g_list_append (geometries, geometry);
                                                                }
 
                                                        break;
@@ -213,7 +212,7 @@ gtk_gis_layer_source_shp_fill_layer (GtkGisLayerSource *source,
                                }
                }
 
-       return ret;
+       return geometries;
 }
 
 /**
@@ -234,7 +233,7 @@ gtk_gis_layer_source_shp_get_layer_geometry_type (GtkGisLayerSource *source,
     OGRLayerH layer;
     OGRFeatureDefnH layerDefn;
 
-       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (gtk_gis_layer_source);
+       GtkGisLayerSourceShpPrivate *priv = GTK_GIS_LAYER_SOURCE_SHP_GET_PRIVATE (source);
 
     numLayers = OGR_DS_GetLayerCount (priv->datasource);
     for (i = 0; i < numLayers; i++)
index 19fed238e8955133f4893298c2e4ff3d463f5a7d..fba66294386d1aa6dc8fdd2c59eddab73801ace4 100644 (file)
@@ -53,6 +53,11 @@ GtkGisLayerSourceShp *gtk_gis_layer_source_shp_new (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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f7107fc21be5ad0c4632ce54166168d1cad57fbb 100644 (file)
@@ -0,0 +1,7 @@
+#include <libgtkgis.h>
+
+int
+main (int argc, char *argv[])
+{
+       return 0;
+}