1 /******************************************************************************
2 *
3 * Project: OpenGIS Simple Features Reference Implementation
4 * Purpose: The OGRMultiLineString class.
5 * Author: Frank Warmerdam, warmerdam@pobox.com
6 *
7 ******************************************************************************
8 * Copyright (c) 1999, Frank Warmerdam
9 * Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 * DEALINGS IN THE SOFTWARE.
28 ****************************************************************************/
29
30 #include "cpl_port.h"
31 #include "ogr_geometry.h"
32
33 #include <cstddef>
34
35 #include "cpl_error.h"
36 #include "ogr_core.h"
37 #include "ogr_p.h"
38
39 CPL_CVSID("$Id: ogrmultilinestring.cpp 464e5bd63b59963407c8adc30fcbd5899731eddc 2021-03-16 15:06:30 +0100 Even Rouault $")
40
41 /************************************************************************/
42 /* OGRMultiLineString() */
43 /************************************************************************/
44
45 /**
46 * \brief Create an empty multi line string collection.
47 */
48
49 OGRMultiLineString::OGRMultiLineString() = default;
50
51 /************************************************************************/
52 /* OGRMultiLineString( const OGRMultiLineString& ) */
53 /************************************************************************/
54
55 /**
56 * \brief Copy constructor.
57 *
58 * Note: before GDAL 2.1, only the default implementation of the constructor
59 * existed, which could be unsafe to use.
60 *
61 * @since GDAL 2.1
62 */
63
64 OGRMultiLineString::OGRMultiLineString( const OGRMultiLineString& ) = default;
65
66 /************************************************************************/
67 /* ~OGRMultiLineString() */
68 /************************************************************************/
69
70 OGRMultiLineString::~OGRMultiLineString() = default;
71
72 /************************************************************************/
73 /* operator=( const OGRMultiCurve&) */
74 /************************************************************************/
75
76 /**
77 * \brief Assignment operator.
78 *
79 * Note: before GDAL 2.1, only the default implementation of the operator
80 * existed, which could be unsafe to use.
81 *
82 * @since GDAL 2.1
83 */
84
85 OGRMultiLineString &
operator =(const OGRMultiLineString & other)86 OGRMultiLineString::operator=( const OGRMultiLineString& other )
87 {
88 if( this != &other )
89 {
90 OGRMultiCurve::operator=( other );
91 }
92 return *this;
93 }
94
95 /************************************************************************/
96 /* clone() */
97 /************************************************************************/
98
clone() const99 OGRMultiLineString *OGRMultiLineString::clone() const
100
101 {
102 return new (std::nothrow) OGRMultiLineString(*this);
103 }
104
105 /************************************************************************/
106 /* getGeometryType() */
107 /************************************************************************/
108
getGeometryType() const109 OGRwkbGeometryType OGRMultiLineString::getGeometryType() const
110
111 {
112 if( (flags & OGR_G_3D) && (flags & OGR_G_MEASURED) )
113 return wkbMultiLineStringZM;
114 else if( flags & OGR_G_MEASURED )
115 return wkbMultiLineStringM;
116 else if( flags & OGR_G_3D )
117 return wkbMultiLineString25D;
118 else
119 return wkbMultiLineString;
120 }
121
122 /************************************************************************/
123 /* getGeometryName() */
124 /************************************************************************/
125
getGeometryName() const126 const char * OGRMultiLineString::getGeometryName() const
127
128 {
129 return "MULTILINESTRING";
130 }
131
132 /************************************************************************/
133 /* isCompatibleSubType() */
134 /************************************************************************/
135
136 OGRBoolean
isCompatibleSubType(OGRwkbGeometryType eGeomType) const137 OGRMultiLineString::isCompatibleSubType( OGRwkbGeometryType eGeomType ) const
138 {
139 return wkbFlatten(eGeomType) == wkbLineString;
140 }
141
142 /************************************************************************/
143 /* exportToWkt() */
144 /************************************************************************/
145
exportToWkt(const OGRWktOptions & opts,OGRErr * err) const146 std::string OGRMultiLineString::exportToWkt(const OGRWktOptions& opts,
147 OGRErr *err) const
148
149 {
150 return exportToWktInternal(opts, err, "LINESTRING");
151 }
152
153 /************************************************************************/
154 /* hasCurveGeometry() */
155 /************************************************************************/
156
hasCurveGeometry(int) const157 OGRBoolean OGRMultiLineString::hasCurveGeometry(
158 int /* bLookForNonLinear */ ) const
159 {
160 return false;
161 }
162
163 /************************************************************************/
164 /* CastToMultiCurve() */
165 /************************************************************************/
166
167 /**
168 * \brief Cast to multicurve.
169 *
170 * The passed in geometry is consumed and a new one returned.
171 *
172 * @param poMLS the input geometry - ownership is passed to the method.
173 * @return new geometry.
174 */
175
CastToMultiCurve(OGRMultiLineString * poMLS)176 OGRMultiCurve* OGRMultiLineString::CastToMultiCurve( OGRMultiLineString* poMLS )
177 {
178 OGRMultiCurve* poMLC = new OGRMultiCurve();
179 TransferMembersAndDestroy(poMLS, poMLC);
180 return poMLC;
181 }
182