GEOS 3.16.0dev
FacetSequence.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2016 Daniel Baston
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************
14 *
15 * Last port: operation/distance/FacetSequence.java (aff11591)
16 *
17 **********************************************************************/
18
19#pragma once
20
21#include <geos/geom/Envelope.h>
22#include <geos/geom/Coordinate.h>
23#include <geos/operation/distance/CoordinateSequenceLocation.h>
24
25#include <vector>
26
27namespace geos {
28namespace geom {
29class CoordinateSequence;
30}
31}
32
33namespace geos {
34namespace operation {
35namespace distance {
36
37class FacetSequence {
38
39private:
40
41 const geom::CoordinateSequence* pts;
42 const std::size_t start;
43 const std::size_t end;
44
45 /*
46 * Unlike JTS, we store the envelope in the FacetSequence so
47 * that it has a clear owner. This is helpful when making a
48 * tree of FacetSequence objects (FacetSequenceTreeBuilder)
49 */
50 geom::Envelope env;
51
52 double computeDistanceLineLine(const FacetSequence& facetSeq,
53 std::vector<geom::Coordinate> *locs) const;
54
55 double computeDistancePointLine(const geom::Coordinate& pt,
56 const FacetSequence& facetSeq,
57 std::vector<geom::Coordinate> *locs) const;
58
59 void updateNearestLocationsPointLine(const geom::Coordinate& pt,
60 const geom::Coordinate& q0, const geom::Coordinate &q1,
61 std::vector<geom::Coordinate> *locs) const;
62
63 void updateNearestLocationsLineLine(const geom::Coordinate& p0, const geom::Coordinate& p1,
64 const geom::Coordinate& q0, const geom::Coordinate &q1,
65 std::vector<geom::Coordinate> *locs) const;
66
67 CoordinateSequenceLocation nearestLocationOnLine(const geom::CoordinateXY& pt) const;
68
69 static std::size_t normalize(const geom::CoordinateSequence& pts, std::size_t index);
70
71 void computeEnvelope();
72
73public:
74
75 const geom::Envelope* getEnvelope() const;
76
77 const geom::Coordinate* getCoordinate(std::size_t index) const;
78
79 std::size_t size() const;
80
81 bool isPoint() const;
82
83 double distance(const FacetSequence& facetSeq) const;
84
85 FacetSequence(const geom::CoordinateSequence* pts, std::size_t start, std::size_t end);
86
94 std::vector<geom::Coordinate> nearestLocations(const FacetSequence& facetSeq) const;
95
103 CoordinateSequenceLocation nearestLocation(const geom::CoordinateXY& p) const;
104
105};
106
107}
108}
109}
Basic namespace for all GEOS functionalities.
Definition geos.h:38