// Use this for initialization void Start() { // generate all of the prefabs for the waypoints float xOff = -3.2F; float yOff = 0.0F; foreach (OverlandWaypointModel waypoint in tileModel.waypoints) { GameObject newObject = (GameObject)Instantiate(Resources.Load("Prefabs/WaypointView")); WaypointView objWv = newObject.GetComponent <WaypointView>(); objWv.model = waypoint; objWv.drawBasedOnModel(); newObject.transform.parent = this.transform; newObject.transform.localPosition = new Vector2(xOff, yOff); xOff += 0.4F; yOff -= 0.08F; } // set the first waypoint to reached OverlandWaypointModel first = (OverlandWaypointModel)tileModel.waypoints [0]; first.reached = true; first.passed = false; }
public ActionResult SubmitWaypoint(WaypointView wpt) { List<SubmitError> errors = new List<SubmitError>(); Guid result = Guid.Empty; if (!User.IsInRole("cdb.missioneditors")) { return GetLoginError(); } MissionGeography geog = null; geog = (from g in this.db.MissionGeography where g.Id == wpt.Id select g).FirstOrDefault(); if (geog == null) { geog = new MissionGeography { Mission = (from m in this.db.Missions where m.Id == wpt.EventId select m).First() }; this.db.MissionGeography.Add(geog); } //try //{ if (geog.Kind != wpt.Kind) geog.Kind = wpt.Kind; if (geog.InstanceId != wpt.InstanceId) geog.InstanceId = wpt.InstanceId; SqlGeography defaultCoord = GeographyServices.GetDefaultLocation(); wpt.Lat = Math.Abs(wpt.Lat) * Math.Sign(defaultCoord.Lat.Value); wpt.Long = Math.Abs(wpt.Long) * Math.Sign(defaultCoord.Long.Value); SqlGeography geography = wpt.AsSqlGeography(); if (string.Format("{0}", geog.Geography) != string.Format("{0}", geography)) geog.Geography = geography; if (geog.Description != wpt.Description) geog.Description = wpt.Description; if (geog.Time != wpt.Time) geog.Time = wpt.Time; if (errors.Count == 0) { this.db.SaveChanges(); } //} //catch (RuleViolationsException ex) //{ // //this.CollectRuleViolations(ex, fields); // foreach (RuleViolation v in ex.Errors) // { // errors.Add(new SubmitError { Error = v.ErrorMessage, Property = v.PropertyName, Id = new[] { v.EntityKey } }); // } //} return Data(new SubmitResult<GeographyView> { Errors = errors.ToArray(), Result = (errors.Count > 0) ? (GeographyView)null : GeographyView.BuildGeographyView(geog) //new WaypointView //{ // Id = newView.Id, // MissionId = newView.Mission.Id, // Kind = newView.Kind, // Desc = newView.Description, // Lat = GeographyServices.FormatCoordinate(newView.Geography.Lat.Value, this.UserSettings.CoordinateDisplay), // Long = GeographyServices.FormatCoordinate(newView.Geography.Long.Value, this.UserSettings.CoordinateDisplay), // Instance = newView.InstanceId, // Time = newView.Geography.M.IsNull ? (DateTime?)null : DateTime.FromOADate(newView.Geography.M.Value) //} }); }
public ActionResult SubmitWaypoint(WaypointView wpt) { List <SubmitError> errors = new List <SubmitError>(); Guid result = Guid.Empty; if (!User.IsInRole("cdb.missioneditors")) { return(GetLoginError()); } MissionGeography geog = null; geog = (from g in this.db.MissionGeography where g.Id == wpt.Id select g).FirstOrDefault(); if (geog == null) { geog = new MissionGeography { Mission = (from m in this.db.Missions where m.Id == wpt.EventId select m).First() }; this.db.MissionGeography.Add(geog); } //try //{ if (geog.Kind != wpt.Kind) { geog.Kind = wpt.Kind; } if (geog.InstanceId != wpt.InstanceId) { geog.InstanceId = wpt.InstanceId; } SqlGeography defaultCoord = GeographyServices.GetDefaultLocation(); wpt.Lat = Math.Abs(wpt.Lat) * Math.Sign(defaultCoord.Lat.Value); wpt.Long = Math.Abs(wpt.Long) * Math.Sign(defaultCoord.Long.Value); SqlGeography geography = wpt.AsSqlGeography(); if (string.Format("{0}", geog.Geography) != string.Format("{0}", geography)) { geog.Geography = geography; } if (geog.Description != wpt.Description) { geog.Description = wpt.Description; } if (geog.Time != wpt.Time) { geog.Time = wpt.Time; } if (errors.Count == 0) { this.db.SaveChanges(); } //} //catch (RuleViolationsException ex) //{ // //this.CollectRuleViolations(ex, fields); // foreach (RuleViolation v in ex.Errors) // { // errors.Add(new SubmitError { Error = v.ErrorMessage, Property = v.PropertyName, Id = new[] { v.EntityKey } }); // } //} return(Data(new SubmitResult <GeographyView> { Errors = errors.ToArray(), Result = (errors.Count > 0) ? (GeographyView)null : GeographyView.BuildGeographyView(geog) //new WaypointView //{ // Id = newView.Id, // MissionId = newView.Mission.Id, // Kind = newView.Kind, // Desc = newView.Description, // Lat = GeographyServices.FormatCoordinate(newView.Geography.Lat.Value, this.UserSettings.CoordinateDisplay), // Long = GeographyServices.FormatCoordinate(newView.Geography.Long.Value, this.UserSettings.CoordinateDisplay), // Instance = newView.InstanceId, // Time = newView.Geography.M.IsNull ? (DateTime?)null : DateTime.FromOADate(newView.Geography.M.Value) //} })); }
public void AddItem(GeographyView item, string name, string kind, string description, Guid?folder) { bool visible = true; kind = (kind ?? "").ToLowerInvariant(); TimeZoneInfo pacific = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); var itemNode = Create("Placemark", name, description); if (documentNode.Elements(KML_NS + "Style").SingleOrDefault(f => f.Attribute("id").Value == "noLabel") == null) { var styleNode = new XElement(KML_NS + "Style"); styleNode.SetAttributeValue("id", "noLabel"); styleNode.Add(new XElement("LabelStyle", new XElement("scale", "0.5"))); documentNode.Add(styleNode); } if (item is RouteView) { List <string> coords = new List <string>(); List <string> times = new List <string>(); bool useTimestamp = true; itemNode.Add(new XElement(KML_NS + "styleUrl", "#" + GetLineStyle(colors[ColorIndex++ % colors.Length]))); var lineNode = new XElement(GEXT_NS + "Track"); itemNode.Add(lineNode); if (((RouteView)item).Points.All(f => f.Z.HasValue)) { // lineNode.Add(new XElement(KML_NS + "altitudeMode", "absolute")); } foreach (var pt in ((RouteView)item).Points) { coords.Add(string.Format("{0} {1} {2}", pt.Long, pt.Lat, pt.Z)); if (useTimestamp && pt.Time.HasValue) { times.Add((pt.Time.Value - pacific.GetUtcOffset(pt.Time.Value)).ToString("s") + "Z"); } else { useTimestamp = false; } } if (useTimestamp) { foreach (string time in times) { lineNode.Add(new XElement(KML_NS + "when", time)); } } foreach (string coord in coords) { lineNode.Add(new XElement(GEXT_NS + "coord", coord)); } //var lineNode = new XElement(KML_NS + "LineString"); //lineNode.Add(new XElement(KML_NS + "extrude", 1)); //lineNode.Add(new XElement(KML_NS + "tessellate", 1)); //lineNode.Add(new XElement(KML_NS + "altitudeMode", "clampToGround")); //lineNode.Add(new XElement(KML_NS + "coordinates", string.Join("\n", ((RouteView)item).Points.Select(f => string.Format("{0},{1},10", f.Long, f.Lat)).ToArray()))); itemNode.Add(lineNode); } else if (item is WaypointView) { WaypointView wpt = (WaypointView)item; itemNode.Add(new XElement(KML_NS + "Point", new XElement(KML_NS + "coordinates", string.Format("{0},{1}", wpt.Long, wpt.Lat)))); if (item.Kind == "team") { visible = false; } itemNode.Add(new XElement(KML_NS + "styleUrl", "#" + (knownIconTypes.Contains(kind) ? kind : "noLabel"))); } itemNode.Add(new XElement(KML_NS + "visibility", visible ? 1 : 0)); folders[folder ?? Guid.Empty].Add(itemNode); }