Skip to content

Commit

Permalink
Add readit().
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Jun 28, 2019
1 parent f7a0b98 commit 2d54b75
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
36 changes: 29 additions & 7 deletions io/Ilvis2Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ std::ostream& operator<<(std::ostream& out,
return out;
}

namespace
{
void readit(std::ifstream& stream, const std::string& filename)
{
stream.open(filename);
if (!stream.good())
std::cerr << "Bad stream on open!\n";
if (!stream.is_open())
std::cerr << "Not open!\n";
else
std::cerr << "Open!\n";
std::cerr << "Position = " << stream.tellg() << "!\n";

for (size_t i = 0; stream.good() && i < 2; ++i)
{
std::string line;
std::getline(stream, line);
}
stream.close();
}
} // namespace


void Ilvis2Reader::addArgs(ProgramArgs& args)
{
Expand Down Expand Up @@ -119,6 +141,8 @@ void Ilvis2Reader::addDimensions(PointLayoutPtr layout)

void Ilvis2Reader::initialize(PointTableRef)
{
readit(m_stream, m_filename);

std::cerr << "Skip init!\n";
/**
if (!m_metadataFile.empty() && !FileUtils::fileExists(m_metadataFile))
Expand Down Expand Up @@ -193,6 +217,8 @@ void Ilvis2Reader::readPoint(PointRef& point, StringList s,
void Ilvis2Reader::ready(PointTableRef table)
{
std::cerr << "+Ready!\n";
readit(m_stream, m_filename);
std::cerr << "Done readit!\n";
/**
if (!m_metadataFile.empty())
{
Expand All @@ -211,13 +237,6 @@ std::cerr << ".. read metadata!\n";
static const int HeaderSize = 2;

m_lineNum = 0;
/*
**/
FILE* fp = fopen(m_filename.c_str(), "r");
char c;
while (fread(&c, 1, 1, fp) == 1)
std::cerr << c;
fclose(fp);
std::cerr << "Filename = " << m_filename << "!\n";

std::ifstream in;
Expand All @@ -229,6 +248,9 @@ while (in.good())
d = in.get();
}
std::cerr << "Done new open!\n";
readit(m_stream, m_filename);
std::cerr << "About to do problem read!\n";

m_stream.open(m_filename);
if (!m_stream.good())
throwError("Couldn't open file '" + m_filename + "'.");
Expand Down
6 changes: 6 additions & 0 deletions test/unit/filters/MergeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,15 @@ TEST(MergeTest, test6)
{
using namespace pdal;

//Adding logging.
LogPtr log(new Log("pdal merge", &std::clog));
log->setLevel((LogLevel)5);

PipelineManager mgr;
mgr.setLog(log);
mgr.readPipeline(Support::configuredpath("filters/merge3.json"));
mgr.execute();

PointViewSet viewSet = mgr.views();
EXPECT_EQ(1u, viewSet.size());
PointViewPtr view = *viewSet.begin();
Expand Down

0 comments on commit 2d54b75

Please sign in to comment.