/src/geos/src/operation/overlayng/PrecisionReducer.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 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/overlayng/PrecisionReducer.h> |
16 | | |
17 | | #include <geos/operation/overlayng/OverlayNG.h> |
18 | | #include <geos/geom/Geometry.h> |
19 | | |
20 | | |
21 | | namespace geos { // geos |
22 | | namespace operation { // geos.operation |
23 | | namespace overlayng { // geos.operation.overlayng |
24 | | |
25 | | using geos::geom::Geometry; |
26 | | using geos::geom::GeometryFactory; |
27 | | |
28 | | /*public static*/ |
29 | | std::unique_ptr<Geometry> |
30 | | PrecisionReducer::reducePrecision(const Geometry* geom, const PrecisionModel* pm, bool replacePrecisionModel) |
31 | 0 | { |
32 | 0 | if (replacePrecisionModel) { |
33 | 0 | auto gf = GeometryFactory::create(pm, geom->getSRID()); |
34 | 0 | OverlayNG ov(geom, nullptr, gf.get(), OverlayNG::UNION); |
35 | | /** |
36 | | * Ensure reducing a area only produces polygonal result. |
37 | | * (I.e. collapse lines are not output) |
38 | | */ |
39 | 0 | if (geom->getDimension() == 2) |
40 | 0 | ov.setAreaResultOnly(true); |
41 | |
|
42 | 0 | return ov.getResult(); |
43 | 0 | } |
44 | 0 | else { |
45 | 0 | OverlayNG ov(geom, nullptr, pm, OverlayNG::UNION); |
46 | 0 | if (geom->getDimension() == 2) |
47 | 0 | ov.setAreaResultOnly(true); |
48 | |
|
49 | 0 | return ov.getResult(); |
50 | 0 | } |
51 | 0 | } |
52 | | |
53 | | |
54 | | |
55 | | } // namespace geos.operation.overlayng |
56 | | } // namespace geos.operation |
57 | | } // namespace geos |