public ActionResult DigitizeMap(HttpPostedFileBase file, long eventId) { if (file != null && file.ContentLength > 0) { try { XmlReader reader = XmlReader.Create(file.InputStream); XDocument xDoc = System.Xml.Linq.XDocument.Load(reader); KMLParser kmlParser = new KMLParser(); kmlParser.Parse(xDoc, eventId); ViewBag.Message = "File is uploaded and parsed successfully"; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { ViewBag.Message = "You have not specified a file."; } var model = events.GetAll(); ViewBag.year = model.Max(x => x.year); ViewBag.eventId = eventId; return(View(model)); }
private void RenderKML() { var path = NSBundle.MainBundle.PathForResource("KML_Sample", "kml"); var url = new NSUrl(path, isDir: false); var parser = new KMLParser(url); parser.Parse(); var renderer = new GeometryRenderer(mapView, parser.Placemarks, parser.Styles); renderer.Render(); }
/// <summary> /// Creates and initializes a new NetworkLink /// </summary> /// <param name="owner">The owner of this NetworkLink</param> /// <param name="layer">The layer to update the NetworkLink to</param> /// <param name="url">The URL to update the NetworkLink from</param> /// <param name="tickTime">The interval, in milliseconds, at which the NetworkLink should update</param> /// <param name="viewTime">The time, in milliseconds, after the view stops moving which the NetworkLink should update</param> internal KMLNetworkLink(KMLParser owner, Icons layer, string url, int tickTime, int viewTime) { this.owner = owner; this.url = url; this.layer = layer; if (tickTime > 0) { tickTimer.Interval = (double)tickTime; tickTimer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); tickTimer.Start(); } if (viewTime > 0) { viewTimer.Interval = (double)viewTime; viewTimer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); viewTimer.Start(); } }
public void TestGetField() { var kml = "<kml" + "xmlns=\"http://earth.google.com/kml/2.1\">" + "<Folder>" + "<name />" + "<Placemark>" + "<name>Grutto</name>" + "<MultiGeometry>" + "<Polygon>" + "<outerBoundaryIs>" + "<LinearRing>" + "<coordinates>6.0476651,51.3896597,1 6.0473710,51.3918162,1 6.0495220,51.3919244,1 6.0495271,51.3920493,1 6.0509313,51.3920026,1 6.0510568,51.3919528,1 6.0512439,51.3919579,1 6.0511644,51.3905310,1 6.0476651,51.3896597,1</coordinates>" + "</LinearRing>" + "</outerBoundaryIs>" + "</Polygon>" + "</MultiGeometry>" + "</Placemark>" + "</Folder>" + "</kml>"; var coords = new List <Position> { new Position(51.3896597, 6.0476651), new Position(51.3918162, 6.0473710), new Position(51.3919244, 6.0495220), new Position(51.3920493, 6.0495271), new Position(51.3920026, 6.0509313), new Position(51.3919528, 6.0510568), new Position(51.3919579, 6.0512439), new Position(51.3905310, 6.0511644), new Position(51.3896597, 6.0476651) }; var field = KMLParser.GetField(kml); Assert.AreEqual(field.Name, "Grutto"); Assert.AreEqual(field.BoundingCoordinates, coords); }
public ActionResult DigitizeMap(HttpPostedFileBase file, long eventId) { long sessionID = sessionService.GetSessionID(this.HttpContext, true, true); if (file != null && file.ContentLength > 0) { try { XmlReader reader = XmlReader.Create(file.InputStream); XDocument xDoc = System.Xml.Linq.XDocument.Load(reader); KMLParser kmlParser = new KMLParser(); kmlParser.Parse(xDoc, eventId); ViewBag.Message = "File is uploaded and parsed successfully"; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { ViewBag.Message = "You have not specified a file."; } var model = events.GetAll(); if (eventId == -1) { eventId = model.Where(x => x.year == (DateTime.Now.Year + 1)).First <ipmevent>().ID; } ViewBag.eventId = eventId; var year = model.Where(m => m.ID == eventId).First <ipmevent>().year; ViewBag.year = year; return(View(model)); }
// Use this for initialization public void makeMap(string latLong, int zoom = 14, string kmlpath = "depareusa") { StaticMapDownload mapDownloader = new StaticMapDownload(); var mapTex = mapDownloader.downloadImage(latLong, zoom); var renderer = plane.GetComponent <Renderer>(); renderer.material.mainTexture = mapTex; renderer.material.shader = Shader.Find("Unlit/Transparent"); MercatorProjection mp = new MercatorProjection(); string[] latLongArray = latLong.Split(','); Vector2[] corners = mp.getCorners(new Vector2(float.Parse(latLongArray[0]), float.Parse(latLongArray[1])), zoom, 512, 512); Debug.Log(corners[0] + ", " + corners[1]); var distance = mp.distanceBetweenCoord(corners[0], corners[1]); Debug.Log("Distance " + distance); float heightRatio = (10 * Mathf.Sqrt(2)) / distance; KMLParser parser = (KMLParser)ScriptableObject.CreateInstance(typeof(KMLParser)); parser.getXmlData(corners, kmlpath); vertices = parser.getVertices(heightRatio); Triangulation delaunay = (Triangulation)ScriptableObject.CreateInstance(typeof(Triangulation)); var triangles = delaunay.triangulate(vertices); Mesh mesh = new Mesh(); GetComponent <MeshFilter>().mesh = mesh; mesh.vertices = vertices; Debug.Log(Mathf.Min(triangles) + " " + Mathf.Max(triangles)); mesh.triangles = triangles; mesh.RecalculateNormals(); }
public PrototypeUIController() { kmlParser = new KMLParser(); }