[GRASS-SVN] r55759 - grass/trunk/lib/vector/diglib
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Apr 13 08:12:38 PDT 2013
Author: mmetz
Date: 2013-04-13 08:12:38 -0700 (Sat, 13 Apr 2013)
New Revision: 55759
Modified:
grass/trunk/lib/vector/diglib/cindex.c
Log:
diglib: resolve ties for dig_cidx_sort()
Modified: grass/trunk/lib/vector/diglib/cindex.c
===================================================================
--- grass/trunk/lib/vector/diglib/cindex.c 2013-04-13 15:11:56 UTC (rev 55758)
+++ grass/trunk/lib/vector/diglib/cindex.c 2013-04-13 15:12:38 UTC (rev 55759)
@@ -135,7 +135,7 @@
return 1;
}
-/* Compare by cat */
+/* Compare by cat, resolve ties by type, resolve ties by id */
static int cmp_cat(const void *pa, const void *pb)
{
int *p1 = (int *)pa;
@@ -145,6 +145,14 @@
return -1;
if (p1[0] > p2[0])
return 1;
+ if (p1[1] < p2[1])
+ return -1;
+ if (p1[1] > p2[1])
+ return 1;
+ if (p1[2] < p2[2])
+ return -1;
+ if (p1[2] > p2[2])
+ return 1;
return 0;
}
@@ -334,7 +342,7 @@
ci = &(Plus->cidx[f]);
- /* Sort by category */
+ /* Sort by 1. category, 2. type, 3. line id */
qsort(ci->cat, ci->n_cats, 3 * sizeof(int), cmp_cat);
/* Calculate number of unique cats */
More information about the grass-commit
mailing list