[GRASS-SVN] r63618 - in grass/trunk/vector: v.external v.in.ogr
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 19 11:16:08 PST 2014
Author: martinl
Date: 2014-12-19 11:16:08 -0800 (Fri, 19 Dec 2014)
New Revision: 63618
Modified:
grass/trunk/vector/v.external/list.c
grass/trunk/vector/v.in.ogr/main.c
Log:
fix compilation of v.in.ogr and v.external agaist GDAL < 1.11
Modified: grass/trunk/vector/v.external/list.c
===================================================================
--- grass/trunk/vector/v.external/list.c 2014-12-19 18:21:24 UTC (rev 63617)
+++ grass/trunk/vector/v.external/list.c 2014-12-19 19:16:08 UTC (rev 63618)
@@ -278,14 +278,18 @@
for (i = 0; i < nlayers; i++) {
Ogr_layer = OGR_DS_GetLayer(Ogr_ds, i);
Ogr_featuredefn = OGR_L_GetLayerDefn(Ogr_layer);
+#if GDAL_VERSION_NUM < 1110000
+ Ogr_geom_type = OGR_FD_GetGeomType(Ogr_featuredefn);
+#endif
layer_name = (char *) OGR_FD_GetName(Ogr_featuredefn);
if (fd) {
if (print_types) {
int proj_same, igeom;
OGRSpatialReferenceH Ogr_projection;
+#if GDAL_VERSION_NUM >= 1110000
OGRGeomFieldDefnH Ogr_geomdefn;
-
+#endif
/* projection check */
Ogr_projection = OGR_L_GetSpatialRef(Ogr_layer);
proj_same = 0;
@@ -304,7 +308,7 @@
proj_same = 0;
}
G_suppress_warnings(FALSE);
-
+#if GDAL_VERSION_NUM >= 1110000
for (igeom = 0; igeom < OGR_FD_GetGeomFieldCount(Ogr_featuredefn); igeom++) {
Ogr_geomdefn = OGR_FD_GetGeomFieldDefn(Ogr_featuredefn, igeom);
if (!Ogr_geomdefn) {
@@ -317,6 +321,11 @@
feature_type(OGRGeometryTypeToName(Ogr_geom_type)),
proj_same, OGR_GFld_GetNameRef(Ogr_geomdefn));
}
+#else
+ fprintf(fd, "%s,%s,%d,\n", layer_name,
+ feature_type(OGRGeometryTypeToName(Ogr_geom_type)),
+ proj_same);
+#endif
}
else {
fprintf(fd, "%s\n", layer_name);
Modified: grass/trunk/vector/v.in.ogr/main.c
===================================================================
--- grass/trunk/vector/v.in.ogr/main.c 2014-12-19 18:21:24 UTC (rev 63617)
+++ grass/trunk/vector/v.in.ogr/main.c 2014-12-19 19:16:08 UTC (rev 63618)
@@ -433,11 +433,18 @@
if (Ogr_ds == NULL)
G_fatal_error(_("Unable to open data source <%s>"), dsn);
- if (param.geom->answer &&
- !OGR_DS_TestCapability(Ogr_ds, ODsCCreateGeomFieldAfterCreateLayer)) {
- G_warning(_("Option <%s> will be ignored. OGR doesn't support it for selected format (%s)."),
- param.geom->key, OGR_Dr_GetName(OGR_DS_GetDriver(Ogr_ds)));
+ if (param.geom->answer) {
+#if GDAL_VERSION_NUM >= 1110000
+ if (!OGR_DS_TestCapability(Ogr_ds, ODsCCreateGeomFieldAfterCreateLayer)) {
+ G_warning(_("Option <%s> will be ignored. OGR doesn't support it for selected format (%s)."),
+ param.geom->key, OGR_Dr_GetName(OGR_DS_GetDriver(Ogr_ds)));
+ param.geom->answer = NULL;
+ }
+#else
+ G_warning(_("Option <%s> will be ignored. Multiple geometry fields are supported by GDAL >= 1.11"),
+ param.geom->key);
param.geom->answer = NULL;
+#endif
}
/* check encoding for given driver */
@@ -830,13 +837,14 @@
Ogr_layer = OGR_DS_GetLayer(Ogr_ds, layer_id);
Ogr_featuredefn = OGR_L_GetLayerDefn(Ogr_layer);
igeom = -1;
+#if GDAL_VERSION_NUM >= 1110000
if (param.geom->answer) {
igeom = OGR_FD_GetGeomFieldIndex(Ogr_featuredefn, param.geom->answer);
if (igeom < 0)
G_fatal_error(_("Geometry column <%s> not found in OGR layer <%s>"),
param.geom->answer, OGR_L_GetName(Ogr_layer));
}
-
+#endif
n_features = feature_count = 0;
n_features = OGR_L_GetFeatureCount(Ogr_layer, 1);
@@ -849,18 +857,24 @@
G_percent(feature_count++, n_features, 1); /* show something happens */
/* Geometry */
+#if GDAL_VERSION_NUM >= 1110000
for (i = 0; i < OGR_FD_GetGeomFieldCount(Ogr_featuredefn); i++) {
if (igeom > -1 && i != igeom)
continue; /* use only geometry defined via param.geom */
Ogr_geometry = OGR_F_GetGeomFieldRef(Ogr_feature, i);
+#else
+ Ogr_geometry = OGR_F_GetGeometryRef(Ogr_feature);
+#endif
if (Ogr_geometry != NULL) {
if (!flag.no_clean->answer)
poly_count(Ogr_geometry, (type & GV_BOUNDARY));
if (OGR_G_GetCoordinateDimension(Ogr_geometry) > 2)
input3d = 1;
}
+#if GDAL_VERSION_NUM >= 1110000
}
+#endif
OGR_F_Destroy(Ogr_feature);
}
G_percent(1, 1, 1);
@@ -924,9 +938,11 @@
Ogr_featuredefn = OGR_L_GetLayerDefn(Ogr_layer);
igeom = -1;
+#if GDAL_VERSION_NUM >= 1110000
if (param.geom->answer)
igeom = OGR_FD_GetGeomFieldIndex(Ogr_featuredefn, param.geom->answer);
-
+#endif
+
if (param.key->answer) {
const char *fid_column;
fid_column = OGR_L_GetFIDColumn(Ogr_layer);
@@ -1121,12 +1137,15 @@
G_percent(feature_count++, n_features, 1); /* show something happens */
/* Geometry */
+#if GDAL_VERSION_NUM >= 1110000
for (i = 0; i < OGR_FD_GetGeomFieldCount(Ogr_featuredefn); i++) {
if (igeom > -1 && i != igeom)
continue; /* use only geometry defined via param.geom */
Ogr_geometry = OGR_F_GetGeomFieldRef(Ogr_feature, i);
-
+#else
+ Ogr_geometry = OGR_F_GetGeometryRef(Ogr_feature);
+#endif
if (Ogr_geometry == NULL) {
nogeom++;
}
@@ -1139,8 +1158,9 @@
geom(Ogr_geometry, Out, layer + 1, cat, min_area, type,
flag.no_clean->answer);
}
+#if GDAL_VERSION_NUM >= 1110000
}
-
+#endif
/* Attributes */
if (!flag.notab->answer) {
sprintf(buf, "insert into %s values ( %d", Fi->table, cat);
@@ -1374,9 +1394,11 @@
Ogr_featuredefn = OGR_L_GetLayerDefn(Ogr_layer);
igeom = -1;
+#if GDAL_VERSION_NUM >= 1110000
if (param.geom->answer)
igeom = OGR_FD_GetGeomFieldIndex(Ogr_featuredefn, param.geom->answer);
-
+#endif
+
n_features = OGR_L_GetFeatureCount(Ogr_layer, 1);
OGR_L_ResetReading(Ogr_layer);
@@ -1386,17 +1408,22 @@
cat++;
G_percent(cat, n_features, 2);
/* Geometry */
+#if GDAL_VERSION_NUM >= 1110000
for (i = 0; i < OGR_FD_GetGeomFieldCount(Ogr_featuredefn); i++) {
if (igeom > -1 && i != igeom)
continue; /* use only geometry defined via param.geom */
Ogr_geometry = OGR_F_GetGeomFieldRef(Ogr_feature, i);
+#else
+ Ogr_geometry = OGR_F_GetGeometryRef(Ogr_feature);
+#endif
if (Ogr_geometry != NULL) {
centroid(Ogr_geometry, Centr, &si, layer + 1, cat,
min_area, type);
}
+#if GDAL_VERSION_NUM >= 1110000
}
-
+#endif
OGR_F_Destroy(Ogr_feature);
}
}
More information about the grass-commit
mailing list