コード例 #1
0
 public void Read(System.IO.Stream stream)
 {
     //Stopwatch timer = new Stopwatch();
     //timer.Start();
     using (var reader = new Iso8211Reader(stream))
     {
         baseFile = new BaseFile(reader);
     }
     //timer.Stop();
     //Console.WriteLine(((double)(timer.Elapsed.TotalMilliseconds)).ToString("0.00 ms"));
     cell = new Cell(baseFile);
     //timer.Start();
     baseFile.BindVectorPointersOfVectors();
     baseFile.BindVectorPointersOfFeatures();
     baseFile.BuildVectorGeometry();
     baseFile.BindFeatureObjectPointers();
     //timer.Stop();
     //Console.WriteLine(((double)(timer.Elapsed.TotalMilliseconds)).ToString("0.00 ms"));
 }
コード例 #2
0
        public void ReadFromArchive(ZipArchive archive, string MapName, bool ApplyUpdates)
        {
            //Stopwatch timer = new Stopwatch();
            //timer.Start();
            string          basename  = MapName.Remove(MapName.Length - 4);
            Stream          S57map    = null;
            ZipArchiveEntry baseentry = null;
            SortedList <uint, ZipArchiveEntry> updatefiles = new SortedList <uint, ZipArchiveEntry>();
            Stream S57update;

            foreach (ZipArchiveEntry entry in archive.Entries)
            {
                if (entry.Name.Contains(basename))
                {
                    if (entry.Name.Equals(MapName))
                    {
                        baseentry = entry;
                    }
                    else
                    {
                        int    val;
                        string end = entry.Name.Substring(entry.Name.Length - 3);
                        if (char.IsDigit(end[0]) && char.IsDigit(end[1]) && char.IsDigit(end[2]))
                        {
                            int.TryParse(end, out val);
                            updatefiles.Add(Convert.ToUInt32(end.ToString()), entry);
                        }
                    }
                }
            }
            S57map = baseentry.Open();
            using (var reader = new Iso8211Reader(S57map))
            {
                baseFile = new BaseFile(reader);
            }
            S57map.Dispose();
            //timer.Stop();
            //Console.WriteLine(((double)(timer.Elapsed.TotalMilliseconds)).ToString("0.00 ms"));
            //timer.Start();
            if (ApplyUpdates)
            {
                foreach (var entry in updatefiles)
                {
                    S57update = entry.Value.Open();
                    using (var updatereader = new Iso8211Reader(S57update))
                    {
                        UpdateFile updateFile = new UpdateFile(updatereader);
                        baseFile.ApplyUpdateFile(updateFile);
                    }
                    S57update.Dispose();
                }
            }
            //timer.Stop();
            //Console.WriteLine(((double)(timer.Elapsed.TotalMilliseconds)).ToString("0.00 ms"));

            //cell = new Cell(baseFile);
            //timer.Start();
            baseFile.BindVectorPointersOfVectors();
            baseFile.BindVectorPointersOfFeatures();
            baseFile.BuildVectorGeometry();
            baseFile.BindFeatureObjectPointers();
        }
コード例 #3
0
        public void Read(ZipArchive archive, string MapName, bool ApplyUpdates)
        {
            string          basename  = MapName.Remove(MapName.Length - 4);
            Stream          S57map    = null;
            ZipArchiveEntry baseentry = null;
            SortedList <uint, ZipArchiveEntry> updatefiles = new SortedList <uint, ZipArchiveEntry>();
            Stream S57update;

            foreach (ZipArchiveEntry entry in archive.Entries)
            {
                if (entry.Name.Contains(basename))
                {
                    if (entry.Name.Equals(MapName))
                    {
                        baseentry = entry;
                    }
                    else
                    {
                        int    val;
                        string end = entry.Name.Substring(entry.Name.Length - 3);
                        if (char.IsDigit(end[0]) && char.IsDigit(end[1]) && char.IsDigit(end[2]))
                        {
                            int.TryParse(end, out val);
                            updatefiles.Add(Convert.ToUInt32(end.ToString()), entry);
                        }
                    }
                }
            }
            S57map = baseentry.Open();
            int count = (int)baseentry.Length;

            if (fileByteArray == null)
            {
                fileByteArray = new byte[count];
            }
            else
            {
                Array.Clear(fileByteArray, 0, fileByteArray.Length);
                Array.Resize(ref fileByteArray, count);
            }
            MemoryStream memoryStream = new MemoryStream(fileByteArray);

            S57map.CopyTo(memoryStream);
            memoryStream.Dispose();

            using (var reader = new Iso8211Reader(fileByteArray))
            {
                baseFile = new BaseFile(reader);
                foreach (var bla in reader.tagcollector)
                {
                    Console.WriteLine(bla);
                }
            }
            S57map.Dispose();

            if (ApplyUpdates)
            {
                foreach (var entry in updatefiles)
                {
                    S57update = entry.Value.Open();
                    count     = (int)entry.Value.Length;
                    Array.Clear(fileByteArray, 0, fileByteArray.Length);
                    Array.Resize(ref fileByteArray, count);
                    memoryStream = new MemoryStream(fileByteArray);
                    S57update.CopyTo(memoryStream);
                    memoryStream.Dispose();
                    using (var updatereader = new Iso8211Reader(fileByteArray))
                    {
                        UpdateFile updateFile = new UpdateFile(updatereader);
                        baseFile.ApplyUpdateFile(updateFile);
                    }
                    S57update.Dispose();
                }
            }
            cellInfo = new Cell(baseFile);
            baseFile.BindVectorPointersOfVectors();
            baseFile.BindVectorPointersOfFeatures();
            baseFile.BuildVectorGeometry();
            baseFile.BindFeatureObjectPointers();
        }