[GRASS5] reorder points so that little one are in front of big
ones in d.vect.chart
Moritz Lennert
mlennert at club.worldonline.be
Fri Dec 17 12:36:08 EST 2004
On Fri, December 17, 2004 13:04, Moritz Lennert said:
> On Fri, December 17, 2004 0:03, Hamish said:
>>
>> better idea: someone fixes d.vect.chart
>>
>
> I've had a look at d.vect.chart. If I understand correctly, the pies plotting
> is done via the pie() function defined in pie.c. And if I further understand
> correctly, it should be enough to sort the Points structure, once all points
> have been appended, i.e. after line 50. Points is defined in line 43 by
>
> Points = Vect_new_line_struct ();
>
> So we would need to sort this structure. Before I delve into the source code
> and doxygen manual, could someone tell me if sorting functions for qsort
> alreay exist for such structures ? And, whether I am on the right path ? ;-)
>
I've realised that above is completely wrong. It is in plot.c that all the
points are treated, pie.c creates individual pies.
The problem I see now, is that plot.c calls the database table for each vector
element, fetches the necessary data, calls pie to draw the relevant pie and
then goes on to the next element. This makes sorting impossible as the pies
are drawn one by one directly from the database table.
So I can see three possible solutions:
1) create a temporary table sorted in descending order by sizecol and fetch
the elements from there
2) read the complete elements into memory and sort them.
3) read cat and sizecol into memory, sort them and then fetch elements from
the database table in the order of the sorted cat/sizecol.
Solution 2 would certainly be the fastest, but would cause problems if there
are too many elements. So solution 3 sounds like the best to me, but I don't
know how much slower a fetch by cat would be then fetching the elements in
simple line order ?
Any reflections ? Anything I've missed or misunderstood ?
Moritz
More information about the grass-dev
mailing list