/src/geos/src/geom/prep/PreparedLineString.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /********************************************************************** |
2 | | * |
3 | | * GEOS - Geometry Engine Open Source |
4 | | * http://geos.osgeo.org |
5 | | * |
6 | | * Copyright (C) 2020 Sandro Santilli <strk@kbt.io> |
7 | | * Copyright (C) 2001-2002 Vivid Solutions Inc. |
8 | | * |
9 | | * This is free software; you can redistribute and/or modify it under |
10 | | * the terms of the GNU Lesser General Public Licence as published |
11 | | * by the Free Software Foundation. |
12 | | * See the COPYING file for more information. |
13 | | * |
14 | | ********************************************************************** |
15 | | * |
16 | | * Last port: geom/prep/PreparedLineString.java rev 1.3 (JTS-1.10) |
17 | | * |
18 | | **********************************************************************/ |
19 | | |
20 | | |
21 | | #include <geos/geom/prep/PreparedLineString.h> |
22 | | #include <geos/geom/prep/PreparedLineStringDistance.h> |
23 | | #include <geos/geom/prep/PreparedLineStringIntersects.h> |
24 | | #include <geos/geom/prep/PreparedLineStringNearestPoints.h> |
25 | | #include <geos/geom/GeometryFactory.h> |
26 | | #include <geos/noding/SegmentStringUtil.h> |
27 | | #include <geos/noding/FastSegmentSetIntersectionFinder.h> |
28 | | #include <geos/operation/distance/IndexedFacetDistance.h> |
29 | | |
30 | | namespace geos { |
31 | | namespace geom { // geos.geom |
32 | | namespace prep { // geos.geom.prep |
33 | | |
34 | | /* |
35 | | * public: |
36 | | */ |
37 | | |
38 | | PreparedLineString::~PreparedLineString() |
39 | 0 | { |
40 | 0 | for(noding::SegmentString::ConstVect::size_type i = 0, |
41 | 0 | ni = segStrings.size(); i < ni; ++i) { |
42 | 0 | delete segStrings[ i ]; |
43 | 0 | } |
44 | 0 | } |
45 | | |
46 | | noding::FastSegmentSetIntersectionFinder* |
47 | | PreparedLineString::getIntersectionFinder() |
48 | 0 | { |
49 | 0 | if(! segIntFinder) { |
50 | 0 | noding::SegmentStringUtil::extractSegmentStrings(&getGeometry(), segStrings); |
51 | 0 | segIntFinder.reset(new noding::FastSegmentSetIntersectionFinder(&segStrings)); |
52 | 0 | } |
53 | |
|
54 | 0 | return segIntFinder.get(); |
55 | 0 | } |
56 | | |
57 | | bool |
58 | | PreparedLineString::intersects(const geom::Geometry* g) const |
59 | 0 | { |
60 | 0 | geos::util::ensureNoCurvedComponents(g); |
61 | |
|
62 | 0 | if(! envelopesIntersect(g)) { |
63 | 0 | return false; |
64 | 0 | } |
65 | | |
66 | 0 | PreparedLineString& prep = *(const_cast<PreparedLineString*>(this)); |
67 | |
|
68 | 0 | return PreparedLineStringIntersects::intersects(prep, g); |
69 | 0 | } |
70 | | |
71 | | /* public */ |
72 | | operation::distance::IndexedFacetDistance* |
73 | | PreparedLineString:: |
74 | | getIndexedFacetDistance() const |
75 | 0 | { |
76 | 0 | if(! indexedDistance ) { |
77 | 0 | indexedDistance.reset(new operation::distance::IndexedFacetDistance(&getGeometry())); |
78 | 0 | } |
79 | 0 | return indexedDistance.get(); |
80 | 0 | } |
81 | | |
82 | | |
83 | | std::unique_ptr<geom::CoordinateSequence> |
84 | | PreparedLineString::nearestPoints(const geom::Geometry* g) const |
85 | 0 | { |
86 | 0 | return PreparedLineStringNearestPoints::nearestPoints(*this, g); |
87 | 0 | } |
88 | | |
89 | | double |
90 | | PreparedLineString::distance(const geom::Geometry* g) const |
91 | 0 | { |
92 | 0 | return PreparedLineStringDistance::distance(*this, g); |
93 | 0 | } |
94 | | |
95 | | bool |
96 | | PreparedLineString::isWithinDistance(const geom::Geometry* g, double d) const |
97 | 0 | { |
98 | 0 | return PreparedLineStringDistance(*this).isWithinDistance(g, d); |
99 | 0 | } |
100 | | |
101 | | |
102 | | } // namespace geos.geom.prep |
103 | | } // namespace geos.geom |
104 | | } // namespace geos |