[Liblas-commits] hg-main-tree: implement removeDimension
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Jul 20 15:04:34 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/79eacbeb1cb8
changeset: 889:79eacbeb1cb8
user: Howard Butler <hobu.inc at gmail.com>
date: Wed Jul 20 14:03:47 2011 -0500
description:
implement removeDimension
Subject: hg-main-tree: oops, in/out flipped for srs
details: http://hg.libpc.orghg-main-tree/rev/db379d14376d
changeset: 890:db379d14376d
user: Howard Butler <hobu.inc at gmail.com>
date: Wed Jul 20 14:03:59 2011 -0500
description:
oops, in/out flipped for srs
Subject: hg-main-tree: cannot delete a const& from a Schema
details: http://hg.libpc.orghg-main-tree/rev/f96d726d6c33
changeset: 891:f96d726d6c33
user: Howard Butler <hobu.inc at gmail.com>
date: Wed Jul 20 14:04:21 2011 -0500
description:
cannot delete a const& from a Schema
diffstat:
apps/pc2pc.cpp | 6 +-
include/pdal/Schema.hpp | 32 +--------------------
src/Schema.cpp | 65 +++++++++---------------------------------
src/filters/ScalingFilter.cpp | 12 +++---
4 files changed, 25 insertions(+), 90 deletions(-)
diffs (232 lines):
diff -r cd1f7f438601 -r f96d726d6c33 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp Wed Jul 20 12:34:15 2011 -0500
+++ b/apps/pc2pc.cpp Wed Jul 20 14:04:21 2011 -0500
@@ -152,9 +152,9 @@
pdal::OptionsOld options(oracle_options);
boost::property_tree::ptree in_srs_options = las_options.get_child("spatialreference");
- std::string out_wkt = in_srs_options.get<std::string>("userinput");
+ std::string in_wkt = in_srs_options.get<std::string>("userinput");
boost::property_tree::ptree out_srs_options = oracle_options.get_child("spatialreference");
- std::string in_wkt = out_srs_options.get<std::string>("userinput");
+ std::string out_wkt = out_srs_options.get<std::string>("userinput");
pdal::SpatialReference in_ref(in_wkt);
pdal::SpatialReference out_ref(out_wkt);
@@ -180,7 +180,7 @@
scalez, offsetz,
true);
- pdal::filters::ByteSwapFilter swapper(descalingFilter);
+ // pdal::filters::ByteSwapFilter swapper(descalingFilter);
pdal::drivers::oci::Writer writer(descalingFilter, options);
writer.write(numPoints);
diff -r cd1f7f438601 -r f96d726d6c33 include/pdal/Schema.hpp
--- a/include/pdal/Schema.hpp Wed Jul 20 12:34:15 2011 -0500
+++ b/include/pdal/Schema.hpp Wed Jul 20 14:04:21 2011 -0500
@@ -56,40 +56,10 @@
#include <boost/array.hpp>
#include <boost/optional.hpp>
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <boost/multi_index/hashed_index.hpp>
-#include <boost/multi_index/sequenced_index.hpp>
-#include <boost/multi_index/mem_fun.hpp>
-#include <boost/multi_index/random_access_index.hpp>
-
namespace pdal
{
-namespace schema {
-namespace index {
-
-struct name{};
-struct position{};
-struct index{};
-
-typedef boost::multi_index::multi_index_container<
- Dimension,
- boost::multi_index::indexed_by<
- // sort by Dimension::operator<
- // boost::multi_index::ordered_unique<boost::multi_index::tag<position>, boost::multi_index::identity<Dimension> >,
-
- // Random access
- boost::multi_index::random_access<boost::multi_index::tag<index> >
- // sort by less<string> on GetName
- // boost::multi_index::hashed_unique<boost::multi_index::tag<name>, boost::multi_index::const_mem_fun<Dimension,std::string const&,&Dimension::GetName> >
- >
-> IndexMap;
-
-}} // pdal::schema::index
-
/// Schema definition
class PDAL_DLL Schema
{
@@ -140,7 +110,7 @@
// this is a mapping from field name to index position in the
// m_dimensions array (or -1 if field not present)
- int m_indexTable[Dimension::Field_LAST];
+ // int m_indexTable[Dimension::Field_LAST];
};
diff -r cd1f7f438601 -r f96d726d6c33 src/Schema.cpp
--- a/src/Schema.cpp Wed Jul 20 12:34:15 2011 -0500
+++ b/src/Schema.cpp Wed Jul 20 14:04:21 2011 -0500
@@ -55,10 +55,6 @@
Schema::Schema()
{
- for (int i=0; i<Dimension::Field_LAST; i++)
- {
- m_indexTable[i] = -1;
- }
return;
}
@@ -67,10 +63,7 @@
Schema::Schema(Schema const& other)
: m_dimensions(other.m_dimensions)
{
- for (int i=0; i<Dimension::Field_LAST; i++)
- {
- m_indexTable[i] = other.m_indexTable[i];
- }
+
}
@@ -80,10 +73,6 @@
if (&rhs != this)
{
m_dimensions = rhs.m_dimensions;
- for (int i=0; i<Dimension::Field_LAST; i++)
- {
- m_indexTable[i] = rhs.m_indexTable[i];
- }
}
return *this;
@@ -94,10 +83,6 @@
{
if (m_dimensions == other.m_dimensions)
{
- for (int i=0; i<Dimension::Field_LAST; i++)
- {
- if (m_indexTable[i] != other.m_indexTable[i]) return false;
- }
return true;
}
@@ -139,27 +124,15 @@
void Schema::addDimension(Dimension const& dim)
{
- std::size_t index = m_dimensions.size();
-
m_dimensions.push_back(dim);
-
- const Dimension::Field field = dim.getField();
- assert(m_indexTable[field] == -1);
- m_indexTable[field] = (int)index;
-
return;
}
void Schema::removeDimension(Dimension const& dim)
{
- const Dimension::Field field = dim.getField();
- assert(m_indexTable[field] != -1);
- m_indexTable[field] = -1;
-
- //std::size_t index = getDimensionIndex(dim);
- //m_dimensions[index] = Dimension(Dimension::Field_INVALID, Dimension::Int32);
-
+ m_dimensions.erase( std::remove( m_dimensions.begin(), m_dimensions.end(), dim),
+ m_dimensions.end());
return;
}
@@ -184,24 +157,17 @@
int Schema::getDimensionIndex(Dimension::Field field, Dimension::DataType datatype) const
{
- const int index = m_indexTable[field];
-
- // assert(index != -1);
- if (index == -1)
+ DimensionsCIter it = m_dimensions.begin();
+ int i = 0;
+ while (it != m_dimensions.end())
{
- return -1;
- // throw pdal_error("Requested dimension field not present");
+ if (field == it->getField() && datatype == it->getDataType())
+ return i;
+ ++it;
+ ++i;
}
-
- const Dimension& dim = m_dimensions[index];
-
- // assert(dim.getDataType() == datatype);
- if (dim.getDataType() != datatype)
- {
- throw dimension_not_found("Requested dimension field present, but with different datatype");
- }
-
- return index;
+
+ return -1;
}
@@ -213,10 +179,9 @@
bool Schema::hasDimension(Dimension::Field field, Dimension::DataType datatype) const
{
- const int index = m_indexTable[field];
- if (index == -1) return false;
- const Dimension& dim = m_dimensions[index];
- if (dim.getDataType() != datatype) return false;
+ int t = getDimensionIndex(field, datatype);
+ if (t == -1)
+ return false;
return true;
}
diff -r cd1f7f438601 -r f96d726d6c33 src/filters/ScalingFilter.cpp
--- a/src/filters/ScalingFilter.cpp Wed Jul 20 12:34:15 2011 -0500
+++ b/src/filters/ScalingFilter.cpp Wed Jul 20 14:04:21 2011 -0500
@@ -95,9 +95,9 @@
const int indexYd = schema.getDimensionIndex(Dimension::Field_Y, Dimension::Double);
const int indexZd = schema.getDimensionIndex(Dimension::Field_Z, Dimension::Double);
- const Dimension& dimXd = schema.getDimension(indexXd);
- const Dimension& dimYd = schema.getDimension(indexYd);
- const Dimension& dimZd = schema.getDimension(indexZd);
+ const Dimension dimXd = schema.getDimension(indexXd);
+ const Dimension dimYd = schema.getDimension(indexYd);
+ const Dimension dimZd = schema.getDimension(indexZd);
Dimension dimXi(Dimension::Field_X, Dimension::Int32);
Dimension dimYi(Dimension::Field_Y, Dimension::Int32);
@@ -145,9 +145,9 @@
const int indexYi = schema.getDimensionIndex(Dimension::Field_Y, Dimension::Int32);
const int indexZi = schema.getDimensionIndex(Dimension::Field_Z, Dimension::Int32);
- const Dimension& dimXi = schema.getDimension(indexXi);
- const Dimension& dimYi = schema.getDimension(indexYi);
- const Dimension& dimZi = schema.getDimension(indexZi);
+ const Dimension dimXi = schema.getDimension(indexXi);
+ const Dimension dimYi = schema.getDimension(indexYi);
+ const Dimension dimZi = schema.getDimension(indexZi);
Dimension dimXd(Dimension::Field_X, Dimension::Double);
Dimension dimYd(Dimension::Field_Y, Dimension::Double);
More information about the Liblas-commits
mailing list