Пример #1
0
        static void FitTableSize(ZoomlevelData zoomleveldata, bool firstlevel)
        {
            int  minbaseheight = int.MaxValue;
            int  maxbaseheight = int.MinValue;
            int  maxdiff       = int.MinValue;
            uint maxoffset     = uint.MinValue;

            for (int i = 0; i < zoomleveldata.Subtiles.Count; i++)
            {
                minbaseheight = Math.Min(minbaseheight, zoomleveldata.Subtiles[i].Tableitem.Baseheight);
                maxbaseheight = Math.Max(maxbaseheight, zoomleveldata.Subtiles[i].Tableitem.Baseheight);
                maxdiff       = Math.Max(maxdiff, zoomleveldata.Subtiles[i].Tableitem.Diff);
                zoomleveldata.Subtiles[i].Tableitem.Offset = i == 0 ?
                                                             0 :
                                                             zoomleveldata.Subtiles[i - 1].Tableitem.Offset + (uint)zoomleveldata.Subtiles[i - 1].DataLength;
                maxoffset = Math.Max(maxoffset, zoomleveldata.Subtiles[i].Tableitem.Offset);
            }

            zoomleveldata.Tableitem.MinBaseheight = (ushort)minbaseheight;
            zoomleveldata.Tableitem.MaxDiff       = (ushort)maxdiff;

            if (maxoffset < 255)
            {
                zoomleveldata.Tableitem.Structure_OffsetSize = 1;
            }
            else if (maxoffset < 65536)
            {
                zoomleveldata.Tableitem.Structure_OffsetSize = 2;
            }
            else
            {
                zoomleveldata.Tableitem.Structure_OffsetSize = 3;
            }

            if (maxbaseheight < 255)
            {
                zoomleveldata.Tableitem.Structure_BaseheightSize = 1;
            }
            else
            {
                zoomleveldata.Tableitem.Structure_BaseheightSize = 2;
            }

            if (maxdiff < 255)
            {
                zoomleveldata.Tableitem.Structure_DiffSize = 1;
            }
            else
            {
                zoomleveldata.Tableitem.Structure_DiffSize = 2;
            }

            zoomleveldata.Tableitem.Structure_CodingtypeSize = firstlevel ? 1 : 0;
        }
Пример #2
0
        static void ReadBinData(string binfile, ZoomlevelData zoomleveldata)
        {
            int bin_base   = int.MinValue;
            int bin_diff   = int.MinValue;
            int bin_type   = int.MinValue;
            int bin_length = int.MinValue;

            if (File.Exists(binfile + ".info"))
            {
                using (StreamReader sr = new StreamReader(binfile + ".info")) {
                    string txt = null;
                    do
                    {
                        txt = sr.ReadLine();
                        if (txt != null)
                        {
                            txt = txt.Trim();
                            if (txt.Length > 0)
                            {
                                if (txt[0] != '#')
                                {
                                    if (!ReadNotNegativIntFromLine(txt, BIN_BASE, ref bin_base))
                                    {
                                        if (!ReadNotNegativIntFromLine(txt, BIN_DIFF, ref bin_diff))
                                        {
                                            if (!ReadNotNegativIntFromLine(txt, BIN_TYPE, ref bin_type))
                                            {
                                                if (!ReadNotNegativIntFromLine(txt, BIN_LENGTH, ref bin_length))
                                                {
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    } while (txt != null);
                }
            }

            if (bin_base < 0)
            {
                bin_base = 0;
            }
            if (bin_diff < 0)
            {
                bin_diff = 0;
            }
            if (bin_type < 0)
            {
                bin_type = 0;
            }
            if (bin_length < 0)
            {
                bin_length = 0;
            }

            SubtileTableitem tableitem = new SubtileTableitem();

            tableitem.Baseheight = (ushort)bin_base;
            tableitem.Diff       = (ushort)bin_diff;
            tableitem.Type       = (byte)bin_type;

            if (binfile.Length == 0 ||
                !File.Exists(binfile))
            {
                tableitem.Diff = 0;
                zoomleveldata.Subtiles.Add(new Subtile((byte[])null, tableitem));
            }
            else
            {
                zoomleveldata.Subtiles.Add(new Subtile(binfile, tableitem));
            }
        }