[Liblas-commits] hg-main-tree: fix up float->double in
FauxReader/Writer
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Mar 16 13:11:51 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/e42e3d5bfd7e
changeset: 281:e42e3d5bfd7e
user: Howard Butler <hobu.inc at gmail.com>
date: Wed Mar 16 12:11:43 2011 -0500
description:
fix up float->double in FauxReader/Writer
diffstat:
src/drivers/faux/Reader.cpp | 30 +++++++++++++++---------------
test/unit/FauxReaderTest.cpp | 12 ++++++------
test/unit/PointDataTest.cpp | 7 +++----
3 files changed, 24 insertions(+), 25 deletions(-)
diffs (119 lines):
diff -r f39615782b97 -r e42e3d5bfd7e src/drivers/faux/Reader.cpp
--- a/src/drivers/faux/Reader.cpp Wed Mar 16 11:22:48 2011 -0500
+++ b/src/drivers/faux/Reader.cpp Wed Mar 16 12:11:43 2011 -0500
@@ -52,9 +52,9 @@
Header* header = new Header;
Schema& schema = header->getSchema();
- schema.addDimension(Dimension(Dimension::Field_X, Dimension::Float));
- schema.addDimension(Dimension(Dimension::Field_Y, Dimension::Float));
- schema.addDimension(Dimension(Dimension::Field_Z, Dimension::Float));
+ schema.addDimension(Dimension(Dimension::Field_X, Dimension::Double));
+ schema.addDimension(Dimension(Dimension::Field_Y, Dimension::Double));
+ schema.addDimension(Dimension(Dimension::Field_Z, Dimension::Double));
schema.addDimension(Dimension(Dimension::Field_Time, Dimension::Uint64));
header->setNumPoints(numPoints);
@@ -126,27 +126,27 @@
for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
{
- float x;
- float y;
- float z;
+ double x;
+ double y;
+ double z;
if (m_mode == Random)
{
- x = (float)Utils::random(minX, maxX);
- y = (float)Utils::random(minY, maxY);
- z = (float)Utils::random(minZ, maxZ);
+ x = (double)Utils::random(minX, maxX);
+ y = (double)Utils::random(minY, maxY);
+ z = (double)Utils::random(minZ, maxZ);
}
else
{
- x = (float)minX;
- y = (float)minY;
- z = (float)minZ;
+ x = (double)minX;
+ y = (double)minY;
+ z = (double)minZ;
}
data.setValid(pointIndex);
- data.setField<float>(pointIndex, offsetX, x);
- data.setField<float>(pointIndex, offsetY, y);
- data.setField<float>(pointIndex, offsetZ, z);
+ data.setField<double>(pointIndex, offsetX, x);
+ data.setField<double>(pointIndex, offsetY, y);
+ data.setField<double>(pointIndex, offsetZ, z);
data.setField<boost::uint64_t>(pointIndex, offsetT, time);
++time;
diff -r f39615782b97 -r e42e3d5bfd7e test/unit/FauxReaderTest.cpp
--- a/test/unit/FauxReaderTest.cpp Wed Mar 16 11:22:48 2011 -0500
+++ b/test/unit/FauxReaderTest.cpp Wed Mar 16 12:11:43 2011 -0500
@@ -63,9 +63,9 @@
for (boost::uint32_t i=0; i<numRead; i++)
{
- float x = data.getField<float>(i, offsetX);
- float y = data.getField<float>(i, offsetY);
- float z = data.getField<float>(i, offsetZ);
+ double x = data.getField<double>(i, offsetX);
+ double y = data.getField<double>(i, offsetY);
+ double z = data.getField<double>(i, offsetZ);
boost::uint64_t t = data.getField<boost::uint64_t>(i, offsetT);
BOOST_CHECK( Utils::compare_approx( (double)x, 1.0, (std::numeric_limits<double>::min)()) == true);
@@ -99,9 +99,9 @@
for (boost::uint32_t i=0; i<numRead; i++)
{
- float x = data.getField<float>(i, offsetX);
- float y = data.getField<float>(i, offsetY);
- float z = data.getField<float>(i, offsetZ);
+ double x = data.getField<double>(i, offsetX);
+ double y = data.getField<double>(i, offsetY);
+ double z = data.getField<double>(i, offsetZ);
boost::uint64_t t = data.getField<boost::uint64_t>(i, offsetT);
BOOST_CHECK(x >= 1.0 && x <= 101.0);
diff -r f39615782b97 -r e42e3d5bfd7e test/unit/PointDataTest.cpp
--- a/test/unit/PointDataTest.cpp Wed Mar 16 11:22:48 2011 -0500
+++ b/test/unit/PointDataTest.cpp Wed Mar 16 12:11:43 2011 -0500
@@ -139,11 +139,10 @@
int ii = 10;
- BOOST_CHECK(Utils::compare_approx(z, ii+100.0, (std::numeric_limits<double>::min)()) == true);
BOOST_CHECK(x == ii+1);
BOOST_CHECK(y == ii*10);
- BOOST_CHECK(z == ii*100);
+ BOOST_CHECK(Utils::compare_approx(z, ii*100.0, (std::numeric_limits<double>::min)()) == true);
}
for (int i=1; i<18; i++)
{
@@ -154,7 +153,7 @@
int ii = i-1;
BOOST_CHECK(x == ii+1);
BOOST_CHECK(y == ii*10);
- BOOST_CHECK(z == ii*100);
+ BOOST_CHECK(Utils::compare_approx(z, ii*100.0, (std::numeric_limits<double>::min)()) == true);
}
{
const boost::uint8_t x = d2.getField<boost::uint8_t>(18, 0);
@@ -164,7 +163,7 @@
int ii = 11;
BOOST_CHECK(x == ii+1);
BOOST_CHECK(y == ii*10);
- BOOST_CHECK(z == ii*100);
+ BOOST_CHECK(Utils::compare_approx(z, ii+100.0, (std::numeric_limits<double>::min)()) == true);
}
delete data;
More information about the Liblas-commits
mailing list