]> saetta.ns0.it Git - libgtkgis/commitdiff
Fixed libgtkgis.pc.in to include goocanvas and gdal.
authorAndrea Zagli <azagli@libero.it>
Mon, 6 Jul 2009 15:43:27 +0000 (17:43 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 6 Jul 2009 15:43:27 +0000 (17:43 +0200)
Fixed tests/from_xml.c on #include.
Added GtkGisLayerSource::set_max_extent.
Fixed coordinates for multiple layers.
Reduced default geometries line-width to 0.5 instead of 1.0.
Changed goocanvas item type from rect to ellipse for GtkGisGeometryPoint.

12 files changed:
libgtkgis.pc.in
src/geometryline.c
src/geometrypoint.c
src/gtkgis.c
src/layer.c
src/layer.h
src/layersource.c
src/layersource.h
tests/Makefile.am
tests/README [new file with mode: 0644]
tests/from_xml.c
tests/test1.gtkgis

index e2fbbbc928ded1e473d7cedcfb579221d5702713..0c4b67f66fb94eb451d4ea9dc3a10d507aa93a57 100644 (file)
@@ -6,6 +6,6 @@ includedir=@includedir@
 Name: @PACKAGE_NAME@
 Description: A Gtk+ widget to embed base GIS functionalities into applications.
 Version: @PACKAGE_VERSION@
-Requires: gtk+-2.0
-Libs: -L${libdir} -lgtkgis
-Cflags: -I${includedir}
+Requires: gtk+-2.0 goocanvas
+Libs: -L${libdir} @GDAL_LIBS@ -lgtkgis
+Cflags: @GDAL_CFLAGS@ -I${includedir}/gtkgis
index 8dae4e04d6ead07244a802aebfb18411b3c28027..ba25a7cea761462b1ca89fdcfa0a24ecc7d2b887 100644 (file)
@@ -216,7 +216,7 @@ static GooCanvasItem
                        path = convert_comma_to_dot (path);
                        item = goo_canvas_path_new (NULL,
                                                    path,
-                                                   "line-width", 1.0 / scale->xy,
+                                                   "line-width", 0.5 / scale->xy,
                                                    NULL);
                }
 
index 7336fd26bfeac83e5a68671a7d1ea743f00f7dbe..fc4f22f728ec69bb836f930bb6bb6a28a5c0c96b 100644 (file)
@@ -156,11 +156,12 @@ GooCanvasItem *gtk_gis_geometry_point_draw (GtkGisGeometry *point, GtkGisScale *
 
        if (priv->point != NULL)
                {
-                       item = goo_canvas_rect_new (NULL,
-                                                   priv->point->x, priv->point->y,
-                                                   1 / scale->x, 1 / scale->y,
-                                                   "line-width", 1.0 / scale->xy,
-                                                   NULL);
+                       item = goo_canvas_ellipse_new (NULL,
+                                                      priv->point->x, priv->point->y,
+                                                      0.5 / scale->x, 0.5 / scale->y,
+                                                      "line-width", 0.5 / scale->xy,
+                                                      "fill-color", "black",
+                                                      NULL);
                }
 
        return item;
index 34f8b5eec6557ed8e1308301c8f4ad549c35b7ca..64d6ecc3ae40048fd046a10a164b1dc1036c67aa 100644 (file)
@@ -241,6 +241,7 @@ GtkWidget
                                                                                                                                                {
                                                                                                                                                        layer = gtk_gis_layer_new_from_source (layer_source, layer_name);
                                                                                                                                                        gtk_gis_add_layer (GTK_GIS (gtkgis), layer);
+                                                                                                                                                       gtk_gis_layer_source_set_max_extent (layer_source, priv->extent);
                                                                                                                                                }
 
                                                                                                                                        cur = xml_source_spec;
index 0caa3131136dc7c543f6eca28814757c15c7d154..3d01132f9feb6b11753fe06b32eeeff875934704 100644 (file)
@@ -129,8 +129,6 @@ GtkGisLayer
        if (type >= 0)
                {
                        layer = gtk_gis_layer_new (source, name, type);
-
-                       gtk_gis_layer_fill_from_source (layer);
                }
 
        return layer;
@@ -281,7 +279,7 @@ gtk_gis_layer_draw (GtkGisLayer *layer, GooCanvasItem *root, GtkGisScale *scale)
 
        priv = GTK_GIS_LAYER_GET_PRIVATE (layer);
 
-       g_return_if_fail (priv->geometries != NULL);
+       gtk_gis_layer_fill_from_source (layer);
 
        priv->layer_item = goo_canvas_group_new (root, NULL);
 
index a05279541522c510f4b43ccede79f02a2199abdc..84224b68aec42c7d166bac96509ce902ec027435 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <goocanvas.h>
 
+#include "commons.h"
 #include "geometry.h"
 #include "layersource.h"
 
index 258f8742612bbabae202103035156621e25993de..3f8fb2aca134d9c8b65d3ece243de1f044a46fdd 100644 (file)
@@ -53,6 +53,8 @@ typedef struct _GtkGisLayerSourcePrivate GtkGisLayerSourcePrivate;
 struct _GtkGisLayerSourcePrivate
        {
                OGRDataSourceH datasource;
+
+               GtkGisLayerExtent *max_extent;
        };
 
 G_DEFINE_TYPE (GtkGisLayerSource, gtk_gis_layer_source, G_TYPE_OBJECT)
@@ -83,6 +85,8 @@ gtk_gis_layer_source_set_ogr_datasource (GtkGisLayerSource *source,
        GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
 
        priv->datasource = datasource;
+
+       priv->max_extent = NULL;
 }
 
 
@@ -104,11 +108,11 @@ GList
        OGRLayerH layer;
        OGRFeatureH feature;
 
-       GtkGisLayerExtent extent;
-
        OGRGeometryH poGeometry;
        GtkGisGeometry *geometry;
 
+       gdouble fixy;
+
        GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
 
     g_return_if_fail (priv->datasource != NULL);
@@ -117,10 +121,17 @@ GList
 
        g_return_if_fail (layer != NULL);
 
-       extent = gtk_gis_layer_source_get_layer_extent (source, name);
-
        OGR_L_ResetReading (layer);
 
+       /*if (priv->max_extent == NULL)
+               {
+                       fixy = 0.0f;
+               }
+       else
+               {*/
+                       fixy = priv->max_extent->max_y + priv->max_extent->min_y;
+               //}
+
        while ((feature = OGR_L_GetNextFeature (layer)) != NULL)
                {
                        poGeometry = OGR_F_GetGeometryRef (feature);
@@ -131,7 +142,7 @@ GList
                                        GtkGisPoint gpoint;
 
                                        gpoint.x = OGR_G_GetX (poGeometry, 0);
-                                       gpoint.y = extent.max_y - OGR_G_GetY (poGeometry, 0) + extent.min_y;
+                                       gpoint.y = fixy - OGR_G_GetY (poGeometry, 0);
 
                                        geometry = gtk_gis_geometry_point_new (gpoint);
                                }
@@ -151,7 +162,7 @@ GList
                                                        gpoint = g_malloc0 (sizeof (GtkGisPoint));
 
                                                        gpoint->x = OGR_G_GetX (poGeometry, point);
-                                                       gpoint->y = extent.max_y - OGR_G_GetY (poGeometry, point) + extent.min_y;
+                                                       gpoint->y = fixy - OGR_G_GetY (poGeometry, point);
 
                                                        gpoints = g_slist_append (gpoints, gpoint);
                                                }
@@ -185,7 +196,7 @@ GList
                                                                        gpoint = g_malloc0 (sizeof (GtkGisPoint));
 
                                                                        gpoint->x = OGR_G_GetX (poGeometryInt, point);
-                                                                       gpoint->y = extent.max_y - OGR_G_GetY (poGeometryInt, point) + extent.min_y;
+                                                                       gpoint->y = fixy - OGR_G_GetY (poGeometryInt, point);
 
                                                                        gpoints = g_slist_append (gpoints, gpoint);
                                                                }
@@ -283,6 +294,23 @@ gtk_gis_layer_source_get_layer_extent (GtkGisLayerSource *source,
        return extent;
 }
 
+void
+gtk_gis_layer_source_set_max_extent (GtkGisLayerSource *source,
+                                     GtkGisLayerExtent *extent)
+{
+       GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source);
+
+       if (priv->max_extent == NULL)
+               {
+                       priv->max_extent = g_malloc0 (sizeof (GtkGisLayerExtent));
+               }
+
+       priv->max_extent->min_x = extent->min_x;
+       priv->max_extent->max_x = extent->max_x;
+       priv->max_extent->min_y = extent->min_y;
+       priv->max_extent->max_y = extent->max_y;
+}
+
 static void
 gtk_gis_layer_source_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
index 76e2d49ee402d564ad2a624dd75ed2cf5f20d9e4..d325eb902676f8b8e3c1df365b9d762fbe4f341a 100644 (file)
@@ -68,6 +68,9 @@ GtkGisLayerGeometryType gtk_gis_layer_source_get_layer_geometry_type (GtkGisLaye
 GtkGisLayerExtent gtk_gis_layer_source_get_layer_extent (GtkGisLayerSource *source,
                                                          const gchar *name);
 
+void gtk_gis_layer_source_set_max_extent (GtkGisLayerSource *source,
+                                          GtkGisLayerExtent *extent);
+
 
 G_END_DECLS
 
index 27d03314b3c8b1f45193d97b10d4a393cae5d5f7..fc4dc10dc29a1345a5b32adf49f1926a54aba232 100644 (file)
@@ -13,4 +13,6 @@ LDADD = $(libgtkgis)
 
 noinst_PROGRAMS = from_xml
 
-EXTRA_DIST = test1.gtkgis
+EXTRA_DIST = \
+             README \
+             test1.gtkgis
diff --git a/tests/README b/tests/README
new file mode 100644 (file)
index 0000000..d3b149f
--- /dev/null
@@ -0,0 +1,6 @@
+You can find some sample data on
+
+http://www.qgis.org/en/download/sample-data.html
+
+then change accordingly test files *.gtkgis or create new ones based on
+../data/gtkgis.dtd.
index 4dd576cdb3e0e3ab866ffa9172fe36e9b8142756..610ae648a4b42f13431240ca10fd24390f82a08e 100644 (file)
@@ -1,4 +1,4 @@
-#include <libgtkgis.h>
+#include <gtkgis.h>
 
 int
 main (int argc, char *argv[])
index 090eb87d9692a9a56b7d64ec2546afc7dbcdb4e3..3a39de76858bd7f3be68db74b8b8fa6b3c4dd98e 100644 (file)
@@ -2,25 +2,25 @@
 
        <layer name="alaska">
                <source>
-                       <shape filename="tests/samples/alaska.shp" />
+                       <shape filename="samples/alaska.shp" />
                </source>
        </layer>
 
        <layer name="airports">
                <source>
-                       <shape filename="tests/samples/airports.shp" />
+                       <shape filename="samples/airports.shp" />
                </source>
        </layer>
 
        <layer name="railroads">
                <source>
-                       <shape filename="tests/samples/railroads.shp" />
+                       <shape filename="samples/railroads.shp" />
                </source>
        </layer>
 
        <layer name="rivers">
                <source>
-                       <shape filename="tests/samples/rivers.shp" />
+                       <shape filename="samples/rivers.shp" />
                </source>
        </layer>