Skip to content

Commit

Permalink
default to using the file's SRS info, not the tile index column, unle…
Browse files Browse the repository at this point in the history
…ss the user overrides with the explicit 'srs_column' option (#3102)

* default to using the file's SRS info, not the tile index column, unless the user overrides with the explicit 'srs_column' option

* compilation fixes
  • Loading branch information
hobu committed May 27, 2020
1 parent 9b4b8bb commit 5e22e7b
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions io/TIndexReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ TIndexReader::FieldIndexes TIndexReader::getFields()
if (indexes.m_filename < 0)
throwError("Unable to find field '" + m_tileIndexColumnName +
"' in file '" + m_filename + "'.");
indexes.m_srs = OGR_FD_GetFieldIndex(fDefn, m_srsColumnName.c_str());
if (indexes.m_srs < 0)
throwError("Unable to find field '" + m_srsColumnName + "' in file '" +
m_filename + "'.");
if (m_srsColumnName.size())
indexes.m_srs = OGR_FD_GetFieldIndex(fDefn, m_srsColumnName.c_str());

indexes.m_ctime = OGR_FD_GetFieldIndex(fDefn, "created");
indexes.m_mtime = OGR_FD_GetFieldIndex(fDefn, "modified");
Expand All @@ -90,8 +88,12 @@ std::vector<TIndexReader::FileInfo> TIndexReader::getFiles()
FileInfo fileInfo;
fileInfo.m_filename =
OGR_F_GetFieldAsString(feature, indexes.m_filename);
fileInfo.m_srs =
OGR_F_GetFieldAsString(feature, indexes.m_srs);

if (m_srsColumnName.size())
{
fileInfo.m_srs =
OGR_F_GetFieldAsString(feature, indexes.m_srs);
}
output.push_back(fileInfo);

OGR_F_Destroy(feature);
Expand All @@ -105,7 +107,7 @@ void TIndexReader::addArgs(ProgramArgs& args)
{
args.add("lyr_name", "OGR layer name from which to read tile index layer",
m_layerName, "pdal");
args.add("srs_column", "Column to use for SRS", m_srsColumnName, "srs");
args.add("srs_column", "Column to use to override a file's SRS", m_srsColumnName, "");
args.add("tindex_name", "OGR column name from which to read tile "
"index location", m_tileIndexColumnName, "location");
args.add("sql", "OGR-compatible SQL statement for querying tile "
Expand Down Expand Up @@ -226,17 +228,19 @@ void TIndexReader::initialize()
reader->setOptions(readerOptions);
Stage *premerge = reader;

if (m_tgtSrsString != f.m_srs &&
(m_tgtSrsString.size() && f.m_srs.size()))
if (m_tgtSrsString.size() )
{
Stage *repro = m_factory.createStage("filters.reprojection");
repro->setInput(*reader);
Options reproOptions;
reproOptions.add("out_srs", m_tgtSrsString);
reproOptions.add("in_srs", f.m_srs);
log()->get(LogLevel::Debug2) << "Repro = "
<< m_tgtSrsString << "/"
<< f.m_srs << "!\n";
if (m_srsColumnName.size())
{
reproOptions.add("in_srs", f.m_srs);
log()->get(LogLevel::Debug2) << "Repro = "
<< m_tgtSrsString << "/"
<< f.m_srs << "!\n";
}
repro->setOptions(reproOptions);
premerge = repro;
}
Expand Down

0 comments on commit 5e22e7b

Please sign in to comment.