浏览代码

libvect: implement V1_read_line_ogr and V1/V2_rewrite_line()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@40262 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 15 年之前
父节点
当前提交
62f425be6b
共有 5 个文件被更改,包括 237 次插入96 次删除
  1. 6 4
      include/vector.h
  2. 172 84
      lib/vector/Vlib/read_ogr.c
  3. 4 4
      lib/vector/Vlib/write.c
  4. 1 1
      lib/vector/Vlib/write_nat.c
  5. 54 3
      lib/vector/Vlib/write_ogr.c

+ 6 - 4
include/vector.h

@@ -475,6 +475,8 @@ int V2_close_ogr(struct Map_info *);
 /* Read/write lines */
 /* Read/write lines */
 int V1_read_line_nat(struct Map_info *, struct line_pnts *,
 int V1_read_line_nat(struct Map_info *, struct line_pnts *,
 		     struct line_cats *, off_t);
 		     struct line_cats *, off_t);
+int V1_read_line_ogr(struct Map_info *, struct line_pnts *,
+		     struct line_cats *, off_t);
 int V1_read_next_line_nat(struct Map_info *, struct line_pnts *,
 int V1_read_next_line_nat(struct Map_info *, struct line_pnts *,
 			  struct line_cats *);
 			  struct line_cats *);
 int V1_read_next_line_ogr(struct Map_info *, struct line_pnts *,
 int V1_read_next_line_ogr(struct Map_info *, struct line_pnts *,
@@ -503,12 +505,12 @@ off_t V2_write_line_ogr(struct Map_info *, int, const struct line_pnts *,
 			const struct line_cats *);
 			const struct line_cats *);
 off_t V1_rewrite_line_nat(struct Map_info *, off_t, int,
 off_t V1_rewrite_line_nat(struct Map_info *, off_t, int,
 			  const struct line_pnts *, const struct line_cats *);
 			  const struct line_pnts *, const struct line_cats *);
+off_t V1_rewrite_line_ogr(struct Map_info *, off_t, int,
+			  const struct line_pnts *, const struct line_cats *);
 int V2_rewrite_line_nat(struct Map_info *, int, int,
 int V2_rewrite_line_nat(struct Map_info *, int, int,
 			const struct line_pnts *, const struct line_cats *);
 			const struct line_pnts *, const struct line_cats *);
-#if 0
-off_t V1_rewrite_line_ogr(struct Map_info *, off_t, int,
-			 struct line_pnts *, struct line_cats *);
-#endif
+int V2_rewrite_line_ogr(struct Map_info *, int, int,
+			const struct line_pnts *, const struct line_cats *);
 
 
     /* Build topology */
     /* Build topology */
 int Vect_build_nat(struct Map_info *, int);
 int Vect_build_nat(struct Map_info *, int);

+ 172 - 84
lib/vector/Vlib/read_ogr.c

@@ -1,16 +1,17 @@
 /*!
 /*!
-   \file read_ogr.c
+   \file lib/vector/Vlib/read_ogr.c
 
 
    \brief Vector library - reading data (OGR format)
    \brief Vector library - reading data (OGR format)
 
 
    Higher level functions for reading/writing/manipulating vectors.
    Higher level functions for reading/writing/manipulating vectors.
 
 
-   (C) 2001-2009 by the GRASS Development Team
+   (C) 2001-2010 by the GRASS Development Team
 
 
    This program is free software under the GNU General Public License
    This program is free software under the GNU General Public License
-   (>=v2).  Read the file COPYING that comes with GRASS for details.
+   (>=v2). Read the file COPYING that comes with GRASS for details.
 
 
    \author Radim Blazek, Piero Cavalieri
    \author Radim Blazek, Piero Cavalieri
+   \author Martin Landa <landa.martin gmail.com>
  */
  */
 
 
 #include <grass/config.h>
 #include <grass/config.h>
@@ -24,14 +25,14 @@
 /*!
 /*!
  * \brief Recursively read feature and add all elements to points_cache and types_cache.
  * \brief Recursively read feature and add all elements to points_cache and types_cache.
  *
  *
- * ftype : if > 0 use this type (because parts of Polygon are read as wkbLineString)
+ * ftype: if > 0 use this type (because parts of Polygon are read as wkbLineString)
  *
  *
- * \param Map vector map layer
+ * \param Map pointer to Map_info structure
  * \param[out] hGeom OGR geometry
  * \param[out] hGeom OGR geometry
  * \param ftype feature type
  * \param ftype feature type
  * 
  * 
- * \return 0 OK
- * \return 1 error
+ * \return 0 on success
+ * \return 1 on error
  */
  */
 static int cache_feature(struct Map_info *Map, OGRGeometryH hGeom, int ftype)
 static int cache_feature(struct Map_info *Map, OGRGeometryH hGeom, int ftype)
 {
 {
@@ -39,7 +40,7 @@ static int cache_feature(struct Map_info *Map, OGRGeometryH hGeom, int ftype)
     OGRwkbGeometryType type;
     OGRwkbGeometryType type;
     OGRGeometryH hGeom2;
     OGRGeometryH hGeom2;
 
 
-    G_debug(4, "cache_feature");
+    G_debug(4, "cache_feature() ftype = %d", ftype);
 
 
     /* Alloc space */
     /* Alloc space */
     line = Map->fInfo.ogr.lines_num;
     line = Map->fInfo.ogr.lines_num;
@@ -54,8 +55,7 @@ static int cache_feature(struct Map_info *Map, OGRGeometryH hGeom, int ftype)
 	    (int *)G_realloc(Map->fInfo.ogr.lines_types,
 	    (int *)G_realloc(Map->fInfo.ogr.lines_types,
 			     Map->fInfo.ogr.lines_alloc * sizeof(int));
 			     Map->fInfo.ogr.lines_alloc * sizeof(int));
 
 
-	for (i = Map->fInfo.ogr.lines_num; i < Map->fInfo.ogr.lines_alloc;
-	     i++)
+	for (i = Map->fInfo.ogr.lines_num; i < Map->fInfo.ogr.lines_alloc; i++)
 	    Map->fInfo.ogr.lines[i] = Vect_new_line_struct();
 	    Map->fInfo.ogr.lines[i] = Vect_new_line_struct();
 
 
     }
     }
@@ -121,24 +121,23 @@ static int cache_feature(struct Map_info *Map, OGRGeometryH hGeom, int ftype)
 }
 }
 
 
 /*!
 /*!
- * \brief Read next line from OGR layer. Skip empty features.
+ * \brief Read next feature from OGR layer. Skip empty features. (level 1)
  *
  *
  *  The action of this routine can be modified by:
  *  The action of this routine can be modified by:
  *   - Vect_read_constraint_region()
  *   - Vect_read_constraint_region()
  *   - Vect_read_constraint_type()
  *   - Vect_read_constraint_type()
  *   - Vect_remove_constraints()
  *   - Vect_remove_constraints()
  *
  *
- * \param Map vector map layer
+ * \param Map pointer to Map_info structure
  * \param[out] line_p container used to store line points within
  * \param[out] line_p container used to store line points within
  * \param[out] line_c container used to store line categories within
  * \param[out] line_c container used to store line categories within
  *
  *
- * \return  line type
- * \return  -2 no more features (EOF)
- * \return  -1 out of memory
+ * \return feature type
+ * \return -2 no more features (EOF)
+ * \return -1 out of memory
  */
  */
-int
-V1_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
-		      struct line_cats *line_c)
+int V1_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
+			  struct line_cats *line_c)
 {
 {
     int itype;
     int itype;
     struct bound_box lbox, mbox;
     struct bound_box lbox, mbox;
@@ -219,21 +218,22 @@ V1_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
 
 
 	Map->fInfo.ogr.lines_next++;
 	Map->fInfo.ogr.lines_next++;
 	G_debug(4, "next line read, type = %d", itype);
 	G_debug(4, "next line read, type = %d", itype);
-	return (itype);
+	
+	return itype;
     }
     }
     return -2;			/* not reached */
     return -2;			/* not reached */
 }
 }
 
 
 /*!
 /*!
- * \brief Read next line from OGR layer.
+ * \brief Read next feature from OGR layer (topology level).
  *
  *
- * \param Map vector map layer
+ * \param Map pointer to Map_info structure
  * \param[out] line_p container used to store line points within
  * \param[out] line_p container used to store line points within
  * \param[out] line_c container used to store line categories within
  * \param[out] line_c container used to store line categories within
  *
  *
- * \return  line type
- * \return  -2 no more features (EOF)
- * \return  -1 out of memory
+ * \return feature type
+ * \return -2 no more features (EOF)
+ * \return -1 out of memory
  */
  */
 int
 int
 V2_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
 V2_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
@@ -248,13 +248,13 @@ V2_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
 /*!
 /*!
  * \brief Recursively descend to feature and read the part
  * \brief Recursively descend to feature and read the part
  *
  *
- * \param Map vector map layer
+ * \param Map pointer to Map_info structure
  * \param hGeom OGR geometry
  * \param hGeom OGR geometry
  * \param offset given offset
  * \param offset given offset
  * \param[out] Points container used to store line pointes within
  * \param[out] Points container used to store line pointes within
  *
  *
- * \return 0 OK
- * \return 1 error
+ * \return feature type
+ * \return -1 on error
  */
  */
 static int read_line(const struct Map_info *Map, OGRGeometryH hGeom, long offset,
 static int read_line(const struct Map_info *Map, OGRGeometryH hGeom, long offset,
 		     struct line_pnts *Points)
 		     struct line_pnts *Points)
@@ -274,19 +274,23 @@ static int read_line(const struct Map_info *Map, OGRGeometryH hGeom, long offset
     switch (eType) {
     switch (eType) {
     case wkbPoint:
     case wkbPoint:
 	G_debug(4, "Point");
 	G_debug(4, "Point");
-	Vect_append_point(Points, OGR_G_GetX(hGeom, 0), OGR_G_GetY(hGeom, 0),
-			  OGR_G_GetZ(hGeom, 0));
-	return 0;
+	if (Points) {
+	    Vect_append_point(Points, OGR_G_GetX(hGeom, 0), OGR_G_GetY(hGeom, 0),
+			      OGR_G_GetZ(hGeom, 0));
+	}
+	return GV_POINT;
 	break;
 	break;
 
 
     case wkbLineString:
     case wkbLineString:
-	G_debug(4, "LineString");
-	nPoints = OGR_G_GetPointCount(hGeom);
-	for (i = 0; i < nPoints; i++) {
-	    Vect_append_point(Points, OGR_G_GetX(hGeom, i),
-			      OGR_G_GetY(hGeom, i), OGR_G_GetZ(hGeom, i));
+	G_debug(4, "LineString");	
+	if (Points) {
+	    nPoints = OGR_G_GetPointCount(hGeom);
+	    for (i = 0; i < nPoints; i++) {
+		Vect_append_point(Points, OGR_G_GetX(hGeom, i),
+				  OGR_G_GetY(hGeom, i), OGR_G_GetZ(hGeom, i));
+	    }
 	}
 	}
-	return 0;
+	return GV_LINE;
 	break;
 	break;
 
 
     case wkbPolygon:
     case wkbPolygon:
@@ -303,99 +307,183 @@ static int read_line(const struct Map_info *Map, OGRGeometryH hGeom, long offset
 	G_warning(_("OGR feature type %d not supported"), eType);
 	G_warning(_("OGR feature type %d not supported"), eType);
 	break;
 	break;
     }
     }
-    return 1;
+
+    return -1;
 }
 }
 
 
 /*!
 /*!
- * \brief Read line from layer on given offset.
+ * \brief Recursively descend to feature and read the part
+ *
+ * \param Map pointer to Map_info structure
+ * \param hGeom OGR geometry
+ * \param offset given offset
+ * \param[out] Points container used to store line pointes within
  *
  *
- * \param Map vector map layer
+ * \return feature type
+ * \return -1 on error
+ */
+static int get_line_type(const struct Map_info *Map, long FID)
+{
+    int eType;
+    OGRFeatureH hFeat;
+    OGRGeometryH hGeom;
+
+    G_debug(4, "get_line_type() fid = %ld", FID);
+
+    hFeat = OGR_L_GetFeature(Map->fInfo.ogr.layer, FID);
+    if (hFeat == NULL)
+	return -1;
+
+    hGeom = OGR_F_GetGeometryRef(hFeat);
+    if (hGeom == NULL)
+	return -1;
+    
+    eType = wkbFlatten(OGR_G_GetGeometryType(hGeom));
+
+    OGR_F_Destroy(hFeat);
+
+    G_debug(4, "OGR Geometry of type: %d", eType);
+
+    switch (eType) {
+    case wkbPoint:
+    case wkbMultiPoint:
+	return GV_POINT;
+	break;
+	
+    case wkbLineString:
+    case wkbMultiLineString:
+	return GV_LINE;
+	break;
+
+    case wkbPolygon:
+    case wkbMultiPolygon:
+    case wkbGeometryCollection:
+	return GV_BOUNDARY;
+	break;
+
+    default:
+	G_warning(_("OGR feature type %d not supported"), eType);
+	break;
+    }
+
+    return -1;
+}
+
+/*!
+ * \brief Read feature from OGR layer at given offset (level 1)
+ *
+ * \param Map pointer to Map_info structure 
  * \param[out] line_p container used to store line points within
  * \param[out] line_p container used to store line points within
  * \param[out] line_c container used to store line categories within
  * \param[out] line_c container used to store line categories within
- * \param line line id
+ * \param offset given offset 
  *
  *
  * \return line type
  * \return line type
- * \return -2 end of table (last row)
+ * \return 0 dead line
+ * \return -2 no more features
  * \return -1 out of memory
  * \return -1 out of memory
  */
  */
-int
-V2_read_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
-		 struct line_cats *line_c, int line)
+int V1_read_line_ogr(struct Map_info *Map,
+		     struct line_pnts *line_p, struct line_cats *line_c, off_t offset)
 {
 {
-    int node;
-    int offset;
     long FID;
     long FID;
-    struct P_line *Line;
-    struct P_node *Node;
+    int type;
     OGRGeometryH hGeom;
     OGRGeometryH hGeom;
 
 
-    G_debug(4, "V2_read_line_ogr() line = %d", line);
+    G_debug(4, "V1_read_line_ogr() offset = %lu", (long) offset);
 
 
+    if (offset >= Map->fInfo.ogr.offset_num)
+	return -2;
+    
     if (line_p != NULL)
     if (line_p != NULL)
 	Vect_reset_line(line_p);
 	Vect_reset_line(line_p);
     if (line_c != NULL)
     if (line_c != NULL)
 	Vect_reset_cats(line_c);
 	Vect_reset_cats(line_c);
 
 
-    Line = Map->plus.Line[line];
-    offset = (int)Line->offset;
-
+    /*
     if (Line->type == GV_CENTROID) {
     if (Line->type == GV_CENTROID) {
 	G_debug(4, "Centroid");
 	G_debug(4, "Centroid");
 	node = Line->N1;
 	node = Line->N1;
 	Node = Map->plus.Node[node];
 	Node = Map->plus.Node[node];
 
 
-	/* coordinates */
 	if (line_p != NULL) {
 	if (line_p != NULL) {
 	    Vect_append_point(line_p, Node->x, Node->y, 0.0);
 	    Vect_append_point(line_p, Node->x, Node->y, 0.0);
 	}
 	}
 
 
-	/* category */
 	if (line_c != NULL) {
 	if (line_c != NULL) {
-	    /* cat = FID and offset = FID for centroid */
+	cat = FID and offset = FID for centroid
 	    Vect_cat_set(line_c, 1, (int)offset);
 	    Vect_cat_set(line_c, 1, (int)offset);
 	}
 	}
 
 
 	return (GV_CENTROID);
 	return (GV_CENTROID);
     }
     }
-    else {
-	FID = Map->fInfo.ogr.offset[offset];
-	G_debug(4, "  FID = %ld", FID);
+    */
 
 
-	/* coordinates */
-	if (line_p != NULL) {
-	    /* Read feature to cache if necessary */
-	    if (Map->fInfo.ogr.feature_cache_id != FID) {
-		G_debug(4, "Read feature (FID = %ld) to cache.", FID);
-		if (Map->fInfo.ogr.feature_cache) {
-		    OGR_F_Destroy(Map->fInfo.ogr.feature_cache);
-		}
-		Map->fInfo.ogr.feature_cache =
-		    OGR_L_GetFeature(Map->fInfo.ogr.layer, FID);
-		if (Map->fInfo.ogr.feature_cache == NULL) {
-		    G_fatal_error(_("Unable to get feature geometry, FID %ld"),
-				  FID);
-		}
-		Map->fInfo.ogr.feature_cache_id = FID;
+    FID = Map->fInfo.ogr.offset[offset];
+    G_debug(4, "  FID = %ld", FID);
+    
+    /* coordinates */
+    if (line_p != NULL) {
+	/* Read feature to cache if necessary */
+	if (Map->fInfo.ogr.feature_cache_id != FID) {
+	    G_debug(4, "Read feature (FID = %ld) to cache.", FID);
+	    if (Map->fInfo.ogr.feature_cache) {
+		OGR_F_Destroy(Map->fInfo.ogr.feature_cache);
 	    }
 	    }
-
-	    hGeom = OGR_F_GetGeometryRef(Map->fInfo.ogr.feature_cache);
-	    if (hGeom == NULL) {
+	    Map->fInfo.ogr.feature_cache =
+		OGR_L_GetFeature(Map->fInfo.ogr.layer, FID);
+	    if (Map->fInfo.ogr.feature_cache == NULL) {
 		G_fatal_error(_("Unable to get feature geometry, FID %ld"),
 		G_fatal_error(_("Unable to get feature geometry, FID %ld"),
 			      FID);
 			      FID);
 	    }
 	    }
-
-	    read_line(Map, hGeom, Line->offset + 1, line_p);
+	    Map->fInfo.ogr.feature_cache_id = FID;
 	}
 	}
-
-	/* category */
-	if (line_c != NULL) {
-	    Vect_cat_set(line_c, 1, (int)FID);
+	
+	hGeom = OGR_F_GetGeometryRef(Map->fInfo.ogr.feature_cache);
+	if (hGeom == NULL) {
+	    G_fatal_error(_("Unable to get feature geometry, FID %ld"),
+			  FID);
 	}
 	}
+	
+	type = read_line(Map, hGeom, offset + 1, line_p);
+    }
+    else {
+	type = get_line_type(Map, FID);
+    }
 
 
-	return Line->type;
+    /* category */
+    if (line_c != NULL) {
+	Vect_cat_set(line_c, 1, (int) FID);
     }
     }
 
 
-    return -2;			/* not reached */
+    return type;
+}
+
+/*!
+ * \brief Reads feature from OGR layer (topology level)
+ *
+ * \param Map pointer to Map_info structure
+ * \param[out] line_p container used to store line points within
+ * \param[out] line_c container used to store line categories within
+ * \param line feature id
+ *
+ * \return feature type
+ * \return -2 no more features
+ * \return -1 out of memory
+ */
+int V2_read_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
+		     struct line_cats *line_c, int line)
+{
+    struct P_line *Line;
+    
+    G_debug(4, "V2_read_line_ogr() line = %d", line);
+    
+    Line = Map->plus.Line[line];
+    
+    if (Line == NULL)
+	G_fatal_error("V2_read_line_ogr(): %s %d",
+		      _("Attempt to read dead line"), line);
+
+    return V1_read_line_ogr(Map, line_p, line_c, Line->offset);
 }
 }
 
 
 #endif
 #endif

+ 4 - 4
lib/vector/Vlib/write.c

@@ -5,7 +5,7 @@
 
 
    Higher level functions for reading/writing/manipulating vectors.
    Higher level functions for reading/writing/manipulating vectors.
 
 
-   (C) 2001-2009 by the GRASS Development Team
+   (C) 2001-2010 by the GRASS Development Team
 
 
    This program is free software under the GNU General Public License
    This program is free software under the GNU General Public License
    (>=v2). Read the file COPYING that comes with GRASS for details.
    (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -79,12 +79,12 @@ static off_t (*Write_line_array[][3]) () = {
 
 
 static int (*Vect_rewrite_line_array[][3]) () = {
 static int (*Vect_rewrite_line_array[][3]) () = {
     {
     {
-    rewrite_dummy, rewrite_dummy, V2_rewrite_line_nat}
+    rewrite_dummy, V1_rewrite_line_nat, V2_rewrite_line_nat}
 #ifdef HAVE_OGR
 #ifdef HAVE_OGR
     , {
     , {
-    rewrite_dummy, rewrite_dummy, rewrite_dummy}
+    rewrite_dummy, V1_rewrite_line_ogr, V2_rewrite_line_ogr}
     , {
     , {
-    rewrite_dummy, rewrite_dummy, rewrite_dummy}
+    rewrite_dummy, V1_rewrite_line_ogr, V2_rewrite_line_ogr}
 #else
 #else
     , {
     , {
     rewrite_dummy, format, format}
     rewrite_dummy, format, format}

+ 1 - 1
lib/vector/Vlib/write_nat.c

@@ -77,7 +77,7 @@ off_t V2_write_line_nat(struct Map_info *Map,
 }
 }
 
 
 /*!
 /*!
-  \brief Rewrites feature at the given offset.
+  \brief Rewrites feature at the given offset (level 1)
   
   
   If the number of points or cats differs from the original one or
   If the number of points or cats differs from the original one or
   the type is changed: GV_POINTS -> GV_LINES or GV_LINES ->
   the type is changed: GV_POINTS -> GV_LINES or GV_LINES ->

+ 54 - 3
lib/vector/Vlib/write_ogr.c

@@ -27,7 +27,7 @@ static int write_attributes(int, const struct field_info *,
 			    OGRLayerH, OGRFeatureH);
 			    OGRLayerH, OGRFeatureH);
 
 
 /*!
 /*!
-  \brief Writes feature on level 1 (OGR format)
+  \brief Writes feature on level 1
 
 
   \param Map pointer to Map_info structure
   \param Map pointer to Map_info structure
   \param type feature type
   \param type feature type
@@ -117,7 +117,7 @@ off_t V1_write_line_ogr(struct Map_info *Map,
 }
 }
 
 
 /*!
 /*!
-  \brief Writes feature to 'coor' file (topology level)
+  \brief Writes feature (topology level)
   
   
   \param Map pointer to Map_info structure
   \param Map pointer to Map_info structure
   \param type feature type
   \param type feature type
@@ -174,13 +174,64 @@ int V2_delete_line_ogr(struct Map_info *Map, int line)
     return V2__delete_line(Map, line, V1_delete_line_ogr);
     return V2__delete_line(Map, line, V1_delete_line_ogr);
 }
 }
 
 
+/*!
+  \brief Rewrites feature at the given offset (level 1)
+  
+  \param Map pointer to Map_info structure
+  \param offset feature offset
+  \param type feature type
+  \param points feature geometry
+  \param cats feature categories
+  
+  \return feature offset (rewriten feature)
+  \return -1 on error
+*/
+off_t V1_rewrite_line_ogr(struct Map_info *Map,
+			  off_t offset,
+			  int type,
+			  const struct line_pnts *points, const struct line_cats *cats)
+{
+    if (type != V1_read_line_ogr(Map, NULL, NULL, offset)) {
+	G_warning(_("Unable to rewrite feature (incompatible feature types)"));
+	return -1;
+    }
+
+    /* delete old */
+    V1_delete_line_ogr(Map, offset);
+
+    return V1_write_line_ogr(Map, type, points, cats);
+}
+
+/*!
+  \brief Rewrites feature (topology level)
+  
+  \param Map pointer to Map_info structure
+  \param line feature id
+  \param type feature type
+  \param points feature geometry
+  \param cats feature categories
+  
+  \return feature offset (rewriten feature)
+  \return -1 on error
+*/
+int V2_rewrite_line_ogr(struct Map_info *Map,
+			int line,
+			int type,
+			const struct line_pnts *points, const struct line_cats *cats)
+{
+    /* delete old */
+    V2_delete_line_ogr(Map, line);
+
+    return V2_write_line_ogr(Map, type, points, cats);
+}
+
 int write_attributes(int cat, const struct field_info *Fi,
 int write_attributes(int cat, const struct field_info *Fi,
 		     OGRLayerH Ogr_layer, OGRFeatureH Ogr_feature)
 		     OGRLayerH Ogr_layer, OGRFeatureH Ogr_feature)
 {
 {
     int j, ogrfieldnum;
     int j, ogrfieldnum;
     char buf[2000];
     char buf[2000];
     int ncol, colsqltype, colctype, more;
     int ncol, colsqltype, colctype, more;
-    char *fidcol;
+    const char *fidcol;
     dbDriver *Driver;
     dbDriver *Driver;
     dbTable *Table;
     dbTable *Table;
     dbString dbstring;
     dbString dbstring;