GEOS  3.13.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/ItemVisitor.h>
22 #include <geos/index/strtree/TemplateSTRtree.h>
23 #include <geos/geom/Geometry.h>
24 #include <geos/geom/CoordinateSequence.h>
25 #include <geos/operation/distance/FacetSequence.h>
26 
27 namespace geos {
28 namespace operation {
29 namespace distance {
30 class GEOS_DLL FacetSequenceTreeBuilder {
31 private:
32  // 6 seems to be a good facet sequence size
33  static const std::size_t FACET_SEQUENCE_SIZE = 6;
34 
35  // Seems to be better to use a minimum node capacity
36  static const std::size_t STR_TREE_NODE_CAPACITY = 4;
37 
38  static void addFacetSequences(const geom::Geometry* geom,
39  const geom::CoordinateSequence* pts,
40  std::vector<FacetSequence> & sections);
41  static std::vector<FacetSequence> computeFacetSequences(const geom::Geometry* g);
42 
43  class FacetSequenceTree : public geos::index::strtree::TemplateSTRtree<const FacetSequence*> {
44  public:
45  // TODO support TemplateSTRtree<std::unique_ptr<FacetSequence>> and dispense with holding vector.
46  FacetSequenceTree(std::vector<FacetSequence> &&seq) :
47  TemplateSTRtree(STR_TREE_NODE_CAPACITY, seq.size()), sequences(seq) {
48  for (auto& fs : sequences) {
49  TemplateSTRtree::insert(fs.getEnvelope(), &fs);
50  }
51  }
52 
53  private:
54  std::vector<FacetSequence> sequences;
55  };
56 
57 public:
64  static std::unique_ptr<geos::index::strtree::TemplateSTRtree<const FacetSequence*>> build(const geom::Geometry* g);
65 };
66 }
67 }
68 }
69 
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25