This file is indexed.

/usr/include/OTB-6.4/otbVectorDataFileReader.txx is in libotb-dev 6.4.0+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/*
 * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
 *
 * This file is part of Orfeo Toolbox
 *
 *     https://www.orfeo-toolbox.org/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef otbVectorDataFileReader_txx
#define otbVectorDataFileReader_txx

#include <fstream>

#include "otbMacro.h"
#include "otbSystem.h"
#include "otbVectorDataIOFactory.h"
#include "otbVectorDataFileReader.h"
#include "itksys/SystemTools.hxx"
#include "otbVectorDataAdapter.h"
#include "otbVectorData.h"

namespace otb
{
/**
 * Constructor
 */
template <class TOutputVectorData>
VectorDataFileReader<TOutputVectorData>
::VectorDataFileReader() :
  m_VectorDataIO(ITK_NULLPTR),
  m_UserSpecifiedVectorDataIO(false),
  m_FileName("")
{
}

/**
 * Destructor
 */
template <class TOutputVectorData>
VectorDataFileReader<TOutputVectorData>
::~VectorDataFileReader()
{
}

/** Test whether the given filename exist and it is readable,
     this is intended to be called before attempting to use
     VectorDataIO classes for actually reading the file. If the file
     doesn't exist or it is not readable, and exception with an
     appropriate message will be thrown. */
template <class TOutputVectorData>
void
VectorDataFileReader<TOutputVectorData>
::TestFileExistenceAndReadability()
{
  // Test if the file exists.
  if (!itksys::SystemTools::FileExists(this->m_FileName.c_str()))
    {
    VectorDataFileReaderException e(__FILE__, __LINE__);
    std::ostringstream msg;
    msg << "The file doesn't exist. "
        << std::endl << "Filename = " << this->m_FileName
        << std::endl;
    e.SetDescription(msg.str().c_str());
    throw e;
    return;
    }

  // Test if the file can be open for reading access.
  //Only if m_FileName speciy a filename (not a dirname)
  // FIXME shapefile should be able to open a directory and load the
  // individual shapefiles as layers
  if (itksys::SystemTools::FileExists(this->m_FileName.c_str(), true) == true)
    {
    std::ifstream readTester;
    readTester.open(this->m_FileName.c_str());
    if (readTester.fail())
      {
      readTester.close();
      std::ostringstream msg;
      msg << "The file couldn't be opened for reading. "
          << std::endl << "Filename: " << this->m_FileName
          << std::endl;
      VectorDataFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION);
      throw e;
      return;

      }
    readTester.close();
    }
}

template <class TOutputVectorData>
void
VectorDataFileReader<TOutputVectorData>
::SetVectorDataIO(VectorDataIOBaseType * vectorDataIO)
{
  itkDebugMacro("setting VectorDataIO to " << vectorDataIO);
  if (this->m_VectorDataIO != vectorDataIO)
    {
    this->m_VectorDataIO = vectorDataIO;
    this->Modified();
    }
  m_UserSpecifiedVectorDataIO = true;
}

template <class TOutputVectorData>
void
VectorDataFileReader<TOutputVectorData>
::GenerateOutputInformation(void)
{
  typename TOutputVectorData::Pointer output = this->GetOutput();

  itkDebugMacro(<< "Reading file for GenerateOutputInformation()" << m_FileName);

  // Check to see if we can read the file given the name or prefix
  //
  if (m_FileName == "")
    {
    throw VectorDataFileReaderException(__FILE__, __LINE__, "FileName must be specified", ITK_LOCATION);
    }

  // Test if the file exist and if it can be open.
  // and exception will be thrown otherwise.
  //
  try
    {
    m_ExceptionMessage = "";
    this->TestFileExistenceAndReadability();
    }
  catch (itk::ExceptionObject & err)
    {
    m_ExceptionMessage = err.GetDescription();
    }

  if (m_UserSpecifiedVectorDataIO == false)   //try creating via factory
    {
    m_VectorDataIO = VectorDataIOFactory::CreateVectorDataIO(
      m_FileName.c_str(), VectorDataIOFactory::ReadMode);
    }

  if (m_VectorDataIO.IsNull())
    {
    std::ostringstream msg;
    msg << " Could not create IO object for file "
        << m_FileName.c_str() << std::endl;
    if (m_ExceptionMessage.size())
      {
      msg << m_ExceptionMessage;
      }
    else
      {
      msg << "  Tried to create one of the following:" << std::endl;
      std::list<itk::LightObject::Pointer> allobjects =
        itk::ObjectFactoryBase::CreateAllInstance("otbVectorDataIOBase");
      for (std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin();
           i != allobjects.end(); ++i)
        {
        VectorDataIOBase* io = dynamic_cast<VectorDataIOBase*>(i->GetPointer());
        msg << "    " << io->GetNameOfClass() << std::endl;
        }
      msg << "  You probably failed to set a file suffix, or" << std::endl;
      msg << "    set the suffix to an unsupported type." << std::endl;
      }
    VectorDataFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION);
    throw e;
    return;
    }

  m_VectorDataIO->SetFileName(m_FileName.c_str());

  //Copy MetaDataDictionary from instantiated reader to output VectorData.
  output->SetMetaDataDictionary(m_VectorDataIO->GetMetaDataDictionary());
  this->SetMetaDataDictionary(m_VectorDataIO->GetMetaDataDictionary());
}

template <class TOutputVectorData>
void
VectorDataFileReader<TOutputVectorData>
::GenerateData()
{

  typename TOutputVectorData::Pointer output = this->GetOutput();

  itkDebugMacro (<< "VectorDataFileReader::GenerateData() \n");

  // Test if the file exist and if it can be open.
  // and exception will be thrown otherwise.
  try
    {
    m_ExceptionMessage = "";
    this->TestFileExistenceAndReadability();
    }
  catch (itk::ExceptionObject & err)
    {
    m_ExceptionMessage = err.GetDescription();
    }

  m_VectorDataIO->SetFileName(m_FileName.c_str());

  // Tell the VectorDataIO to read the file
  //

  typedef VectorDataAdapter<VectorData<double, 2>, TOutputVectorData> AdapterType;
  typename AdapterType::InputVectorDataType::Pointer input = AdapterType::InputVectorDataType::New();

  m_VectorDataIO->Read(input);

  typename AdapterType::Pointer adapter = AdapterType::New();
  adapter->SetInput(input);
  adapter->GraftOutput(output);
  adapter->Update();
  this->GraftOutput(adapter->GetOutput());

  return;
}

template <class TOutputVectorData>
void
VectorDataFileReader<TOutputVectorData>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
  Superclass::PrintSelf(os, indent);

  if (m_VectorDataIO)
    {
    os << indent << "VectorDataIO: \n";
    m_VectorDataIO->Print(os, indent.GetNextIndent());
    }
  else
    {
    os << indent << "m_VectorDataIO: (null)" << "\n";
    }

  os << indent << "UserSpecifiedVectorDataIO flag: " << m_UserSpecifiedVectorDataIO << "\n";
  os << indent << "m_FileName: " << m_FileName << "\n";
}

} //namespace otb

#endif