GetApplicationPath() public static method

public static GetApplicationPath ( ) : string
return string
コード例 #1
0
ファイル: Utilities.cs プロジェクト: zininzinin/acs-alchemist
        /// <summary>
        /// Scans through our SRID.csv file, and returns all available IDs
        /// </summary>
        /// <returns></returns>
        public static List <string> ListAllCoordinateSystemIDs()
        {
            string sridFilename = Path.Combine(FileUtilities.GetApplicationPath(), "SRID.csv");

            if (!File.Exists(sridFilename))
            {
                _log.Error("Unable to lookup srid by number, no SRID.csv file");
                return(null);
            }

            List <string> results = new List <string>(4096);
            StreamReader  reader  = new StreamReader(sridFilename);
            string        line    = string.Empty;

            while ((line = reader.ReadLine()) != null)
            {
                results.Add(line.Split(';')[0]);
            }
            return(results);
        }
コード例 #2
0
ファイル: Utilities.cs プロジェクト: zininzinin/acs-alchemist
        /// <summary>
        /// Normally I would optimize this if it were getting a lot of use,
        /// but this seems to be incredibly fast on my machine, very easy to change
        /// later if we want.
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static string GetCoordinateSystemWKTByID(string filename)
        {
            int outputSrid = Utilities.GetAs <int>(filename, -1);

            if (outputSrid < 0)
            {
                _log.ErrorFormat("Unable to lookup SRID by id {0} ", filename);
                return(null);
            }

            _log.Info("Retrieving WKT for " + outputSrid);

            /*
             * This is not efficient, but it is very convenient
             */
            //BRUTE FORCE find the srid in our srids file
            string sridFilename = Path.Combine(FileUtilities.GetApplicationPath(), "SRID.csv");

            if (!File.Exists(sridFilename))
            {
                _log.Error("Unable to lookup srid by number, no SRID.csv file");
            }
            StreamReader reader = new StreamReader(sridFilename);
            string       line   = string.Empty;
            string       key    = outputSrid + ";";

            while ((line = reader.ReadLine()) != null)
            {
                if (!line.StartsWith(key))
                {
                    continue;
                }
                else
                {
                    break;
                }
            }
            if (!string.IsNullOrEmpty(line))
            {
                return(line.Split(';')[1]);
            }
            else
            {
                return(string.Empty);
            }



            /**
             * This should work in theory, but either need:
             * * The newest version of spatialite with the 'srs_wkt' column
             * * An easy way to convert proj4 projection descriptions into WKT
             *
             * The newest Spatialite doesn't appear to be a drop in replacement, so that might need to wait
             */

            //SqliteDataClient temp = new SqliteDataClient("_srids.tmp");
            //temp.LoadAllSpatialReferences();

            //string projWKT = "";
            //string sql = "SELECT srs_wkt FROM spatial_ref_sys WHERE srid = " + outputSrid;    //not really worried about injection here
            //using (var cmd = temp.GetCommand(sql))
            //{
            //    projWKT = cmd.ExecuteScalar() as string;
            //}
            //if (!string.IsNullOrEmpty(projWKT))
            //{
            //    return csf.CreateFromWkt(projWKT);
            //}
            //else
            //{
            //    _log.Error("ERROR: Unable to retrieve specified SRID from spatial reference");
            //}
        }