private void toolStripButtonKML_Click(object sender, EventArgs e) { String strAsset = this.m_strAsset; String strMyDocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); strMyDocumentsFolder += "\\RoadCare Projects\\" + strAsset + ".kml"; FormAssetKML formAssetKML = new FormAssetKML(strAsset); //if (formAssetKML.ShowDialog() == DialogResult.OK) { } StringCollection listProperties = new StringCollection(); List <string> atrColumns = DBMgr.GetTableColumns(strAsset); foreach (string columnName in atrColumns) { listProperties.Add(columnName); } KML.CreateAssetKML(strAsset, strMyDocumentsFolder, strAsset, listProperties); System.Diagnostics.Process.Start(strMyDocumentsFolder); }
private void SetupMapIfNeeded() { if (Reachability.InternetConnectionStatus() == NetworkStatus.NotReachable) { return; } if (_GoogleMap == null) { _GoogleMap = _MapFragment.Map; if (_GoogleMap != null) { var cachePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "..", "cache"); _Kml = new KML(_Mappa.Url, Path.Combine(cachePath, "maps")); _Kml.Loaded += () => { RunOnUiThread(() => { LoadPlacemarks(); HideLoadingOverlay(); }); }; _Kml.Load(); ShowLoadingOverlay(); } } }
/// <summary> /// Generate an XML element that has all the information needed for this placemark to /// exist on a Google Earth KML document. /// </summary> /// <param name="kml">The KML object that will be used for generating this KML.</param> /// <returns>An XmlElement or null if this placemark cannot exist in KML.</returns> public virtual XmlElement KMLPlacemark(KML kml) { XmlElement placemark, name, point, styleUrl, coordinates; // // Create the placemark tag. // placemark = kml.xml.CreateElement("Placemark"); // // Create the name tag. // name = kml.xml.CreateElement("name"); name.AppendChild(kml.xml.CreateTextNode(Name.Replace("\\n", ", "))); placemark.AppendChild(name); // // Create the style tag. // styleUrl = kml.xml.CreateElement("styleUrl"); styleUrl.AppendChild(kml.xml.CreateTextNode(kml.RegisterPinStyle(PinImage, 1, null))); placemark.AppendChild(styleUrl); // // Set the coordinates and store the placemark. // point = kml.xml.CreateElement("Point"); coordinates = kml.xml.CreateElement("coordinates"); coordinates.AppendChild(kml.xml.CreateTextNode(String.Format("{0},{1},0", Longitude, Latitude))); point.AppendChild(coordinates); placemark.AppendChild(point); return(placemark); }
static void Main(string[] args) { double Y, KML; int X; X = int.Parse(Console.ReadLine()); Y = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); KML = X / Y; Console.WriteLine(KML.ToString("F3", CultureInfo.InvariantCulture) + " km/l"); }
public KeyValuePair <List <AV_SiteTestSummary>, DataTable> NIReport(Int64 SiteId, ref List <SiteReportPlotVM> PlotData, ref List <AD_ReportConfiguration> rptConf, string kmlPath) { DataSet ds = srd.GetDs("NIReport", SiteId); List <AV_SiteTestSummary> smry = new List <AV_SiteTestSummary>(); if (ds != null && ds.Tables.Count > 0) { AV_SiteTestSummaryBL stb = new AV_SiteTestSummaryBL(); smry = stb.DataTableToList(ds.Tables[0]); // ds.Tables[0].ToList<AV_SiteTestSummary>(); if (ds.Tables.Count > 0) { SiteReportPlotVM plot; DataTable Lagend = ds.Tables[1]; for (int i = 0; i < Lagend.Rows.Count; i++) { plot = new SiteReportPlotVM(); plot.PCI = Lagend.Rows[i]["PciId"].ToString(); plot.plotColorName = Lagend.Rows[i]["pciColor"].ToString(); plot.TestType = Lagend.Rows[i]["TestType"].ToString(); PlotData.Add(plot); } } if (ds.Tables.Count > 1) { DataTable conf = ds.Tables[2]; rptConf = conf.ToList <AD_ReportConfiguration>(); } if (ds.Tables.Count > 2) { DataTable dtkml = ds.Tables[3]; KML km = new KML(); string kml = string.Empty; string PciKml = string.Empty; //var smrFirstRow = smry.Where(m=>m.NetworkMode=="LTE").FirstOrDefault(); var smrFirstRow = smry.FirstOrDefault(); if (smrFirstRow != null) { // string Layer = smrFirstRow.Site + "\\" + smrFirstRow.NetworkMode + "_" + smrFirstRow.Band + "_" + smrFirstRow.Carrier; for (int i = 0; i < dtkml.Rows.Count; i++) { string Layer = dtkml.Rows[i]["Site"].ToString() + "\\" + dtkml.Rows[i]["NetworkMode"].ToString() + "_" + dtkml.Rows[i]["Band"].ToString() + "_" + dtkml.Rows[i]["Carrier"].ToString(); km.SaveKml(dtkml.Rows[i]["pciPlot"].ToString(), "pci", kmlPath + smrFirstRow.ClientPrefix + "\\" + Layer); } } } } return(new KeyValuePair <List <AV_SiteTestSummary>, DataTable>(smry, ds.Tables[4])); }
/// <summary> /// Generate an XML element that has all the information needed for this placemark to /// exist on a Google Earth KML document. /// </summary> /// <param name="kml">The KML object that will be used for generating this KML.</param> /// <returns>An XmlElement or null if this placemark cannot exist in KML.</returns> public override XmlElement KMLPlacemark(KML kml) { XmlElement placemark, name, point, styleUrl, coordinates, description; string style; // // Create the placemark tag. // placemark = kml.xml.CreateElement("Placemark"); // // Create the name tag. // name = kml.xml.CreateElement("name"); name.AppendChild(kml.xml.CreateTextNode(Name)); placemark.AppendChild(name); // // Store the description information. // description = kml.xml.CreateElement("description"); description.InnerXml = "<![CDATA[" + kml.Google.SmallGroupDetailsPopup(_group, false, true) + "]]>"; placemark.AppendChild(description); // // Create the style tag. // style = kml.RegisterPinStyle("http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=glyphish_group|4040FF|000000", 0.75, null); styleUrl = kml.xml.CreateElement("styleUrl"); styleUrl.AppendChild(kml.xml.CreateTextNode(style)); placemark.AppendChild(styleUrl); // // Set the coordinates and store the placemark. // point = kml.xml.CreateElement("Point"); coordinates = kml.xml.CreateElement("coordinates"); coordinates.AppendChild(kml.xml.CreateTextNode(String.Format("{0},{1},0", Longitude, Latitude))); point.AppendChild(coordinates); placemark.AppendChild(point); return(placemark); }
/// <summary> /// Generate an XML element that has all the information needed for this placemark to /// exist on a Google Earth KML document. /// </summary> /// <param name="kml">The KML object that will be used for generating this KML.</param> /// <returns>An XmlElement or null if this placemark cannot exist in KML.</returns> public override XmlElement KMLPlacemark(KML kml) { XmlElement placemark, name, point, styleUrl, coordinates, description; string style; // // Create the placemark tag. // placemark = kml.xml.CreateElement("Placemark"); // // Create the name tag. // name = kml.xml.CreateElement("name"); name.AppendChild(kml.xml.CreateTextNode(Name)); placemark.AppendChild(name); // // Store the description information. // description = kml.xml.CreateElement("description"); description.InnerXml = "<![CDATA[" + kml.Google.FamilyDetailsPopup(_family, false, true) + "]]>"; placemark.AppendChild(description); // // Create the style tag. // style = kml.RegisterPinStyle(PinImage, 0.65, null); styleUrl = kml.xml.CreateElement("styleUrl"); styleUrl.AppendChild(kml.xml.CreateTextNode(style)); placemark.AppendChild(styleUrl); // // Set the coordinates and store the placemark. // point = kml.xml.CreateElement("Point"); coordinates = kml.xml.CreateElement("coordinates"); coordinates.AppendChild(kml.xml.CreateTextNode(String.Format("{0},{1},0", Longitude, Latitude))); point.AppendChild(coordinates); placemark.AppendChild(point); return(placemark); }
public Response DriveRoute(DriveRoute driveRoute) { List <Cordinates> cordinates = driveRoute.cordinates; List <Cordinates> pathJson = driveRoute.pathJson; Response res = new Response(); DirectoryHandler dh = new DirectoryHandler(); string CompleteKml = null; string ClientPrefix = ""; string SiteCode = ""; long RouteId = 0; string Delete = ""; long SiteId = 0; string TestType = ""; int ScopeId = 0; long UserId = 0; string Filter = ""; ClientPrefix = driveRoute.ClientPrefix; SiteCode = driveRoute.SiteCode; RouteId = driveRoute.RouteId; Delete = ""; SiteId = driveRoute.SiteId; TestType = driveRoute.TestType; ScopeId = driveRoute.ScopeId; UserId = driveRoute.UserId; Filter = "Insert"; KML km = new KML(); try { CompleteKml += km.Open("Routes", "Routes For Site"); int count = 1; #region Existing File Coordinates string Path = "/Content/AirViewLogs/" + ClientPrefix + "/" + SiteCode; if (dh.FileExist(HttpContext.Current.Server.MapPath("~" + Path + "/route-" + RouteId + ".kml"))) { string text; var fileStream = new FileStream(HttpContext.Current.Server.MapPath("~" + Path + "/route-" + RouteId + ".kml"), FileMode.Open, FileAccess.Read); using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) { text = streamReader.ReadToEnd(); } MyString ms = new MyString(); string MyPlacemarks = ""; string[] MyPlacemarksSplit; int MyIndex = 5782; if (Delete != "") { MyPlacemarks = ms.BetweenTag(text, "Placemark", "&"); MyPlacemarksSplit = MyPlacemarks.Split('&'); int counter = 0; foreach (var item in MyPlacemarksSplit) { if (item.Contains(Delete)) { MyIndex = counter; } counter++; } } string Cordinate = ms.BetweenTag(text, "coordinates", "&"); string Colors = ms.BetweenTag(text, "color", "&"); string[] ColorsArr = Colors.Split('&'); //Cordinate = Cordinate.Replace(",0", ","); //Cordinate = Cordinate.Replace(",-", "-"); //Cordinate = Cordinate.Replace("-", ",-"); //Cordinate = Cordinate.Replace(",,", ","); string[] Tags = Cordinate.Split('&'); string cords;; string[] Cordinates; for (int i = 0; i < Tags.Length; i++) { if (Delete == "" || (i != MyIndex && MyIndex != 5782)) { if (Tags[i].Trim().Length > 0) { cords = null; Cordinates = Tags[i].Split('\n'); for (int j = 0; j < Cordinates.Length; j++) { if (Cordinates[j].Trim().Length > 0) { cords += Cordinates[j] + "0\n"; } } CompleteKml += km.Style("LineId" + count, "LineStyle", "color", "FFA9A9A9", "width", "4"); CompleteKml += km.Placemark("LineId" + count, "LineId" + count, "LineString", "relative", cords); count++; } } } } #endregion if (cordinates != null || Delete != "") { if (Delete == "") { // foreach (var jk in cordinates) // { string cords = null; string plotColor = "FFA9A9A9"; //(!string.IsNullOrEmpty(r.Color)) ? r.Color.Replace("#", "") : plotColor = "ff" + plotColor.Substring(4, 2) + plotColor.Substring(2, 2) + plotColor.Substring(0, 2); CompleteKml += km.Style("LineId" + count, "LineStyle", "color", plotColor, "width", "4"); foreach (var cor in cordinates) { cords += cor.location.lng + "," + cor.location.lat + ",0\n"; } CompleteKml += km.Placemark("LineId" + count, "LineId" + count, "LineString", "relative", cords); // CompleteKml += km.Placemarks("LineId" + count, "#LineStyle", "relativeToGround", cords); count++; // } } AV_DriveRoutesBL drb = new AV_DriveRoutesBL(); AV_DriveRoutes dr = new AV_DriveRoutes(); dr.CreatedDate = DateTime.Now; dr.RouteId = RouteId; dr.SiteId = Convert.ToInt64(SiteId); dr.CreatedBy = UserId; dr.RoutePath = Path; if (TestType.Length > 1) { dr.TestType = TestType; //.Remove(TestType.Length - 1); } dr.ScopeId = ScopeId; RouteId = drb.Manage(Filter, dr); if (RouteId > 0) { res.Status = "success"; res.Value = RouteId; CompleteKml += km.Close(); dh.CreateDirectory(HttpContext.Current.Server.MapPath(Path)); km.SaveKml2(CompleteKml, "route-" + RouteId, HttpContext.Current.Server.MapPath(Path)); if (pathJson != null) { string jsonpath = "~" + Path; string fname = HttpContext.Current.Server.MapPath(jsonpath); if (!Directory.Exists(fname)) { // if it doesn't exist, create System.IO.Directory.CreateDirectory(fname); } string json = JsonConvert.SerializeObject(pathJson.ToArray()); //write string to file System.IO.File.WriteAllText(fname + "/route-" + RouteId + ".txt", json); } } GC.Collect(); GC.WaitForPendingFinalizers(); if (Delete == "") { res.Message = "Drive Route Planned Successfully."; } else { res.Message = "Drive Route Deleted Successfully."; } } else { res.Status = "danger"; res.Message = "No Route Selected."; } } catch (Exception ex) { res.Status = "danger"; res.Message = ex.Message; } //return Json(res, JsonRequestBehavior.AllowGet); return(res); }
/// <summary> /// User wants to download the data on the map into a KML file for use /// in Google Earth. /// </summary> void downloadButton_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); StringWriter writer = new StringWriter(sb); Google google; KML kml; EnsureChildControls(); // // Create the KML object to work with. // google = new Google(ArenaContext.Current.User, BaseUrl()); kml = new KML(google); // // Add in each individual placemark. // foreach (Placemark placemark in Placemarks) { kml.AddPlacemark(placemark); } // // Run through each RadiusLoader and process it. // foreach (PlacemarkLoader loader in Loaders) { kml.AddLoader(loader); } // // Include the church campuses if they checked the box. // if (downloadIncludeCampus.Checked) { foreach (Campus c in ArenaContext.Current.Organization.Campuses) { kml.AddPlacemark(new CampusPlacemark(c)); } } // // Include the area overlays if the user wants them. // if (downloadIncludeAreaOverlays.Checked) { foreach (Area a in new AreaCollection(ArenaContext.Current.Organization.OrganizationID)) { kml.AddAreaPolygon(a); } } // // Convert the KML into it's raw XML data and send it to the client. // kml.xml.Save(writer); Page.Response.Clear(); Page.Response.ContentType = "application/vnd.google-earth.kml+xml"; Page.Response.AppendHeader("Content-Disposition", "attachment; filename=arena.kml"); Page.Response.Write(sb.ToString()); Page.Response.End(); }