One of the most annoying things to me in Merkaartor is that when I
select two objects (one after another) to compare their tags, they
always are in a different order. It's hard to tell quickly whether they
have the same tags and values assigned. The only solution to this is to
sort the tags in the list. This is what my patch does. It may not be the
most efficient sorting algorithm, in fact it's the first I was thinking
of, to sort the items in-place. It is working fine for me, I could not
determine any data corruption in a small test and it doesn't lead to a
sensible delay. (How could that be for a list of < 10 items...)
Here you go. Feel free to use it. :)
Any ideas about that? Certain requirements that I've missed? Errors in
my code?
Maybe this could be improved by applying a certain pre-defined order
different from the lexical. For example: highway < service < name <
maxspeed < * < note < created_by. That would be more of an order by
importance first, then tag name.
The patch is meant to be applied to 0.13-svn from 2008-01-02.
--
Yves Goergen "LonelyPixel" <[email protected]>
Visit my web laboratory at http://beta.unclassified.de
--- merkaartor\TagModel.cpp.orig Fri Jan 02 23:21:14 2009
+++ merkaartor\TagModel.cpp Sat Jan 03 15:57:32 2009
@@ -37,6 +37,29 @@
if (!F->tagKey(i).startsWith("%kml:"))
Tags.push_back(std::make_pair(F->tagKey(i),F->tagValue(i)));
}
+
+ // Sort all tags by their key
+ bool exchanged;
+ do
+ {
+ exchanged = false;
+ for (int m = 0; m < Tags.size(); m++)
+ {
+ for (int n = m; n < Tags.size(); n++)
+ {
+ if (Tags[m].first > Tags[n].first)
+ {
+ // Swap Tags items m and n
+ std::pair<QString, QString> p =
Tags[m];
+ Tags[m] = Tags[n];
+ Tags[n] = p;
+ exchanged = true;
+ }
+ }
+ }
+ }
+ while (exchanged);
+
beginInsertRows(QModelIndex(),0,Tags.size());
endInsertRows();
}
_______________________________________________
Merkaartor mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/merkaartor