Exemple #1
0
 public CoursePoint(string name, JsonGeometry geometry)
 {
     this.Name   = name;
     Coordinates = new List <GeoCoordinate>();
     foreach (double[] coor in geometry.CoordinatesList)
     {
         Coordinates.Add(new GeoCoordinate(coor[1], coor[0]));
     }
 }
Exemple #2
0
        public static CoursePoint ReadJson(string fileName)
        {
            if (!File.Exists(fileName))
            {
                return(null);
            }

            string     jsonstring = File.ReadAllText(fileName, Encoding.GetEncoding("UTF-8"));
            JsonCourse json       = Deserialize <JsonCourse>(jsonstring);

            if (json.Features.Count != 1)
            {
                throw new ArgumentOutOfRangeException("" + fileName + " は複数の線で構成されているので無効です。");
            }
            JsonGeometry geometry = null;

            foreach (JsonFeatures feature in json.Features)
            {
                geometry = feature.Geometry;
            }
            return(new CoursePoint(Path.GetFileNameWithoutExtension(fileName), geometry));
        }