[GRASS-SVN] r67063 - in grass/trunk: include/defs lib/python/pygrass/vector lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 11 02:45:14 PST 2015
Author: huhabla
Date: 2015-12-11 02:45:14 -0800 (Fri, 11 Dec 2015)
New Revision: 67063
Modified:
grass/trunk/include/defs/vector.h
grass/trunk/lib/python/pygrass/vector/__init__.py
grass/trunk/lib/vector/Vlib/geos_to_wktb.c
Log:
vector library and pygrass rpc: Fixed bug in vector line to wkb conversion
Modified: grass/trunk/include/defs/vector.h
===================================================================
--- grass/trunk/include/defs/vector.h 2015-12-11 08:22:28 UTC (rev 67062)
+++ grass/trunk/include/defs/vector.h 2015-12-11 10:45:14 UTC (rev 67063)
@@ -611,7 +611,7 @@
unsigned char *Vect_read_line_to_wkb(const struct Map_info *,
struct line_pnts *,
struct line_cats *,
- int line, size_t *);
+ int, size_t *, int *);
#endif
/* Raster color tables */
Modified: grass/trunk/lib/python/pygrass/vector/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/__init__.py 2015-12-11 08:22:28 UTC (rev 67062)
+++ grass/trunk/lib/python/pygrass/vector/__init__.py 2015-12-11 10:45:14 UTC (rev 67063)
@@ -714,7 +714,6 @@
>>> test_vect.close()
-
"""
supported = ['point', 'line', 'boundary', 'centroid']
@@ -737,14 +736,21 @@
line_c = libvect.line_cats()
size = ctypes.c_size_t()
cat = ctypes.c_int()
+ error = ctypes.c_int()
for f_id in bboxlist.ids:
barray = libvect.Vect_read_line_to_wkb(self.c_mapinfo,
ctypes.byref(line_p),
ctypes.byref(line_c),
- f_id, ctypes.byref(size))
+ f_id,
+ ctypes.byref(size),
+ ctypes.byref(error))
if not barray:
- raise GrassError(_("Unable to read line of feature %i"%(f_id)))
+ if error == -1:
+ raise GrassError(_("Unable to read line of feature %i"%(f_id)))
+ if error == -2:
+ print("Empty feature %i"%(f_id))
+ continue
ok = libvect.Vect_cat_get(ctypes.byref(line_c), field,
ctypes.byref(cat))
Modified: grass/trunk/lib/vector/Vlib/geos_to_wktb.c
===================================================================
--- grass/trunk/lib/vector/Vlib/geos_to_wktb.c 2015-12-11 08:22:28 UTC (rev 67062)
+++ grass/trunk/lib/vector/Vlib/geos_to_wktb.c 2015-12-11 10:45:14 UTC (rev 67063)
@@ -125,7 +125,8 @@
unsigned char *Vect_read_line_to_wkb(const struct Map_info *Map,
struct line_pnts *line_p,
struct line_cats *line_c,
- int line, size_t *size)
+ int line, size_t *size,
+ int *error)
{
static int init = 0;
/* The writer is static for performance reasons */
@@ -150,6 +151,8 @@
}
int f_type = Vect_read_line(Map, line_p, line_c, line);
+ /* Save the error state */
+ *error = f_type;
if(f_type < 0)
return(NULL);
@@ -157,7 +160,13 @@
GEOSWKBWriter_setOutputDimension(writer, Vect_is_3d(Map) ? 3 : 2);
GEOSGeometry *geom = Vect_line_to_geos(line_p, f_type, Vect_is_3d(Map));
+
+ if(destroy_cats == 1)
+ Vect_destroy_cats_struct(line_c);
+ if(destroy_line == 1)
+ Vect_destroy_line_struct(line_p);
+
if(!geom) {
return(NULL);
}
@@ -165,13 +174,7 @@
wkb = GEOSWKBWriter_write(writer, geom, size);
GEOSGeom_destroy(geom);
-
- if(destroy_cats == 1)
- Vect_destroy_cats_struct(line_c);
- if(destroy_line == 1)
- Vect_destroy_line_struct(line_p);
-
return(wkb);
}
More information about the grass-commit
mailing list