Added GtkGisGeometry::add_line_from_list.
Added support for relative filename path.
priv->lines = g_slist_append (priv->lines, line);
}
+/**
+ * gtk_gis_geometry_polygon_add_line_from_list:
+ * @polygon:
+ * @points:
+ *
+ */
+void
+gtk_gis_geometry_polygon_add_line_from_list (GtkGisGeometryPolygon *polygon,
+ GSList *points)
+{
+ GtkGisGeometry *line;
+
+ line = gtk_gis_geometry_line_new_from_list (points);
+
+ if (line != NULL)
+ {
+ gtk_gis_geometry_polygon_add_line (polygon, GTK_GIS_GEOMETRY_LINE (line));
+ }
+}
+
/**
* gtk_gis_geometry_polygon_remove_line:
* @polygon:
if (priv->lines != NULL)
{
GSList *cur;
- GtkGisGeometryLine *line;
+ GtkGisGeometry *line;
GooCanvasItem *item = NULL;
polygon_item = goo_canvas_group_new (NULL, NULL);
cur = priv->lines;
- line = (GtkGisGeometryLine *)cur->data;
-
while (cur != NULL)
{
- item = gtk_gis_geometry_draw (GTK_GIS_GEOMETRY (line));
+ line = (GtkGisGeometry *)cur->data;
+ item = gtk_gis_geometry_draw (line);
if (item != NULL)
{
GtkGisGeometry *gtk_gis_geometry_polygon_new_from_list (GSList *points);
void gtk_gis_geometry_polygon_add_line (GtkGisGeometryPolygon *polygon, GtkGisGeometryLine *line);
+void gtk_gis_geometry_polygon_add_line_from_list (GtkGisGeometryPolygon *polygon, GSList *points);
void gtk_gis_geometry_polygon_remove_line (GtkGisGeometryPolygon *polygon, GtkGisGeometryLine *line);
filename = xmlGetProp (cur, (const xmlChar *)"filename");
if (filename != NULL)
{
+ if (!g_path_is_absolute (filename))
+ {
+ filename = g_build_filename (g_get_current_dir (),
+ filename,
+ NULL);
+ }
+
layer_source = gtk_gis_layer_source_shp_new ((const gchar *)filename);
}
}
{
GtkWidget *gtkgis = NULL;
- xmlDoc *xdoc = xmlParseFile (filename);
+ gchar *path = g_strdup (filename);
+
+ if (!g_path_is_absolute (path))
+ {
+ path = g_build_filename (g_get_current_dir (),
+ path,
+ NULL);
+ }
+
+ xmlDoc *xdoc = xmlParseFile (path);
if (xdoc != NULL)
{
gtkgis = gtk_gis_new_from_xml (xdoc);
gint num_geometries;
gint i_geometry;
- OGRGeometryH poGeometryIns;
+ OGRGeometryH poGeometryInt;
num_geometries = OGR_G_GetGeometryCount (poGeometry);
GtkGisPoint *gpoint;
- poGeometryIns = OGR_G_GetGeometryRef (poGeometry, i_geometry);
+ poGeometryInt = OGR_G_GetGeometryRef (poGeometry, i_geometry);
- points = OGR_G_GetPointCount (poGeometryIns);
+ points = OGR_G_GetPointCount (poGeometryInt);
for (point = 0; point < points; point++)
{
gpoint = g_malloc0 (sizeof (GtkGisPoint));
- gpoint->x = OGR_G_GetX (poGeometryIns, point);
- gpoint->y = OGR_G_GetY (poGeometryIns, point);
+ gpoint->x = OGR_G_GetX (poGeometryInt, point);
+ gpoint->y = OGR_G_GetY (poGeometryInt, point);
gpoints = g_slist_append (gpoints, gpoint);
}
- geometry = gtk_gis_geometry_polygon_new_from_list (gpoints);
+ if (i_geometry == 0)
+ {
+ geometry = gtk_gis_geometry_polygon_new_from_list (gpoints);
+ }
+ else
+ {
+ gtk_gis_geometry_polygon_add_line_from_list (GTK_GIS_GEOMETRY_POLYGON (geometry), gpoints);
+ }
}
}
<gtkgis>
- <!--<layer name="alaska">
+ <layer name="alaska">
<source>
- <shape filename="/home/andreaz/files/c/libgtkgis/tests/samples/alaska.shp" />
+ <shape filename="tests/samples/alaska.shp" />
</source>
- </layer>-->
+ </layer>
<!--<layer name="airports">
<source>
- <shape filename="/home/andreaz/files/c/libgtkgis/tests/samples/airports.shp" />
+ <shape filename="tests/samples/airports.shp" />
</source>
- </layer>-->
+ </layer>
<layer name="railroads">
<source>
- <shape filename="/home/andreaz/files/c/libgtkgis/tests/samples/railroads.shp" />
+ <shape filename="tests/samples/railroads.shp" />
</source>
</layer>
- <!--<layer name="rivers">
+ <layer name="rivers">
<source>
- <shape filename="/home/andreaz/files/c/libgtkgis/tests/samples/rivers.shp" />
+ <shape filename="tests/samples/rivers.shp" />
</source>
</layer>-->