--- /dev/null
+/*
+ * This file is part of jSpeed.
+ *
+ * jSpeed is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * jSpeed is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with jSpeed. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <QtCore/QFile>
+#include <QtCore/QString>
+#include <QtCore/QByteArray>
+#include <QtCore/QDebug>
+#include <QtCore/QRegExp>
+#include "poiascreader.h"
+
+PoiAscReader::PoiAscReader(QString filename): PoiReader(), filename_(filename)
+{
+}
+
+bool PoiAscReader::read(QList<Poi>& pois)
+{
+ QFile file(filename_);
+
+ if(!file.open(QIODevice::ReadOnly))
+ {
+ setError("Unable to open file (check permissions)");
+ return false;
+ }
+
+ QString data = QString(file.readAll());
+ static QRegExp matcher("([0-9]{1,3})\\.([0-9]+), ([0-9]{1,3})\\.([0-9]+), \"(.*)\"");
+ matcher.setMinimal(true);
+
+ int pos = 0;
+
+ while((pos = matcher.indexIn(data, pos)) != -1)
+ {
+ pos += matcher.matchedLength();
+
+ Poi poi;
+
+ bool ok;
+
+ QString latitude = matcher.cap(1) + "." + matcher.cap(2);
+ QString longitude = matcher.cap(3) + "." + matcher.cap(4);
+
+ double doubleLatitude = latitude.toDouble(&ok);
+
+ if(!ok)
+ {
+ continue;
+ }
+
+ double doubleLongitude = longitude.toDouble(&ok);
+
+ if(!ok)
+ {
+ continue;
+ }
+
+ poi.latitude = doubleLatitude;
+ poi.longitude = doubleLongitude;
+ poi.name = matcher.cap(5);
+
+ pois.push_back(poi);
+
+ }
+
+ if(pois.size() == 0)
+ {
+ setError("No valid poi data found from file");
+ return false;
+ }
+
+ return true;
+}