private static void LoadCoordinates(XDocument xml)
        {
            var query = from c in xml.Root.Descendants("node")
                        select new
            {
                id        = c.Attribute("id").Value,
                latitude  = c.Attribute("lat").Value,
                longitude = c.Attribute("lon").Value
            };

            foreach (var item in query)
            {
                double latitude  = Double.Parse(item.latitude, CultureInfo.InvariantCulture.NumberFormat);
                double longitude = Double.Parse(item.longitude, CultureInfo.InvariantCulture.NumberFormat);

                var gps = new GpsCoordinate
                {
                    Id        = Convert.ToInt64(item.id),
                    Latitude  = latitude,
                    Longitude = longitude
                };

                uow.GpsCoordinateRepository.Insert(gps);
            }

            uow.SaveChanges();
        }
Beispiel #2
0
        public List <Tuple <DateTime, GpsCoordinate> > GetGpsTrend(Trip trip)
        {
            int    status        = 0; //+1=longitude is set       +2=latitude is set
            double tempLongitude = 0;
            double tempLatitude  = 0;

            List <Tuple <DateTime, GpsCoordinate> > returnValue = new List <Tuple <DateTime, GpsCoordinate> >();

            foreach (var currentTripData in trip.TripData.OrderBy(td => td.Timestamp))
            {
                if (currentTripData?.SignalType?.SignalName == Signal.GpsLongitude)
                {
                    tempLongitude = currentTripData.Value;
                    status       += 1;
                }

                if (currentTripData?.SignalType?.SignalName == Signal.GpsLatitude)
                {
                    tempLatitude = currentTripData.Value;
                    status      += 2;
                }

                if (status >= 3)
                {
                    status = 0;
                    GpsCoordinate tempGpsCoordinate = new GpsCoordinate(tempLatitude, tempLongitude);
                    returnValue.Add(Tuple.Create <DateTime, GpsCoordinate>(currentTripData.Timestamp, tempGpsCoordinate));
                }
            }
            return(returnValue);
        }
Beispiel #3
0
        public bool UpdateLocation(int timeout)
        {
            bool result = false;

            if (_manager != null)
            {
                DateTime lastTime = DateTime.Now;
                while (lastTime.AddSeconds(timeout) > DateTime.Now)
                {
                    CLLocation location = _manager.Location;

                    if (location != null)
                    {
                        DateTime time = DateTime.SpecifyKind(location.Timestamp, DateTimeKind.Unspecified);
                        if (DateTime.UtcNow < time.AddMinutes(5))
                        {
                            _currentLocation = new GpsCoordinate(location.Coordinate.Latitude, location.Coordinate.Longitude, time);
                            result           = true;
                            break;
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #4
0
        public MapData Get(string id, DateTime sDate, DateTime eDate)
        {
            MapData mapData = new MapData();

            logger.Info("start GpsCoordinate: ");
            if (id != null)
            {
                int         Id = Convert.ToInt32(id);
                AuthContext db = new AuthContext();
                mapData.deliveryboy = db.GpsCoordinateDb.Where(x => x.DeliveryBoyId == Id && x.CreatedDate > sDate && x.CreatedDate <= eDate).OrderBy(o => o.CreatedDate).ToList();
                People p    = db.Peoples.Where(x => x.PeopleID == Id).SingleOrDefault();
                var    list = db.OrderDispatchedMasters.Where(x => x.DboyMobileNo == p.Mobile && x.Deliverydate >= sDate && x.Deliverydate <= eDate).ToList();//&& (x.Status == "Ready to Dispatch" || x.Status == "Delivery Redispatch")
                List <GpsCoordinate> displist = new List <GpsCoordinate>();
                foreach (OrderDispatchedMaster m in list)
                {
                    Customer      c  = db.Customers.Where(x => x.CustomerId == m.CustomerId).SingleOrDefault();
                    GpsCoordinate gc = new GpsCoordinate()
                    {
                        DeliveryBoyId = Id,
                        lat           = c.lat,
                        lg            = c.lg,
                        CustomerName  = c.ShopName,
                        isDestination = true,
                        status        = m.Status
                    };

                    displist.Add(gc);
                }
                mapData.customer = displist;
                return(mapData);
            }
            return(null);
        }
        private void ExifGpsView_Parse(object sender, ConvertEventArgs e)
        {
            GpsCoordinate c = new GpsCoordinate();

            c.FromString(e.Value.ToString());
            e.Value = c;
        }
Beispiel #6
0
        private IList <MemberLocation> GenerateMemberLocations()
        {
            GpsCoordinate loc1 = new GpsCoordinate {
                Latitude  = 42.00,
                Longitude = 27.00
            };

            List <MemberLocation> list = new List <MemberLocation>();

            list.Add(new MemberLocation {
                MemberID = Guid.NewGuid(),
                Location = loc1
            });

            list.Add(new MemberLocation {
                MemberID = Guid.NewGuid(),
                Location = loc1
            });

            list.Add(new MemberLocation {
                MemberID = Guid.NewGuid(),
                Location = loc1
            });

            return(list);
        }
        public ExifGpsModel(PictureMetaData pmd)
        {
            if (pmd == null)
            {
                return;
            }

            this.latitudeRef       = Util.unNull(pmd.GpsLatitudeRef);
            this.longitudeRef      = Util.unNull(pmd.GpsLongitudeRef);
            this.altitudeRef       = Util.unNull(pmd.GpsAltitudeRef);
            this.speedRef          = Util.unNull(pmd.GpsSpeedRef);
            this.trackRef          = Util.unNull(pmd.GpsTrackRef);
            this.imageDirectionRef = Util.unNull(pmd.GpsImgDirectionRef);

            this.latitude       = pmd.GpsLatitude;
            this.longitude      = pmd.GpsLongitude;
            this.altitude       = pmd.GpsAltitude.GetValueOrDefault();
            this.speed          = pmd.GpsSpeed.GetValueOrDefault();
            this.track          = pmd.GpsTrack.GetValueOrDefault();
            this.imageDirection = pmd.GpsImgDirection.GetValueOrDefault();

            if (pmd.GpsDateTimeStamp.HasValue)
            {
                this.date = pmd.GpsDateTimeStamp.Value;
            }
            else
            {
                this.date = DateTime.MinValue;
            }
        }
Beispiel #8
0
        public HashtagRepositoryMock()
        {
            var b = new BusinessHours {
                FromHour = new TimeSpan(9, 0, 0), ToHour = new TimeSpan(17, 59, 58)
            };

            user = new User()
            {
                Id          = Guid.NewGuid().ToString(),
                UserName    = "******",
                Email       = "*****@*****.**",
                DisplayName = "Administrator"
            };

            coords = new GpsCoordinate
            {
                Id        = 129557542,
                Altitude  = 0,
                Latitude  = 41.1454754,
                Longitude = -8.6155655
            };

            location = new Location("Torre dos Clérigos", coords);
            poi      = new PointOfInterest(location, "Mock POI", b, 3, user);

            Setup();
        }
        private BaiduCoordinate ConvertCoordinate(GpsCoordinate gpsCoord)
        {
            //其中:
            //from: 来源坐标系   (0表示原始GPS坐标,2表示Google坐标)
            //to:   转换后的坐标   (4就是百度自己啦,好像这个必须是4才行)
            //x:    经度
            //y:    纬度
            //返回的结果是一个json字符串:
            //{"error":0,"x":"MTIxLjUwMDIyODIxNDk2","y":"MzEuMjM1ODUwMjYwMTE3"}
            //其中:
            //error:是结果是否出错标志位,"0"表示OK
            //x:     百度坐标系的经度(Base64加密)
            //y:     百度坐标系的纬度(Base64加密)

            string url = string.Format("http://api.map.baidu.com/ag/coord/convert?from={0}&to={1}&x={2}&y={3}", 0, 4, gpsCoord.Longitude, gpsCoord.Latitude);
            WebClient wc = new WebClient();
            byte[] gps = wc.DownloadData(url);

            JavaScriptSerializer js = new JavaScriptSerializer();
            CoordinateConvertResponse rsp = js.Deserialize<CoordinateConvertResponse>(Encoding.UTF8.GetString(gps));

            BaiduCoordinate baiduCoord = new BaiduCoordinate();

            baiduCoord.Latitude = Convert.ToDecimal(Encoding.UTF8.GetString(Convert.FromBase64String(rsp.y)));
            baiduCoord.Longitude = Convert.ToDecimal(Encoding.UTF8.GetString(Convert.FromBase64String(rsp.x)));
            return baiduCoord;
        }
Beispiel #10
0
        public GpsCoordinate GetCurrentCoordinates(int tenantId = 1)
        {
            var retrievedCoordinate = new GpsCoordinate();

            using (var conn = new MySqlConnection(_connectionString))
            {
                try
                {
                    conn.Open();
                    var comm = conn.CreateCommand();
                    comm.CommandText =
                        "SELECT latitude, longitude, elevation FROM gps_coordinate_log WHERE tenantid = @tenantId ORDER BY time_collected DESC LIMIT 1";

                    comm.Parameters.AddWithValue("@tenantId", 1);
                    var retrievedCoordinateReader = comm.ExecuteReader();
                    while (retrievedCoordinateReader.Read())
                    {
                        retrievedCoordinate.Lat = Convert.ToDouble(retrievedCoordinateReader.GetString("latitude"));
                        retrievedCoordinate.Lon = Convert.ToDouble(retrievedCoordinateReader.GetString("longitude"));
                        retrievedCoordinate.Ele = Convert.ToDouble(retrievedCoordinateReader.GetString("elevation"));
                    }
                }
                catch (Exception e)
                {
                    // TODO: Write to database
                    Console.WriteLine(e);
                }
                finally
                {
                    conn.Close();
                }

                return(retrievedCoordinate);
            }
        }
        /*
         * This method assumes that the memberLocations collection only
         * applies to members applicable for proximity detection. In other words,
         * non-team-mates must be filtered out before using this method.
         * distance threshold is in Kilometers.
         */
        public ICollection <ProximityDetectedEvent> DetectProximityEvents(
            MemberLocationRecordedEvent memberLocationEvent,
            ICollection <MemberLocation> memberLocations,
            double distanceThreshold)
        {
            GpsUtility    gpsUtility       = new GpsUtility();
            GpsCoordinate sourceCoordinate = new GpsCoordinate()
            {
                Latitude  = memberLocationEvent.Latitude,
                Longitude = memberLocationEvent.Longitude
            };

            return(memberLocations.Where(
                       ml => ml.MemberID != memberLocationEvent.MemberID &&
                       gpsUtility.DistanceBetweenPoints(sourceCoordinate, ml.Location) < distanceThreshold)
                   .Select(ml => {
                return new ProximityDetectedEvent()
                {
                    SourceMemberID = memberLocationEvent.MemberID,
                    TargetMemberID = ml.MemberID,
                    TeamID = memberLocationEvent.TeamID,
                    DetectionTime = DateTime.UtcNow.Ticks,
                    SourceMemberLocation = sourceCoordinate,
                    TargetMemberLocation = ml.Location,
                    MemberDistance = gpsUtility.DistanceBetweenPoints(sourceCoordinate, ml.Location)
                };
            }).ToList());
        }
        public void Delete(GpsCoordinate entity)
        {
            var data = this.gps.ToList();

            data.Remove(entity);

            this.gps = data.AsQueryable();
        }
Beispiel #13
0
        static GpsCoordinate Convert(Location location)
        {
            GpsCoordinate result = location != null
                ? new GpsCoordinate(location.Latitude, location.Longitude, location.Time.ToDateTime().ToLocalTime())
                : new GpsCoordinate();

            return(result);
        }
Beispiel #14
0
    public void Convert()
    {
        GpsCoordinate coord = ConversionMode switch
        {
            GpsConversionMode.FromDegrees => new GpsCoordinate(
                GetLatitudeDegrees(DLatDegrees, DLatReference),
                GetLongitudeDegrees(DLngDegrees, DLngReference)
                ),
            GpsConversionMode.FromDegreesMinutes => new GpsCoordinate(
                GetLatitudeDegrees(DmLatDegrees, DmLatReference), GetFloat(DmLatMinutes),
                GetLongitudeDegrees(DmLngDegrees, DmLngReference), GetFloat(DmLngMinutes)
                ),
            GpsConversionMode.FromDegreesMinutesSeconds => new GpsCoordinate(
                GetLatitudeDegrees(DmsLatDegrees, DmsLatReference), GetFloat(DmsLatMinutes), GetFloat(DmsLatSeconds),
                GetLongitudeDegrees(DmsLngDegrees, DmsLngReference), GetFloat(DmsLngMinutes), GetFloat(DmsLngSeconds)
                ),
            _ => throw new InvalidOperationException($"Specified conversion mode [{ ConversionMode }] is not supported")
        };

        // prepare degree portion
        coord.GetLatitudeDegrees(out float degrees);
        DLatDegrees   = Math.Abs(degrees);
        DLatReference = coord.LatitudeRef;
        DLatString    = $"{Math.Abs(degrees):f4} deg {coord.LatitudeRef}";

        coord.GetLongitudeDegrees(out degrees);
        DLngDegrees   = Math.Abs(degrees);
        DLngReference = coord.LongitudeRef;
        DLngString    = $"{Math.Abs(degrees):f4} deg {coord.LongitudeRef}";

        // prepare degree minute portion
        coord.GetLatitudeDegreesMinutes(out degrees, out float minutes);
        DmLatDegrees   = Math.Abs(degrees);
        DmLatMinutes   = minutes;
        DmLatReference = coord.LatitudeRef;
        DmLatString    = $"{Math.Abs(degrees)} deg {minutes:f4}' {coord.LatitudeRef}";

        coord.GetLongitudeDegreesMinutes(out degrees, out minutes);
        DmLngDegrees   = Math.Abs(degrees);
        DmLngMinutes   = minutes;
        DmLngReference = coord.LongitudeRef;
        DmLngString    = $"{Math.Abs(degrees)} deg {minutes:f4}' {coord.LongitudeRef}";

        // prepare degree minute seconds portion
        coord.GetLatitudeDegreesMinutesSeconds(out degrees, out minutes, out float seconds);
        DmsLatDegrees   = Math.Abs(degrees);
        DmsLatMinutes   = minutes;
        DmsLatSeconds   = seconds;
        DmsLatReference = coord.LatitudeRef;
        DmsLatString    = $"{Math.Abs(degrees)} deg {minutes}' {seconds:f4}\" {coord.LatitudeRef}";

        coord.GetLongitudeDegreesMinutesSeconds(out degrees, out minutes, out seconds);
        DmsLngDegrees   = Math.Abs(degrees);
        DmsLngMinutes   = minutes;
        DmsLngSeconds   = seconds;
        DmsLngReference = coord.LongitudeRef;
        DmsLngString    = $"{Math.Abs(degrees)} deg {minutes}' {seconds:f4}\" {coord.LongitudeRef}";
    }
Beispiel #15
0
 public GpsCoordinate post(GpsCoordinate obj)
 {
     try
     {
         return(context.Addgps(obj));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
        public LocationRepositoryMock()
        {
            coords = new GpsCoordinate
            {
                Id        = 129557542,
                Altitude  = 0,
                Latitude  = 41.1454754,
                Longitude = -8.6155655
            };

            this.locations = SetupLocations();
        }
        public void Update(GpsCoordinate entity)
        {
            var oldPoi = this.Get(entity.Id);

            var data = this.gps.ToList();

            data.Remove(oldPoi);

            data.Add(entity);

            this.gps = data.AsQueryable();
        }
        public GpsCoordinate Insert(GpsCoordinate entity)
        {
            var data = this.gps.ToList();

            entity.Id = data.Count + 1;

            data.Add(entity);

            this.gps = data.AsQueryable();

            return(entity);
        }
Beispiel #19
0
        public void Init()
        {
            this.repository = MocksFactory.LocationRepository;

            this.coords = new GpsCoordinate
            {
                Id        = 129557542,
                Altitude  = 0,
                Latitude  = 41.1454754,
                Longitude = -8.6155655
            };
        }
        private void ExifGpsView_Format(object sender, ConvertEventArgs e)
        {
            GpsCoordinate c = e.Value as GpsCoordinate;

            if (c != null)
            {
                e.Value = c.ToString();
            }
            else
            {
                e.Value = "";
            }
        }
Beispiel #21
0
 private MemberLocationRecordedEvent FakeEvent(Guid teamId, Guid memberId, GpsCoordinate location)
 {
     return(new MemberLocationRecordedEvent
     {
         Origin = "IntegrationTest",
         Latitude = location.Latitude,
         Longitude = location.Longitude,
         MemberID = memberId,
         TeamID = teamId,
         ReportID = Guid.NewGuid(),
         RecordedTime = DateTime.UtcNow.Ticks
     });
 }
        public PointOfInterestRepositoryMock()
        {
            coords = new GpsCoordinate
            {
                Id        = 129557542,
                Altitude  = 0,
                Latitude  = 41.1454754,
                Longitude = -8.6155655
            };

            location = new Location("Torre dos Clérigos", coords);

            Setup();
        }
Beispiel #23
0
        private Location CreateLocation(double latitude, double longitude)
        {
            var count = unitOfWork.GpsCoordinateRepository.Count();

            var c = new GpsCoordinate
            {
                Id        = count + 100000000000,
                Latitude  = latitude,
                Longitude = longitude
            };

            var location = new Location("", c);

            return(location);
        }
Beispiel #24
0
 public Task SetGpsOverrideAsync(int photoId, GpsCoordinate gps, string username)
 {
     return(RunAsync(conn =>
                     conn.QueryAsync <long>(
                         "SELECT * FROM photo.set_gps_override(@photoId, @latitude, @longitude, @username, @updateDate);",
                         new
     {
         photoId,
         latitude = gps.Latitude,
         longitude = gps.Longitude,
         username = username.ToLowerInvariant(),
         updateDate = DateTime.Now
     }
                         )
                     ));
 }
Beispiel #25
0
        private bool Start()
        {
            if (_manager != null && !_trackingStarted)
            {
                _currentLocation = new GpsCoordinate();

                if (new Version(UIDevice.CurrentDevice.SystemVersion).Major > 7)
                {
                    _manager.RequestAlwaysAuthorization();
                }

                _manager.StartUpdatingLocation();
                _trackingStarted = true;
                return(true);
            }
            return(false);
        }
Beispiel #26
0
        public void ProducesAccurateDistanceMeasurements()
        {
            var gpsUtility = new GpsUtility();
            var losAngelesCoordinate = new GpsCoordinate{
                Latitude = 34.0522222,
                Longitude = -118.2427778
            };

            var newYorkCoordinate = new GpsCoordinate{
                Latitude = 40.7141667,
                Longitude = -74.0063889
            };

            var distance = gpsUtility.DistanceBetweenPoints(losAngelesCoordinate, newYorkCoordinate);

            Assert.Equal(3933, Math.Round(distance));
            Assert.Equal(0, gpsUtility.DistanceBetweenPoints(losAngelesCoordinate, losAngelesCoordinate));
        }
    public async Task <ActionResult <GpsDetail> > SetGpsOverrideAsync(int id, GpsCoordinate gps)
    {
        if (gps == null)
        {
            throw new ArgumentNullException(nameof(gps));
        }

        await _svc.SetGpsOverrideAsync(id, gps, User.GetUsername());

        var detail = await _svc.GetGpsDetailAsync(id, User.GetAllRoles());

        if (detail == null)
        {
            return(NotFound());
        }

        return(detail);
    }
Beispiel #28
0
        private GpsCoordinate AsGps(Array array, string gpsDir)
        {
            if (array.Length != 3)
            {
                return(null);
            }

            GpsCoordinate gps = new GpsCoordinate();

            if (array.GetValue(0) is Rational <uint> )
            {
                gps.Degrees = (Rational <uint>)array.GetValue(0);
            }
            else
            {
                gps.SetDegrees(Convert.ToDecimal(array.GetValue(0)));
            }

            if (array.GetValue(1) is Rational <uint> )
            {
                gps.Minutes = (Rational <uint>)array.GetValue(1);
            }
            else
            {
                gps.SetMinutes(Convert.ToDecimal(array.GetValue(1)));
            }

            if (array.GetValue(2) is Rational <uint> )
            {
                gps.Seconds = (Rational <uint>)array.GetValue(2);
            }
            else
            {
                gps.SetSeconds(Convert.ToDecimal(array.GetValue(2)));
            }

            try
            {
                gps.Direction = gpsDir;
            }
            catch { }

            return(gps);
        }
        private static void LoadGpdAndLocation(XDocument xml)
        {
            var query = from c in xml.Root.Descendants("node")
                        select new
            {
                id        = c.Attribute("id").Value,
                latitude  = c.Attribute("lat").Value,
                longitude = c.Attribute("lon").Value,
                tags      = c.Elements()
            };

            foreach (var item in query)
            {
                double latitude  = Double.Parse(item.latitude, CultureInfo.InvariantCulture.NumberFormat);
                double longitude = Double.Parse(item.longitude, CultureInfo.InvariantCulture.NumberFormat);

                var gps = new GpsCoordinate
                {
                    Id        = Convert.ToInt64(item.id),
                    Latitude  = latitude,
                    Longitude = longitude
                };

                coordinates.Add(gps); // adiciona à memoria para pesquisar aquando da criação das estradas

                foreach (var tag in item.tags)
                {
                    if (tag.Attribute("k").Value == "name")
                    {
                        var location = new Location(tag.Attribute("v").Value, gps);

                        uow.LocationRepository.Insert(location);
                    }
                }

                uow.GpsCoordinateRepository.Insert(gps);
            }

            uow.SaveChanges();
        }
Beispiel #30
0
 public Task SetGpsOverrideAsync(int photoId, GpsCoordinate gps, string username)
 {
     return(_repo.SetGpsOverrideAsync(photoId, gps, username));
 }
Beispiel #31
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// References:
        /// http://www.media.mit.edu/pia/Research/deepview/exif.html
        /// http://en.wikipedia.org/wiki/APEX_system
        /// http://en.wikipedia.org/wiki/Exposure_value
        /// </remarks>
        protected string FormatValue()
        {
            object rawValue = this.Value;

            switch (this.Tag)
            {
            case ExifTag.ISOSpeed:
            {
                if (rawValue is Array)
                {
                    Array array = (Array)rawValue;
                    if (array.Length < 1 || !(array.GetValue(0) is IConvertible))
                    {
                        goto default;
                    }
                    rawValue = array.GetValue(0);
                }

                if (!(rawValue is IConvertible))
                {
                    goto default;
                }

                return(String.Format("ISO-{0:###0}", Convert.ToDecimal(rawValue)));
            }

            case ExifTag.Aperture:
            case ExifTag.MaxAperture:
            {
                // The actual aperture value of lens when the image was taken.
                // To convert this value to ordinary F-number(F-stop),
                // calculate this value's power of root 2 (=1.4142).
                // For example, if value is '5', F-number is 1.4142^5 = F5.6.
                double fStop = Math.Pow(2.0, Convert.ToDouble(rawValue) / 2.0);
                return(String.Format("f/{0:#0.0}", fStop));
            }

            case ExifTag.FNumber:
            {
                // The actual F-number (F-stop) of lens when the image was taken.
                return(String.Format("f/{0:#0.0}", Convert.ToDecimal(rawValue)));
            }

            case ExifTag.FocalLength:
            case ExifTag.FocalLengthIn35mmFilm:
            {
                return(String.Format("{0:#0.#} mm", Convert.ToDecimal(rawValue)));
            }

            case ExifTag.ShutterSpeed:
            {
                if (!(rawValue is Rational <int>))
                {
                    goto default;
                }

                // To convert this value to ordinary 'Shutter Speed';
                // calculate this value's power of 2, then reciprocal.
                // For example, if value is '4', shutter speed is 1/(2^4)=1/16 second.
                Rational <int> shutter = (Rational <int>)rawValue;

                if (shutter.Numerator > 0)
                {
                    double speed = Math.Pow(2.0, Convert.ToDouble(shutter));
                    return(String.Format("1/{0:####0} sec", speed));
                }
                else
                {
                    double speed = Math.Pow(2.0, -Convert.ToDouble(shutter));
                    return(String.Format("{0:####0.##} sec", speed));
                }
            }

            case ExifTag.ExposureTime:
            {
                if (!(rawValue is Rational <uint>))
                {
                    goto default;
                }

                // Exposure time (reciprocal of shutter speed). Unit is second.
                Rational <uint> exposure = (Rational <uint>)rawValue;

                if (exposure.Numerator < exposure.Denominator)
                {
                    exposure.Reduce();
                    return(String.Format("{0} sec", exposure));
                }
                else
                {
                    return(String.Format("{0:####0.##} sec", Convert.ToDecimal(rawValue)));
                }
            }

            case ExifTag.XResolution:
            case ExifTag.YResolution:
            case ExifTag.ThumbnailXResolution:
            case ExifTag.ThumbnailYResolution:
            case ExifTag.FocalPlaneXResolution:
            case ExifTag.FocalPlaneYResolution:
            {
                return(String.Format("{0:###0} dpi", Convert.ToDecimal(rawValue)));
            }

            case ExifTag.ImageHeight:
            case ExifTag.ImageWidth:
            case ExifTag.CompressedImageHeight:
            case ExifTag.CompressedImageWidth:
            case ExifTag.ThumbnailHeight:
            case ExifTag.ThumbnailWidth:
            {
                return(String.Format("{0:###0} pixels", Convert.ToDecimal(rawValue)));
            }

            case ExifTag.SubjectDistance:
            {
                return(String.Format("{0:###0.#} m", Convert.ToDecimal(rawValue)));
            }

            case ExifTag.ExposureBias:
            case ExifTag.Brightness:
            {
                string val;
                if (rawValue is Rational <int> )
                {
                    val = ((Rational <int>)rawValue).Numerator != 0 ? rawValue.ToString() : "0";
                }
                else
                {
                    val = Convert.ToDecimal(rawValue).ToString();
                }

                return(String.Format("{0} EV", val));
            }

            case ExifTag.CompressedBitsPerPixel:
            {
                return(String.Format("{0:###0.0} bits", Convert.ToDecimal(rawValue)));
            }

            case ExifTag.DigitalZoomRatio:
            {
                return(Convert.ToString(rawValue).Replace('/', ':'));
            }

            case ExifTag.GpsLatitude:
            case ExifTag.GpsLongitude:
            case ExifTag.GpsDestLatitude:
            case ExifTag.GpsDestLongitude:
            {
                if (!(rawValue is Array))
                {
                    goto default;
                }

                Array array = (Array)rawValue;
                if (array.Length < 1)
                {
                    return(String.Empty);
                }
                else if (array.Length != 3)
                {
                    goto default;
                }

                // attempt to use the GPSCoordinate XMP formatting guidelines
                GpsCoordinate gps = new GpsCoordinate();

                if (array.GetValue(0) is Rational <uint> )
                {
                    gps.Degrees = (Rational <uint>)array.GetValue(0);
                }
                else
                {
                    gps.SetDegrees(Convert.ToDecimal(array.GetValue(0)));
                }
                if (array.GetValue(1) is Rational <uint> )
                {
                    gps.Minutes = (Rational <uint>)array.GetValue(1);
                }
                else
                {
                    gps.SetMinutes(Convert.ToDecimal(array.GetValue(1)));
                }
                if (array.GetValue(2) is Rational <uint> )
                {
                    gps.Seconds = (Rational <uint>)array.GetValue(2);
                }
                else
                {
                    gps.SetSeconds(Convert.ToDecimal(array.GetValue(2)));
                }

                return(gps.ToString());
            }

            case ExifTag.GpsTimeStamp:
            {
                Array array = (Array)rawValue;
                if (array.Length < 1)
                {
                    return(String.Empty);
                }

                string[] time = new string[array.Length];
                for (int i = 0; i < array.Length; i++)
                {
                    time[i] = Convert.ToDecimal(array.GetValue(i)).ToString();
                }
                return(String.Join(":", time));
            }

            default:
            {
                if (rawValue is Enum)
                {
                    string description = Utility.GetDescription((Enum)rawValue);
                    if (!String.IsNullOrEmpty(description))
                    {
                        return(description);
                    }
                }
                else if (rawValue is Array)
                {
                    Array array = (Array)rawValue;
                    if (array.Length < 1)
                    {
                        return(String.Empty);
                    }

                    Type type = array.GetValue(0).GetType();
                    if (!type.IsPrimitive || type == typeof(char) || type == typeof(float) || type == typeof(double))
                    {
                        return(Convert.ToString(rawValue));
                    }

                    //const int ElemsPerRow = 40;
                    int           charSize = 2 * System.Runtime.InteropServices.Marshal.SizeOf(type);
                    string        format   = "{0:X" + (charSize) + "}";
                    StringBuilder builder  = new StringBuilder(((charSize + 1) * array.Length) /*+(2*array.Length/ElemsPerRow)*/);
                    for (int i = 0; i < array.Length; i++)
                    {
                        if (i > 0)
                        {
                            //if ((i+1)%ElemsPerRow == 0)
                            //{
                            //    builder.AppendLine();
                            //}
                            //else
                            {
                                builder.Append(" ");
                            }
                        }

                        builder.AppendFormat(format, array.GetValue(i));
                    }
                    return(builder.ToString());
                }

                return(Convert.ToString(rawValue));
            }
            }
        }