Coverage Report

Created: 2024-07-27 06:14

/src/geos/src/geom/Coordinate.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) 2001-2002 Vivid Solutions Inc.
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/geom/Coordinate.h>
16
#include <geos/constants.h> // for std::isnan
17
18
#include <sstream>
19
#include <string>
20
#include <iomanip>
21
#include <cmath>
22
23
24
namespace geos {
25
namespace geom { // geos::geom
26
27
const CoordinateXY CoordinateXY::_nullCoord = CoordinateXY(DoubleNotANumber, DoubleNotANumber);
28
const Coordinate Coordinate::_nullCoord = Coordinate(DoubleNotANumber, DoubleNotANumber, DoubleNotANumber);
29
const CoordinateXYM CoordinateXYM::_nullCoord = CoordinateXYM(DoubleNotANumber, DoubleNotANumber, DoubleNotANumber);
30
const CoordinateXYZM CoordinateXYZM::_nullCoord = CoordinateXYZM(DoubleNotANumber, DoubleNotANumber, DoubleNotANumber, DoubleNotANumber);
31
32
const CoordinateXY&
33
CoordinateXY::getNull()
34
773k
{
35
773k
    return _nullCoord;
36
773k
}
37
38
const Coordinate&
39
Coordinate::getNull()
40
163k
{
41
163k
    return _nullCoord;
42
163k
}
43
44
const CoordinateXYM&
45
CoordinateXYM::getNull()
46
0
{
47
0
    return _nullCoord;
48
0
}
49
50
const CoordinateXYZM&
51
CoordinateXYZM::getNull()
52
0
{
53
0
    return _nullCoord;
54
0
}
55
56
std::string
57
Coordinate::toString() const
58
87.0k
{
59
87.0k
    std::ostringstream s;
60
87.0k
    s << std::setprecision(17) << *this;
61
87.0k
    return s.str();
62
87.0k
}
63
64
std::string
65
CoordinateXY::toString() const
66
1
{
67
1
    std::ostringstream s;
68
1
    s << std::setprecision(17) << *this;
69
1
    return s.str();
70
1
}
71
72
std::string
73
CoordinateXYM::toString() const
74
0
{
75
0
    std::ostringstream s;
76
0
    s << std::setprecision(17) << *this;
77
0
    return s.str();
78
0
}
79
80
std::string
81
CoordinateXYZM::toString() const
82
80.7k
{
83
80.7k
    std::ostringstream s;
84
80.7k
    s << std::setprecision(17) << *this;
85
80.7k
    return s.str();
86
80.7k
}
87
88
std::ostream&
89
operator<< (std::ostream& os, const CoordinateType typ)
90
0
{
91
0
    switch(typ) {
92
0
        case CoordinateType::XY: os << "XY"; break;
93
0
        case CoordinateType::XYZ: os << "XYZ"; break;
94
0
        case CoordinateType::XYM: os << "XYM"; break;
95
0
        case CoordinateType::XYZM: os << "XYZM"; break;
96
0
    }
97
98
0
    return os;
99
0
}
100
101
std::ostream&
102
operator<< (std::ostream& os, const CoordinateXY& c)
103
1
{
104
1
    os << c.x << " " << c.y;
105
1
    return os;
106
1
}
107
108
std::ostream&
109
operator<< (std::ostream& os, const Coordinate& c)
110
87.0k
{
111
87.0k
    os << c.x << " " << c.y;
112
87.0k
    if(!std::isnan(c.z)) {
113
4.00k
        os << " " << c.z;
114
4.00k
    }
115
87.0k
    return os;
116
87.0k
}
117
118
std::ostream&
119
operator<< (std::ostream& os, const CoordinateXYM& c)
120
0
{
121
0
    os << c.x << " " << c.y;
122
0
    if(!std::isnan(c.m)) {
123
0
        os << " " << c.m;
124
0
    }
125
0
    return os;
126
0
}
127
128
std::ostream&
129
operator<< (std::ostream& os, const CoordinateXYZM& c)
130
80.7k
{
131
80.7k
    os << c.x << " " << c.y;
132
80.7k
    if(!std::isnan(c.z) || !std::isnan(c.m)) {
133
2.17k
        os << " " << c.z;
134
2.17k
    }
135
80.7k
    if(!std::isnan(c.m)) {
136
682
        os << " " << c.m;
137
682
    }
138
80.7k
    return os;
139
80.7k
}
140
141
} // namespace geos::geom
142
} // namespace geos
143