Exemple #1
0
        public override System.IO.MemoryStream AsBinary()
        {
            System.Collections.Generic.List <System.IO.MemoryStream> buffers = new System.Collections.Generic.List <System.IO.MemoryStream>(0);
            int size = 9;
            int n    = NumGeometries();

            for (int i = 0; i < n; i++)
            {
                System.IO.MemoryStream buffer = GeometryN(i).AsBinary();
                buffers.Add(buffer);
                size += buffer.Capacity();
            }
            System.IO.MemoryStream wkbBuffer = System.IO.MemoryStream.Allocate(size).Order(java.nio.ByteOrder.NativeOrder());
            byte byteOrder = unchecked ((byte)(wkbBuffer.Order() == java.nio.ByteOrder.LITTLE_ENDIAN ? 1 : 0));
            int  wkbType   = 7;

            if (Is3D())
            {
                wkbType += 1000;
            }
            if (IsMeasured())
            {
                wkbType += 2000;
            }
            wkbBuffer.Put(0, byteOrder);
            wkbBuffer.PutInt(1, wkbType);
            wkbBuffer.PutInt(5, n);
            int offset = 9;

            for (int i_1 = 0; i_1 < n; i_1++)
            {
                byte[] arr = ((byte[])buffers[i_1].Array());
                System.Array.Copy(arr, 0, ((byte[])wkbBuffer.Array()), offset, arr.Length);
                offset += arr.Length;
            }
            return(wkbBuffer);
        }