blob: 44e5c38b5f6714fc754e17c707bf297125b6d343 (
plain) (
blame)
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
|
#include "polygon.h"
namespace NGeo {
TMaybe<TGeoPolygon> TGeoPolygon::TryParse(TStringBuf s, TStringBuf llDelimiter, TStringBuf pointsDelimiter) {
TVector<TGeoPoint> points;
for (const auto& pointString : StringSplitter(s).SplitByString(pointsDelimiter).SkipEmpty()) {
auto curPoint = TGeoPoint::TryParse(pointString.Token(), llDelimiter);
if (!curPoint) {
return {};
}
points.push_back(*curPoint);
}
if (points.size() < 3) {
return {};
}
return TGeoPolygon(points);
}
TGeoPolygon TGeoPolygon::Parse(TStringBuf s, TStringBuf llDelimiter, TStringBuf pointsDelimiter) {
auto res = TGeoPolygon::TryParse(s, llDelimiter, pointsDelimiter);
if (!res) {
ythrow yexception() << "Can't parse polygon from input string: " << s;
}
return *res;
}
} // namespace NGeo
|