示例#1
0
        // Initialize the private variables of the object before using it (acts
        // like a constructor).
        public void Initialize(int zoom)
        {
            // read file as a basic xml file
            XDocument myGPX = XDocument.Load(_gpxFileName);

            // manager for the .gpx file format
            XmlNamespaceManager r = new XmlNamespaceManager(new NameTable());

            r.AddNamespace("p", "http://www.topografix.com/GPX/1/1");

            // create gpx reader and retrieve coordinate and elevation data
            var gPXReader = new GPXReaderLib.GPXReader(myGPX, r);

            _coordinates = gPXReader.GetGPXCoordinates();
            _elevation   = gPXReader.GetGPXAltimetry().Altimetries.Select(c => c.Elevation).ToList();

            // Find the corner OSM tiles (bottom left, top rigth) based on the
            // gpx coordinates and the desired zoom level.
            var coords = ComputeTrackCoordinates(_coordinates);

            _leftBottom = AwesomeTiles.Tile.CreateAroundLocation(coords.minLat,
                                                                 coords.minLon, zoom);
            _rightTop = AwesomeTiles.Tile.CreateAroundLocation(coords.maxLat,
                                                               coords.maxLon, zoom);
        }
示例#2
0
        // get the corner (Lon, Lat) coordinates of the GPX track.
        public CornerCoordinates ComputeTrackCoordinates(GPXCoordinateList coords)
        {
            var coord = new CornerCoordinates();

            coord.maxLon = coords.Max(c => c.Longitude);
            coord.maxLat = coords.Max(c => c.Latitude);
            coord.minLon = coords.Min(c => c.Longitude);
            coord.minLat = coords.Min(c => c.Latitude);
            return(coord);
        }