Пример #1
0
    public S2CellUnion GetInteriorCovering(IS2Region region)
    {
        interior_covering_ = true;
        var result = GetCoveringInternal(region);

        return(S2CellUnion.FromVerbatim(result));
    }
Пример #2
0
        public void Test_S2CellUnion_IsNormalized()
        {
            var id         = new S2CellId(new S2Point(1, 0, 0)).Parent(10);
            var cell_union = S2CellUnion.FromVerbatim(
                new List <S2CellId> {
                id.Child(0), id.Child(1), id.Child(2), id.Child(3)
            });

            Assert.True(cell_union.IsValid());
            Assert.False(cell_union.IsNormalized());
        }
Пример #3
0
        public void Test_S2CellUnion_ToStringOver500Cells()
        {
            List <S2CellId> ids = new();

            new S2CellUnion(new List <S2CellId> {
                S2CellId.FromFace(1)
            }).Denormalize(6, 1, ids);                                                           // 4096 cells
            var result = S2CellUnion.FromVerbatim(ids).ToString();

            Assert.Equal(result.Count(t => t == ','), 500);
            Assert.Equal(result[^ 4..], ",...");
Пример #4
0
        public void Test_S2CellUnion_EncodeDecode()
        {
            var cell_ids = new List <S2CellId> {
                new S2CellId(0x33),
                new S2CellId(0x8e3748fab),
                new S2CellId(0x91230abcdef83427)
            };
            var cell_union = S2CellUnion.FromVerbatim(cell_ids);

            Encoder encoder = new();

            cell_union.Encode(encoder);
            var decoder = encoder.Decoder();

            var(success, decoded_cell_union) = S2CellUnion.Decode(decoder);
            Assert.True(success);
            Assert.Equal(cell_union, decoded_cell_union);
        }
Пример #5
0
        public void Test_S2CellUnion_RefuseToDecode()
        {
            List <S2CellId> cellids = new();
            S2CellId        id      = S2CellId.Begin(S2.kMaxCellLevel);

            for (int i = 0; i <= S2CellUnion.Union_decode_max_num_cells; ++i)
            {
                cellids.Add(id);
                id = id.Next();
            }
            S2CellUnion cell_union = S2CellUnion.FromVerbatim(cellids);
            Encoder     encoder    = new();

            cell_union.Encode(encoder);
            var decoder = encoder.Decoder();

            var(success, _) = S2CellUnion.Decode(decoder);
            Assert.False(success);
        }