Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move CityObjectsType & -Mask away from PoT enum values #104

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
38ba039
Hide msvc DLL interface warnings.
gostefan Aug 1, 2024
fe685cb
Make msvc dll warning suppression less obnoxious.
gostefan Aug 1, 2024
aace344
Cast size_t to unsigned int to avoid conversion warnings.
gostefan Aug 1, 2024
a7886fc
Use unsigned int in loops to avoid conversion warnings.
gostefan Aug 1, 2024
f40dc71
Remove name of unused variable.
gostefan Aug 1, 2024
02af448
Add override keyword to overriding functions.
gostefan Aug 1, 2024
3fcfced
Allow triggering the build workflow manually.
gostefan Sep 16, 2024
e51a2f1
Add empty Google Test Framework.
gostefan Oct 19, 2024
f9971b5
Increase C++ version to 17.
gostefan Oct 19, 2024
b962be7
Recreate the current tests in the new framework.
gostefan Oct 19, 2024
bf70125
Remove unused CTest definitions.
gostefan Oct 26, 2024
f63c66e
Fix override warnings on clang.
gostefan Oct 26, 2024
b44bd00
Merge branch 'fixWarnings' into HEAD
gostefan Nov 1, 2024
2029596
Don't export a template from the library.
gostefan Nov 5, 2024
1c469cb
Add tests for CityObjectsTypeMask.
gostefan Oct 26, 2024
917f0ba
Move CityObjectType operators to Bitmask.
gostefan Oct 26, 2024
d5a753c
Move enum bitmask to std::bitmask.
gostefan Nov 5, 2024
2b3a7a6
Move CitObjecsType enum away from PoT values.
gostefan Nov 5, 2024
4618d7c
Handle legacy ParserParams initializations.
gostefan Nov 5, 2024
c904947
Move CityObjectsTypeMask out of CityObject.
gostefan Dec 15, 2024
aea2204
Adapt Tests to new CityObjectsTypeMask interface.
gostefan Dec 15, 2024
5920384
Hide intentional test of deprecated method.
gostefan Dec 15, 2024
81d745f
Implement skipping of top level city objects.
gostefan Dec 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:

env:
XERCES_C_VERSION: v3.2.5
Expand Down
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0 FATAL_ERROR)
CMAKE_MINIMUM_REQUIRED(VERSION 3.8.0 FATAL_ERROR)

set(CMAKE_CXX_STANDARD 17)

PROJECT ( libcitygml )

Expand Down Expand Up @@ -58,9 +60,9 @@ ENDIF(WIN32)
if(UNIX)
if(APPLE)
MESSAGE(STATUS "APPLE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
else(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")

MESSAGE(STATUS "Setting UNIX compile flags: ${CMAKE_CXX_FLAGS}")
endif(APPLE)
Expand Down Expand Up @@ -152,6 +154,8 @@ OPTION(LIBCITYGML_TESTS "Set to ON to build libcitygml tests programs." ON)
IF (LIBCITYGML_TESTS)
enable_testing()
ADD_SUBDIRECTORY( test )

ADD_SUBDIRECTORY( systemTests )
ENDIF(LIBCITYGML_TESTS)


Expand Down
5 changes: 0 additions & 5 deletions CTestTestfile.cmake

This file was deleted.

67 changes: 67 additions & 0 deletions data/systemTests/CityObjectsTypeMask/BridgeAndBuilding.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<core:CityModel xmlns:gml="http://www.opengis.net/gml" xmlns:core="http://www.opengis.net/citygml/2.0" xmlns:brid="http://www.opengis.net/citygml/bridge/2.0" xmlns:bldg="http://www.opengis.net/citygml/building/2.0">
<gml:boundedBy>
<gml:Envelope srsName="EPSG:23632" srsDimension="3">
<gml:lowerCorner>457644.585 5439126.455 109.0</gml:lowerCorner>
<gml:upperCorner>457708.084 5439157.169 124.3</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<core:cityObjectMember>
<brid:Bridge>
<brid:lod2MultiSurface>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">
0 0 0
0 10 0
10 10 0
10 0 0
0 0 0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</brid:lod2MultiSurface>
</brid:Bridge>
</core:cityObjectMember>
<core:cityObjectMember>
<bldg:Building>
<bldg:consistsOfBuildingPart>
<bldg:BuildingPart>
<bldg:boundedBy>
<bldg:WallSurface>
<bldg:lod2MultiSurface>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:CompositeSurface>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">
15 0 0
15 10 0
25 10 0
25 0 0
15 0 0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:CompositeSurface>
</gml:surfaceMember>
</gml:MultiSurface>
</bldg:lod2MultiSurface>
</bldg:WallSurface>
</bldg:boundedBy>
</bldg:BuildingPart>
</bldg:consistsOfBuildingPart>
</bldg:Building>
</core:cityObjectMember>
</core:CityModel>
10 changes: 7 additions & 3 deletions osgplugin/ReaderWriterCityGML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ class CityGMLSettings
{
std::transform( currentOption.begin(), currentOption.end(), currentOption.begin(), ::tolower );
if ( currentOption == "names" ) _printNames = true;
else if ( currentOption == "mask" ) iss >> _params.objectsMask;
else if ( currentOption == "mask" ) {
citygml::CityObjectsTypeMask mask;
iss >> mask;
_params.objectsMask = mask;
}
else if ( currentOption == "minlod" ) iss >> _params.minLOD;
else if ( currentOption == "maxlod" ) iss >> _params.maxLOD;
else if ( currentOption == "optimize" ) _params.optimize = true;
Expand Down Expand Up @@ -177,15 +181,15 @@ class ReaderWriterCityGML : public osgDB::ReaderWriter

virtual ReadResult readNode( const std::string&, const osgDB::ReaderWriter::Options* ) const override;
virtual ReadResult readNode( std::istream&, const osgDB::ReaderWriter::Options* ) const override;
virtual ReadResult readObject(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
virtual ReadResult readObject(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const override
{
ReadResult result = readNode(fileName, options);
osg::Node* node = result.getNode();
if (node) return node;
else return result;
}

virtual ReadResult readObject(std::istream& fin, const Options* options) const
virtual ReadResult readObject(std::istream& fin, const Options* options) const override
{
ReadResult result = readNode(fin, options);
osg::Node* node = result.getNode();
Expand Down
2 changes: 1 addition & 1 deletion sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ SET(PUBLIC_HEADER
include/citygml/citygml_api.h
include/citygml/citygml_export.h
include/citygml/attributesmap.h
include/citygml/enum_type_bitmask.h
include/citygml/citygmllogger.h
include/citygml/polygon.h
include/citygml/material.h
Expand Down Expand Up @@ -164,6 +163,7 @@ SET(PUBLIC_HEADER
include/citygml/address.h
include/citygml/rectifiedgridcoverage.h
include/citygml/externalreference.h
include/citygml/warnings.h
)


Expand Down
3 changes: 3 additions & 0 deletions sources/include/citygml/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <citygml/citygml_api.h>
#include <citygml/object.h>
#include <citygml/warnings.h>

namespace citygml {

Expand All @@ -26,11 +27,13 @@ namespace citygml {
void setThoroughfareNumber(const std::string& thoroughfareNumber);

protected:
PRAGMA_WARN_DLL_BEGIN
std::string m_country;
std::string m_locality;
std::string m_thoroughfareName;
std::string m_thoroughfareNumber;
std::string m_postalCode;
PRAGMA_WARN_DLL_END
};

} /* namespace citygml */
7 changes: 7 additions & 0 deletions sources/include/citygml/appearance.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <citygml/citygml_api.h>
#include <citygml/object.h>
#include <citygml/warnings.h>
#include <citygml/appearancetarget.h>

namespace citygml {
Expand All @@ -14,8 +15,11 @@ namespace citygml {
class Texture;
class GeoreferencedTexture;


PRAGMA_WARN_DLL_BEGIN
class LIBCITYGML_EXPORT Appearance : public Object, public std::enable_shared_from_this<Appearance>
{
PRAGMA_WARN_DLL_END
public:
std::string getType() const;

Expand All @@ -41,8 +45,11 @@ namespace citygml {

protected:
Appearance( const std::string& id, const std::string& typeString );
PRAGMA_WARN_DLL_BEGIN
std::string m_typeString;
std::vector<std::string> m_themes;
PRAGMA_WARN_DLL_END

bool m_isFront;
};

Expand Down
3 changes: 3 additions & 0 deletions sources/include/citygml/appearancemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <unordered_map>

#include <citygml/object.h>
#include <citygml/warnings.h>
#include <citygml/vecs.hpp>

namespace citygml {
Expand Down Expand Up @@ -53,12 +54,14 @@ namespace citygml {


protected:
PRAGMA_WARN_DLL_BEGIN
std::unordered_map<std::string, std::shared_ptr<Appearance> > m_appearancesMap;
std::vector<std::shared_ptr<MaterialTargetDefinition> > m_materialTargetDefinitions;
std::vector<std::shared_ptr<TextureTargetDefinition> > m_texTargetDefinitions;
std::unordered_set<std::string> m_themes;
std::unordered_map<std::string, AppearanceTarget*> m_appearanceTargetsMap;
std::shared_ptr<CityGMLLogger> m_logger;
PRAGMA_WARN_DLL_END

void addThemesFrom(std::shared_ptr<Appearance> surfaceData);
};
Expand Down
3 changes: 3 additions & 0 deletions sources/include/citygml/appearancetarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <citygml/object.h>
#include <citygml/appearancetargetdefinition.h>
#include <citygml/warnings.h>


namespace citygml {
Expand Down Expand Up @@ -45,11 +46,13 @@ namespace citygml {


private:
PRAGMA_WARN_DLL_BEGIN
std::unordered_map<std::string, std::shared_ptr<MaterialTargetDefinition> > m_themeMatMapFront;
std::unordered_map<std::string, std::shared_ptr<MaterialTargetDefinition> > m_themeMatMapBack;

std::unordered_map<std::string, std::shared_ptr<TextureTargetDefinition> > m_themeTexMapFront;
std::unordered_map<std::string, std::shared_ptr<TextureTargetDefinition> > m_themeTexMapBack;
PRAGMA_WARN_DLL_END

};
}
4 changes: 4 additions & 0 deletions sources/include/citygml/appearancetargetdefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>

#include <citygml/object.h>
#include <citygml/warnings.h>

namespace citygml {

Expand Down Expand Up @@ -39,8 +40,11 @@ namespace citygml {
virtual ~AppearanceTargetDefinition() {}

protected:
PRAGMA_WARN_DLL_BEGIN
std::string m_targetID;
std::shared_ptr<T> m_appearance;
PRAGMA_WARN_DLL_END

};

}
3 changes: 3 additions & 0 deletions sources/include/citygml/attributesmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <map>

#include <citygml/citygml_api.h>
#include <citygml/warnings.h>

namespace citygml
{
Expand Down Expand Up @@ -45,7 +46,9 @@ class LIBCITYGML_EXPORT AttributeValue
int asInteger(int defaultValue=0) const;
private:
AttributeType m_type;
PRAGMA_WARN_DLL_BEGIN
std::string m_value;
PRAGMA_WARN_DLL_END
};

LIBCITYGML_EXPORT std::ostream& operator<<(std::ostream& os, const AttributeValue& o);
Expand Down
24 changes: 20 additions & 4 deletions sources/include/citygml/citygml.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <citygml/cityobject.h>
#include <citygml/envelope.h>
#include <citygml/tesselatorbase.h>
#include <citygml/warnings.h>

namespace citygml
{
Expand All @@ -42,8 +43,6 @@ namespace citygml
class Material;
class AppearanceManager;

typedef EnumClassBitmask<CityObject::CityObjectsType> CityObjectsTypeMask;


///////////////////////////////////////////////////////////////////////////////
// Parsing routines
Expand All @@ -63,7 +62,7 @@ namespace citygml
{
public:
ParserParams()
: objectsMask(CityObject::CityObjectsType::COT_All)
: objectsMask(~CityObjectsTypeMask{})
, minLOD( 0 )
, maxLOD( 4 )
, optimize( false )
Expand All @@ -75,15 +74,32 @@ namespace citygml
{ }

public:
CityObjectsTypeMask objectsMask;
template <typename New, typename Old, New (*Transform)(Old)>
class LegacyAssignable {
public:
LegacyAssignable(New const& val) : value(val) {}
New& operator=(New const& val) { value = val; return value; }
[[deprecated]] Old operator=(Old val) { value = Transform(val); return val; }
New const& operator->() const { return value; }
New const& get() const { return value; }
operator New const&() const { return value; }
private:
New value;
};

PRAGMA_WARN_DLL_BEGIN
LegacyAssignable<CityObjectsTypeMask, CityObject::CityObjectsType, toMask> objectsMask;
PRAGMA_WARN_DLL_END
unsigned int minLOD;
unsigned int maxLOD;
bool optimize;
bool pruneEmptyObjects;
bool tesselate;
bool keepVertices;
PRAGMA_WARN_DLL_BEGIN
std::string destSRS;
std::string srcSRS;
PRAGMA_WARN_DLL_END
};

LIBCITYGML_EXPORT std::shared_ptr<const CityModel> load( std::istream& stream, const ParserParams& params, std::unique_ptr<TesselatorBase> tesselator, std::shared_ptr<CityGMLLogger> logger = nullptr);
Expand Down
3 changes: 3 additions & 0 deletions sources/include/citygml/citygmlfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <citygml/geometry.h>
#include <citygml/cityobject.h>
#include <citygml/externalreference.h>
#include <citygml/warnings.h>

#include <memory>

Expand Down Expand Up @@ -70,10 +71,12 @@ namespace citygml {
protected:
void appearanceTargetCreated(AppearanceTarget* obj);

PRAGMA_WARN_DLL_BEGIN
std::shared_ptr<CityGMLLogger> m_logger;
std::unique_ptr<AppearanceManager> m_appearanceManager;
std::unique_ptr<PolygonManager> m_polygonManager;
std::unique_ptr<GeometryManager> m_geometryManager;
PRAGMA_WARN_DLL_END
};

}
Loading
Loading