// As above, but does not Debug.Assert-fail on invalid input. Returns true if // conversion is successful. public static bool MakePolyline(string str, out S2Polyline?polyline, S2Debug override_ = S2Debug.ALLOW) { polyline = null; var vertices = new List <S2Point>(); if (!ParsePoints(str, vertices)) { return(false); } polyline = new S2Polyline(vertices.ToArray(), override_); return(true); }
// As above, but does not Debug.Assert-fail on invalid input. Returns true if // conversion is successful. public static bool MakeLoop(string str, out S2Loop?loop, S2Debug override_ = S2Debug.ALLOW) { if (str == "empty") { loop = S2Loop.kEmpty; return(true); } if (str == "full") { loop = S2Loop.kFull; return(true); } loop = null; var vertices = new List <S2Point>(); if (!ParsePoints(str, vertices)) { return(false); } loop = new S2Loop(vertices, override_); return(true); }
// Similar to MakeLoop(), but returns an S2Polyline rather than an S2Loop. public static S2Polyline MakePolylineOrDie(string str, S2Debug override_ = S2Debug.ALLOW) { System.Diagnostics.Debug.Assert(MakePolyline(str, out var polyline, override_)); return(polyline !.Value); }
// Given a string of latitude-longitude coordinates in degrees, // returns a newly allocated loop. Example of the input format: // "-20:150, 10:-120, 0.123:-170.652" // The strings "empty" or "full" create an empty or full loop respectively. public static S2Loop MakeLoopOrDie(string str, S2Debug override_ = S2Debug.ALLOW) { System.Diagnostics.Debug.Assert(MakeLoop(str, out var loop, override_)); return(loop !); }