[GRASS-SVN] r37325 - in grass/branches/develbranch_6:
lib/vector/Vlib vector/v.select
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu May 21 08:21:30 EDT 2009
Author: martinl
Date: 2009-05-21 08:21:30 -0400 (Thu, 21 May 2009)
New Revision: 37325
Modified:
grass/branches/develbranch_6/lib/vector/Vlib/geos.c
grass/branches/develbranch_6/vector/v.select/geos.c
grass/branches/develbranch_6/vector/v.select/main.c
grass/branches/develbranch_6/vector/v.select/proto.h
Log:
v.select/geos: point/line related fixes
Modified: grass/branches/develbranch_6/lib/vector/Vlib/geos.c
===================================================================
--- grass/branches/develbranch_6/lib/vector/Vlib/geos.c 2009-05-21 11:11:14 UTC (rev 37324)
+++ grass/branches/develbranch_6/lib/vector/Vlib/geos.c 2009-05-21 12:21:30 UTC (rev 37325)
@@ -192,7 +192,6 @@
GEOSGeometry *Vect__read_line_geos(struct Map_info *Map, long offset, int *type)
{
int ftype;
- double *x, *y, *z;
GEOSGeometry *geom;
GEOSCoordSequence *pseq;
@@ -220,12 +219,7 @@
G_debug(3, " geos_type = linestring");
}
}
-
- G_free((void *) x);
- G_free((void *) y);
- if (z)
- G_free((void *) z);
-
+
/* GEOSCoordSeq_destroy(pseq); */
if (type)
@@ -282,7 +276,9 @@
GEOSCoordSequence *V1_read_line_geos(struct Map_info *Map, long offset, int *type)
{
int i, n_points;
- char rhead;
+ int do_cats, n_cats;
+ char rhead, nc;
+ long size;
double *x, *y, *z;
GEOSCoordSequence *pseq;
@@ -301,6 +297,11 @@
if (!(rhead & 0x01)) /* dead line */
return GEOSCoordSeq_create(0, (Map->head.with_z) ? 3 : 2);
+
+ if (rhead & 0x02) /* categories exists */
+ do_cats = 1; /* do not return here let file offset moves forward to next */
+ else /* line */
+ do_cats = 0;
rhead >>= 2;
*type = dig_type_from_store((int) rhead);
@@ -308,9 +309,31 @@
/* read only points / lines / boundaries */
if (!(*type & (GV_POINT | GV_LINES)))
return GEOSCoordSeq_create(0, (Map->head.with_z) ? 3 : 2);
-
+
+ /* skip categories */
+ if (do_cats) {
+ if (Map->head.Version_Minor == 1) { /* coor format 5.1 */
+ if (0 >= dig__fread_port_I(&n_cats, 1, &(Map->dig_fp)))
+ return NULL;
+ }
+ else { /* coor format 5.0 */
+ if (0 >= dig__fread_port_C(&nc, 1, &(Map->dig_fp)))
+ return NULL;
+ n_cats = (int) nc;
+ }
+ G_debug(3, " n_cats = %d", n_cats);
+
+ if (Map->head.Version_Minor == 1) { /* coor format 5.1 */
+ size = (2 * PORT_INT) * n_cats;
+ }
+ else { /* coor format 5.0 */
+ size = (PORT_SHORT + PORT_INT) * n_cats;
+ }
+ dig_fseek(&(Map->dig_fp), size, SEEK_CUR);
+ }
+
if (*type & GV_POINTS) {
- n_points = 1;
+ n_points = 1;
}
else {
if (0 >= dig__fread_port_I(&n_points, 1, &(Map->dig_fp)))
Modified: grass/branches/develbranch_6/vector/v.select/geos.c
===================================================================
--- grass/branches/develbranch_6/vector/v.select/geos.c 2009-05-21 11:11:14 UTC (rev 37324)
+++ grass/branches/develbranch_6/vector/v.select/geos.c 2009-05-21 12:21:30 UTC (rev 37325)
@@ -7,22 +7,22 @@
#ifdef HAVE_GEOS
-static int relate_geos(const struct Map_info *, const GEOSGeometry *,
+static int relate_geos(struct Map_info *, const GEOSGeometry *,
int, int, const char *, int);
-int line_relate_geos(const struct Map_info *BIn, const GEOSGeometry * AGeom,
+int line_relate_geos(struct Map_info *BIn, const GEOSGeometry * AGeom,
int bline, int operator, const char *relate)
{
return relate_geos(BIn, AGeom, bline, operator, relate, 0);
}
-int area_relate_geos(const struct Map_info *BIn, const GEOSGeometry * AGeom,
+int area_relate_geos(struct Map_info *BIn, const GEOSGeometry * AGeom,
int barea, int operator, const char *relate)
{
return relate_geos(BIn, AGeom, barea, operator, relate, 1);
}
-int relate_geos(const struct Map_info *BIn, const GEOSGeometry * AGeom,
+int relate_geos(struct Map_info *BIn, const GEOSGeometry * AGeom,
int bfid, int operator, const char *relate, int area)
{
GEOSGeometry *BGeom = NULL;
@@ -32,7 +32,7 @@
if (area)
BGeom = Vect_read_area_geos(BIn, bfid);
else
- BGeom = Vect_read_line_geos(BIn, bfid);
+ BGeom = Vect_read_line_geos(BIn, bfid, NULL);
if (!BGeom)
return 0;
Modified: grass/branches/develbranch_6/vector/v.select/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.select/main.c 2009-05-21 11:11:14 UTC (rev 37324)
+++ grass/branches/develbranch_6/vector/v.select/main.c 2009-05-21 12:21:30 UTC (rev 37325)
@@ -245,24 +245,27 @@
}
/* Read line and check type */
- ltype = Vect_read_line(&(In[0]), APoints, NULL, aline);
- if (!(ltype & itype[0]))
- continue;
-
- Vect_get_line_box(&(In[0]), aline, &abox);
- abox.T = PORT_DOUBLE_MAX;
- abox.B = -PORT_DOUBLE_MAX;
-
if (flag.geos && flag.geos->answer) {
+#ifdef HAVE_GEOS
+ AGeom = Vect_read_line_geos(&(In[0]), aline, <ype);
+#endif
if (!(ltype & (GV_POINT | GV_LINE)))
continue;
-#ifdef HAVE_GEOS
- AGeom = Vect_line_to_geos(&(In[0]), APoints, ltype);
-#endif
+
if (!AGeom)
G_fatal_error(_("Unable to read line id %d from vector map <%s>"),
aline, Vect_get_full_name(&(In[0])));
}
+ else {
+ ltype = Vect_read_line(&(In[0]), APoints, NULL, aline);
+ }
+
+ if (!(ltype & itype[0]))
+ continue;
+
+ Vect_get_line_box(&(In[0]), aline, &abox);
+ abox.T = PORT_DOUBLE_MAX;
+ abox.B = -PORT_DOUBLE_MAX;
/* Check if this line overlaps any feature in B */
/* x Lines in B */
Modified: grass/branches/develbranch_6/vector/v.select/proto.h
===================================================================
--- grass/branches/develbranch_6/vector/v.select/proto.h 2009-05-21 11:11:14 UTC (rev 37324)
+++ grass/branches/develbranch_6/vector/v.select/proto.h 2009-05-21 12:21:30 UTC (rev 37325)
@@ -10,9 +10,9 @@
#ifdef HAVE_GEOS
/* geos.c */
-int line_relate_geos(const struct Map_info *, const GEOSGeometry *,
+int line_relate_geos(struct Map_info *, const GEOSGeometry *,
int, int, const char *);
-int area_relate_geos(const struct Map_info *, const GEOSGeometry *,
+int area_relate_geos(struct Map_info *, const GEOSGeometry *,
int, int, const char *);
#endif
More information about the grass-commit
mailing list