public void Open(PoI p, PoiService service) // REVIEW TODO fix: async removed { var f = p.Id + ".t"; string folder = service.Folder + "\\tracks\\"; if (!service.store.HasFile(folder, f)) return; var his = service.store.GetString(folder + "\\" + f); // REVIEW TODO fix: await removed foreach (var ln in his.Split('\n')) { try { if (!ln.StartsWith("#")) { var pos = new Position(ln); History.Add(pos); } } catch (Exception e) { // FIXME TODO Deal with exception! //Logger.Log("DataService","Error opening track file",e.Message,Logger.Level.Error); } } }
/// <summary> /// Check whether the point is in the arc segment. /// </summary> /// <param name="center">Center point of the arc segment.</param> /// <param name="point">Point to check.</param> /// <param name="startAngle">Angle in degree, where North is zero.</param> /// <param name="endAngle">Angle in degree, where North is zero.</param> /// <param name="radiusInMeter">Radius in meters.</param> /// <returns>True if the point is within the arc segment, otherwise false.</returns> private bool isInArcSegment(Position center, Position point, double startAngle, double endAngle, double radiusInMeter) { var distanceInMeter = CoordinateUtils.Distance(center.Latitude, center.Longitude, point.Latitude, point.Longitude) * 1000; if (distanceInMeter > radiusInMeter) return false; // Compute the angle between the vertical Y-axis and the line between center and point var relativePoint = new Point(point.Longitude - center.Longitude, point.Latitude - center.Latitude); // Compute the angle in clock wise orientation: for that reason, I've swapped the X and Y! var angle = CoordinateUtils.Rad2Deg(Math.Atan2(relativePoint.X, relativePoint.Y)); // Adjust the angle for being in the third or fourth quadrant (bottom half of the clock) if (relativePoint.X < 0) angle += 360; if (startAngle < 0) startAngle += 360; if (endAngle < 0) endAngle += 360; return (endAngle <= startAngle) ? (startAngle <= angle && angle <= 360) || (0 <= angle && angle <= endAngle) : (startAngle <= angle && angle <= endAngle); }
public void FromXmlBase(ref XElement res, string directoryName) { //var xmlSerializer = new XmlSerializer(typeof (PoI)); //var p = xmlSerializer.Deserialize(res.CreateReader()); try { Id = res.GetGuid("Id"); if (Id == Guid.Empty) Id = Guid.NewGuid(); var n = res.GetString("Name"); ContentId = res.GetString("PoiId", ""); if (String.IsNullOrEmpty(ContentId)) ContentId = n; Priority = res.GetInt("Priority", 2); UserId = res.GetString("UserId"); DateLong = res.GetLong("Date", DateTime.Now.ToEpoch()); UpdatedLong = res.GetLong("Updated", DateTime.Now.ToEpoch()); Layer = res.GetString("Layer"); MaxItems = res.GetNullInt("MaxItems"); var xMid = res.Element("MetaInfoData"); PoiTypeId = res.GetString("PoiTypeId", ""); IsVisibleInMenu = res.GetBool("IsVisibleInMenu", true); Orientation = res.GetDouble("Orientation", 0.0); //if (!string.IsNullOrEmpty(PoiTypeId)) //{ //} if (xMid != null) { var metaInfo = new MetaInfoCollection(); foreach (var xMi in xMid.Elements()) { var mi = new MetaInfo(); mi.FromXml(xMi); metaInfo.Add(mi); } MetaInfo = metaInfo; } if (res.Element("WKT") != null) { var xElement = res.Element("WKT"); if (xElement != null) WktText = xElement.Value; } var xlabels = res.Element("Labels"); if (xlabels != null) { Labels = new Dictionary<string, string>(); foreach (var xk in xlabels.Elements()) { var k = xk.Name.LocalName; // Restore keys starting with numbers or having % or '. k = k.Replace(LabelPercentSubst, "%"); k = k.Replace(LabelQuoteSubst, "'"); if (k.StartsWith(LabelNumPrefix)) { k = k.Substring(LabelNumPrefix.Length); } var s = xk.InnerXml(); Labels[k] = s.RestoreInvalidCharacters(); Labels[k] = Labels[k].Replace("<", "<").Replace(">", ">"); } } var xkeywords = res.Element("Keywords"); if (xkeywords != null) { Keywords = new WordHistogram(); Keywords.FromXml(xkeywords); } if (res.Element("Style") != null) { try { var newStyle = new PoIStyle(); newStyle.FromXml(res.Element("Style"), directoryName, false); //, Service.Settings); // TODO REVIEW: Settings were ignored. Style = newStyle; } catch (Exception) { // OK, keep the old style. } } var media = res.Element("AllMedia"); if (media != null) { AllMedia = new BindableCollection<Media>(); foreach (var m in media.Elements()) { var me = new Media { Content = this }; me.FromXml(m); AllMedia.Add(me); } } var xpos = res.Element("Position"); if (xpos != null) Position = new Position(xpos.GetDouble(Position.LONG_LABEL), xpos.GetDouble(Position.LAT_LABEL), xpos.GetDouble(Position.ALT_LABEL)); // TODO Remember other Position attributes. var px = res.Element("Points"); var mo = res.Element("Models"); if (mo != null) { Models = new List<Model>(); foreach (var xm in mo.Elements()) { var m = new Model(); m.FromXml(xm); Models.Add(m); } } if (px == null) return; var pp = px.Value; Points = new ObservableCollection<Point>(); var ppo = pp.Split(' '); foreach (var poss in ppo) { var split = poss.Split(','); var pt = new Point( Double.Parse(split[0], CultureInfo.InvariantCulture), Double.Parse(split[1], CultureInfo.InvariantCulture)); Points.Add(pt); } } catch (SystemException e) { Logger.Log("DataServer.BaseContent", "Error reading XML " + res + " from " + directoryName, e.Message, Logger.Level.Error, true); } }
public void SetPosition(double pLongitude, double pLatitude) { if (Position == null) { Position = new Position(pLongitude, pLatitude); } else { Position.Longitude = pLongitude; Position.Latitude = pLatitude; } TriggerPositionChanged(); }
public void AddPosition(Position myPosition, DateTime date, bool track = true) { Position = myPosition; if (!track) return; AddSensorData("[lat]", date, Position.Latitude); AddSensorData("[lon]", date, Position.Longitude); }
public CreatePoiByPoiTypeEventArgs(PoI pPoiType, Position pPosition) { LatLonPosition = pPosition; PoiType = pPoiType; }