Esempio n. 1
0
    public void Test_GetLength_ThreePolylinesInOneShape()
    {
        // S2EdgeVectorShape is the only standard S2Shape that can have more than
        // one edge chain of dimension 1.
        var p = ParsePointsOrDie("0:0, 1:0, 2:0, 3:0");
        S2EdgeVectorShape shape = new(new List <(S2Point, S2Point)> {
            (p[0], p[1]), (p[0], p[2]), (p[0], p[3])
        });

        Assert.Equal(S1Angle.FromDegrees(6), S2.GetLength(shape));
    }
Esempio n. 2
0
    // Returns the total length of all polylines in the index.  Returns zero if no
    // polylines are present.
    //
    // All edges are modeled as spherical geodesics.  The result can be converted
    // to a distance on the Earth's surface (with a worst-case error of 0.562%
    // near the equator) using the functions in s2earth.h.
    public static S1Angle GetLength(S2ShapeIndex index)
    {
        var length = S1Angle.Zero;

        for (int i = 0; i < index.NumShapeIds(); ++i)
        {
            var shape = index.Shape(i);
            if (shape != null)
            {
                length += S2.GetLength(shape);
            }
        }
        return(length);
    }
Esempio n. 3
0
 public void Test_GetLength_WrongDimension()
 {
     Assert.Equal(S1Angle.Zero, S2.GetLength(MakeIndexOrDie("0:0 # #").Shape(0)));
     Assert.Equal(S1Angle.Zero,
                  S2.GetLength(MakeLaxPolygonOrDie("0:0, 0:1, 1:0")));
 }