/src/geos/src/operation/buffer/SegmentMCIndex.cpp
Line | Count | Source |
1 | | /********************************************************************** |
2 | | * |
3 | | * GEOS - Geometry Engine Open Source |
4 | | * http://geos.osgeo.org |
5 | | * |
6 | | * Copyright (C) 2021 Paul Ramsey <pramsey@cleverelephant.ca> |
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 | | #include <geos/operation/buffer/SegmentMCIndex.h> |
16 | | #include <geos/geom/CoordinateSequence.h> |
17 | | #include <geos/geom/Envelope.h> |
18 | | #include <geos/index/ItemVisitor.h> |
19 | | #include <geos/index/chain/MonotoneChainBuilder.h> |
20 | | #include <geos/index/chain/MonotoneChainSelectAction.h> |
21 | | |
22 | | using geos::geom::CoordinateSequence; |
23 | | using geos::geom::Envelope; |
24 | | using namespace geos::index; |
25 | | |
26 | | namespace geos { |
27 | | namespace operation { |
28 | | namespace buffer { |
29 | | |
30 | | /* public */ |
31 | | SegmentMCIndex::SegmentMCIndex(const CoordinateSequence* segs) |
32 | 0 | { |
33 | 0 | buildIndex(segs); |
34 | 0 | } |
35 | | |
36 | | /* private */ |
37 | | void |
38 | | SegmentMCIndex::buildIndex(const CoordinateSequence* segs) |
39 | 0 | { |
40 | 0 | chain::MonotoneChainBuilder::getChains(segs, nullptr, segChains); |
41 | 0 | for (chain::MonotoneChain& mc : segChains) { |
42 | 0 | index.insert(&(mc.getEnvelope()), &mc); |
43 | 0 | } |
44 | 0 | return; |
45 | 0 | } |
46 | | |
47 | | /* public */ |
48 | | void |
49 | | SegmentMCIndex::query(const Envelope* env, chain::MonotoneChainSelectAction& action) |
50 | 0 | { |
51 | 0 | index.query(*env, [&env, &action](const chain::MonotoneChain* indexChain) { |
52 | 0 | indexChain->select(*env, action); |
53 | 0 | return true; |
54 | 0 | } |
55 | 0 | ); |
56 | 0 | } |
57 | | |
58 | | |
59 | | } // namespace geos.operation.buffer |
60 | | } // namespace geos.operation |
61 | | } // namespace geos |
62 | | |