* @param kkj the KKJ coordinate
* @return the zone number or -1 on error
*/
- static int getZoneNumberFromEasting(const KKJ &kkj);
+ static int getZoneNumberFromEasting(const KKJGridCoordinate &kkj);
/**
* Determines a zone number from the KKJ longitude value. If the longitude is not within any of
{33.0, 5500000.0} };// zone 5
-int KKJZone::getZoneNumberFromEasting(const KKJ &kkj) {
+int KKJZone::getZoneNumberFromEasting(const KKJGridCoordinate &kkj) {
int zoneNumber = floor(kkj.easting() / 1000000.0);
if (zoneNumber < MIN_ZONE || zoneNumber > MAX_ZONE) {
zoneNumber = -1;
* @param zoneNumber the zone number in which the input coordinate resides
* @return the transformed coordinate
*/
-KKJ transformToKKJGridCoordinate(const KKJGeoCoordinate &fromCoordinate) {
+KKJGridCoordinate transformToKKJGridCoordinate(const KKJGeoCoordinate &fromCoordinate) {
int zoneNumber = KKJZone::getZoneNumberFromLongitude(fromCoordinate);
double Lo = radians(fromCoordinate.longitude()) - radians(KKJZone::getCentralMeridianOfZone(zoneNumber));
double cosLa = cos(radians(fromCoordinate.latitude()));
unsigned int outY = A1 * LaF - A2 * sin(2.0 * LaF) + A3 * sin(4.0 * LaF) - A4 * sin(6.0 * LaF);
unsigned int outX = HayfordEllipsoid::c * log(t + sqrt(1.0 + t * t)) + 500000.0 + zoneNumber * 1000000.0;
- return KKJ(outY, outX);
+ return KKJGridCoordinate(outY, outX);
}
/**
* @param fromCoordinate the input coordinate
* @return the transformed coordinate
*/
-KKJGeoCoordinate transformToKKJGeoCoordinate(const KKJ &fromCoordinate) {
+KKJGeoCoordinate transformToKKJGeoCoordinate(const KKJGridCoordinate &fromCoordinate) {
// Scan iteratively the target area, until find matching
// KKJ coordinate value. Area is defined with Hayford Ellipsoid.
double minLo = 18.5;
double deltaLa = maxLa - minLa;
ret.setLongitude(minLo + 0.5 * deltaLo);
ret.setLatitude(minLa + 0.5 * deltaLa);
- KKJ kkj = transformToKKJGridCoordinate(ret);
+ KKJGridCoordinate kkj = transformToKKJGridCoordinate(ret);
if (kkj.northing() < fromCoordinate.northing()) {
minLa = minLa + 0.45 * deltaLa;
} else {
}
-KKJ CoordinateSystemTransformer::transformToKKJ(const QGeoCoordinate &fromCoordinate)
+KKJGridCoordinate CoordinateSystemTransformer::transformToKKJ(const QGeoCoordinate &fromCoordinate)
{
KKJGeoCoordinate tmpKKJ = transformToKKJGeoCoordinate(fromCoordinate);
return transformToKKJGridCoordinate(tmpKKJ);
}
-QGeoCoordinate CoordinateSystemTransformer::transformToWGS84(const KKJ &fromCoordinate)
+QGeoCoordinate CoordinateSystemTransformer::transformToWGS84(const KKJGridCoordinate &fromCoordinate)
{
KKJGeoCoordinate tmpKKJ = transformToKKJGeoCoordinate(fromCoordinate);
return transformToWGS84GeoCoordinate(tmpKKJ);
#ifndef COORDINATESYSTEMTRANSFORMER_H
#define COORDINATESYSTEMTRANSFORMER_H
-#include "kkj.h"
+#include "kkjgridcoordinate.h"
#include <QGeoCoordinate>
/**
* @param fromCoordinate the WGS84 coordinate that will be transformed.
* @return the transformed coordinate in KKJ coordinate system.
*/
- static KKJ transformToKKJ(const QTM_NAMESPACE::QGeoCoordinate &fromCoordinate);
+ static KKJGridCoordinate transformToKKJ(const QTM_NAMESPACE::QGeoCoordinate &fromCoordinate);
/**
* Makes a coordinate transformation from KKJ rectangular grid coordinate system
* @param fromCoordinate the KKJ coordinate that will be transformed.
* @return the transformed coordinate in WGS84 coordinate system.
*/
- static QTM_NAMESPACE::QGeoCoordinate transformToWGS84(const KKJ &fromCoordinate);
+ static QTM_NAMESPACE::QGeoCoordinate transformToWGS84(const KKJGridCoordinate &fromCoordinate);
};
#endif // COORDINATESYSTEMTRANSFORMER_H
+++ /dev/null
-#include "kkj.h"
-#include "kkj_p.h"
-
-KKJPrivate::~KKJPrivate()
-{
-}
-
-void KKJPrivate::init(unsigned int northing, unsigned int easting)
-{
- this->northing = northing;
- this->easting = easting;
-}
-
-
-KKJ::KKJ(unsigned int northing, unsigned int easting) :
- d_ptr(new KKJPrivate)
-{
- Q_D(KKJ);
- d->q_ptr = this;
- d->init(northing, easting);
-}
-
-KKJ::KKJ(KKJPrivate &dd, unsigned int northing, unsigned int easting) :
- d_ptr(&dd)
-{
- Q_D(KKJ);
- d->q_ptr = this;
- d->init(northing, easting);
-}
-
-KKJ::~KKJ()
-{
-}
-
-bool KKJ::operator==(const KKJ &rhs) const
-{
- return northing() == rhs.northing() && easting() == rhs.easting();
-}
-
-KKJ& KKJ::operator=(const KKJ &rhs)
-{
- Q_D(KKJ);
- d->northing = rhs.northing();
- d->easting = rhs.easting();
-
- return *this;
-}
-
-unsigned int KKJ::northing() const
-{
- Q_D(const KKJ);
- return d->northing;
-}
-
-unsigned int KKJ::easting() const
-{
- Q_D(const KKJ);
- return d->easting;
-}
+++ /dev/null
-#ifndef KKJ_H
-#define KKJ_H
-
-#include <QtGlobal>
-
-class KKJPrivate;
-
-/**
- * A class representing the Finnish KKJ coordinate.
- * This is the rectangular grid coordinate version.
- */
-class KKJ
-{
-public:
- /**
- * Constructs a new KKJ coordinate with the given values.
- * @param northing the northing coordinate.
- * @param easting the easting coordinate.
- */
- KKJ(unsigned int northing, unsigned int easting);
-
- /**
- * Destructor.
- */
- virtual ~KKJ();
-
- /**
- * Equals operator.
- * Tests the equality of this coordinate and another coordinate and returns \c true
- * if the coordinates represent the same position.
- * @param rhs the other coordinate to test against.
- * @return \c true if the coordinates are the same, \c false otherwise.
- */
- bool operator==(const KKJ &rhs) const;
-
- /**
- * Assignment operator.
- * @param rhs the object that is copied.
- * @return this object.
- */
- KKJ& operator=(const KKJ &rhs);
-
- /**
- * Returns the northing of the coordinate.
- * @return the northing.
- */
- unsigned int northing() const;
-
- /**
- * Returns the easting of the coordinate.
- * @return the easting.
- */
- unsigned int easting() const;
-
-protected:
- /**
- * Constructs a new KKJ coordinate with the given values.
- * @param dd a private implementation member.
- * @param northing the northing coordinate.
- * @param easting the easting coordinate.
- */
- KKJ(KKJPrivate &dd, unsigned int northing, unsigned int easting);
-
-
-private:
- /// Pointer to the private member
- KKJPrivate *const d_ptr;
-
- Q_DECLARE_PRIVATE(KKJ)
-
-};
-
-#endif // KKJ_H
+++ /dev/null
-#ifndef KKJ_P_H
-#define KKJ_P_H
-
-#include <QtGlobal>
-
-class KKJ;
-
-/**
- * A private member class for class KKJ.
- */
-class KKJPrivate
-{
-public:
- /**
- * Destructor.
- */
- virtual ~KKJPrivate();
-
-private:
- /**
- * Initializes the private class.
- * @param northing the northing of the coordinate.
- * @param easting the easting of the coordinate.
- */
- void init(unsigned int northing, unsigned int easting);
-
- /// The northing of the coordinate.
- unsigned int northing;
-
- /// The easting of the coordinate.
- unsigned int easting;
-
- /// The concrete class owning this private implementation member.
- KKJ *q_ptr;
-
- Q_DECLARE_PUBLIC(KKJ)
-
-};
-
-#endif // KKJ_P_H
--- /dev/null
+#include "kkjgridcoordinate.h"
+#include "kkjgridcoordinate_p.h"
+
+KKJGridCoordinatePrivate::~KKJGridCoordinatePrivate()
+{
+}
+
+void KKJGridCoordinatePrivate::init(unsigned int northing, unsigned int easting)
+{
+ this->northing = northing;
+ this->easting = easting;
+}
+
+
+KKJGridCoordinate::KKJGridCoordinate(unsigned int northing, unsigned int easting) :
+ d_ptr(new KKJGridCoordinatePrivate)
+{
+ Q_D(KKJGridCoordinate);
+ d->q_ptr = this;
+ d->init(northing, easting);
+}
+
+KKJGridCoordinate::KKJGridCoordinate(KKJGridCoordinatePrivate &dd, unsigned int northing, unsigned int easting) :
+ d_ptr(&dd)
+{
+ Q_D(KKJGridCoordinate);
+ d->q_ptr = this;
+ d->init(northing, easting);
+}
+
+KKJGridCoordinate::~KKJGridCoordinate()
+{
+}
+
+bool KKJGridCoordinate::operator==(const KKJGridCoordinate &rhs) const
+{
+ return northing() == rhs.northing() && easting() == rhs.easting();
+}
+
+KKJGridCoordinate& KKJGridCoordinate::operator=(const KKJGridCoordinate &rhs)
+{
+ Q_D(KKJGridCoordinate);
+ d->northing = rhs.northing();
+ d->easting = rhs.easting();
+
+ return *this;
+}
+
+unsigned int KKJGridCoordinate::northing() const
+{
+ Q_D(const KKJGridCoordinate);
+ return d->northing;
+}
+
+unsigned int KKJGridCoordinate::easting() const
+{
+ Q_D(const KKJGridCoordinate);
+ return d->easting;
+}
--- /dev/null
+#ifndef KKJGRIDCOORDINATE_H
+#define KKJGRIDCOORDINATE_H
+
+#include <QtGlobal>
+
+class KKJGridCoordinatePrivate;
+
+/**
+ * A class representing the Finnish KKJ coordinate.
+ * This is the rectangular grid coordinate version.
+ */
+class KKJGridCoordinate
+{
+public:
+ /**
+ * Constructs a new KKJ coordinate with the given values.
+ * @param northing the northing coordinate.
+ * @param easting the easting coordinate.
+ */
+ KKJGridCoordinate(unsigned int northing, unsigned int easting);
+
+ /**
+ * Destructor.
+ */
+ virtual ~KKJGridCoordinate();
+
+ /**
+ * Equals operator.
+ * Tests the equality of this coordinate and another coordinate and returns \c true
+ * if the coordinates represent the same position.
+ * @param rhs the other coordinate to test against.
+ * @return \c true if the coordinates are the same, \c false otherwise.
+ */
+ bool operator==(const KKJGridCoordinate &rhs) const;
+
+ /**
+ * Assignment operator.
+ * @param rhs the object that is copied.
+ * @return this object.
+ */
+ KKJGridCoordinate& operator=(const KKJGridCoordinate &rhs);
+
+ /**
+ * Returns the northing of the coordinate.
+ * @return the northing.
+ */
+ unsigned int northing() const;
+
+ /**
+ * Returns the easting of the coordinate.
+ * @return the easting.
+ */
+ unsigned int easting() const;
+
+protected:
+ /**
+ * Constructs a new KKJ coordinate with the given values.
+ * @param dd a private implementation member.
+ * @param northing the northing coordinate.
+ * @param easting the easting coordinate.
+ */
+ KKJGridCoordinate(KKJGridCoordinatePrivate &dd, unsigned int northing, unsigned int easting);
+
+
+private:
+ /// Pointer to the private member
+ KKJGridCoordinatePrivate *const d_ptr;
+
+ Q_DECLARE_PRIVATE(KKJGridCoordinate)
+
+};
+
+#endif // KKJGRIDCOORDINATE_H
--- /dev/null
+#ifndef KKJGRIDCOORDINATE_P_H
+#define KKJGRIDCOORDINATE_P_H
+
+#include <QtGlobal>
+
+class KKJGridCoordinate;
+
+/**
+ * A private member class for class KKJGridCoordinate.
+ */
+class KKJGridCoordinatePrivate
+{
+public:
+ /**
+ * Destructor.
+ */
+ virtual ~KKJGridCoordinatePrivate();
+
+private:
+ /**
+ * Initializes the private class.
+ * @param northing the northing of the coordinate.
+ * @param easting the easting of the coordinate.
+ */
+ void init(unsigned int northing, unsigned int easting);
+
+ /// The northing of the coordinate.
+ unsigned int northing;
+
+ /// The easting of the coordinate.
+ unsigned int easting;
+
+ /// The concrete class owning this private implementation member.
+ KKJGridCoordinate *q_ptr;
+
+ Q_DECLARE_PUBLIC(KKJGridCoordinate)
+
+};
+
+#endif // KKJGRIDCOORDINATE_P_H
TARGET = ptascommon
INSTALL_HEADERS = \
- kkj.h
+ coordinatesystemtransformer.h \
+ kkjgridcoordinate.h \
+
PRIVATE_HEADERS = \
- kkj_p.h
+ kkjgridcoordinate_p.h
HEADERS += \
$$INSTALL_HEADERS \
$$PRIVATE_HEADERS
SOURCES += \
- kkj.cpp
+ coordinatesystemtransformer.cpp \
+ kkjgridcoordinate.cpp
TEMPLATE = subdirs
SUBDIRS = \
ut_coordinatesystemtransformer \
- ut_kkj
+ ut_kkjgridcoordinate
check.target = check
check.CONFIG = recursive
class CoordinateSystemTransformerTest : public ::testing::Test
{
public:
- QList<QPair<QTM_NAMESPACE::QGeoCoordinate, KKJ> > testData;
+ QList<QPair<QTM_NAMESPACE::QGeoCoordinate, KKJGridCoordinate> > testData;
CoordinateSystemTransformerTest() {
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.2528, 25.02051), KKJ(6682815, 2556686));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.18713, 24.832), KKJ(6675352, 2546340));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.27414, 25.04465), KKJ(6685213, 2557985));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.2507, 25.01767), KKJ(6682578, 2556532));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.2902, 24.44804), KKJ(6686629, 2524959));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.35033, 25.06718), KKJ(6693721, 2559094));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25471, 25.02373), KKJ(6683030, 2556861));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25417, 25.0242), KKJ(6682971, 2556888));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.39737, 25.08981), KKJ(6698983, 2560257));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.28923, 25.12709), KKJ(6686969, 2562518));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.1727, 24.65643), KKJ(6673635, 2536615));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.35133, 25.06764), KKJ(6693833, 2559118));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.34949, 25.06874), KKJ(6693629, 2559182));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25119, 25.02518), KKJ(6682640, 2556947));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25196, 25.02294), KKJ(6682723, 2556822));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.34929, 25.06705), KKJ(6693605, 2559089));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.18855, 24.83393), KKJ(6675512, 2546445));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25091, 25.02547), KKJ(6682609, 2556964));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25321, 25.0215), KKJ(6682861, 2556740));
- testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.35291, 25.06559), KKJ(6694007, 2559002));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.2528, 25.02051), KKJGridCoordinate(6682815, 2556686));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.18713, 24.832), KKJGridCoordinate(6675352, 2546340));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.27414, 25.04465), KKJGridCoordinate(6685213, 2557985));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.2507, 25.01767), KKJGridCoordinate(6682578, 2556532));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.2902, 24.44804), KKJGridCoordinate(6686629, 2524959));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.35033, 25.06718), KKJGridCoordinate(6693721, 2559094));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25471, 25.02373), KKJGridCoordinate(6683030, 2556861));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25417, 25.0242), KKJGridCoordinate(6682971, 2556888));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.39737, 25.08981), KKJGridCoordinate(6698983, 2560257));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.28923, 25.12709), KKJGridCoordinate(6686969, 2562518));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.1727, 24.65643), KKJGridCoordinate(6673635, 2536615));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.35133, 25.06764), KKJGridCoordinate(6693833, 2559118));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.34949, 25.06874), KKJGridCoordinate(6693629, 2559182));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25119, 25.02518), KKJGridCoordinate(6682640, 2556947));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25196, 25.02294), KKJGridCoordinate(6682723, 2556822));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.34929, 25.06705), KKJGridCoordinate(6693605, 2559089));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.18855, 24.83393), KKJGridCoordinate(6675512, 2546445));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25091, 25.02547), KKJGridCoordinate(6682609, 2556964));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.25321, 25.0215), KKJGridCoordinate(6682861, 2556740));
+ testData << qMakePair(QTM_NAMESPACE::QGeoCoordinate(60.35291, 25.06559), KKJGridCoordinate(6694007, 2559002));
}
};
TEST_F(CoordinateSystemTransformerTest, WGS84CoordinatesToKKJCoordinates)
{
- QListIterator<QPair<QTM_NAMESPACE::QGeoCoordinate, KKJ> > it(testData);
+ QListIterator<QPair<QTM_NAMESPACE::QGeoCoordinate, KKJGridCoordinate> > it(testData);
while (it.hasNext()) {
- const QPair<QTM_NAMESPACE::QGeoCoordinate, KKJ> &datum = it.next();
- KKJ result = CoordinateSystemTransformer::transformToKKJ(datum.first);
- KKJ expected = datum.second;
+ const QPair<QTM_NAMESPACE::QGeoCoordinate, KKJGridCoordinate> &datum = it.next();
+ KKJGridCoordinate result = CoordinateSystemTransformer::transformToKKJ(datum.first);
+ KKJGridCoordinate expected = datum.second;
// Allow one unit difference from the expected
int northDiff = abs((long)expected.northing() - (long)result.northing());
int eastDiff = abs((long)expected.easting() - (long)result.easting());
TEST_F(CoordinateSystemTransformerTest, KKJCoordinatesToWGS84Coordinates)
{
- QListIterator<QPair<QTM_NAMESPACE::QGeoCoordinate, KKJ> > it(testData);
+ QListIterator<QPair<QTM_NAMESPACE::QGeoCoordinate, KKJGridCoordinate> > it(testData);
while (it.hasNext()) {
- const QPair<QTM_NAMESPACE::QGeoCoordinate, KKJ> &datum = it.next();
+ const QPair<QTM_NAMESPACE::QGeoCoordinate, KKJGridCoordinate> &datum = it.next();
QTM_NAMESPACE::QGeoCoordinate result = CoordinateSystemTransformer::transformToWGS84(datum.second);
QTM_NAMESPACE::QGeoCoordinate expected = datum.first;
// Allow small difference from the expected
SOURCES += \
ut_coordinatesystemtransformer.cpp \
$$SRCDIR/coordinatesystemtransformer.cpp \
- $$SRCDIR/kkj.cpp
+ $$SRCDIR/kkjgridcoordinate.cpp
HEADERS += \
$$SRCDIR/coordinatesystemtransformer.h \
- $$SRCDIR/kkj.h
+ $$SRCDIR/kkjgridcoordinate.h
include(../gmock.pri)
include(../check.pri)
+++ /dev/null
-Makefile
-ut_kkj
+++ /dev/null
-#include "kkj.h"
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#include "stlhelpers.h"
-
-class KKJTest : public ::testing::Test
-{
-public:
- const unsigned int northing;
- const unsigned int easting;
-
- KKJTest() :
- northing(6682815),
- easting(2556686)
- {
- }
-};
-
-TEST_F(KKJTest, ConstructorValuesReceivedViaGetters)
-{
- KKJ kkj(northing , easting);
- ASSERT_EQ(northing, kkj.northing());
- ASSERT_EQ(easting, kkj.easting());
-}
-
-TEST_F(KKJTest, EqualsOperatorReturnsTrueForEqualCoordinates)
-{
- KKJ kkj1(northing, easting);
- KKJ kkj2(northing, easting);
- ASSERT_TRUE(kkj1 == kkj2);
-}
-
-TEST_F(KKJTest, EqualsOperatorReturnsFalseForCoordinatesWithDifferentNorthing)
-{
- KKJ kkj1(northing - 1, easting);
- KKJ kkj2(northing, easting);
- ASSERT_FALSE(kkj1 == kkj2);
-}
-
-TEST_F(KKJTest, EqualsOperatorReturnsFalseForCoordinatesWithDifferentEasting)
-{
- KKJ kkj1(northing, easting - 1);
- KKJ kkj2(northing, easting);
- ASSERT_FALSE(kkj1 == kkj2);
-}
-
-TEST_F(KKJTest, AssignmentOperator)
-{
- const KKJ kkj1(northing, easting);
- KKJ kkj2(0, 0);
- kkj2 = kkj1;
- ASSERT_EQ(northing, kkj2.northing());
- ASSERT_EQ(easting, kkj2.easting());
-}
-
-int main(int argc, char *argv[])
-{
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
+++ /dev/null
-include(../ut_common.pri)
-
-TARGET = ut_kkj
-QT += testlib
-QT -= gui
-CONFIG += console
-CONFIG -= app_bundle
-TEMPLATE = app
-OBJECTS_DIR = .obj
-MOC_DIR = .moc
-SOURCES += ut_kkj.cpp \
- $$SRCDIR/kkj.cpp
-HEADERS += \
- $$SRCDIR/kkj.h
-
-include(../gmock.pri)
-include(../check.pri)
--- /dev/null
+ut_kkjgridcoordinate
--- /dev/null
+#include "kkjgridcoordinate.h"
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "stlhelpers.h"
+
+class KKJGridCoordinateTest : public ::testing::Test
+{
+public:
+ const unsigned int northing;
+ const unsigned int easting;
+
+ KKJGridCoordinateTest() :
+ northing(6682815),
+ easting(2556686)
+ {
+ }
+};
+
+TEST_F(KKJGridCoordinateTest, ConstructorValuesReceivedViaGetters)
+{
+ KKJGridCoordinate kkj(northing , easting);
+ ASSERT_EQ(northing, kkj.northing());
+ ASSERT_EQ(easting, kkj.easting());
+}
+
+TEST_F(KKJGridCoordinateTest, EqualsOperatorReturnsTrueForEqualCoordinates)
+{
+ KKJGridCoordinate kkj1(northing, easting);
+ KKJGridCoordinate kkj2(northing, easting);
+ ASSERT_TRUE(kkj1 == kkj2);
+}
+
+TEST_F(KKJGridCoordinateTest, EqualsOperatorReturnsFalseForCoordinatesWithDifferentNorthing)
+{
+ KKJGridCoordinate kkj1(northing - 1, easting);
+ KKJGridCoordinate kkj2(northing, easting);
+ ASSERT_FALSE(kkj1 == kkj2);
+}
+
+TEST_F(KKJGridCoordinateTest, EqualsOperatorReturnsFalseForCoordinatesWithDifferentEasting)
+{
+ KKJGridCoordinate kkj1(northing, easting - 1);
+ KKJGridCoordinate kkj2(northing, easting);
+ ASSERT_FALSE(kkj1 == kkj2);
+}
+
+TEST_F(KKJGridCoordinateTest, AssignmentOperator)
+{
+ const KKJGridCoordinate kkj1(northing, easting);
+ KKJGridCoordinate kkj2(0, 0);
+ kkj2 = kkj1;
+ ASSERT_EQ(northing, kkj2.northing());
+ ASSERT_EQ(easting, kkj2.easting());
+}
+
+int main(int argc, char *argv[])
+{
+ ::testing::InitGoogleMock(&argc, argv);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+include(../ut_common.pri)
+
+TARGET = ut_kkjgridcoordinate
+QT += testlib
+QT -= gui
+CONFIG += console \
+ mobility
+CONFIG -= app_bundle
+MOBILITY = location
+TEMPLATE = app
+OBJECTS_DIR = .obj
+MOC_DIR = .moc
+SOURCES += ut_kkjgridcoordinate.cpp \
+ $$SRCDIR/kkjgridcoordinate.cpp
+HEADERS += \
+ $$SRCDIR/kkjgridcoordinate.h
+
+include(../gmock.pri)
+include(../check.pri)
#define STLHELPERS_H
#include <ostream>
-#include "kkj.h"
+#include "kkjgridcoordinate.h"
#include <QGeoCoordinate>
-std::ostream& operator<<(std::ostream& stream, const KKJ &val)
+std::ostream& operator<<(std::ostream& stream, const KKJGridCoordinate &val)
{
stream << val.northing() << ", " << val.easting();
return stream;