GEOS 3.15.0dev
FacetSequenceTreeBuilder.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/FacetSequenceTreeBuilder.java (f6187ee2 JTS-1.14)
16 *
17 **********************************************************************/
18
19#pragma once
20
21#include <geos/index/strtree/TemplateSTRtree.h>
22#include <geos/operation/distance/FacetSequence.h>
23
24
25namespace geos {
26namespace geom {
27class CoordinateSequence;
28class Geometry;
29}
30}
31
32namespace geos {
33namespace operation {
34namespace distance {
35
36class GEOS_DLL FacetSequenceTreeBuilder {
37
38private:
39
40 // 6 seems to be a good facet sequence size
41 static const std::size_t FACET_SEQUENCE_SIZE = 6;
42
43 // Seems to be better to use a minimum node capacity
44 static const std::size_t STR_TREE_NODE_CAPACITY = 4;
45
46 static void addFacetSequences(const geom::CoordinateSequence* pts,
47 std::vector<FacetSequence> & sections);
48 static std::vector<FacetSequence> computeFacetSequences(const geom::Geometry* g);
49
50 class FacetSequenceTree : public geos::index::strtree::TemplateSTRtree<const FacetSequence*> {
51 public:
52 // TODO support TemplateSTRtree<std::unique_ptr<FacetSequence>> and dispense with holding vector.
53 FacetSequenceTree(std::vector<FacetSequence> &&seq) :
54 TemplateSTRtree(STR_TREE_NODE_CAPACITY, seq.size()), sequences(seq) {
55 for (auto& fs : sequences) {
56 TemplateSTRtree::insert(fs.getEnvelope(), &fs);
57 }
58 }
59
60 private:
61 std::vector<FacetSequence> sequences;
62 };
63
64public:
65
72 static std::unique_ptr<geos::index::strtree::TemplateSTRtree<const FacetSequence*>> build(const geom::Geometry* g);
73};
74
75}
76}
77}
78
Basic namespace for all GEOS functionalities.
Definition geos.h:38