Ejemplo n.º 1
0
        /// <summary>
        /// Writes location to a KML file.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <param name="dbLocation">The database location.</param>
        public static void WriteToKml(string filePath, FormationMatcher dbLocation)
        {
            // This is the root element of the file
            Dom.Kml kml = AssembleToKml(dbLocation);

            WriteToKml(filePath, kml);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads all of the database locations and returns a list of objects with data.
        /// </summary>
        /// <param name="excel">The excel application.</param>
        /// <returns>List&lt;DBLocation&gt;.</returns>
        public static List <FormationMatcher> ReadDBLocations(ExcelHelper excel)
        {
            List <FormationMatcher> locations = new List <FormationMatcher>();
            List <string>           areas     = excel.RangeValuesBelowHeader("AreaChild");
            List <string>           names     = excel.RangeValuesBelowHeader("Formation");
            int           numberOfRows        = names.Count;
            List <string> latitudes           = excel.RangeValuesBelowHeader("Latitude", includeNull: true, numberOfRows: numberOfRows);
            List <string> longitudes          = excel.RangeValuesBelowHeader("Longitude", includeNull: true, numberOfRows: numberOfRows);
            List <string> otherNames          = excel.RangeValuesBelowHeader("SubFormation", includeNull: true, numberOfRows: numberOfRows);

            for (int i = 0, length = names.Count; i < length; i++)
            {
                double longitude;
                if (!double.TryParse(longitudes[i], out longitude))
                {
                    longitude = 0;
                }
                double latitude;
                if (!double.TryParse(latitudes[i], out latitude))
                {
                    latitude = 0;
                }
                if (Math.Abs(longitude) < 1 && Math.Abs(latitude) < 1)
                {
                    FormationMatcher location = new FormationMatcher(areas[i], names[i], otherNames[i]);
                    locations.Add(location);
                }
            }
            return(locations);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds the location to the region if the region name matches.
 /// </summary>
 /// <param name="location">The location.</param>
 public void AddLocationByRegionName(FormationMatcher location)
 {
     if (string.Compare(location.RegionName, Name, StringComparison.Ordinal) == 0)
     {
         Locations.Add(location);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Assembles location to KML.
        /// </summary>
        /// <param name="dbLocation">The database location.</param>
        /// <returns>Dom.Kml.</returns>
        public static Dom.Kml AssembleToKml(FormationMatcher dbLocation)
        {
            // This is the root element of the file
            Dom.Kml kml = new Dom.Kml {
                Feature = AssembleToFolder(dbLocation)
            };

            return(kml);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Assembles location to folder.
        /// </summary>
        /// <param name="dbLocation">The database location.</param>
        /// <returns>Dom.Folder.</returns>
        private static Dom.Folder AssembleToFolder(FormationMatcher dbLocation)
        {
            Dom.Folder locationGroup = new Dom.Folder {
                Name = dbLocation.FormationName
            };
            if (!string.IsNullOrWhiteSpace(dbLocation.SubFormationName))
            {
                locationGroup.Name += " (" + dbLocation.SubFormationName + ")";
            }
            Location location = dbLocation.MatchedLocation;

            if (location == null)
            {
                return(locationGroup);
            }

            // This will be used for the placemark
            Dom.Point point = new Dom.Point {
                Coordinate = new Vector(location.Latitude, location.Longitude)
            };

            Dom.Placemark placemark = new Dom.Placemark {
                Name = location.Name
            };
            if (!string.IsNullOrWhiteSpace(location.OtherName))
            {
                placemark.Name += " (" + location.OtherName + ")";
            }
            placemark.Geometry = point;

            locationGroup.AddFeature(placemark);
            //foreach (PeakbaggerLocation location in dbLocation.PossibleLocations)
            //{
            //    // This will be used for the placemark
            //    Dom.Point point = new Dom.Point {Coordinate = new Vector(location.Latitude, location.Longitude)};

            //    Dom.Placemark placemark = new Dom.Placemark {Name = location.Name};
            //    if (!string.IsNullOrWhiteSpace(location.OtherName))
            //    {
            //        placemark.Name += " (" + location.OtherName + ")";
            //    }
            //    placemark.Geometry = point;

            //    locationGroup.AddFeature(placemark);
            //}
            return(locationGroup);

            // Add to the root
            //kml.Feature = locationGroup;

            //WriteToKml(filePath, kml);
            //Console.WriteLine(serializer.Xml);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Opens the in google earth.
        /// </summary>
        /// <param name="dbLocation">The database location.</param>
        /// <param name="pathFile">The path file.</param>
        /// <param name="pathApplication">The path application.</param>
        public static void OpenInGoogleEarth(FormationMatcher dbLocation, string pathFile, string pathApplication)
        {
            Kml.WriteToKml(pathFile, dbLocation);

            System.Diagnostics.Process          process   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.FileName    = "cmd.exe";
            // /C Carries out the command specified by string and then terminates
            startInfo.Arguments = "/C \"" + pathApplication + "\" \"" + pathFile + "\"";
            process.StartInfo   = startInfo;
            process.Start();
        }