예제 #1
0
 public bool Equals(Incident other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return this.IncidentID == other.IncidentID;
 }
 public static IncidentViewModel Create(Incident incident)
 {
     var i = Mapper.Map<IncidentViewModel>(incident);
     i.Opened = incident.Opened.ToLocal(incident.Agency.TimeZone);
     i.Closed = incident.Closed.ToLocal(incident.Agency.TimeZone);
     return i;
 }
        private string CreateGPX(Incident incident, List<Track> tracks)
        {
            GpxClass gpx = new GpxClass()
            {
                creator = "Blue Diamond",
                trk = new trkTypeCollection()
            };

            gpx.metadata = new metadataType()
            {
                name = incident.Name,
            };

            foreach (var track in tracks)
            {
                trkType trk = new trkType()
                {
                    name = incident.Name,
                };

                trk.trkseg = new trksegTypeCollection();
                trksegType segment = new trksegType()
                {
                    trkpt = new wptTypeCollection()
                };

                trk.trkseg.Add(segment);

                foreach (var pt in track.Points)
                {
                    wptType wpt = new wptType()
                    {
                        lat = (decimal)pt.Latitude,
                        lon = (decimal)pt.Longitude,
                        ele = (decimal)pt.Altitude,
                        eleSpecified = true,
                        time = pt.TimeStamp,
                    };
                    segment.trkpt.Add(wpt);
                }

                gpx.trk.Add(trk);
            }

            try
            {
                var gpx11 = ToGpx1_1(gpx);
                XmlSerializer serializer = new XmlSerializer(gpx11.GetType());
                Utf8StringWriter sw = new Utf8StringWriter();
                serializer.Serialize(sw, gpx11);
                return sw.ToString();
            }
            catch (Exception ex)
            {
                Trace.TraceError("error serializing:\r\n{0}", ex);
                return null;
            }
        }