/usr/include/geos/algorithm/distance/PointPairDistance.h is in libgeos++-dev 3.6.2-1build2.
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 | /**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2009 Sandro Santilli <strk@keybit.net>
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: algorithm/distance/PointPairDistance.java 1.1 (JTS-1.9)
*
**********************************************************************/
#ifndef GEOS_ALGORITHM_DISTANCE_POINTPAIRDISTANCE_H
#define GEOS_ALGORITHM_DISTANCE_POINTPAIRDISTANCE_H
#include <geos/platform.h> // for DoubleNotANumber
#include <geos/geom/Coordinate.h> // for inlines
#include <vector> // for composition
#include <cassert>
namespace geos {
namespace algorithm { // geos::algorithm
namespace distance { // geos::algorithm::distance
/**
* Contains a pair of points and the distance between them.
* Provides methods to update with a new point pair with
* either maximum or minimum distance.
*/
class PointPairDistance
{
public:
PointPairDistance()
:
pt(2),
distance(DoubleNotANumber),
isNull(true)
{
assert(pt.size() == 2);
}
void initialize()
{
isNull = true;
}
void initialize(const geom::Coordinate& p0, const geom::Coordinate& p1)
{
pt[0] = p0;
pt[1] = p1;
distance = p0.distance(p1);
isNull = false;
}
double getDistance() const
{
return distance;
}
const std::vector<geom::Coordinate>& getCoordinates() const
{
return pt;
}
const geom::Coordinate& getCoordinate(unsigned int i) const
{
assert(i<pt.size());
return pt[i];
}
void setMaximum(const PointPairDistance& ptDist)
{
setMaximum(ptDist.pt[0], ptDist.pt[1]);
}
void setMaximum(const geom::Coordinate& p0, const geom::Coordinate& p1)
{
if (isNull) {
initialize(p0, p1);
return;
}
double dist = p0.distance(p1);
if (dist > distance)
initialize(p0, p1, dist);
}
void setMinimum(const PointPairDistance& ptDist)
{
setMinimum(ptDist.pt[0], ptDist.pt[1]);
}
void setMinimum(const geom::Coordinate& p0, const geom::Coordinate& p1)
{
if (isNull) {
initialize(p0, p1);
return;
}
double dist = p0.distance(p1);
if (dist < distance)
initialize(p0, p1, dist);
}
private:
/**
* Initializes the points, avoiding recomputing the distance.
* @param p0
* @param p1
* @param dist the distance between p0 and p1
*/
void initialize(const geom::Coordinate& p0, const geom::Coordinate& p1,
double dist)
{
pt[0] = p0;
pt[1] = p1;
distance = dist;
isNull = false;
}
std::vector<geom::Coordinate> pt;
double distance;
bool isNull;
};
} // geos::algorithm::distance
} // geos::algorithm
} // geos
#endif // GEOS_ALGORITHM_DISTANCE_POINTPAIRDISTANCE_H
|