Пример #1
0
        /// <summary>
        /// Enumerates all SRID's in the SRID.csv file.
        /// </summary>
        /// <returns>Enumerator</returns>
        public static IEnumerable <WktString> GetSrids()
        {
            using (var sr = File.OpenText(Filename))
            {
                while (!sr.EndOfStream)
                {
                    var line = sr.ReadLine();
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    var split = line.IndexOf(';');
                    if (split <= -1)
                    {
                        continue;
                    }

                    var wkt = new WktString
                    {
                        WktId = int.Parse(line.Substring(0, split)),
                        Wkt   = line.Substring(split + 1)
                    };
                    yield return(wkt);
                }
                sr.Close();
            }
        }
Пример #2
0
        /// <summary>
        /// Enumerates all SRID's in the SRID.csv file.
        /// </summary>
        /// <returns>Enumerator</returns>
        public static IEnumerable <WktString> GetSrids(string filename = null)
        {
            Stream stream = string.IsNullOrWhiteSpace(filename)
                ? Assembly.GetExecutingAssembly().GetManifestResourceStream("ProjNET.Tests.SRID.csv")
                : File.OpenRead(filename);

            using (var sr = new StreamReader(stream, Encoding.UTF8))
            {
                while (!sr.EndOfStream)
                {
                    var line = sr.ReadLine();
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    var split = line.IndexOf(';');
                    if (split <= -1)
                    {
                        continue;
                    }

                    var wkt = new WktString
                    {
                        WktId = int.Parse(line.Substring(0, split)),
                        Wkt   = line.Substring(split + 1)
                    };
                    yield return(wkt);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Enumerates all SRID's in the SRID.csv file.
        /// </summary>
        /// <returns>Enumerator</returns>
        public static IEnumerable <WktString> GetSrids(string filename = null)
        {
            //var stream = string.IsNullOrWhiteSpace(filename)
            //    ? Assembly.GetExecutingAssembly().GetManifestResourceStream("ProjNET.Tests.SRID.csv")
            //    : File.OpenRead(filename);

            using (StringReader reader = new StringReader(Resource.SRID))
            {
                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    var split = line.IndexOf(';');
                    if (split <= -1)
                    {
                        continue;
                    }

                    var wkt = new WktString
                    {
                        WktId = int.Parse(line.Substring(0, split)),
                        Wkt   = line.Substring(split + 1)
                    };
                    yield return(wkt);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Enumerates all SRID's in the SRID.csv file.
        /// </summary>
        /// <returns>Enumerator</returns>
        public static IEnumerable<WktString> GetSrids(string filename = null)
        {
            if (string.IsNullOrWhiteSpace(filename))
                filename = Filename;

            using (var sr = File.OpenText(filename))
            {
                while (!sr.EndOfStream)
                {
                    var line = sr.ReadLine();
                    if (string.IsNullOrEmpty(line)) continue;

                    var split = line.IndexOf(';');
                    if (split <= -1) continue;

                    var wkt = new WktString
                                  { 
                                      WktId = int.Parse(line.Substring(0, split)), 
                                      Wkt = line.Substring(split + 1)
                                  };
                    yield return wkt;
                }
                sr.Close();
            }
        }
        /// <summary>
        /// Enumerates all SRID's in the SRID.csv file.
        /// </summary>
        /// <returns>Enumerator</returns>
        private string GetSrids(string filename = null, int id = 0)
        {
            if (WktStrings != null)
            {
                return(WktStrings.Where(x => x.WktId == id).Select(x => x.Wkt).First());
            }
            else
            {
                WktStrings = new List <WktString>();
                string dir = System.IO.Path.GetDirectoryName(
                    System.Reflection.Assembly.GetExecutingAssembly().Location);

                string file = dir + @"\Media\CoordinateSystems\SRID.csv";

                var stream = string.IsNullOrWhiteSpace(filename)
                    ? File.OpenRead(file)
                    : File.OpenRead(filename);

                foreach (string line in File.ReadLines(string.IsNullOrWhiteSpace(filename) ? file : filename, Encoding.ASCII))
                {
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }

                    string line1 = line.Substring(1, line.Length - 1).Replace("\"\"", "\"");

                    int split = line1.IndexOf(';');
                    if (split <= -1)
                    {
                        continue;
                    }

                    var wkt = new WktString
                    {
                        WktId = int.Parse(line1.Substring(0, split)),
                        Wkt   = line1.Substring(split + 1)
                    };

                    WktStrings.Add(wkt);
                }
            }

            return(WktStrings.Where(x => x.WktId == id).Select(x => x.Wkt).First());
        }
Пример #6
0
 /// <summary>
 /// Enumerates all SRID's in the SRID.csv file.
 /// </summary>
 /// <returns>Enumerator</returns>
 public static IEnumerable <WktString> GetSRIDs(string filename)
 {
     using (StreamReader sr = File.OpenText(filename))
     {
         while (!sr.EndOfStream)
         {
             string line  = sr.ReadLine();
             int    split = line.IndexOf(';');
             if (split > -1)
             {
                 WktString wkt = new WktString();
                 wkt.WKID = int.Parse(line.Substring(0, split));
                 wkt.WKT  = line.Substring(split + 1);
                 yield return(wkt);
             }
         }
         sr.Close();
     }
 }