Map related classes, initial commit. Also added .gitignore file.
authorSami Rämö <sami.ramo@ixonos.com>
Mon, 29 Mar 2010 09:40:33 +0000 (12:40 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Mon, 29 Mar 2010 09:40:33 +0000 (12:40 +0300)
22 files changed:
.gitignore [new file with mode: 0644]
doc/map/map_class_diagram.dia [new file with mode: 0644]
src/map/mapengine.cpp [new file with mode: 0644]
src/map/mapengine.h [new file with mode: 0644]
src/map/mapscene.cpp [new file with mode: 0644]
src/map/mapscene.h [new file with mode: 0644]
src/map/maptile.cpp [new file with mode: 0644]
src/map/maptile.h [new file with mode: 0644]
src/map/mapview.cpp [new file with mode: 0644]
src/map/mapview.h [new file with mode: 0644]
tests/testMap/testMapEngine/testMapEngine [new file with mode: 0755]
tests/testMap/testMapEngine/testMapEngine.pro [new file with mode: 0644]
tests/testMap/testMapEngine/testmapengine.cpp [new file with mode: 0644]
tests/testMap/testMapScene/testMapScene [new file with mode: 0755]
tests/testMap/testMapScene/testMapScene.pro [new file with mode: 0644]
tests/testMap/testMapScene/testmapscene.cpp [new file with mode: 0644]
tests/testMap/testMapTile/testMapTile [new file with mode: 0755]
tests/testMap/testMapTile/testMapTile.pro [new file with mode: 0644]
tests/testMap/testMapTile/testmaptile.cpp [new file with mode: 0644]
tests/testMap/testMapView/testMapView [new file with mode: 0755]
tests/testMap/testMapView/testMapView.pro [new file with mode: 0644]
tests/testMap/testMapView/testmapview.cpp [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..4f0f80b
--- /dev/null
@@ -0,0 +1,13 @@
+# git-ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
+
+*.[oa]
+*~
+moc_*
+*.moc
+*.pro.user
+Makefile
diff --git a/doc/map/map_class_diagram.dia b/doc/map/map_class_diagram.dia
new file mode 100644 (file)
index 0000000..45f962b
Binary files /dev/null and b/doc/map/map_class_diagram.dia differ
diff --git a/src/map/mapengine.cpp b/src/map/mapengine.cpp
new file mode 100644 (file)
index 0000000..0e91fbe
--- /dev/null
@@ -0,0 +1,57 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Sami Rämö - sami.ramo@ixonos.com
+
+    Situare 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 2
+    of the License, or (at your option) any later version.
+
+    Situare 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 Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+#include <math.h>
+
+#include "mapengine.h"
+#include "maptile.h"
+
+MapEngine::MapEngine()
+{
+}
+
+MapEngine::MapEngine(MapView *mapView)
+{
+//    m_mapView = mapView;
+//    m_mapScene = new MapScene();
+//    mapView->setScene(m_mapScene);
+//
+//    /// \todo remove debug data
+//    for (int x=4261; x<=4264; x++) {
+//        for (int y=9352; y<=9353; y++) {
+//            MapTile *mapTile = new MapTile();
+//            mapTile->setZoomLevel(14);
+//            mapTile->setTileXY(x, y);
+//            mapTile->setPixmap(QPixmap("/home/ramosam-local/situare/src/map/static_test_tiles/14_9352_4261.png"));
+//            mapTile->setOffset((x-4261)*256, (y-9352)*256);
+//            m_mapScene->addMapTile(mapTile);
+//        }
+//    }
+}
+
+QPoint MapEngine::convertTileNumberToSceneCoordinate(int zoomLevel, QPoint tileNumber)
+{
+    int x = tileNumber.x() * TILE_SIZE_X * pow(2, MAX_ZOOM_LEVEL - zoomLevel);
+    int y = tileNumber.y() * TILE_SIZE_Y * pow(2, MAX_ZOOM_LEVEL - zoomLevel);
+
+    return QPoint(x, y);
+}
diff --git a/src/map/mapengine.h b/src/map/mapengine.h
new file mode 100644 (file)
index 0000000..85c8ff0
--- /dev/null
@@ -0,0 +1,47 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Sami Rämö - sami.ramo@ixonos.com
+
+    Situare 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 2
+    of the License, or (at your option) any later version.
+
+    Situare 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 Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+
+#ifndef MAPENGINE_H
+#define MAPENGINE_H
+
+#include "mapview.h"
+#include "mapscene.h"
+
+class MapEngine
+{
+public:
+    MapEngine();
+    MapEngine(MapView *mapView);
+    QPoint convertTileNumberToSceneCoordinate(int zoomLevel, QPoint tileNumber);
+
+public:
+    static const int TILE_SIZE_X = 256;
+    static const int TILE_SIZE_Y = 256;
+    static const int MAX_ZOOM_LEVEL = 18;
+
+private:
+    MapView *m_mapView;
+    MapScene *m_mapScene;
+};
+
+#endif // MAPENGINE_H
diff --git a/src/map/mapscene.cpp b/src/map/mapscene.cpp
new file mode 100644 (file)
index 0000000..385fa65
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Sami Rämö - sami.ramo@ixonos.com
+
+    Situare 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 2
+    of the License, or (at your option) any later version.
+
+    Situare 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 Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+
+#include "mapscene.h"
+
+MapScene::MapScene(QObject *parent) : QGraphicsScene(parent)
+{
+}
+
+void MapScene::addMapTile(MapTile *mapTile)
+{
+//    /// \todo set offset & transfor (=zoom)
+//    mapTile->setOffset(x, y);
+//    //mapTile->setTransform();
+//    addItem(mapTile);
+}
diff --git a/src/map/mapscene.h b/src/map/mapscene.h
new file mode 100644 (file)
index 0000000..67dfdfc
--- /dev/null
@@ -0,0 +1,40 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Sami Rämö - sami.ramo@ixonos.com
+
+    Situare 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 2
+    of the License, or (at your option) any later version.
+
+    Situare 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 Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+
+#ifndef MAPSCENE_H
+#define MAPSCENE_H
+
+#include <QGraphicsScene>
+
+#include "map/maptile.h"
+
+
+class MapScene : public QGraphicsScene
+{
+public:
+
+    MapScene(QObject *parent = 0);
+    void addMapTile(MapTile *mapTile);
+};
+
+#endif // MAPSCENE_H
diff --git a/src/map/maptile.cpp b/src/map/maptile.cpp
new file mode 100644 (file)
index 0000000..8232075
--- /dev/null
@@ -0,0 +1,48 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Sami Rämö - sami.ramo@ixonos.com
+
+    Situare 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 2
+    of the License, or (at your option) any later version.
+
+    Situare 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 Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+
+#include "maptile.h"
+
+MapTile::MapTile()
+{
+}
+
+quint8 MapTile::zoomLevel()
+{
+    return m_zoomLevel;
+}
+
+void MapTile::setZoomLevel(quint8 zoomLevel)
+{
+    m_zoomLevel = zoomLevel;
+}
+
+QPoint MapTile::tileNumber()
+{
+    return m_tileNumber;
+}
+
+void MapTile::setTileNumber(QPoint tileNumber)
+{
+    m_tileNumber = tileNumber;
+}
diff --git a/src/map/maptile.h b/src/map/maptile.h
new file mode 100644 (file)
index 0000000..ca04793
--- /dev/null
@@ -0,0 +1,44 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Sami Rämö - sami.ramo@ixonos.com
+
+    Situare 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 2
+    of the License, or (at your option) any later version.
+
+    Situare 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 Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+
+#ifndef MAPTILE_H
+#define MAPTILE_H
+
+#include <QGraphicsPixmapItem>
+#include <QPoint>
+
+class MapTile : public QGraphicsPixmapItem
+{
+public:
+    MapTile();
+    quint8 zoomLevel();
+    void setZoomLevel(quint8 zoomLevel);
+    QPoint tileNumber();
+    void setTileNumber(QPoint tileNumber);
+
+private:
+    quint32 m_zoomLevel;
+    QPoint m_tileNumber;
+};
+
+#endif // MAPTILE_H
diff --git a/src/map/mapview.cpp b/src/map/mapview.cpp
new file mode 100644 (file)
index 0000000..7da7ef7
--- /dev/null
@@ -0,0 +1,30 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Sami Rämö - sami.ramo@ixonos.com
+
+    Situare 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 2
+    of the License, or (at your option) any later version.
+
+    Situare 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 Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+
+#include "mapview.h"
+
+MapView::MapView(QWidget *parent) : QGraphicsView(parent)
+{
+    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+}
diff --git a/src/map/mapview.h b/src/map/mapview.h
new file mode 100644 (file)
index 0000000..2a2eb36
--- /dev/null
@@ -0,0 +1,35 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Sami Rämö - sami.ramo@ixonos.com
+
+    Situare 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 2
+    of the License, or (at your option) any later version.
+
+    Situare 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 Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+
+#ifndef MAPVIEW_H
+#define MAPVIEW_H
+
+#include <QGraphicsView>
+
+class MapView : public QGraphicsView
+{
+public:
+    MapView(QWidget *parent = 0);
+};
+
+#endif // MAPVIEW_H
diff --git a/tests/testMap/testMapEngine/testMapEngine b/tests/testMap/testMapEngine/testMapEngine
new file mode 100755 (executable)
index 0000000..6e76cc0
Binary files /dev/null and b/tests/testMap/testMapEngine/testMapEngine differ
diff --git a/tests/testMap/testMapEngine/testMapEngine.pro b/tests/testMap/testMapEngine/testMapEngine.pro
new file mode 100644 (file)
index 0000000..fd155bd
--- /dev/null
@@ -0,0 +1,14 @@
+# #####################################################################
+# Automatically generated by qmake (2.01a) Fri Mar 26 15:09:16 2010
+# #####################################################################
+CONFIG += qtestlib
+TEMPLATE = app
+TARGET = 
+DEPENDPATH += .
+INCLUDEPATH += . \
+    ../../../src/
+
+# Input
+SOURCES += testmapengine.cpp \
+    ../../../src/map/mapengine.cpp
+HEADERS += ../../../src/map/mapengine.h
diff --git a/tests/testMap/testMapEngine/testmapengine.cpp b/tests/testMap/testMapEngine/testmapengine.cpp
new file mode 100644 (file)
index 0000000..a19dcbc
--- /dev/null
@@ -0,0 +1,22 @@
+#include <QtTest/QtTest>
+
+#include "map/mapengine.h"
+
+class TestMapEngine: public QObject
+{
+    Q_OBJECT
+private slots:
+    void convertTileNumberToSceneCoordinate();
+};
+
+void TestMapEngine::convertTileNumberToSceneCoordinate()
+{
+    MapEngine mapEngine;
+
+    QCOMPARE(mapEngine.convertTileNumberToSceneCoordinate(18, QPoint(0,0)), QPoint(0,0));
+    QCOMPARE(mapEngine.convertTileNumberToSceneCoordinate(18, QPoint(1,2)), QPoint(256,512));
+    QCOMPARE(mapEngine.convertTileNumberToSceneCoordinate(16, QPoint(3,4)), QPoint(3072,4096));
+}
+
+QTEST_MAIN(TestMapEngine)
+#include "testmapengine.moc"
diff --git a/tests/testMap/testMapScene/testMapScene b/tests/testMap/testMapScene/testMapScene
new file mode 100755 (executable)
index 0000000..ee4b55f
Binary files /dev/null and b/tests/testMap/testMapScene/testMapScene differ
diff --git a/tests/testMap/testMapScene/testMapScene.pro b/tests/testMap/testMapScene/testMapScene.pro
new file mode 100644 (file)
index 0000000..1ec24d9
--- /dev/null
@@ -0,0 +1,16 @@
+# #####################################################################
+# Automatically generated by qmake (2.01a) Mon Mar 29 10:06:28 2010
+# #####################################################################
+CONFIG += qtestlib
+TEMPLATE = app
+TARGET = 
+DEPENDPATH += .
+INCLUDEPATH += . \
+    ../../../src/
+
+# Input
+SOURCES += testmapscene.cpp \
+    ../../../src/map/mapscene.cpp \
+    ../../../src/map/maptile.cpp
+HEADERS += ../../../src/map/mapscene.h \
+    ../../../src/map/maptile.h
diff --git a/tests/testMap/testMapScene/testmapscene.cpp b/tests/testMap/testMapScene/testmapscene.cpp
new file mode 100644 (file)
index 0000000..8abdfc1
--- /dev/null
@@ -0,0 +1,27 @@
+#include <QtTest/QtTest>
+
+#include "map/mapscene.h"
+#include "map/maptile.h"
+
+class TestMapScene : public QObject
+{
+    Q_OBJECT
+private slots:
+    void addMapTile();
+};
+
+void TestMapScene::addMapTile()
+{
+    MapScene mapScene;
+
+    MapTile mapTile;
+    mapTile.setZoomLevel(18);
+    mapTile.setTileNumber(QPoint(12, 47));
+
+    mapScene.addMapTile(&mapTile);
+
+    QVERIFY(mapTile.zoomLevel() == 13);
+}
+
+QTEST_MAIN(TestMapScene)
+#include "testmapscene.moc"
diff --git a/tests/testMap/testMapTile/testMapTile b/tests/testMap/testMapTile/testMapTile
new file mode 100755 (executable)
index 0000000..92a172a
Binary files /dev/null and b/tests/testMap/testMapTile/testMapTile differ
diff --git a/tests/testMap/testMapTile/testMapTile.pro b/tests/testMap/testMapTile/testMapTile.pro
new file mode 100644 (file)
index 0000000..70c9a69
--- /dev/null
@@ -0,0 +1,14 @@
+# #####################################################################
+# Automatically generated by qmake (2.01a) Mon Mar 29 10:06:28 2010
+# #####################################################################
+CONFIG += qtestlib
+TEMPLATE = app
+TARGET = 
+DEPENDPATH += .
+INCLUDEPATH += . \
+    ../../../src/
+
+# Input
+SOURCES += testmaptile.cpp \
+    ../../../src/map/maptile.cpp
+HEADERS += ../../../src/map/maptile.h
diff --git a/tests/testMap/testMapTile/testmaptile.cpp b/tests/testMap/testMapTile/testmaptile.cpp
new file mode 100644 (file)
index 0000000..d875c67
--- /dev/null
@@ -0,0 +1,28 @@
+#include <QtTest/QtTest>
+
+#include "map/maptile.h"
+
+class TestMapTile : public QObject
+{
+    Q_OBJECT
+private slots:
+    void zoomLevel();
+    void tileNumber();
+};
+
+void TestMapTile::zoomLevel()
+{
+    MapTile mapTile;
+    mapTile.setZoomLevel(13);
+    QVERIFY(mapTile.zoomLevel() == 13);
+}
+
+void TestMapTile::tileNumber()
+{
+    MapTile mapTile;
+    mapTile.setTileNumber(QPoint(24, 17));
+    QVERIFY(mapTile.tileNumber() == QPoint(24, 17));
+}
+
+QTEST_MAIN(TestMapTile)
+#include "testmaptile.moc"
diff --git a/tests/testMap/testMapView/testMapView b/tests/testMap/testMapView/testMapView
new file mode 100755 (executable)
index 0000000..a1d221c
Binary files /dev/null and b/tests/testMap/testMapView/testMapView differ
diff --git a/tests/testMap/testMapView/testMapView.pro b/tests/testMap/testMapView/testMapView.pro
new file mode 100644 (file)
index 0000000..fbd09d9
--- /dev/null
@@ -0,0 +1,14 @@
+# #####################################################################
+# Automatically generated by qmake (2.01a) Fri Mar 26 15:22:56 2010
+# #####################################################################
+CONFIG += qtestlib
+TEMPLATE = app
+TARGET = 
+DEPENDPATH += .
+INCLUDEPATH += . \
+    ../../../src/
+
+# Input
+SOURCES += testmapview.cpp \
+    ../../../src/map/mapview.cpp
+HEADERS += ../../../src/map/mapview.h
diff --git a/tests/testMap/testMapView/testmapview.cpp b/tests/testMap/testMapView/testmapview.cpp
new file mode 100644 (file)
index 0000000..7cfb174
--- /dev/null
@@ -0,0 +1,18 @@
+#include <QtTest/QtTest>
+
+#include "map/mapview.h"
+
+class TestMapView: public QObject
+{
+    Q_OBJECT
+private slots:
+    void dummyTestCase();
+};
+
+void TestMapView::dummyTestCase()
+{
+    QVERIFY(true);
+}
+
+QTEST_MAIN(TestMapView)
+#include "testmapview.moc"