line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODULE = Geo::Geos PACKAGE = Geo::Geos::Algorithm |
2
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
3
|
|
|
|
|
|
|
|
4
|
8
|
50
|
|
|
|
|
double toDegrees (double radians) { RETVAL = Angle::toDegrees(radians); } |
5
|
|
|
|
|
|
|
|
6
|
1
|
50
|
|
|
|
|
double toRadians (double angleDegrees) { RETVAL = Angle::toRadians(angleDegrees); } |
7
|
|
|
|
|
|
|
|
8
|
1
|
50
|
|
|
|
|
double angle (Coordinate& p0) { RETVAL = Angle::angle(p0); } |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
bool isAcute (Coordinate* p0, Coordinate* p1, Coordinate *p2) { |
11
|
1
|
50
|
|
|
|
|
RETVAL = Angle::isAcute(*p0, *p1, *p2); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
bool isObtuse (Coordinate& p0, Coordinate& p1, Coordinate& p2) { |
15
|
1
|
50
|
|
|
|
|
RETVAL = Angle::isObtuse(p0, p1, p2); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
double angleBetween (Coordinate& tip1, Coordinate& tail, Coordinate& tip2) { |
19
|
1
|
50
|
|
|
|
|
RETVAL = Angle::angleBetween(tip1, tail, tip2); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
double angleBetweenOriented (Coordinate& tip1, Coordinate& tail, Coordinate& tip2) { |
23
|
1
|
50
|
|
|
|
|
RETVAL = Angle::angleBetweenOriented (tip1, tail, tip2); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
double interiorAngle(Coordinate& p0, Coordinate& p1, Coordinate& p2) { |
27
|
1
|
50
|
|
|
|
|
RETVAL = Angle::interiorAngle(p0, p1, p2); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
|
int getTurn (double ang1, double ang2) { RETVAL = Angle::getTurn(ang1, ang2); } |
31
|
|
|
|
|
|
|
|
32
|
1
|
50
|
|
|
|
|
double normalize (double angle) { RETVAL = Angle::normalize(angle); } |
33
|
|
|
|
|
|
|
|
34
|
1
|
50
|
|
|
|
|
double normalizePositive (double angle) { RETVAL = Angle::normalizePositive(angle); } |
35
|
|
|
|
|
|
|
|
36
|
1
|
50
|
|
|
|
|
double diff (double ang1, double ang2) { RETVAL = Angle::diff(ang1, ang2); } |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Coordinate* centroid (Geometry& g) { |
39
|
3
|
|
|
|
|
|
Coordinate c; |
40
|
2
|
50
|
|
|
|
|
if (Centroid::getCentroid(g, c)) RETVAL = new Coordinate(c); |
41
|
2
|
50
|
|
|
|
|
else XSRETURN_UNDEF; |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
42
|
1
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Coordinate* centroidArea (Array geoms) { |
45
|
6
|
100
|
|
|
|
|
Coordinate result; |
46
|
3
|
50
|
|
|
|
|
CentroidArea acc; |
47
|
6
|
50
|
|
|
|
|
for(size_t i = 0; i < geoms.size(); ++i) { |
|
|
100
|
|
|
|
|
|
48
|
5
|
50
|
|
|
|
|
auto item = geoms.at(i); |
|
|
100
|
|
|
|
|
|
49
|
4
|
50
|
|
|
|
|
if (item.is_array_ref()) { |
50
|
2
|
100
|
|
|
|
|
auto seq = Helper::convert_coords(Array(item)); |
51
|
2
|
50
|
|
|
|
|
acc.add(&seq); |
|
|
50
|
|
|
|
|
|
52
|
1
|
50
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
|
|
|
|
|
|
acc.add(&xs::in(item)); |
55
|
1
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
if (acc.getCentroid(result)) RETVAL = new Coordinate(result); |
58
|
3
|
50
|
|
|
|
|
else XSRETURN_UNDEF; |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
59
|
1
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Coordinate* centroidLine (Array geoms) { |
63
|
4
|
100
|
|
|
|
|
Coordinate result; |
64
|
2
|
50
|
|
|
|
|
CentroidLine acc; |
65
|
4
|
50
|
|
|
|
|
for(size_t i = 0; i < geoms.size(); ++i) { |
|
|
100
|
|
|
|
|
|
66
|
3
|
50
|
|
|
|
|
auto item = geoms.at(i); |
|
|
100
|
|
|
|
|
|
67
|
2
|
50
|
|
|
|
|
if (item.is_array_ref()) { |
68
|
1
|
50
|
|
|
|
|
auto seq = Helper::convert_coords(Array(item)); |
69
|
0
|
0
|
|
|
|
|
acc.add(&seq); |
|
|
0
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
|
|
|
|
|
|
acc.add(&xs::in(item)); |
73
|
1
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
if (acc.getCentroid(result)) RETVAL = new Coordinate(result); |
76
|
2
|
50
|
|
|
|
|
else XSRETURN_UNDEF; |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
77
|
1
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Coordinate* centroidPoint (Array geoms) { |
80
|
6
|
100
|
|
|
|
|
Coordinate result; |
81
|
3
|
50
|
|
|
|
|
CentroidPoint acc; |
82
|
6
|
50
|
|
|
|
|
for(size_t i = 0; i < geoms.size(); ++i) { |
|
|
100
|
|
|
|
|
|
83
|
6
|
50
|
|
|
|
|
Object item = Object(geoms.at(i)); |
|
|
100
|
|
|
|
|
|
84
|
8
|
50
|
|
|
|
|
if (!item) throw ("invalid argument"); |
|
|
50
|
|
|
|
|
|
85
|
4
|
100
|
|
|
|
|
if (item.stash().name() == "Geo::Geos::Coordinate") { |
86
|
3
|
50
|
|
|
|
|
acc.add(&xs::in(item)); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
} |
|
|
0
|
|
|
|
|
|
88
|
|
|
|
|
|
|
else acc.add(&xs::in(item)); |
89
|
3
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
90
|
|
|
|
|
|
|
if (acc.getCentroid(result)) RETVAL = new Coordinate(result); |
91
|
2
|
50
|
|
|
|
|
else XSRETURN_UNDEF; |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
92
|
1
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
bool isPointInRing(Coordinate& p, Array ring) { |
95
|
2
|
50
|
|
|
|
|
auto seq = Helper::convert_coords(ring); |
|
|
50
|
|
|
|
|
|
96
|
1
|
50
|
|
|
|
|
RETVAL = CGAlgorithms::isPointInRing(p, &seq); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
int locatePointInRing(Coordinate& p,Array ring) { |
100
|
2
|
50
|
|
|
|
|
auto seq = Helper::convert_coords(ring); |
|
|
50
|
|
|
|
|
|
101
|
1
|
50
|
|
|
|
|
RETVAL = CGAlgorithms::locatePointInRing(p, seq); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
bool isOnLine(Coordinate& p, Array line) { |
105
|
2
|
50
|
|
|
|
|
auto seq = Helper::convert_coords(line); |
|
|
50
|
|
|
|
|
|
106
|
1
|
50
|
|
|
|
|
RETVAL = CGAlgorithms::isPointInRing(p, &seq); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
bool isCCW(Array ring) { |
110
|
2
|
50
|
|
|
|
|
auto seq = Helper::convert_coords(ring); |
|
|
50
|
|
|
|
|
|
111
|
1
|
50
|
|
|
|
|
RETVAL = CGAlgorithms::isCCW(&seq); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
int computeOrientation(Coordinate& p1, Coordinate& p2, Coordinate& q){ |
115
|
1
|
50
|
|
|
|
|
RETVAL = CGAlgorithms::computeOrientation(p1, p2, q); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
double distancePointLine(Coordinate& p, Coordinate& A, Coordinate& B) { |
119
|
1
|
50
|
|
|
|
|
RETVAL = CGAlgorithms::distancePointLine(p, A, B); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
double distancePointLinePerpendicular(Coordinate& p, Coordinate& A, Coordinate& B) { |
123
|
1
|
50
|
|
|
|
|
RETVAL = CGAlgorithms::distancePointLinePerpendicular(p, A, B); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
double distanceLineLine (Coordinate& A, Coordinate& B, Coordinate& C, Coordinate& D) { |
127
|
1
|
50
|
|
|
|
|
RETVAL = CGAlgorithms::distanceLineLine(A, B, C, D); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
double signedArea (Array ring) { |
131
|
2
|
50
|
|
|
|
|
auto seq = Helper::convert_coords(ring); |
|
|
50
|
|
|
|
|
|
132
|
1
|
50
|
|
|
|
|
RETVAL = CGAlgorithms::signedArea(&seq); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
double length(Array pts) { |
136
|
2
|
50
|
|
|
|
|
auto seq = Helper::convert_coords(pts); |
|
|
50
|
|
|
|
|
|
137
|
1
|
50
|
|
|
|
|
RETVAL = CGAlgorithms::signedArea(&seq); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
int orientationIndex(Coordinate& p1, Coordinate& p2, Coordinate& q) { |
141
|
1
|
50
|
|
|
|
|
RETVAL = CGAlgorithms::computeOrientation(p1, p2, q); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Coordinate* getIntersection(Coordinate& p00, Coordinate& p01, Coordinate& p10, Coordinate& p11) { |
145
|
2
|
|
|
|
|
|
//auto& c = CentralEndpointIntersector::getIntersection(p00, p01, p10, p11); |
146
|
|
|
|
|
|
|
// ^ buggy implementation in 3.6.3, as it returns dangling reference; |
147
|
|
|
|
|
|
|
CentralEndpointIntersector intor(p00, p01, p10, p11); |
148
|
2
|
50
|
|
|
|
|
auto& c = intor.getIntersection(); |
149
|
1
|
|
|
|
|
|
RETVAL = new Coordinate(c); |
150
|
1
|
50
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Sv convexHull(Geometry& newGeometry) { |
153
|
2
|
50
|
|
|
|
|
auto ch = ConvexHull(&newGeometry); |
|
|
50
|
|
|
|
|
|
154
|
1
|
50
|
|
|
|
|
RETVAL = Helper::uplift(ch.getConvexHull()); |
|
|
50
|
|
|
|
|
|
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Coordinate* interiorPointArea(Geometry& g) { |
158
|
2
|
|
|
|
|
|
InteriorPointArea ip(&g); |
159
|
2
|
50
|
|
|
|
|
Coordinate c; |
|
|
50
|
|
|
|
|
|
160
|
1
|
50
|
|
|
|
|
if (ip.getInteriorPoint(c)) RETVAL = new Coordinate(c); |
161
|
1
|
50
|
|
|
|
|
else XSRETURN_UNDEF; |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Coordinate* interiorPointLine(Geometry& g) { |
165
|
2
|
|
|
|
|
|
InteriorPointLine ip(&g); |
166
|
2
|
50
|
|
|
|
|
Coordinate c; |
|
|
50
|
|
|
|
|
|
167
|
1
|
50
|
|
|
|
|
if (ip.getInteriorPoint(c)) RETVAL = new Coordinate(c); |
168
|
1
|
50
|
|
|
|
|
else XSRETURN_UNDEF; |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Coordinate* interiorPointPoint(Geometry& g) { |
172
|
2
|
|
|
|
|
|
InteriorPointPoint ip(&g); |
173
|
2
|
50
|
|
|
|
|
Coordinate c; |
|
|
50
|
|
|
|
|
|
174
|
1
|
50
|
|
|
|
|
if (ip.getInteriorPoint(c)) RETVAL = new Coordinate(c); |
175
|
1
|
50
|
|
|
|
|
else XSRETURN_UNDEF; |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
176
|
0
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
int locate(Coordinate& p, Geometry& geom) { |
179
|
2
|
|
|
|
|
|
PointLocator pl; |
180
|
1
|
50
|
|
|
|
|
RETVAL = pl.locate(p, &geom); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
bool intersects(Coordinate& p, Geometry& geom) { |
184
|
2
|
|
|
|
|
|
PointLocator pl; |
185
|
1
|
50
|
|
|
|
|
RETVAL = pl.intersects(p, &geom); |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
int signOfDet2x2(double x1, double y1, double x2, double y2) { |
189
|
1
|
50
|
|
|
|
|
RETVAL = RobustDeterminant::signOfDet2x2(x1, y1, x2, y2); |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
int locateIndexedPointInArea(Coordinate& p, Geometry& geom) { |
193
|
2
|
50
|
|
|
|
|
locate::IndexedPointInAreaLocator locator(geom); |
194
|
1
|
50
|
|
|
|
|
RETVAL = locator.locate(&p); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
int locateSimplePointInArea(Coordinate& p, Geometry& geom) { |
198
|
2
|
|
|
|
|
|
locate::SimplePointInAreaLocator locator(&geom); |
199
|
1
|
50
|
|
|
|
|
RETVAL = locator.locate(&p); |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
BOOT { |
203
|
92
|
50
|
|
|
|
|
auto this_stash = Stash(__PACKAGE__); |
204
|
368
|
50
|
|
|
|
|
xs::exp::create_constants(this_stash, { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
205
|
|
|
|
|
|
|
{"TYPE_TURN_CLOCKWISE", CGAlgorithms::CLOCKWISE}, |
206
|
|
|
|
|
|
|
{"TYPE_TURN_COLLINEAR", CGAlgorithms::COLLINEAR}, |
207
|
|
|
|
|
|
|
{"TYPE_TURN_COUNTERCLOCKWISE", CGAlgorithms::COUNTERCLOCKWISE}, |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
{"TYPE_ORIENT_RIGHT", CGAlgorithms::RIGHT}, |
210
|
|
|
|
|
|
|
{"TYPE_ORIENT_LEFT" , CGAlgorithms::LEFT}, |
211
|
|
|
|
|
|
|
{"TYPE_ORIENT_STRAIGHT", CGAlgorithms::STRAIGHT} |
212
|
322
|
50
|
|
|
|
|
}); |
213
|
46
|
50
|
|
|
|
|
xs::exp::autoexport(this_stash); |
|
|
50
|
|
|
|
|
|
214
|
|
|
|
|
|
|
} |