Commit 20a5cc18 authored by Luc Hermitte's avatar Luc Hermitte

DOC: OTB-134/OGR -> field

parent 62169541
......@@ -82,6 +82,10 @@ void otb::ogr::DataSource::Reset(OGRDataSource * source)
}
namespace { // Anonymous namespace
/**\ingroup GeometryInternals
* \brief Type for associating filename extension with OGR driver names.
* \since OTB v 3.14.0
*/
struct ExtensionDriverAssociation
{
char const* extension;
......@@ -91,6 +95,10 @@ struct ExtensionDriverAssociation
return ext == extension;
}
};
/**\ingroup GeometryInternals
* \brief Associative table of filename extension -> OGR driver names.
* \since OTB v 3.14.0
*/
const ExtensionDriverAssociation k_ExtensionDriverMap[] =
{
{"SHP", "ESRI Shapefile"},
......@@ -100,6 +108,14 @@ const ExtensionDriverAssociation k_ExtensionDriverMap[] =
{"SQLITE", "SQLite"},
{"KML", "KML"},
};
/**\ingroup GeometryInternals
* \brief Returns the OGR driver name associated to a filename.
* \since OTB v 3.14.0
* \note Relies on the driver name associated to the filename extension in \c
* k_ExtensionDriverMap.
* \note As a special case, filenames starting with "PG:" are bound to
* "PostgreSQL".
*/
char const* DeduceDriverName(std::string filename)
{
std::transform(filename.begin(), filename.end(), filename.begin(), (int (*)(int))toupper);
......@@ -168,7 +184,8 @@ otb::ogr::DataSource::New(std::string const& filename, Modes::type mode)
char const* driverName = DeduceDriverName(filename);
if (!driverName)
{
itkGenericExceptionMacro(<< "No OGR driver known to OTB to create and handle a DataSource named <"<<filename<<">.");
itkGenericExceptionMacro(<< "No OGR driver known to OTB to create and handle a DataSource named <"
<<filename<<">.");
}
OGRSFDriver * d = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driverName);
......@@ -354,18 +371,22 @@ otb::ogr::Layer otb::ogr::DataSource::ExecuteSQL(
/*===============================[ features ]================================*/
/*===========================================================================*/
namespace { // Anonymous namespace
struct AccuLayersSizes
/**\ingroup GeometryInternals
* \brief %Functor used to accumulate the sizes of the layers in a \c DataSource.
* \since OTB v 3.14.0
*/
struct AccuLayersSizes
{
AccuLayersSizes(bool doForceComputation)
: m_doForceComputation(doForceComputation) { }
int operator()(int accumulated, otb::ogr::Layer const& layer) const
{
AccuLayersSizes(bool doForceComputation)
: m_doForceComputation(doForceComputation) { }
int operator()(int accumulated, otb::ogr::Layer const& layer) const
{
const int loc_size = layer.GetFeatureCount(m_doForceComputation);
return loc_size < 0 ? loc_size : loc_size+accumulated;
}
private:
bool m_doForceComputation;
};
const int loc_size = layer.GetFeatureCount(m_doForceComputation);
return loc_size < 0 ? loc_size : loc_size+accumulated;
}
private:
bool m_doForceComputation;
};
} // Anonymous namespace
int otb::ogr::DataSource::Size(bool doForceComputation) const
......
......@@ -29,7 +29,7 @@
/*===========================[ Static Assertions ]===========================*/
/*===========================================================================*/
namespace otb { namespace ogr {
namespace metaprog {
namespace internal {
BOOST_STATIC_ASSERT(!(boost::is_same<
MemberGetterPtr<int, &OGRFeature::GetFieldAsInteger>,
MemberGetterPtr<double, &OGRFeature::GetFieldAsDouble>
......@@ -84,13 +84,13 @@ BOOST_STATIC_ASSERT((boost::is_contiguous<std::vector<int> >::value));
std::string otb::ogr::FieldDefn::GetName() const
{
assert(m_definition);
assert(m_definition && "No field definition wrapped");
return m_definition->GetNameRef();
}
OGRFieldType otb::ogr::FieldDefn::GetType() const
{
assert(m_definition);
assert(m_definition && "No field definition wrapped");
return m_definition->GetType();
}
......@@ -103,13 +103,13 @@ otb::ogr::Field::Field(otb::ogr::Feature & feature, size_t index)
, m_Feature(feature.sptr())
, m_index(index)
{
assert(m_Feature);
assert(m_Feature->GetFieldDefnRef(index));
CheckInvariants();
}
std::ostream & otb::ogr::Field::PrintSelf(
std::ostream& os, itk::Indent indent) const
{
CheckInvariants();
const itk::Indent one_indent = itk::Indent().GetNextIndent();
// os << indent << "|" << one_indent << "+ ";
os << indent << this->GetName() << ": ";
......@@ -143,12 +143,12 @@ std::ostream & otb::ogr::Field::PrintSelf(
bool otb::ogr::Field::HasBeenSet() const
{
assert(m_Feature);
CheckInvariants();
return m_Feature->IsFieldSet(m_index);
}
void otb::ogr::Field::Unset() const
{
assert(m_Feature);
CheckInvariants();
m_Feature->UnsetField(m_index);
}
This diff is collapsed.
......@@ -23,11 +23,21 @@ class OGRGeometry;
namespace otb { namespace ogr {
namespace internal {
/**\ingroup GeometryInternals
* Deleter dedicated to \c OGRGeometry.
* \internal
* Unlike OGR, works as a no-op on null geometries.
*
* Unlike the other deleters used, the type of this one needs to be known in the
* header file in order to define the type \c UniqueGeometryPtr. As a
* consequence, it is not in an anonymous namespace , but in \c
* otb::ogr::internal.
*/
struct GeometryDeleter
{
void operator()(OGRGeometry* p);
};
} // metaprog namespace
} // internal namespace
// we don't encapsulate OGRGeometry, but please, don't create new geometries with a new.
......
......@@ -30,10 +30,10 @@
/*======================[ Construction & Destruction ]=======================*/
/*===========================================================================*/
namespace { // Anonymous namespace
/**\ingroup Geometry
/**\ingroup GeometryInternals
* Deleter for \c boost::shared_ptr<> that doesn't delete.
* This is required for \c OGRLayer s that belong to \c OGRDataSource.
* \internal
* \internal Unlike OGR, works as a no-op on null geometries.
*/
struct LeaveAloneDeleter
{
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbBoostDox_h
#define __otbBoostDox_h
/**\defgroup boost Boost alike helpers
* \ingroup Thematic
* Various helpers that are likelly to end-up in boost by themselves eventually.
* \see http://www.boost.org/
* @{
*/
namespace boost { }
//@}
#endif // __otbBoostDox_h
......@@ -63,6 +63,7 @@ template <typename T, std::size_t N> class array;
template <typename T, std::size_t N, typename CloneAllocator> class ptr_array;
template <typename T, typename CloneAllocator, typename Allocator> class ptr_vector;
// is_contiguous specialisations
template <typename T, typename Allocator> struct is_contiguous<std::vector<T, Allocator> >
{ enum {value = true}; };
template <typename T, std::size_t N> struct is_contiguous<boost::array<T, N> >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment