-
Notifications
You must be signed in to change notification settings - Fork 340
/
MultiLineString.cpp
129 lines (110 loc) · 3.16 KB
/
MultiLineString.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
* Copyright (C) 2005-2006 Refractions Research Inc.
* Copyright (C) 2001-2002 Vivid Solutions Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: geom/MultiLineString.java r320 (JTS-1.12)
*
**********************************************************************/
#include <geos/geomgraph/GeometryGraph.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/MultiLineString.h>
#include <geos/operation/BoundaryOp.h>
#include <vector>
#include <cassert>
using geos::geom::GeometryFactory;
using geos::geom::MultiLineString;
using geos::geomgraph::GeometryGraph;
namespace geos {
namespace geom { // geos::geom
/*protected*/
MultiLineString::MultiLineString(std::vector<Geometry*>* newLines,
const GeometryFactory* factory)
:
GeometryCollection(newLines, factory)
{
}
MultiLineString::MultiLineString(std::vector<std::unique_ptr<LineString>> && newLines,
const GeometryFactory& factory)
: GeometryCollection(std::move(newLines), factory)
{}
MultiLineString::MultiLineString(std::vector<std::unique_ptr<Geometry>> && newLines,
const GeometryFactory& factory)
: GeometryCollection(std::move(newLines), factory)
{}
Dimension::DimensionType
MultiLineString::getDimension() const
{
return Dimension::L; // line
}
int
MultiLineString::getBoundaryDimension() const
{
if(isClosed()) {
return Dimension::False;
}
return 0;
}
std::string
MultiLineString::getGeometryType() const
{
return "MultiLineString";
}
bool
MultiLineString::isClosed() const
{
if(isEmpty()) {
return false;
}
for(const auto& g : geometries) {
const LineString* ls = detail::down_cast<const LineString*>(g.get());
if(! ls->isClosed()) {
return false;
}
}
return true;
}
std::unique_ptr<Geometry>
MultiLineString::getBoundary() const
{
operation::BoundaryOp bop(*this);
return bop.getBoundary();
}
GeometryTypeId
MultiLineString::getGeometryTypeId() const
{
return GEOS_MULTILINESTRING;
}
MultiLineString*
MultiLineString::reverseImpl() const
{
if(isEmpty()) {
return clone().release();
}
std::vector<std::unique_ptr<Geometry>> reversed(geometries.size());
std::transform(geometries.begin(),
geometries.end(),
reversed.begin(),
[](const std::unique_ptr<Geometry> & g) {
return g->reverse();
});
return getFactory()->createMultiLineString(std::move(reversed)).release();
}
const LineString*
MultiLineString::getGeometryN(std::size_t i) const
{
return static_cast<const LineString*>(geometries[i].get());
}
} // namespace geos::geom
} // namespace geos