Skip to content

Commit

Permalink
cleaned up the namespacing and includes
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgerlek committed May 21, 2015
1 parent f63aca0 commit 731d5cc
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 170 deletions.
26 changes: 6 additions & 20 deletions plugins/rialto/io/RialtoDb.cpp
Expand Up @@ -34,30 +34,15 @@

#include "RialtoDb.hpp"

#include <pdal/BufferReader.hpp>
#include <pdal/Dimension.hpp>
#include <pdal/Options.hpp>
#include <pdal/pdal_error.hpp>
#include <pdal/pdal_types.hpp>
#include <pdal/PointTable.hpp>
#include <pdal/PointView.hpp>
#include <pdal/util/Bounds.hpp>
#include <pdal/util/FileUtils.hpp>

#include <cstdint>

#include <../plugins/sqlite/io/SQLiteCommon.hpp> // TODO: fix path
#include <pdal/../../plugins/sqlite/io/SQLiteCommon.hpp> // TODO: fix path


namespace pdal
{

namespace
namespace rialto
{

} // anonymous namespace



RialtoDb::RialtoDb(const std::string& connection, LogPtr log) :
m_connection(connection),
Expand Down Expand Up @@ -583,7 +568,7 @@ void RialtoDb::readTileSetInfo(std::string const& name, TileSetInfo& info) const
}


void RialtoDb::readTileInfo(std::string const& name, uint32_t tileId, bool withPoints, RialtoDb::TileInfo& info) const
void RialtoDb::readTileInfo(std::string const& name, uint32_t tileId, bool withPoints, TileInfo& info) const
{
if (!m_sqlite)
{
Expand Down Expand Up @@ -693,7 +678,7 @@ void RialtoDb::readDimensionsInfo(std::string const& name, std::vector<Dimension
}


void RialtoDb::writeTileSet(const RialtoDb::TileSetInfo& data)
void RialtoDb::writeTileSet(const TileSetInfo& data)
{
if (!m_sqlite)
{
Expand Down Expand Up @@ -868,7 +853,7 @@ void RialtoDb::writeDimensions(uint32_t tileSetId,
}


void RialtoDb::writeTile(const std::string& tileSetName, const RialtoDb::TileInfo& data)
void RialtoDb::writeTile(const std::string& tileSetName, const TileInfo& data)
{
if (!m_sqlite)
{
Expand Down Expand Up @@ -1144,4 +1129,5 @@ void RialtoDb::dumpStats() const
}
}

} // namespace rialto
} // namespace pdal
101 changes: 51 additions & 50 deletions plugins/rialto/io/RialtoDb.hpp
Expand Up @@ -36,19 +36,18 @@

#include <pdal/pdal.hpp>


#include "RialtoEvent.hpp"

namespace pdal {
class Log;
class SQLite;
}

namespace pdal
{
class Log;
class SQLite;

using namespace pdal;
namespace rialto
{


class PDAL_DLL MyPatch
{
public:
Expand Down Expand Up @@ -116,51 +115,51 @@ class PDAL_DLL MyPatch
};


struct DimensionInfo {
std::string name;
uint32_t position;
std::string dataType;
std::string description;
double minimum;
double mean;
double maximum;
};

// Rialto has some hard-coded restrictions:
// we always use EPSG:4326
// we always start with two tiles at the root
// we always cover the whole globe at the root
// we always do power-of-two reductions
// we store all levels between 0 and max, inclusive
struct TileSetInfo {
std::string datetime;
std::string name; // aka filename
uint32_t maxLevel;
uint32_t numDimensions;
std::vector<DimensionInfo> dimensions;
double data_min_x; // data extents
double data_min_y;
double data_max_x;
double data_max_y;
double tmset_min_x; // tile extents
double tmset_min_y;
double tmset_max_x;
double tmset_max_y;
};

struct TileInfo {
uint32_t tileSetId;
uint32_t level;
uint32_t column;
uint32_t row;
uint32_t numPoints; // used in database, but not on disk version
uint32_t mask; // used in disk version, but not in database
MyPatch patch;
};

class PDAL_DLL RialtoDb
{
public:
struct DimensionInfo {
std::string name;
uint32_t position;
std::string dataType;
std::string description;
double minimum;
double mean;
double maximum;
};

// Rialto has some hard-coded restrictions:
// we always use EPSG:4326
// we always start with two tiles at the root
// we always cover the whole globe at the root
// we always do power-of-two reductions
// we store all levels between 0 and max, inclusive
struct TileSetInfo {
std::string datetime;
std::string name; // aka filename
uint32_t maxLevel;
uint32_t numDimensions;
std::vector<DimensionInfo> dimensions;
double data_min_x; // data extents
double data_min_y;
double data_max_x;
double data_max_y;
double tmset_min_x; // tile extents
double tmset_min_y;
double tmset_max_x;
double tmset_max_y;
};

struct TileInfo {
uint32_t tileSetId;
uint32_t level;
uint32_t column;
uint32_t row;
uint32_t numPoints; // used in database, but not on disk version
uint32_t mask; // used in disk version, but not in database
MyPatch patch;
};

// pass it the filename of the sqlite db
RialtoDb(const std::string& connection, LogPtr log);

Expand All @@ -175,10 +174,10 @@ class PDAL_DLL RialtoDb
// adds a tile set to the database, including its dimensions
//
// returns id of new data set
void writeTileSet(const RialtoDb::TileSetInfo& data);
void writeTileSet(const TileSetInfo& data);

// returns id of new tile
void writeTile(const std::string& tileSetName, const RialtoDb::TileInfo& data);
void writeTile(const std::string& tileSetName, const TileInfo& data);

// get list all the tile sets in the database, as a list of its
void readTileSetIds(std::vector<std::string>& names) const;
Expand Down Expand Up @@ -268,4 +267,6 @@ class PDAL_DLL RialtoDb
RialtoDb(const RialtoDb&); // not implemented
};

} // namespace rialto

} // namespace pdal
31 changes: 23 additions & 8 deletions plugins/rialto/io/RialtoDbReader.cpp
Expand Up @@ -34,7 +34,6 @@

#include "RialtoDbReader.hpp"
#include "RialtoDb.hpp"
#include <pdal/PointView.hpp>

namespace pdal
{
Expand All @@ -44,31 +43,46 @@ static PluginInfo const s_info = PluginInfo(
"Read data from a Rialto DB",
"" );

CREATE_SHARED_PLUGIN(1, 0, RialtoDbReader, Reader, s_info)
CREATE_SHARED_PLUGIN(1, 0, rialto::RialtoDbReader, Reader, s_info)

namespace rialto
{


std::string RialtoDbReader::getName() const { return s_info.name; }


RialtoDbReader::RialtoDbReader() :
Reader()
Reader(),
m_db(NULL)
{}


RialtoDbReader::~RialtoDbReader()
{
if (m_db)
{
m_db->close();
delete m_db;
}
}


void RialtoDbReader::initialize()
{
log()->get(LogLevel::Debug) << "RialtoDbReader::initialize()" << std::endl;

if (!m_db.get())
if (!m_db)
{
m_db = std::unique_ptr<RialtoDb>(new RialtoDb(m_filename, log()));
m_db = new RialtoDb(m_filename, log());
m_db->open(false);

std::vector<std::string> names;
m_db->readTileSetIds(names);
m_tileSetName = names[0];
assert(names.size()==1); // TODO: always take the first one for now

m_tileSetInfo = std::unique_ptr<RialtoDb::TileSetInfo>(new RialtoDb::TileSetInfo());
m_tileSetInfo = std::unique_ptr<TileSetInfo>(new TileSetInfo());

m_db->readTileSetInfo(m_tileSetName, *m_tileSetInfo);
}
Expand Down Expand Up @@ -142,7 +156,7 @@ point_count_t RialtoDbReader::read(PointViewPtr view, point_count_t count)

m_db->queryForTileInfosBegin(m_tileSetName, minx, miny, maxx, maxy, maxLevel);

RialtoDb::TileInfo info;
TileInfo info;

do {
bool ok = m_db->queryForTileInfos(info);
Expand Down Expand Up @@ -170,9 +184,10 @@ point_count_t RialtoDbReader::read(PointViewPtr view, point_count_t count)
return view->size();
}

} // namespace rialto

void Options::remove(const std::string& name)
{
m_options.erase(name);
}

} // namespace pdal
17 changes: 11 additions & 6 deletions plugins/rialto/io/RialtoDbReader.hpp
Expand Up @@ -34,20 +34,24 @@

#pragma once

#include <pdal/pdal_export.hpp>
#include <pdal/Reader.hpp>

#include "RialtoDb.hpp" // TODO: do not expose

namespace pdal
{
//class RialtoDb;
//struct RialtoDb::TileSetInfo;
namespace rialto
{


struct TileSetInfo;
class RialtoDb;


class PDAL_DLL RialtoDbReader : public Reader
{
public:
RialtoDbReader();
~RialtoDbReader();

static void * create();
static int32_t destroy(void *);
Expand All @@ -63,14 +67,15 @@ class PDAL_DLL RialtoDbReader : public Reader
point_count_t read(PointViewPtr view, point_count_t count);

private:
std::unique_ptr<RialtoDb> m_db;
RialtoDb* m_db;
std::string m_tileSetName;
uint32_t m_level;
std::unique_ptr<RialtoDb::TileSetInfo> m_tileSetInfo;
std::unique_ptr<TileSetInfo> m_tileSetInfo;
BOX3D m_query;

RialtoDbReader& operator=(const RialtoDbReader&); // not implemented
RialtoDbReader(const RialtoDbReader&); // not implemented
};

} // rialto namespace
} // pdal namespace
25 changes: 5 additions & 20 deletions plugins/rialto/io/RialtoDbWriter.cpp
Expand Up @@ -33,21 +33,8 @@
****************************************************************************/

#include "RialtoDbWriter.hpp"

#include <pdal/BufferReader.hpp>
#include <pdal/Dimension.hpp>
#include <pdal/Options.hpp>
#include <pdal/pdal_error.hpp>
#include <pdal/pdal_types.hpp>
#include <pdal/PointTable.hpp>
#include <pdal/PointView.hpp>
#include <pdal/util/Bounds.hpp>
#include <pdal/util/FileUtils.hpp>

#include "RialtoDb.hpp"

#include <cstdint>


namespace pdal
{
Expand All @@ -57,12 +44,10 @@ static PluginInfo const s_info = PluginInfo(
"Rialto DB Writer",
"http://pdal.io/stages/writers.rialtodb.html" );

CREATE_SHARED_PLUGIN(1, 0, RialtoDbWriter, Writer, s_info)
CREATE_SHARED_PLUGIN(1, 0, rialto::RialtoDbWriter, Writer, s_info)

namespace
namespace rialto
{
} // anonymous namespace



void RialtoDbWriter::writeHeader(const std::string& tileSetName,
Expand All @@ -71,7 +56,7 @@ void RialtoDbWriter::writeHeader(const std::string& tileSetName,
{
log()->get(LogLevel::Debug) << "RialtoDbWriter::writeHeader()" << std::endl;

RialtoDb::TileSetInfo tileSetInfo;
TileSetInfo tileSetInfo;
serializeToTileSetInfo(tileSetName, tileSetNode, layout, tileSetInfo);

m_rialtoDb->writeTileSet(tileSetInfo);
Expand All @@ -84,7 +69,7 @@ void RialtoDbWriter::writeTile(const std::string& tileSetName, PointView* view,

//printf("writing tile %d/%d/%d\n", level, col, row);

RialtoDb::TileInfo tileInfo;
TileInfo tileInfo;
serializeToTileInfo(view, tileInfo, level, col, row, mask);

if (!tileInfo.patch.isEmpty())
Expand Down Expand Up @@ -141,5 +126,5 @@ void RialtoDbWriter::localFinish()
m_rialtoDb = NULL;
}


} // namespace rialto
} // namespace pdal

0 comments on commit 731d5cc

Please sign in to comment.