|
@@ -3,7 +3,8 @@
|
|
#include "local_proto.h"
|
|
#include "local_proto.h"
|
|
|
|
|
|
int mk_att(int cat, struct field_info *Fi, dbDriver *Driver, int ncol,
|
|
int mk_att(int cat, struct field_info *Fi, dbDriver *Driver, int ncol,
|
|
- int doatt, int nocat, OGRFeatureH Ogr_feature, int *noatt, int *fout)
|
|
|
|
|
|
+ int doatt, int nocat, OGRFeatureH Ogr_feature, int *noatt,
|
|
|
|
+ int *fout)
|
|
{
|
|
{
|
|
int j, ogrfieldnum;
|
|
int j, ogrfieldnum;
|
|
char buf[2000];
|
|
char buf[2000];
|
|
@@ -22,8 +23,8 @@ int mk_att(int cat, struct field_info *Fi, dbDriver *Driver, int ncol,
|
|
if (!doatt) {
|
|
if (!doatt) {
|
|
ogrfieldnum = OGR_F_GetFieldIndex(Ogr_feature, "cat");
|
|
ogrfieldnum = OGR_F_GetFieldIndex(Ogr_feature, "cat");
|
|
OGR_F_UnsetField(Ogr_feature, ogrfieldnum);
|
|
OGR_F_UnsetField(Ogr_feature, ogrfieldnum);
|
|
- /* doatt reset moved into have cat loop as the table needs to be
|
|
|
|
- open to know the OGR field ID. Hopefully this has no ill consequences */
|
|
|
|
|
|
+ /* doatt reset moved into have cat loop as the table needs to be
|
|
|
|
+ open to know the OGR field ID. Hopefully this has no ill consequences */
|
|
}
|
|
}
|
|
|
|
|
|
/* Read & set attributes */
|
|
/* Read & set attributes */
|
|
@@ -45,12 +46,14 @@ int mk_att(int cat, struct field_info *Fi, dbDriver *Driver, int ncol,
|
|
/* G_warning ("No database record for cat = %d", cat); */
|
|
/* G_warning ("No database record for cat = %d", cat); */
|
|
/* Set at least key column to category */
|
|
/* Set at least key column to category */
|
|
if (!nocat) {
|
|
if (!nocat) {
|
|
- ogrfieldnum = OGR_F_GetFieldIndex(Ogr_feature, Fi->key);
|
|
|
|
- OGR_F_SetFieldInteger(Ogr_feature, ogrfieldnum, cat);
|
|
|
|
- (*noatt)++;
|
|
|
|
- } else {
|
|
|
|
- G_fatal_error (_("No database record for cat = %d and export of 'cat' disabled"),
|
|
|
|
- cat);
|
|
|
|
|
|
+ ogrfieldnum =
|
|
|
|
+ OGR_F_GetFieldIndex(Ogr_feature, Fi->key);
|
|
|
|
+ OGR_F_SetFieldInteger(Ogr_feature, ogrfieldnum, cat);
|
|
|
|
+ (*noatt)++;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ G_fatal_error(_("No database record for cat = %d and export of 'cat' disabled"),
|
|
|
|
+ cat);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -67,10 +70,11 @@ int mk_att(int cat, struct field_info *Fi, dbDriver *Driver, int ncol,
|
|
G_debug(2, " colctype = %d", colctype);
|
|
G_debug(2, " colctype = %d", colctype);
|
|
|
|
|
|
ogrfieldnum = OGR_F_GetFieldIndex(Ogr_feature,
|
|
ogrfieldnum = OGR_F_GetFieldIndex(Ogr_feature,
|
|
- db_get_column_name(Column));
|
|
|
|
- G_debug(2, " column = %s -> fieldnum = %d",
|
|
|
|
|
|
+ db_get_column_name
|
|
|
|
+ (Column));
|
|
|
|
+ G_debug(2, " column = %s -> fieldnum = %d",
|
|
db_get_column_name(Column), ogrfieldnum);
|
|
db_get_column_name(Column), ogrfieldnum);
|
|
-
|
|
|
|
|
|
+
|
|
/* Reset */
|
|
/* Reset */
|
|
OGR_F_UnsetField(Ogr_feature, ogrfieldnum);
|
|
OGR_F_UnsetField(Ogr_feature, ogrfieldnum);
|
|
|
|
|
|
@@ -78,30 +82,34 @@ int mk_att(int cat, struct field_info *Fi, dbDriver *Driver, int ncol,
|
|
if (!db_test_value_isnull(Value)) {
|
|
if (!db_test_value_isnull(Value)) {
|
|
switch (colctype) {
|
|
switch (colctype) {
|
|
case DB_C_TYPE_INT:
|
|
case DB_C_TYPE_INT:
|
|
- OGR_F_SetFieldInteger(Ogr_feature, ogrfieldnum,
|
|
|
|
- db_get_value_int(Value));
|
|
|
|
|
|
+ OGR_F_SetFieldInteger(Ogr_feature,
|
|
|
|
+ ogrfieldnum,
|
|
|
|
+ db_get_value_int
|
|
|
|
+ (Value));
|
|
break;
|
|
break;
|
|
case DB_C_TYPE_DOUBLE:
|
|
case DB_C_TYPE_DOUBLE:
|
|
OGR_F_SetFieldDouble(Ogr_feature, ogrfieldnum,
|
|
OGR_F_SetFieldDouble(Ogr_feature, ogrfieldnum,
|
|
- db_get_value_double(Value));
|
|
|
|
|
|
+ db_get_value_double
|
|
|
|
+ (Value));
|
|
break;
|
|
break;
|
|
case DB_C_TYPE_STRING:
|
|
case DB_C_TYPE_STRING:
|
|
OGR_F_SetFieldString(Ogr_feature, ogrfieldnum,
|
|
OGR_F_SetFieldString(Ogr_feature, ogrfieldnum,
|
|
- db_get_value_string(Value));
|
|
|
|
|
|
+ db_get_value_string
|
|
|
|
+ (Value));
|
|
break;
|
|
break;
|
|
case DB_C_TYPE_DATETIME:
|
|
case DB_C_TYPE_DATETIME:
|
|
db_convert_column_value_to_string(Column,
|
|
db_convert_column_value_to_string(Column,
|
|
&dbstring);
|
|
&dbstring);
|
|
OGR_F_SetFieldString(Ogr_feature, ogrfieldnum,
|
|
OGR_F_SetFieldString(Ogr_feature, ogrfieldnum,
|
|
- db_get_string(&dbstring));
|
|
|
|
|
|
+ db_get_string
|
|
|
|
+ (&dbstring));
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- db_close_cursor (&cursor);
|
|
|
|
|
|
+ db_close_cursor(&cursor);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
else { /* Use cat only */
|
|
else { /* Use cat only */
|
|
ogrfieldnum = OGR_F_GetFieldIndex(Ogr_feature, "cat");
|
|
ogrfieldnum = OGR_F_GetFieldIndex(Ogr_feature, "cat");
|