On Tue, 27 Sep 2011, Michael Klein wrote:
Attached is also a simple implementation of the Douglas-Peucker algorithm in
Lua. Filtering a track with 3000 points takes only a few seconds on my dated
G4 Powerbook, and it seems most of the time is actually spent in
track.rebuild() *after* the Lua work. So performance is IMHO no showstopper.
the reason for track.rebuild() being rather slow is actually a Qt/Mac
deficiency, where QDateTime::toString(Qt::TextDate) if rather expensive.
I filed a bug: https://bugreports.qt.nokia.com/browse/QTBUG-21678
Attached is a workaround. I'm sure you don't like it very much. I don't
like it either, but waiting several seconds for Qt+Apple to format a few
silly date string is no fun either. It brings loading a track with
~3000 points into the track editor from 6-7 seconds down to 1-2 seconds.
The other patch fixes a runtime warning because of missing keys in
Info.plist.
--
Michael
registered linux user #189917 -- http://counter.li.org/
From 573bcff88161640a615d4311f2800143fffa66e9 Mon Sep 17 00:00:00 2001
From: Michael Klein <[email protected]>
Date: Tue, 20 Sep 2011 20:44:51 +0200
Subject: [PATCH 1/2] add CFBundleTypeRole to info.plist
---
MacOSX/Info.plist.in | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/MacOSX/Info.plist.in b/MacOSX/Info.plist.in
index dcea43a..341f41d 100644
--- a/MacOSX/Info.plist.in
+++ b/MacOSX/Info.plist.in
@@ -43,6 +43,8 @@
<string>GPS exchange data</string>
<key>CFBundleTypeIconFile</key>
<string>qlandkartegt-gpx.icns</string>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
@@ -53,6 +55,8 @@
<string>QLandkarte data</string>
<key>CFBundleTypeIconFile</key>
<string>qlandkartegt-qlb.icns</string>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
@@ -63,6 +67,8 @@
<string>TrainingsCenterExchange data</string>
<key>CFBundleTypeIconFile</key>
<string>qlandkartegt-tcx.icns</string>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
@@ -73,6 +79,8 @@
<string>MapSource data</string>
<key>CFBundleTypeIconFile</key>
<string>qlandkartegt-gdb.icns</string>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
@@ -83,6 +91,8 @@
<string>Google Earth (Keyhole) data</string>
<key>CFBundleTypeIconFile</key>
<string>qlandkartegt-kml.icns</string>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
@@ -93,6 +103,8 @@
<string>Geocaching.com - EasyGPS data</string>
<key>CFBundleTypeIconFile</key>
<string>qlandkartegt-loc.icns</string>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
@@ -103,6 +115,8 @@
<string>OziExplorer track</string>
<key>CFBundleTypeIconFile</key>
<string>qlandkartegt-plt.icns</string>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
@@ -113,6 +127,8 @@
<string>OziExplorer route</string>
<key>CFBundleTypeIconFile</key>
<string>qlandkartegt-rte.icns</string>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
@@ -123,6 +139,8 @@
<string>OziExplorer waypoint</string>
<key>CFBundleTypeIconFile</key>
<string>qlandkartegt-wpt.icns</string>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
</dict>
</array>
</dict>
--
1.7.6.1
From 08e58eb8cc3f82f1a58a20ebdab76cc833fd3878 Mon Sep 17 00:00:00 2001
From: Michael Klein <[email protected]>
Date: Wed, 28 Sep 2011 23:16:56 +0200
Subject: [PATCH 2/2] work around slow QDateTime::toString() on OS X
---
src/CMakeLists.txt | 1 +
src/CTrackEditWidget.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 09b79dd..4c5af48 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -617,6 +617,7 @@ if (APPLE)
add_executable(${PROGNAME} MACOSX_BUNDLE ${qlandkarte_ALLINP}
${MAC_EXTRA_RES})
set_target_properties(${PROGNAME} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/MacOSX/Info.plist.in
+ LINK_FLAGS "-framework CoreFoundation"
)
add_custom_target(mac-deploy macdeployqt "${MAC_BUNDLE_PATH}"
diff --git a/src/CTrackEditWidget.cpp b/src/CTrackEditWidget.cpp
index 3ecb683..87a6312 100644
--- a/src/CTrackEditWidget.cpp
+++ b/src/CTrackEditWidget.cpp
@@ -41,6 +41,38 @@
#include <QtGui>
+
+#ifdef Q_WS_MAC
+#include <CoreFoundation/CoreFoundation.h>
+
+template<class T>
+class CFType
+{
+public:
+ CFType(const T & t) : ref(t) { }
+ ~CFType() { CFRelease(ref); }
+ operator T() const { return ref; }
+
+private:
+ T ref;
+};
+
+static QString CFStringToQString(const CFStringRef & str)
+{
+ CFIndex length = CFStringGetLength(str);
+ const UniChar * chars = CFStringGetCharactersPtr(str);
+ if (chars == 0) {
+ UniChar buffer[length];
+ CFStringGetCharacters(str, CFRangeMake(0, length), buffer);
+ return QString(reinterpret_cast<const QChar *>(buffer), length);
+ } else {
+ return QString(reinterpret_cast<const QChar *>(chars), length);
+ }
+}
+
+#endif
+
+
bool CTrackTreeWidgetItem::operator< ( const QTreeWidgetItem & other ) const
{
const QString speed("/h");
@@ -497,6 +529,13 @@ void CTrackEditWidget::slotUpdate()
QList<CTrack::pt_t>& trkpts = track->getTrackPoints();
QList<CTrack::pt_t>::iterator trkpt = trkpts.begin();
+#ifdef Q_WS_MAC
+ // work around https://bugreports.qt.nokia.com/browse/QTBUG-21678
+ CFType<CFLocaleRef> loc(CFLocaleCopyCurrent());
+ CFType<CFDateFormatterRef> df(CFDateFormatterCreate(NULL, loc,
kCFDateFormatterNoStyle, kCFDateFormatterNoStyle));
+ CFDateFormatterSetFormat(df, CFSTR("EEE MMM d HH:mm:ss yyyy"));
+#endif
+
while(trkpt != trkpts.end())
{
CTrackTreeWidgetItem * item;
@@ -576,7 +615,13 @@ void CTrackEditWidget::slotUpdate()
{
QDateTime time = QDateTime::fromTime_t(trkpt->timestamp);
time.setTimeSpec(Qt::LocalTime);
+#ifdef Q_WS_MAC
+ CFType<CFDateRef> cfdate(CFDateCreate(NULL, time.toTime_t() -
kCFAbsoluteTimeIntervalSince1970));
+ CFType<CFStringRef>
cfstr(CFDateFormatterCreateStringWithDate(NULL, df, cfdate));
+ str = CFStringToQString(cfstr);
+#else
str = time.toString();
+#endif
}
else
{
--
1.7.6.1
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Qlandkartegt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users