private void writeTrackPoint(IDGTrackPoint tp, XmlWriter wr, String startElement) { int tpType = tp.getTrackFormat(); wr.WriteStartElement(startElement); Tuple <Int16, Double> coord = tp.getLatitude(); wr.WriteAttributeString("lat", coord.Item1.ToString() + this.makeDecimalMinutes(coord.Item2)); coord = tp.getLongitude(); wr.WriteAttributeString("lon", coord.Item1.ToString() + this.makeDecimalMinutes(coord.Item2)); wr.WriteElementString("time", tp.getDateTime().ToString("yyyy-MM-ddTHH:mm:ssZ")); if (tpType == BaseDGTrackPoint.FORMAT_POSITION_DATE_SPEED || tpType == BaseDGTrackPoint.FORMAT_POSITION_DATE_SPEED_ALTITUDE) { wr.WriteElementString("cmt", tp.getSpeed().ToString() + "km/h"); } if (tpType == BaseDGTrackPoint.FORMAT_POSITION_DATE_SPEED_ALTITUDE) { wr.WriteElementString("ele", tp.getAltitude().ToString()); } wr.WriteEndElement(); }
/// <summary> /// Constructor. Initializes the internal settings to produce the correct track type for all records. /// </summary> /// <param name="buffer">Buffer of data to process.</param> public DGTrackPointFactory(CommandBuffer buffer) { this._buf = buffer; // Read the first track to find out what the format is for the rest of them. this._buf.Position = BaseCommandResult.PAYLOAD_START; byte[] firstTrackArr = new byte[32]; this._buf.Read(firstTrackArr, 0, firstTrackArr.Length); this._firstTrack = new DGFirstTrackPoint(firstTrackArr); // The byte size of the remaining records is based on what's found in the first one. this._formatType = this._firstTrack.getTrackFormat(); this._expectedBytes = this._formatType == BaseDGTrackPoint.FORMAT_POSITION_DATE_SPEED_ALTITUDE ? 32 : 20; switch (this._formatType) { case 0: this.getTrackPoint = this.getPositionOnlyTrackPoint; break; case 1: this.getTrackPoint = this.getDateTimeTrackPoint; break; default: this.getTrackPoint = this.getAltitudeTrackPoint; break; } }