File PreparedGeometry.h
File List > src > PreparedGeometry.h
Go to the documentation of this file
// Copyright (c) 2012-2013, IGN France.
// Copyright (c) 2012-2022, Oslandia.
// SPDX-License-Identifier: LGPL-2.0-or-later
#ifndef _SFCGAL_PREPARED_GEOMETRY_H_
#define _SFCGAL_PREPARED_GEOMETRY_H_
#include "SFCGAL/config.h"
#include "SFCGAL/Envelope.h"
#include <boost/endian/conversion.hpp>
#include <boost/noncopyable.hpp>
#include <boost/optional.hpp>
#include <boost/serialization/split_member.hpp>
#include <stdint.h> // uint32_t
namespace SFCGAL {
class Geometry;
typedef uint32_t srid_t;
class SFCGAL_API PreparedGeometry : public boost::noncopyable {
public:
PreparedGeometry();
PreparedGeometry(std::unique_ptr<Geometry> &&geometry, srid_t srid = 0);
PreparedGeometry(Geometry *geometry, srid_t srid = 0);
virtual ~PreparedGeometry();
const Geometry &
geometry() const;
Geometry &
geometry();
void
resetGeometry(Geometry *geom);
const srid_t &
SRID() const
{
return _srid;
}
srid_t &
SRID()
{
return _srid;
}
const Envelope &
envelope() const;
void
invalidateCache();
std::string
asEWKT(const int &numDecimals = -1) const;
auto
asEWKB(boost::endian::order wkbOrder = boost::endian::order::native,
bool asHex = false) const -> std::string;
template <class Archive>
void
save(Archive &ar, const unsigned int /*version*/) const
{
ar &_srid;
const Geometry *pgeom = _geometry.get();
ar &pgeom;
}
template <class Archive>
void
load(Archive &ar, const unsigned int /*version*/)
{
ar &_srid;
Geometry *pgeom;
ar &pgeom;
_geometry.reset(pgeom);
}
template <class Archive>
void
serialize(Archive &ar, const unsigned int version)
{
boost::serialization::split_member(ar, *this, version);
}
protected:
// Pointer to underlying Geometry
std::unique_ptr<Geometry> _geometry;
// SRID of the geometry
srid_t _srid;
// bbox of the geometry
mutable boost::optional<Envelope> _envelope;
};
} // namespace SFCGAL
#endif