Commit e30a44af authored by Mohammed Nafees's avatar Mohammed Nafees

Introduce the GeoDataBuilding class

Differential Revision: https://phabricator.kde.org/D6222
parent d00d4b8d
......@@ -76,6 +76,7 @@ SET ( geodata_data_SRCS
geodata/data/GeoDataDelete.cpp
geodata/data/GeoDataSchemaData.cpp
geodata/data/GeoDataSimpleData.cpp
geodata/data/GeoDataBuilding.cpp
)
SET ( geodata_scene_SRCS
......
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2017 Mohammed Nafees <nafees.technocool@gmail.com>
//
#include "GeoDataBuilding.h"
#include "GeoDataBuilding_p.h"
#include "GeoDataTypes.h"
namespace Marble {
GeoDataBuilding::GeoDataBuilding()
: GeoDataGeometry(new GeoDataBuildingPrivate),
d(new GeoDataBuildingPrivate)
{
}
GeoDataBuilding::GeoDataBuilding(const GeoDataGeometry &other)
: GeoDataGeometry(other),
d(new GeoDataBuildingPrivate)
{
}
GeoDataBuilding::GeoDataBuilding(const GeoDataBuilding &other)
: GeoDataGeometry(other),
d(new GeoDataBuildingPrivate(*other.d))
{
}
GeoDataBuilding::~GeoDataBuilding()
{
delete d;
}
GeoDataBuilding& GeoDataBuilding::operator=(const GeoDataBuilding& other)
{
GeoDataGeometry::operator=(other);
*d = *other.d;
return *this;
}
const char *GeoDataBuilding::nodeType() const
{
return GeoDataTypes::GeoDataBuildingType;
}
EnumGeometryId GeoDataBuilding::geometryId() const
{
return GeoDataBuildingId;
}
GeoDataGeometry *GeoDataBuilding::copy() const
{
return new GeoDataBuilding(*this);
}
double GeoDataBuilding::height() const
{
return d->m_height;
}
void GeoDataBuilding::setHeight(double height)
{
d->m_height = height;
}
int GeoDataBuilding::minLevel() const
{
return d->m_minLevel;
}
void GeoDataBuilding::setMinLevel(int minLevel)
{
d->m_minLevel = minLevel;
}
int GeoDataBuilding::maxLevel() const
{
return d->m_maxLevel;
}
void GeoDataBuilding::setMaxLevel(int maxLevel)
{
d->m_maxLevel = maxLevel;
}
QVector<int> GeoDataBuilding::nonExistentLevels() const
{
return d->m_nonExistentLevels;
}
void GeoDataBuilding::setNonExistentLevels(const QVector<int> &nonExistentLevels)
{
d->m_nonExistentLevels = nonExistentLevels;
}
GeoDataMultiGeometry* GeoDataBuilding::multiGeometry() const
{
return &d->m_multiGeometry;
}
}
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2017 Mohammed Nafees <nafees.technocool@gmail.com>
//
#ifndef MARBLE_GEODATABUILDING_H
#define MARBLE_GEODATABUILDING_H
#include <QVector>
#include "GeoDataGeometry.h"
#include "geodata_export.h"
namespace Marble {
class GeoDataBuildingPrivate;
/*!
\class GeoDataBuilding
\brief Contains important information about a building and its floors (levels)
GeoDataBuilding holds information such as minimum floor, maximum floor,
floor data and their respective MultiGeometry and other possible metadata such
as the total height of the building, type etc.
*/
class GEODATA_EXPORT GeoDataBuilding : public GeoDataGeometry
{
public:
explicit GeoDataBuilding();
explicit GeoDataBuilding(const GeoDataGeometry &other);
explicit GeoDataBuilding(const GeoDataBuilding &other);
GeoDataBuilding& operator=(const GeoDataBuilding &other);
const char *nodeType() const override;
EnumGeometryId geometryId() const override;
GeoDataGeometry *copy() const override;
/*!
Destroys the GeoDataBuilding
*/
~GeoDataBuilding() override;
/*!
@return the height of the building
*/
double height() const;
/*!
Sets the height of the building
@param height
*/
void setHeight(double height);
/*!
@return the minimum level
*/
int minLevel() const;
/*!
Sets the minimum level of the building
@param minLevel
*/
void setMinLevel(int minLevel);
/*!
@return the maximum level of the building
*/
int maxLevel() const;
/*!
Sets the maximum level of the building
@param maxLevel
*/
void setMaxLevel(int maxLevel);
/*!
@return the non existent levels in the building
*/
QVector<int> nonExistentLevels() const;
/*!
Sets the non existent levels of the building
@param nonExistentLevels
*/
void setNonExistentLevels(const QVector<int>& nonExistentLevels);
/*!
* @return the multigeometry associated with the building
*/
GeoDataMultiGeometry* multiGeometry() const;
private:
GeoDataBuildingPrivate* const d;
};
}
#endif
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2017 Mohammed Nafees <nafees.technocool@gmail.com>
//
#ifndef MARBLE_GEODATABUILDING_P_H
#define MARBLE_GEODATABUILDING_P_H
#include "GeoDataGeometry_p.h"
#include "GeoDataMultiGeometry.h"
namespace Marble {
class GeoDataBuildingPrivate : public GeoDataGeometryPrivate
{
public:
GeoDataBuildingPrivate()
: m_height(0.0),
m_minLevel(0),
m_maxLevel(0)
{
}
GeoDataGeometryPrivate *copy() const override
{
GeoDataBuildingPrivate* copy = new GeoDataBuildingPrivate;
*copy = *this;
return copy;
}
double m_height;
int m_minLevel;
int m_maxLevel;
QVector<int> m_nonExistentLevels;
GeoDataMultiGeometry m_multiGeometry;
};
}
#endif
......@@ -46,7 +46,8 @@ enum EnumGeometryId {
GeoDataMultiGeometryId,
GeoDataMultiTrackId,
GeoDataModelId,
GeoDataTrackId
GeoDataTrackId,
GeoDataBuildingId
};
}
......
......@@ -92,6 +92,7 @@ const char GeoDataImagePyramidType[] = "GeoDataImagePyramid";
const char GeoDataViewVolumeType[] = "GeoDataViewVolume";
const char GeoDataNetworkLinkControlType[] = "GeoDataNetworkLinkControl";
const char GeoDataUpdateType[] = "GeoDataUpdate";
const char GeoDataBuildingType[] = "GeoDataBuilding";
}
}
......@@ -101,6 +101,7 @@ GEODATA_EXPORT extern const char GeoDataImagePyramidType[];
GEODATA_EXPORT extern const char GeoDataViewVolumeType[];
GEODATA_EXPORT extern const char GeoDataNetworkLinkControlType[];
GEODATA_EXPORT extern const char GeoDataUpdateType[];
GEODATA_EXPORT extern const char GeoDataBuildingType[];
}
}
......
......@@ -110,6 +110,7 @@ marble_add_test( TestEquality )
marble_add_test( TestFeatureDetach )
marble_add_test( TestGeometryDetach )
marble_add_test( TestTileProjection )
marble_add_test( TestGeoDataBuilding )
qt_add_resources(TestGeoDataCopy_SRCS TestGeoDataCopy.qrc) # Check copy operations on CoW classes
marble_add_test( TestGeoDataCopy ${TestGeoDataCopy_SRCS} )
......
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2017 Mohammed Nafees <nafees.technocool@gmail.com>
//
#include <QTest>
#include <QVector>
#include "GeoDataBuilding.h"
#include "GeoDataMultiGeometry.h"
#include "GeoDataLinearRing.h"
namespace Marble {
class TestGeoDataBuilding : public QObject {
Q_OBJECT
private Q_SLOTS:
void defaultConstructor();
};
void TestGeoDataBuilding::defaultConstructor() {
GeoDataBuilding building;
QCOMPARE(building.height(), 0.0);
QCOMPARE(building.minLevel(), 0);
QCOMPARE(building.maxLevel(), 0);
building.setHeight(24.5);
building.setMinLevel(-2);
building.setMaxLevel(10);
QCOMPARE(building.height(), 24.5);
QCOMPARE(building.minLevel(), -2);
QCOMPARE(building.maxLevel(), 10);
QVERIFY(building.nonExistentLevels().isEmpty());
QVector<int> nonExistentLevels;
nonExistentLevels << 4 << 13;
building.setNonExistentLevels(nonExistentLevels);
QVERIFY(!building.nonExistentLevels().isEmpty());
QVERIFY(building.multiGeometry()->size() == 0);
building.multiGeometry()->append(new GeoDataLinearRing);
QVERIFY(building.multiGeometry()->size() > 0);
GeoDataBuilding building2(building);
QCOMPARE(building2.height(), 24.5);
QCOMPARE(building2.minLevel(), -2);
QCOMPARE(building2.maxLevel(), 10);
QVERIFY(!building2.nonExistentLevels().isEmpty());
QVERIFY(building2.multiGeometry()->size() > 0);
}
}
QTEST_MAIN(Marble::TestGeoDataBuilding)
#include "TestGeoDataBuilding.moc"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment