This file is indexed.

/usr/include/OTB-5.8/otbDBOverlapDataNodeFeatureFunction.txx is in libotb-dev 5.8.0+dfsg-3.

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
/*=========================================================================

  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 otbDBOverlapDataNodeFeatureFunction_txx
#define otbDBOverlapDataNodeFeatureFunction_txx

#include "otbDBOverlapDataNodeFeatureFunction.h"

namespace otb
{

/**
 * Constructor
 */
template <class TCoordRep, class TPrecision>
DBOverlapDataNodeFeatureFunction<TCoordRep, TPrecision>
::DBOverlapDataNodeFeatureFunction()
 :m_DistanceThreshold(50)//in physical coordinates
{
}

/**
 * Standard "PrintSelf" method
 */
template <class TCoordRep, class TPrecision>
void
DBOverlapDataNodeFeatureFunction<TCoordRep, TPrecision>
::PrintSelf(
  std::ostream& os,
  itk::Indent indent) const
{
  Superclass::PrintSelf( os, indent );
  os << indent << "Distance Threshold: " << m_DistanceThreshold << std::endl;
}

/**
 * Method to compute the distance of a point to a segment
 */
template <class TCoordRep, class TPrecision>
double
DBOverlapDataNodeFeatureFunction<TCoordRep, TPrecision>
::ComputeEuclideanDistanceMetricToSegment(VertexType q1, VertexType q2, VertexType p) const
{
  // Length of the segment
  double l2 = q1.SquaredEuclideanDistanceTo(q2);

  // Is the projection of p on the segment inside (0<u<1) or
  // inside the segment bounds
  double u = ((p[0] - q1[0]) *(q2[0] - q1[0] ) +
    (p[1] - q1[1]) *(q2[1] - q1[1])) / l2;

  if( u < 1e-10 ) u = 0.;
  if( u -1. > 1e-10 ) u = 1.;
  double x = q1[0] + u *(q2[0] - q1[0] );
  double y = q1[1] + u *(q2[1] - q1[1] );
  double dx = x - p[0];
  double dy = y - p[1];

  return vcl_sqrt(dx*dx + dy*dy);
 }

template <class TCoordRep, class TPrecision>
typename DBOverlapDataNodeFeatureFunction<TCoordRep, TPrecision>
::OutputType
DBOverlapDataNodeFeatureFunction<TCoordRep, TPrecision>
::Evaluate( const DataNodeType& node ) const
{
  OutputType output;

  //build the tmp DataTree containing polygon within the radius
  typename VectorDataType::Pointer tmpDataTree = VectorDataType::New();
  typename DataNodeType::Pointer root = tmpDataTree->GetDataTree()->GetRoot()->Get();
  typename DataNodeType::Pointer document = DataNodeType::New();
  document->SetNodeType(otb::DOCUMENT);
  tmpDataTree->GetDataTree()->Add(document, root);

  TreeIteratorType itVector(this->GetInputVectorData()->GetDataTree());
  itVector.GoToBegin();
    while (!itVector.IsAtEnd())
      {
      if (itVector.Get()->IsPolygonFeature())
        {
        typename DataNodeType::Pointer currentGeometry = itVector.Get();
        unsigned int i=0;
        while (i<currentGeometry->GetPolygonExteriorRing()->GetVertexList()->Size())
          {
          unsigned int j=0;
          while (j<node.GetLine()->GetVertexList()->Size()-1)
            {
            double dist;
            dist = this->ComputeEuclideanDistanceMetricToSegment(node.GetLine()->GetVertexList()->GetElement(j),
                                                     node.GetLine()->GetVertexList()->GetElement(j+1),
                                                     currentGeometry->GetPolygonExteriorRing()->GetVertexList()->GetElement(i));
            //std::cout << "dist: " << dist << std::endl;
            //std::cout << "m_DistanceThreshold: " << m_DistanceThreshold << std::endl;
            if (dist <= m_DistanceThreshold)
              {
              //Add the current polygon to the tmp DataTree
              //jump to the next one
              tmpDataTree->GetDataTree()->Add(currentGeometry, document);
              j = node.GetLine()->GetVertexList()->Size();
              i = currentGeometry->GetPolygonExteriorRing()->GetVertexList()->Size();
              }
            ++j;
            }
          ++i;
          }
        }
      ++itVector;
      }

  /*
  std::cout << this->GetInputVectorData()->GetDataTree()->Count() << std::endl;
  std::cout << tmpDataTree->GetDataTree()->Count() << std::endl;
  */
  unsigned int crossAcc = 0;
  unsigned int nbBuildings = 0;

  TreeIteratorType it(tmpDataTree->GetDataTree());
  it.GoToBegin();
  while (!it.IsAtEnd())
    {
    if (it.Get()->IsPolygonFeature())
      {
      typename DataNodeType::Pointer currentGeometry = it.Get();
      nbBuildings ++;
      for (unsigned int i=0; i<node.GetLine()->GetVertexList()->Size()-1; ++i)
        {

        if(currentGeometry->GetPolygonExteriorRing()->NbCrossing(node.GetLine()->GetVertexList()->GetElement(i),
                                                                 node.GetLine()->GetVertexList()->GetElement(i+1)))
          {
          crossAcc ++;
          break;
          }
        }
      }
    ++it;
    }

  if(nbBuildings == 0)
    {
    output.push_back(static_cast<PrecisionType>(0.));
    }
  else
    {
    output.push_back(static_cast<PrecisionType>((double)(crossAcc)/(double)(nbBuildings)));
    }

  output.push_back(static_cast<PrecisionType>(crossAcc));
  output.push_back(static_cast<PrecisionType>(nbBuildings));

  return output;
}


} // end namespace otb

#endif