Пример #1
0
 private static void ListFeatures(S57Reader reader)
 {
     foreach (var obj in S57ObjectInfo.S57Dict)
     {
         int    a    = reader.GetFeaturesOfClass(obj.Key).Count;
         string test = obj.Key.ToString();
         if (a > 0)
         {
             var features = reader.GetFeaturesOfClass(obj.Key);
             int count    = 0;
             for (int i = 0; i < features.Count; i++)
             {
                 if (features[i].Attributes != null && features[i].Attributes.ContainsKey(S57Att.SCAMIN))
                 {
                     count++;
                 }
             }
             string tempString = null;
             if (features[0].Attributes != null)
             {
                 features[0].Attributes.TryGetValue(S57Att.SCAMIN, out tempString);
             }
             Console.WriteLine(test + ": " + count + "/" + a + " " + tempString);
             //Console.WriteLine(test + ": " + "{0:G}", a.ToString());
         }
     }
 }
Пример #2
0
        //static void Main(string[] args)
        static void Main()
        {
            //string path = args[0];
            var    reader  = new S57Reader();
            string ZipName = "NC_ENCs.zip";
            //string MapName = "ENC_ROOT/CATALOG.031";
            //string MapName = "ENC_ROOT/US5NC51M/US5NC51M.000";
            string MapName  = "ENC_ROOT/US5NC18M/US5NC18M.000";
            string rootPath = "D:/Familie/Documents/Programming/test";
            string zipPath  = Path.Combine(rootPath, ZipName);
            var    bla      = ZipFile.OpenRead(zipPath);
            Stream S57map   = bla.GetEntry(MapName).Open();

            //reader.ReadCatalogue(S57map);
            reader.Read(S57map);

            //reader.Read(new FileStream(path, FileMode.Open));
            //ListFeatures(reader);
            var features = reader.GetFeaturesOfClass(S57Objects.DEPARE);

            //var test1 = features.First(x => x.RecordName == 6140u);
            //var test2 = features.First(x => x.RecordName == 6140u).GetGeometry() as PolygonSet;
            //var test1 = features.First(x => x.RecordName == 6156u);
            //var test2 = features.First(x => x.RecordName == 6156u).GetGeometry() as PolygonSet;
            //var test1 = features.First(x => x.RecordName == 6134u);
            //var test2 = features.First(x => x.RecordName == 6134u).GetGeometry() as PolygonSet;
            //var test1 = features.First(x => x.RecordName == 6155u);
            var test2 = features.First(x => x.RecordName == 6155u).GetGeometry() as Area;

            features = reader.GetFeaturesOfClass(S57Objects.SOUNDG);
            for (int i = 0; i < features.Count; i++)
            {
                if (features[i].Primitive == GeometricPrimitive.Point)
                {
                    var TempSet = features[i].ExtractSoundings();
                }
                else
                {
                    continue;
                }
            }

            //var features = reader.GetFeaturesOfClass(S57Objects.DEPCNT);
            //var test1 = features.First(x => x.RecordName == 6345u);
            //var test2 = features.First(x => x.RecordName == 6345u).GetGeometry() as Line;
            //foreach (var xyz in test2.Areas)
            //{
            //foreach (var xy in xyz.points)
            //foreach (var xy in test2.points)
            //{
            //    var a = xy.X;
            //    var b = xy.Y;
            //    Console.WriteLine($"{a:0.0######}" + " , " + $"{b:0.0######}");
            //}
            //}
            Console.ReadKey();
        }
Пример #3
0
        //static void Main(string[] args)
        static void Main()
        {
            var        reader   = new S57Reader();
            string     ZipName  = "FR571370.zip";
            string     rootPath = "/home/gabin/Projet_gabin/Shom.S57/Shom.S57.Tests/";
            string     zipPath  = Path.Combine(rootPath, ZipName);
            ZipArchive archive  = ZipFile.OpenRead(zipPath);

            string MapName = "FR571370.000";

            reader.ReadFromArchive(archive, MapName, true);
            archive.Dispose();

            ListRelationships(reader, S57Obj.BOYSAW);

            ListFeatures(reader);

            QalityOfPosition(reader);

            FlatPolygon TempSet;
            var         features = reader.GetFeaturesOfClass(S57Obj.BOYCAR);

            for (int i = 0; i < features.Count; i++)
            {
                if (features[i].Primitive == GeometricPrimitive.Area)
                {
                    TempSet = features[i].GetGeometry(true) as FlatPolygon;
                }
            }

            var    features1    = reader.GetFeaturesOfClass(S57Obj.BOYCAR);
            string description1 = null;

            Console.WriteLine(" BUOY Car extraction");
            for (int i = 0; i < features1.Count; i++)
            {
                Console.WriteLine(features1[i].Attributes.TryGetValue(S57Att.COLOUR, out description1));     //http://www.s-57.com/
                Console.WriteLine(description1);

                var test3 = features1[0].GetGeometry(false) as Point;
                Console.WriteLine(test3.Y);
                Console.WriteLine(test3.X);
            }

            // information liées aux boués latérale.
            var features2 = reader.GetFeaturesOfClass(S57Obj.BOYLAT);

            Console.WriteLine(" BUOY Lat extraction");
            for (int i = 0; i < features2.Count; i++)
            {
                Console.WriteLine(features2[i].Attributes.TryGetValue(S57Att.COLOUR, out description1));    //http://www.s-57.com/
                Console.WriteLine(description1);
            }

            var test2 = features1[0].GetGeometry(false) as Line;
        }
Пример #4
0
        public static BoundingBox FromS57(S57Reader s57)
        {
            var boundingBox = new BoundingBox();
            var mapCovers   = s57.GetFeaturesOfClass("M_COVR");

            foreach (var mapCover in mapCovers)
            {
                var geom = mapCover.GetGeometry();
                if (geom is Area)
                {
                    var area = geom as Area;
                    foreach (var point in area.points)
                    {
                        if (point.X < boundingBox.westLongitude)
                        {
                            boundingBox.westLongitude = point.X;
                        }
                        else if (point.X > boundingBox.eastLongitude)
                        {
                            boundingBox.eastLongitude = point.X;
                        }
                        if (point.Y > boundingBox.northLatitude)
                        {
                            boundingBox.northLatitude = point.Y;
                        }
                        else if (point.Y < boundingBox.southLatitude)
                        {
                            boundingBox.southLatitude = point.Y;
                        }
                    }
                }
            }
            return(boundingBox);
        }
Пример #5
0
        static void Main(string[] args)
        {
            string path   = args[0];
            var    reader = new S57Reader();

            reader.Read(new FileStream(path, FileMode.Open));
            var features = reader.GetFeaturesOfClass(119);
        }
Пример #6
0
 private static void QalityOfPosition(S57Reader reader)
 {
     foreach (var bla in Enum.GetValues(typeof(S57Obj)))
     {
         var features = reader.GetFeaturesOfClass((S57Obj)bla);
         for (int i = 0; i < features.Count; i++)
         {
             var bla2 = features[i].GetSpacialAttributes();
         }
     }
 }
Пример #7
0
 private static void ListFeatures(S57Reader reader)
 {
     foreach (var obj in S57ObjectInfo.S57Dict)
     {
         int    a    = reader.GetFeaturesOfClass(obj.Key).Count;
         string test = obj.Key.ToString();
         if (a > 0)
         {
             Console.WriteLine(test + ": " + "{0:G}", a.ToString());
         }
     }
 }
Пример #8
0
 private static void ListFeatures(S57Reader reader)
 {
     for (uint i = 1; i < 500; i++)
     {
         if (S57Objects.IsIn(i))
         {
             int    a    = reader.GetFeaturesOfClass(i).Count();
             string test = S57Objects.Get(i).Acronym.ToString();
             if (a > 0)
             {
                 Console.WriteLine(test + ": " + "{0:G}", a.ToString());
             }
         }
     }
 }
Пример #9
0
        private static void ListRelationships(S57Reader reader, S57Obj type)
        {
            var features = reader.GetFeaturesOfClass(type);

            for (int i = 0; i < features.Count; i++)
            {
                string description = null;
                features[i].Attributes.TryGetValue(S57Att.OBJNAM, out description);
                string rcid       = features[i].namekey.RecordIdentificationNumber.ToString();
                string targetinfo = null;
                int    counter    = 0;
                if (features[i].enhFeaturePtrs != null)
                {
                    foreach (var bla in features[i].enhFeaturePtrs.FeatureList)
                    {
                        string relationship = ((Relationship)features[i].FeatureRecord.Fields.GetFieldByTag("FFPT").subFields.GetUInt32(counter++, "RIND")).ToString();
                        string targettype   = ((S57Obj)(bla.ObjectCode)).ToString();
                        string targetname   = bla.namekey.RecordIdentificationNumber.ToString();
                        targetinfo = targetinfo + " |" + targetname + "." + targettype + "." + relationship;
                    }
                }
                Console.WriteLine(rcid + "." + description + targetinfo);
            }
        }
Пример #10
0
        //static void Main(string[] args)
        static void Main()
        {
            S57Reader reader;
            string    ZipName        = "NC_ENCs.zip";
            string    zipRootPath    = "D:/Familie/Documents/Programming/test";
            string    zipPath        = Path.Combine(zipRootPath, ZipName);
            string    VolumeRootPath = "D:/Familie/Documents/Programming/test/ENC_ROOT";
            string    MapName        = "US5NC51M.000"; //US5NC12M.000  US5NC51M.000
            Stopwatch timer          = new Stopwatch();

            //timer.Start();
            //var reader = new S57Reader();
            //reader.ReadCatalogue(VolumeRootPath);
            //foreach (var map in reader.BaseFiles)
            //{
            //    string name = map.Value.fileName;
            //    string _MapName = name.Substring(name.IndexOf("\\") + 1);
            //    reader.Read(VolumeRootPath, MapName, false);
            //    Console.WriteLine(_MapName);
            //    var bla = reader.GetFeaturesOfClass(S57Obj.M_COVR);
            //};
            //timer.Stop();
            //Console.WriteLine(((double)(timer.Elapsed.TotalMilliseconds)).ToString("0.00 ms"));


            ZipArchive archive = ZipFile.OpenRead(zipPath);

            timer.Reset();
            timer.Start();
            reader = new S57Reader();
            reader.ReadCatalogue(archive);
            foreach (var map in reader.BaseFiles)
            {
                string name     = map.Value.fileName;
                string _MapName = name.Substring(name.IndexOf("\\") + 1);
                reader.Read(archive, _MapName, false);
                Console.WriteLine(_MapName);
                var bla = reader.GetFeaturesOfClass(S57Obj.DEPARE);
            }
            ;
            //reader.Read(archive, MapName, true);
            archive.Dispose();
            timer.Stop();
            Console.WriteLine(((double)(timer.Elapsed.TotalMilliseconds)).ToString("0.00 ms"));

            //ListRelationships(reader, S57Obj.BOYSAW);
            //ListFeatures(reader);
            //QalityOfPosition(reader);

            //FlatPolygon TempSet;
            //var features = reader.GetFeaturesOfClass(S57Obj.DEPARE);
            //for (int i = 0; i < features.Count; i++)
            //{
            //    if (features[i].Primitive == GeometricPrimitive.Area)
            //    {
            //        TempSet = features[i].GetGeometry(true) as FlatPolygon;
            //    }
            //}
            //var features = reader.GetFeaturesOfClass(S57Obj.LNDMRK);
            //for (int i = 0; i < features.Count; i++)
            //{
            //    string tempString;
            //    features[i].Attributes.TryGetValue(S57Att.SCAMIN, out tempString);
            //}
            Console.ReadKey();
        }
Пример #11
0
        //static void Main(string[] args)
        static void Main()
        {
            var        reader   = new S57Reader();
            string     ZipName  = "NC_ENCs.zip";
            string     rootPath = "D:/Familie/Documents/Programming/test";
            string     zipPath  = Path.Combine(rootPath, ZipName);
            ZipArchive archive  = ZipFile.OpenRead(zipPath);
            //reader.ReadCatalogue(S57map);
            //string MapName = "CATALOG.031";
            //reader.ReadArchiveCatalogue(archive, MapName);

            //string MapName = "US5NC12M.000";
            string MapName = "US5NC18M.000";

            //string MapName = "US5NC51M.000";
            reader.ReadFromArchive(archive, MapName, true);
            archive.Dispose();
            //ListRelationships(reader, S57Obj.BOYSAW);
            //ListFeatures(reader);
            //QalityOfPosition(reader);

            //reader.Read(new FileStream(path, FileMode.Open));

            FlatPolygon TempSet;
            var         features = reader.GetFeaturesOfClass(S57Obj.DEPARE);

            for (int i = 0; i < features.Count; i++)
            {
                //if (features[i].namekey.RecordIdentificationNumber == 6163)
                //{
                if (features[i].Primitive == GeometricPrimitive.Area)
                {
                    TempSet = features[i].GetGeometry(true) as FlatPolygon;
                }
                //}
            }
            //var test1 = features.First(x => x.RecordName == 6140u);
            //var test2 = features.First(x => x.RecordName == 6140u).GetGeometry() as PolygonSet;
            //var test1 = features.First(x => x.RecordName == 6156u);
            //var test2 = features.First(x => x.RecordName == 6156u).GetGeometry() as PolygonSet;
            //var test1 = features.First(x => x.RecordName == 6134u);
            //var test2 = features.First(x => x.RecordName == 6134u).GetGeometry() as PolygonSet;
            //var test1 = features.First(x => x.RecordName == 6155u);
            //var test2 = features.First(x => x.RecordName == 6155u).GetGeometry() as Area;
            //var features = reader.GetFeaturesOfClass(S57Objects.SOUNDG);
            //for (int i = 0; i < features.Count; i++)
            //{
            //    if (features[i].Primitive == GeometricPrimitive.Point)
            //    {
            //        var TempSet = features[i].ExtractSoundings();
            //        var TempSet2 = features[i].VectorPtrs[0].Vector.SoundingList;
            //    }
            //    else
            //    {
            //        continue;
            //    }
            //}

            //var features = reader.GetFeaturesOfClass(S57Objects.DEPCNT);
            //var test1 = features.First(x => x.RecordName == 6345u);
            //var test2 = features.First(x => x.RecordName == 6345u).GetGeometry() as Line;
            //foreach (var xyz in test2.Areas)
            //{
            //foreach (var xy in xyz.points)
            //foreach (var xy in test2.points)
            //{
            //    var a = xy.X;
            //    var b = xy.Y;
            //    Console.WriteLine($"{a:0.0######}" + " , " + $"{b:0.0######}");
            //}
            //}
            Console.ReadKey();
        }