コード例 #1
0
ファイル: GPXLoaderv1.cs プロジェクト: sayrun/Bayaki
        /// <summary>
        /// GPXファイルの読み込み
        /// </summary>
        /// <param name="filePath">GPXファイルのパス</param>
        /// <returns>PGXから読み込んだ座標情報リスト</returns>
        private static TrackItem LoadGpxFile(string filePath)
        {
            TrackItem result = null;

            using (TrackItemReader tir = new TrackItemReader(filePath))
            {
                result = tir.Read();
            }
            return(result);
        }
コード例 #2
0
        public TrackItem GetTrackItem(out ITrackItemCache nextStatus)
        {
            string filePath = System.IO.Path.Combine(_savePath, _fileName);

            using (TrackItemReader tir = new TrackItemReader(filePath))
            {
                _item = tir.Read();
            }

            nextStatus = new TrackItemCacheLoaded(_item, _fileName);
            return(_item);
        }
コード例 #3
0
        public void Load()
        {
            // 場所情報のサマリーを取得する
            string locations = System.IO.Path.Combine(_savePath, "BayakiSummary.dat");

            if (File.Exists(locations))
            {
                using (var stream = new FileStream(locations, FileMode.Open))
                {
                    BinaryFormatter bf = new BinaryFormatter();
                    _locations = bf.Deserialize(stream) as List <TrackItemSummary>;
                }
            }
            else
            {
                // ファイルがないけど、リカバリーを試みよう
                DirectoryInfo di = new DirectoryInfo(_savePath);
                foreach (FileInfo fi in di.GetFiles("TrackItem*.dat"))
                {
                    try
                    {
                        using (TrackItemReader tir = new TrackItemReader(fi.FullName))
                        {
                            bykIFv1.TrackItem item = tir.Read();
                            if (null != item)
                            {
                                TrackItemSummary summary = new TrackItemSummary(item, fi.FullName);

                                _locations.Add(summary);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        // 読み込みでエラーが発生する可能性は、この場合では無視する。
                        System.Diagnostics.Debug.Print(ex.Message);
                    }
                }

                if (0 < _locations.Count)
                {
                    Save();
                }
            }
        }