[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Oct 26 10:46:46 EDT 2010
changeset fdc33fcd75bc in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=fdc33fcd75bc
summary: silence issues with _fseeki64 and #ifdef it to only be used on _MSC_VER
changeset 974aab1b8277 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=974aab1b8277
summary: clean up some warnings and add some error checking to color filter
diffstat:
apps/laskernel.cpp | 26 ++++++++++++++++++++++----
src/lasindex.cpp | 28 ++++++++++++++++++++++++----
2 files changed, 46 insertions(+), 8 deletions(-)
diffs (145 lines):
diff -r 973726947c23 -r 974aab1b8277 apps/laskernel.cpp
--- a/apps/laskernel.cpp Tue Oct 26 07:31:35 2010 -0600
+++ b/apps/laskernel.cpp Tue Oct 26 09:46:37 2010 -0500
@@ -153,7 +153,7 @@
tree.get<double>("summary.points.maximum.y"),
tree.get<double>("summary.points.maximum.z"));
- } catch (liblas::property_tree::ptree_bad_path const& e)
+ } catch (liblas::property_tree::ptree_bad_path const& )
{
std::cerr << "Unable to write header bounds info. Does the outputted file have any points?";
return;
@@ -175,7 +175,7 @@
header.SetPointRecordsByReturnCount(i-1, count);
}
- } catch (liblas::property_tree::ptree_bad_path const& e)
+ } catch (liblas::property_tree::ptree_bad_path const& )
{
std::cerr << "Unable to write header point return count info. Does the outputted file have any points?";
return;
@@ -585,7 +585,16 @@
std::vector<liblas::Color::value_type> rgb;
for(tokenizer::iterator c = rgbs.begin(); c != rgbs.end(); ++c)
{
- rgb.push_back(atoi((*c).c_str()));
+ int color_val = atoi((*c).c_str());
+ if (color_val < std::numeric_limits<boost::uint16_t>::min() ||
+ color_val > std::numeric_limits<boost::uint16_t>::max())
+ {
+ ostringstream oss;
+ oss << "Color value must be between 0-65536, not " << color_val;
+ throw std::runtime_error( oss.str() );
+
+ }
+ rgb.push_back(static_cast<boost::uint16_t>(color_val));
}
liblas::Color color(rgb[0], rgb[1], rgb[2]);
colors.push_back(color);
@@ -611,7 +620,16 @@
std::vector<liblas::Color::value_type> rgb;
for(tokenizer::iterator c = rgbs.begin(); c != rgbs.end(); ++c)
{
- rgb.push_back(atoi((*c).c_str()));
+ int color_val = atoi((*c).c_str());
+ if (color_val < std::numeric_limits<boost::uint16_t>::min() ||
+ color_val > std::numeric_limits<boost::uint16_t>::max())
+ {
+ ostringstream oss;
+ oss << "Color value must be between 0-65536, not " << color_val;
+ throw std::runtime_error( oss.str() );
+
+ }
+ rgb.push_back(static_cast<boost::uint16_t>(color_val));
}
liblas::Color color(rgb[0], rgb[1], rgb[2]);
colors.push_back(color);
diff -r 973726947c23 -r 974aab1b8277 src/lasindex.cpp
--- a/src/lasindex.cpp Tue Oct 26 07:31:35 2010 -0600
+++ b/src/lasindex.cpp Tue Oct 26 09:46:37 2010 -0500
@@ -914,7 +914,7 @@
{
// seek and read
assert(static_cast<boost::uint32_t>(PointID) < m_pointRecordsCount);
- PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
+ PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
} // if
if (PtRead)
{
@@ -957,7 +957,7 @@
{
// seek and read
assert(static_cast<boost::uint32_t>(PointID) < m_pointRecordsCount);
- PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
+ PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
} // if
if (PtRead)
{
@@ -1001,7 +1001,7 @@
{
// seek and read
assert(static_cast<boost::uint32_t>(PointID) < m_pointRecordsCount);
- PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
+ PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
} // if
if (PtRead)
{
@@ -1190,7 +1190,7 @@
{
// get the actual point from the las file
assert(MapIt->first < m_pointRecordsCount);
- if (m_reader->seek(MapIt->first) && m_reader->ReadNextPoint())
+ if (m_reader->seek(MapIt->first) && m_reader->ReadNextPoint())
{
boost::uint32_t FirstPt = 0, LastCellZ = static_cast<boost::uint32_t>(~0);
boost::uint32_t LastSubCell = static_cast<boost::uint32_t>(~0);
@@ -1412,13 +1412,22 @@
liblas::detail::TempFileOffsetType LastWriteLocation = CellBlock[x][y].GetFileOffset();
if (LastWriteLocation == 0)
LastWriteLocation = (x * m_cellsY + y) * sizeof(liblas::detail::TempFileOffsetType);
+#ifdef _MSC_VER
_fseeki64(m_tempFile, LastWriteLocation, SEEK_SET);
+#else
+ fseek(m_tempFile, LastWriteLocation, SEEK_SET);
+#endif
if (fwrite(&m_tempFileWrittenBytes, sizeof(liblas::detail::TempFileOffsetType), 1, m_tempFile) < 1)
return (FileError("Index::PurgePointsToTempFile"));
CellBlock[x][y].SetFileOffset(m_tempFileWrittenBytes);
// seek to end of file where next block of data will be written
+#ifdef _MSC_VER
_fseeki64(m_tempFile, 0, SEEK_END);
+#else
+ fseek(m_tempFile, 0, SEEK_END);
+#endif
+
// write a blank space for later placement of next file block for this cell
if (fwrite(&EmptyOffset, sizeof(liblas::detail::TempFileOffsetType), 1, m_tempFile) < 1)
return (FileError("Index::PurgePointsToTempFile"));
@@ -1468,14 +1477,25 @@
// load the cell as it was written
// read the first offset for this cell
+
+#ifdef _MSC_VER
if (_fseeki64(m_tempFile, (CurCellX * m_cellsY + CurCellY) * sizeof (liblas::detail::TempFileOffsetType), SEEK_SET))
+#else
+ if (fseek(m_tempFile, (CurCellX * m_cellsY + CurCellY) * sizeof (liblas::detail::TempFileOffsetType), SEEK_SET))
+#endif
return (FileError("Index::LoadCellFromTempFile"));
if (fread(&FileOffset, sizeof (liblas::detail::TempFileOffsetType), 1, m_tempFile) < 1)
return (FileError("Index::LoadCellFromTempFile"));
while (FileOffset > 0)
{
// jump to the first block for this cell, read the next offset
+
+#ifdef _MSC_VER
if (_fseeki64(m_tempFile, FileOffset, SEEK_SET))
+#else
+ if (fseek(m_tempFile, FileOffset, SEEK_SET))
+#endif
+
return (FileError("Index::LoadCellFromTempFile"));
if (fread(&FileOffset, sizeof (liblas::detail::TempFileOffsetType), 1, m_tempFile) < 1)
return (FileError("Index::LoadCellFromTempFile"));
More information about the Liblas-commits
mailing list