From: Andrea Zagli Date: Wed, 24 Jun 2009 20:34:48 +0000 (+0200) Subject: Continued base classes: now it compiles X-Git-Tag: GTKGIS_0_0_1~9 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=bcf6fe9c4f146fb94be9646001ae5e15e8251162;p=libgtkgis Continued base classes: now it compiles --- diff --git a/.gitignore b/.gitignore index 1fc3380..095b9a4 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ src/.deps/ src/.libs/ stamp-h1 tests/.deps +tests/from_xml # temporarily TODO.tasks diff --git a/src/geometryline.c b/src/geometryline.c index eaa91d7..3cc42a2 100644 --- a/src/geometryline.c +++ b/src/geometryline.c @@ -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); } diff --git a/src/geometrypoint.c b/src/geometrypoint.c index ad18bb4..f9b9611 100644 --- a/src/geometrypoint.c +++ b/src/geometrypoint.c @@ -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; } diff --git a/src/geometrypolygon.h b/src/geometrypolygon.h index 97e9a9d..2309170 100644 --- a/src/geometrypolygon.h +++ b/src/geometrypolygon.h @@ -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; diff --git a/src/gtkgis.c b/src/gtkgis.c index c2ef009..cc0f842 100644 --- a/src/gtkgis.c +++ b/src/gtkgis.c @@ -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) diff --git a/src/gtkgis.h b/src/gtkgis.h index a45abf9..bc1a1f1 100644 --- a/src/gtkgis.h +++ b/src/gtkgis.h @@ -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); diff --git a/src/layer.c b/src/layer.c index 3634bf0..c7bc950 100644 --- a/src/layer.c +++ b/src/layer.c @@ -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 diff --git a/src/layer.h b/src/layer.h index a00a71e..b39d6c8 100644 --- a/src/layer.h +++ b/src/layer.h @@ -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); diff --git a/src/layersgroup.c b/src/layersgroup.c index 389f28c..024540d 100644 --- a/src/layersgroup.c +++ b/src/layersgroup.c @@ -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); diff --git a/src/layersgroup.h b/src/layersgroup.h index beb141d..2c213d0 100644 --- a/src/layersgroup.h +++ b/src/layersgroup.h @@ -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); diff --git a/src/layersource.c b/src/layersource.c index 3c7222b..571d269 100644 --- a/src/layersource.c +++ b/src/layersource.c @@ -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; } /** diff --git a/src/layersource.h b/src/layersource.h index 480ffc0..7c91002 100644 --- a/src/layersource.h +++ b/src/layersource.h @@ -23,7 +23,7 @@ #include #include -#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); diff --git a/src/layersourcepostgis.c b/src/layersourcepostgis.c index 6ec1326..b6afb77 100644 --- a/src/layersourcepostgis.c +++ b/src/layersourcepostgis.c @@ -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 diff --git a/src/layersourceshp.c b/src/layersourceshp.c index 3b718cf..e51ecdd 100644 --- a/src/layersourceshp.c +++ b/src/layersourceshp.c @@ -24,9 +24,9 @@ #include #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++) diff --git a/src/layersourceshp.h b/src/layersourceshp.h index 19fed23..fba6629 100644 --- a/src/layersourceshp.h +++ b/src/layersourceshp.h @@ -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 diff --git a/tests/from_xml.c b/tests/from_xml.c index e69de29..f7107fc 100644 --- a/tests/from_xml.c +++ b/tests/from_xml.c @@ -0,0 +1,7 @@ +#include + +int +main (int argc, char *argv[]) +{ + return 0; +}