示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Feed"/> class.
        /// Creates the generic feed object based on a parsed BaseFeed
        /// </summary>
        /// <param name="feed">BaseFeed which is a <see cref="Rss20Feed"/> , <see cref="Rss10Feed"/>, or another.</param>
        public Feed(BaseFeed feed)
        {
            SpecificFeed = feed;

            Title = feed.Title;
            Link  = feed.Link;

            Items = feed.Items.Select(x => x.ToFeedItem()).ToList();
        }
示例#2
0
        private async void ExportData_Clicked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (CurrentDataSet == null)
                {
                    MessageBox.Show("No data to export.");
                    return;
                }

                var selectedItem = sender as System.Windows.Controls.MenuItem;

                BaseFeed writer     = null;
                string   defaultExt = string.Empty;
                string   filters    = string.Empty;
                string   fileType   = selectedItem.Tag.ToString();

                GetFileSettings(fileType, out writer, out defaultExt, out filters);

                var sfg = new SaveFileDialog()
                {
                    DefaultExt = defaultExt,
                    Filter     = filters
                };

                var state = sfg.ShowDialog();
                if (state.HasValue && state.Value)
                {
                    using (var fileStream = sfg.OpenFile())
                    {
                        if (string.Compare(fileType, "kmz") == 0)
                        {
                            await(writer as KmlFeed).WriteAsync(CurrentDataSet, fileStream, true);
                        }
                        else if (writer is BingDataSourceFeed)
                        {
                            await(writer as BingDataSourceFeed).WriteAsync(CurrentDataSet, fileStream);
                        }
                        else if (writer != null)
                        {
                            await writer.WriteAsync(CurrentDataSet, fileStream);
                        }
                    }

                    MessageBox.Show("Export Complete.");
                }
            }
            catch { }
        }
示例#3
0
 public string GetPriority(BaseFeed baseFeed)
 {
     return(!baseFeed.FeedPriority.Value.IsNullOrEmpty() && !baseFeed.FeedPriority.Value.Any(x => char.IsLetter(x)) ? baseFeed.FeedPriority.Value : System.Int16.MaxValue.ToString());
 }
示例#4
0
        private async void ImportData_Clicked(object sender, RoutedEventArgs e)
        {
            try
            {
                var selectedItem = sender as System.Windows.Controls.MenuItem;

                //Check to see if the Tag property of the selected item has a string that is a spatial file type.
                if (selectedItem != null)
                {
                    string   fileType   = selectedItem.Tag.ToString();
                    BaseFeed reader     = null;
                    string   defaultExt = string.Empty;
                    string   filters    = string.Empty;

                    GetFileSettings(fileType, out reader, out defaultExt, out filters);

                    ClearMap();

                    //Create a FileOpenPicker to allow the user to select which file to import
                    var openPicker = new OpenFileDialog()
                    {
                        DefaultExt = defaultExt,
                        Filter     = filters,
                    };

                    //Get the selected file
                    var state = openPicker.ShowDialog();
                    if (state.HasValue && state.Value)
                    {
                        using (var fileStream = openPicker.OpenFile())
                        {
                            SpatialDataSet data = null;
                            if (reader != null)
                            {
                                //Read the spatial data file
                                if (reader is BingDataSourceFeed)
                                {
                                    data = await(reader as BingDataSourceFeed).ReadAsync(fileStream);
                                }
                                else
                                {
                                    data = await reader.ReadAsync(fileStream);
                                }
                            }

                            if (data != null && string.IsNullOrEmpty(data.Error))
                            {
                                //Load the spatial set data into the map
                                MapTools.LoadGeometries(data, PinLayer, PolyLayer, DefaultStyle, GeometryTapped);

                                CurrentDataSet = data;

                                DisplayMetadata(data.Metadata);

                                //If the data set has a bounding box defined, use it to set the map view.
                                if (data.BoundingBox != null)
                                {
                                    MyMap.SetView(data.BoundingBox.ToBMGeometry());
                                }
                                double dist     = 0;
                                var    temppath = new LocationCollection();


                                var ls = new LineSeries {
                                    Title = "Altitude"
                                };



                                for (int i = 0; i < ((LineString)((MultiLineString)data.Geometries[0]).Geometries[0]).Vertices.Count; i++)
                                {
                                    Coordinate coor = ((LineString)((MultiLineString)data.Geometries[0]).Geometries[0]).Vertices[i];
                                    if (i == 0)
                                    {
                                        path.Add(new PathPoint(coor.Latitude, coor.Longitude, (double)coor.Altitude, 0));
                                    }
                                    else
                                    {
                                        Coordinate coorant = ((LineString)((MultiLineString)data.Geometries[0]).Geometries[0]).Vertices[i - 1];

                                        var sCoord = new GeoCoordinate(coorant.Latitude, coorant.Longitude);
                                        var eCoord = new GeoCoordinate(coor.Latitude, coor.Longitude);
                                        dist += sCoord.GetDistanceTo(eCoord);

                                        path.Add(new PathPoint(coor.Latitude, coor.Longitude, (double)coor.Altitude, dist));
                                        temppath.Add(new Location(coor.Latitude, coor.Longitude));

                                        double x = dist;
                                        double y = (double)coor.Altitude;
                                        ls.Points.Add(new DataPoint(x, y));
                                    }
                                }
                                //var pin = new Pushpin();
                                MyModel.Series.Add(ls);
                                var ls2 = new LineSeries {
                                    Title = "Real Altitude"
                                };
                                MyModel.Series.Add(ls2);

                                MyModel.Axes.Add(new LinearAxis {
                                    Position = AxisPosition.Bottom, Title = "Altitude"
                                });

                                MyModel.InvalidatePlot(true);
                                Coordinate tmpCoor = ((LineString)((MultiLineString)data.Geometries[0]).Geometries[0]).Vertices[0];
                                MapLayer.SetPosition(pin, new Location(tmpCoor.Latitude, tmpCoor.Longitude, (double)tmpCoor.Altitude));

                                MyMap.Children.Add(pin);
                                DistancePathAnimation currentAnimation = new DistancePathAnimation(path, (coord, pathIdx, frameIdx) =>
                                {
                                    MapLayer.SetPosition(pin, coord);
                                    ((LineSeries)MyModel.Series[1]).Points.Add(new DataPoint(path[pathIdx].distance, path[pathIdx].height));
                                    MyModel.InvalidatePlot(true);
                                }, false, 10000);

                                currentAnimation.Play();

                                //aTimer.Enabled = true;
                            }
                            else
                            {
                                //If there is an error message, display it to the user.
                                MessageBox.Show((data != null) ? data.Error : "Unable to parse file.");
                            }
                        }
                    }
                }
            }
            catch {}
        }
示例#5
0
        private void GetFileSettings(string fileType, out BaseFeed feed, out string defaultExt, out string filters)
        {
            switch (fileType)
            {
            case "wkt":
                feed       = new WellKnownText();
                defaultExt = ".txt";
                filters    = "Text (.txt)|*.txt";
                break;

            case "shp":
                feed       = new ShapefileReader();
                defaultExt = ".shp";
                filters    = "Shapefile (.shp)|*.shp";
                break;

            case "gpx":
                feed       = new GpxFeed();
                defaultExt = ".gpx";
                filters    = "Xml (.xml)|*.xml|Gpx (.gpx)|*.gpx";
                break;

            case "georss":
                feed       = new GeoRssFeed();
                defaultExt = ".xml";
                filters    = "Xml (.xml)|*.xml|Rss (.rss)|*.rss";
                break;

            case "kml":
                feed       = new KmlFeed();
                defaultExt = ".kml";
                filters    = "Kml (.kml)|*.kml|Kmz (.kmz)|*.kmz|Xml (.xml)|*.xml";
                break;

            case "kmz":
                feed       = new KmlFeed();
                defaultExt = ".kmz";
                filters    = "Kmz (.kmz)|*.kmz|Zip (.zip)|*.zip";
                break;

            case "geojson":
                feed       = new GeoJsonFeed();
                defaultExt = ".js";
                filters    = "JavaScript (.js)|*.js|Json (.json)|*.json";
                break;

            case "bing-xml":
                feed       = new BingDataSourceFeed(BingDataSourceType.XML);
                defaultExt = ".xml";
                filters    = "Xml (.xml)|*.xml";
                break;

            case "bing-csv":
                feed       = new BingDataSourceFeed(BingDataSourceType.CSV);
                defaultExt = ".csv";
                filters    = "CSV (*.csv)|*.csv|Text (*.txt)|*.txt|All files (*.*)|*.*";
                break;

            case "bing-tab":
                feed       = new BingDataSourceFeed(BingDataSourceType.TAB);
                defaultExt = ".txt";
                filters    = "Text (*.txt)|*.txt|TSV (*.tsv)|*.tsv|All files (*.*)|*.*";
                break;

            case "bing-pipe":
                feed       = new BingDataSourceFeed(BingDataSourceType.PIPE);
                defaultExt = ".txt";
                filters    = "Text (*.txt)|*.txt|All files (*.*)|*.*";
                break;

            default:
                feed       = null;
                defaultExt = string.Empty;
                filters    = string.Empty;
                break;
            }
        }