示例#1
0
        internal async Task ForcePosition(GpsLocation _location)
        {
            await Pictures[0].UpdateMetadata(_location);

            Position = new GpsLocation(_location);
            RequestLocationUpdate();
        }
示例#2
0
 public GpsRect(GpsLocation _location)
 {
     TopLeft         = new GpsLocation(_location);
     BottomRight     = new GpsLocation(_location);
     TopLeftDisp     = new GpsLocation(_location);
     BottomRightDisp = new GpsLocation(_location);
     Center          = new GpsLocation(_location);
 }
示例#3
0
 public GpsRect(GpsRect _other)
 {
     TopLeft         = new GpsLocation(_other.TopLeft);
     BottomRight     = new GpsLocation(_other.BottomRight);
     TopLeftDisp     = new GpsLocation(_other.TopLeftDisp);
     BottomRightDisp = new GpsLocation(_other.BottomRightDisp);
     Center          = new GpsLocation(_other.Center);
 }
示例#4
0
        public void UpdateDispDiff(Double _offset)
        {
            TopLeftDisp.Latitude      = TopLeft.Latitude + _offset * (TopLeft.Latitude - BottomRight.Latitude);
            BottomRightDisp.Latitude  = BottomRight.Latitude - _offset * (TopLeft.Latitude - BottomRight.Latitude);
            TopLeftDisp.Longitude     = TopLeft.Longitude - _offset * (BottomRight.Longitude - TopLeft.Longitude);
            BottomRightDisp.Longitude = BottomRight.Longitude + 2 * _offset * (BottomRight.Longitude - TopLeft.Longitude);

            Center = (BottomRight + TopLeft) / 2;
        }
示例#5
0
        public Itinerary()
        {
            Points    = new GpsLocation[2];
            Points[0] = new GpsLocation();
            Points[1] = new GpsLocation();

            DownloadSucceeded = false;
            RequestDownload   = false;
        }
示例#6
0
        public async Task <Boolean> GetMetadata()
        {
            ImageProperties m_imageProperties;

            try
            {
                m_imageProperties = await _fileHandler.Properties.GetImagePropertiesAsync();
            }
            catch (FileNotFoundException)
            {
                return(false);
            }

            if (m_imageProperties != null)
            {
                Position = new GpsLocation();

                if (m_imageProperties.Latitude != null)
                {
                    Position.Latitude = Math.Min((double)m_imageProperties.Latitude, Gps.LATITUDE_DEG_MAX);
                }

                if (m_imageProperties.Longitude != null)
                {
                    Position.Longitude = Math.Min((double)m_imageProperties.Longitude, Gps.LONGITUDE_DEG_MAX);
                }

                if ((m_imageProperties.DateTaken.Year > 1995) && (m_imageProperties.DateTaken.Year < 2030))
                {
                    Date = m_imageProperties.DateTaken.DateTime;
                }
                else
                {
                    Date = _fileHandler.DateCreated.DateTime;
                }

                if (Position.Latitude != 0)
                {
                    PositionPresent = true;
                }
            }
            else
            {
                PositionPresent    = false;
                Position.Latitude  = 0;
                Position.Longitude = 0;
                Date = _fileHandler.DateCreated.DateTime;
            }
            return(true);
        }
示例#7
0
        public Album(int _id, String _path, String _root)
        {
            Pictures   = new List <Picture>();
            AlbumInfos = new PlaceInfos();
            Summary    = new AlbumSummary();
            Position   = new GpsLocation();

            Id        = _id.ToString();
            PathAlbum = _path.Replace(_root + "\\", "");
            PathRoot  = _root;

            // download at first import
            _requestLocationUpdate  = true;
            _requestThumbnailUpdate = true;
        }
示例#8
0
        public void UpdatePoints(GpsLocation _point, int _index)
        {
            if (Points.Length > _index)
            {
                if (!Points[_index].Equals(_point))
                {
                    Points[_index].Copy(_point);

                    if (!(Points[0].Undefined() || Points[1].Undefined()))
                    {
                        RequestDownload = true;
                    }
                }
            }
        }
示例#9
0
        public void UpdateRangeFromLocation(GpsLocation _location)
        {
            if (_location.Latitude > TopLeft.Latitude)
            {
                TopLeft.Latitude = _location.Latitude;
            }
            else if (_location.Latitude < BottomRight.Latitude)
            {
                BottomRight.Latitude = _location.Latitude;
            }

            if (_location.Longitude < TopLeft.Longitude)
            {
                TopLeft.Longitude = _location.Longitude;
            }
            else if (_location.Longitude > BottomRight.Longitude)
            {
                BottomRight.Longitude = _location.Longitude;
            }
        }
示例#10
0
        public async Task <Boolean> UpdatePosition()
        {
            int     _connectionFailedStatus = 0;
            int     CONNECTION_FAIL_MAX     = 3;
            Boolean _first = true;

            DateArrival   = Pictures.First <Picture>().Date;
            DateDeparture = Pictures.Last <Picture>().Date;

            // download only if requested before
            foreach (Picture _picture in Pictures)
            {
                // stop try downloading if 3 fails before
                if ((_picture.PositionPresent) && (_requestLocationUpdate) && (_connectionFailedStatus < CONNECTION_FAIL_MAX))
                {
                    // update album position from first valid picture only
                    if (_first)
                    {
                        Position = new GpsLocation(_picture.Position);
                        _first   = false;
                    }

                    if (await _picture.Download())
                    {
                        if (_picture.PictureInfos.InfoPresent)
                        {
                            if (_picture.PictureInfos.City != null)
                            {
                                DisplayName = _picture.PictureInfos.City + ", " + _picture.PictureInfos.Country;
                            }
                            else if (_picture.PictureInfos.Region != null)
                            {
                                DisplayName = _picture.PictureInfos.Region + ", " + _picture.PictureInfos.Country;
                            }
                            else if (_picture.PictureInfos.Establishment != null)
                            {
                                DisplayName = _picture.PictureInfos.Establishment;
                            }
                            else
                            {
                                DisplayName = _picture.PictureInfos.Country;
                            }

                            AlbumInfos             = _picture.PictureInfos;
                            _requestLocationUpdate = false;
                        }
                        else
                        {
                            _connectionFailedStatus++;
                        }
                    }
                    else
                    {
                        _connectionFailedStatus++;
                    }
                }
            }
            if ((DisplayName == null) && (!AlbumInfos.InfoPresent))
            {
                DisplayName = PathAlbum.Remove(0, PathAlbum.LastIndexOf("\\") + 1);
            }

            Summary.Id   = Id;
            Summary.Name = DisplayName;

            if (AlbumInfos.InfoPresent)
            {
                Summary.StrLocationShort = AlbumInfos.Region;

                if ((AlbumInfos.City == null) && (AlbumInfos.Region != null))
                {
                    Summary.StrLocationShort = AlbumInfos.Region;
                    Summary.StrLocation      = AlbumInfos.Region;
                }
                else if ((AlbumInfos.City != null) && (AlbumInfos.Region == null))
                {
                    Summary.StrLocationShort = AlbumInfos.City;
                    Summary.StrLocation      = AlbumInfos.City;
                }
                else if ((AlbumInfos.City != null) && (AlbumInfos.Region != null))
                {
                    Summary.StrLocationShort = AlbumInfos.City;
                    Summary.StrLocation      = AlbumInfos.City + ", " + AlbumInfos.Region;
                }
                else
                {
                    Summary.StrLocationShort = DisplayName;
                    Summary.StrLocation      = DisplayName;
                }
            }
            else
            {
                Summary.StrLocationShort = DisplayName;
                Summary.StrLocation      = DisplayName;
            }

            return(true);
        }
示例#11
0
 public GpsLocationDec(GpsLocation _location)
 {
     Latitude  = new GpsUnitDec(_location.Latitude, GpsUnitDec.ECoordType.Latitude);
     Longitude = new GpsUnitDec(_location.Longitude, GpsUnitDec.ECoordType.Longitude);
 }
示例#12
0
        public MarkerPosition(FrameworkElement view, MapUIElementCollection _element, object _tag, object Icon, GpsLocation pos, Boolean _visible, int _size)
        {
            _location   = pos;
            _viewParent = view;

            _image = new Image();
            _icon  = Icon;

            if (Icon is EIcon)
            {
                _albumIcon    = (EIcon)Icon;
                _image.Source = ImageFromRelativePath(view, GetIconInactive(_albumIcon));
            }
            else if (Icon is BitmapImage)
            {
                _image.Source = Icon as BitmapImage;
            }
            else if (Icon is String)
            {
                _image.Source = ImageFromRelativePath(view, Icon as String);
            }

            _elementUI = _element;

            try
            {
                _image.Width   = _size;
                _image.Height  = _size;
                _image.Tag     = _tag;
                _image.Tapped += image_Tapped;

                MapLayer.SetPosition(_image, Gps.ConvertGpsToLoc(_location));

                if (Icon is BitmapImage)
                {
                    MapLayer.SetPositionAnchor(_image, GetOffsetImage(2));
                }
                else
                {
                    MapLayer.SetPositionAnchor(_image, GetOffsetImage(1));
                }

                _elementUI.Add(_image);

#if DEBUG
                if (_tag != null)
                {
                    _legend = new TextBlock();

                    if (_tag is Country)
                    {
                        _legend.Text = (_tag as Country).Name.ToString();
                    }
                    else
                    {
                        _legend.Text = _tag.ToString();
                    }

                    _legend.Foreground = new SolidColorBrush(Windows.UI.Colors.White);

                    MapLayer.SetPosition(_legend, Gps.ConvertGpsToLoc(_location));
                    MapLayer.SetPositionAnchor(_legend, GetOffsetLegend());
                    _elementUI.Add(_legend);
                }
#else
                _legend = null;
#endif

                if (!_visible)
                {
                    Hide();
                }
                else
                {
                    Show();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
示例#13
0
 public GpsLocation(GpsLocation _location)
 {
     Latitude  = _location.Latitude;
     Longitude = _location.Longitude;
 }
示例#14
0
        public async Task <Boolean> UpdateMetadata(GpsLocation _position)
        {
            Position        = _position;
            PositionPresent = true;

            GpsLocationDec _locationDec = new GpsLocationDec(_position);
            StorageFile    _file;

            try
            {
                _file = await StorageFile.GetFileFromPathAsync(GetPath());
            }
            catch (FileNotFoundException)
            {
                PositionPresent    = false;
                Position.Latitude  = 0;
                Position.Longitude = 0;
                Date = _fileHandler.DateCreated.DateTime;
                return(false);
            }

            ImageProperties m_imageProperties = await _file.Properties.GetImagePropertiesAsync();

            PropertySet propertiesToSave = new PropertySet();

            // The Latitude and Longitude properties are read-only. Instead,
            // write to System.GPS.LatitudeNumerator, LatitudeDenominator, etc.
            // These are length 3 arrays of integers. For simplicity, the
            // seconds data is rounded to the nearest 10000th.
            uint[] latitudeNumerator =
            {
                (uint)_locationDec.Latitude.Deg,
                (uint)_locationDec.Latitude.Min,
                (uint)(_locationDec.Latitude.Sec * 10000)
            };

            uint[] longitudeNumerator =
            {
                (uint)_locationDec.Longitude.Deg,
                (uint)_locationDec.Longitude.Min,
                (uint)(_locationDec.Longitude.Sec * 10000)
            };

            // LatitudeDenominator and LongitudeDenominator share the same values.
            uint[] denominator =
            {
                1,
                1,
                10000
            };

            propertiesToSave.Add("System.GPS.LatitudeRef", _locationDec.Latitude.Ref);
            propertiesToSave.Add("System.GPS.LongitudeRef", _locationDec.Longitude.Ref);

            propertiesToSave.Add("System.GPS.LatitudeNumerator", latitudeNumerator);
            propertiesToSave.Add("System.GPS.LatitudeDenominator", denominator);
            propertiesToSave.Add("System.GPS.LongitudeNumerator", longitudeNumerator);
            propertiesToSave.Add("System.GPS.LongitudeDenominator", denominator);

            try
            {
                await m_imageProperties.SavePropertiesAsync(propertiesToSave);
            }
            catch (Exception err)
            {
                Debug.WriteLine(err.Message);
                return(false);
            }
            return(true);
        }
示例#15
0
 public static Location ConvertGpsToLoc(GpsLocation _location)
 {
     return(new Location(_location.Latitude, _location.Longitude));
 }
示例#16
0
 public Boolean Equals(GpsLocation _locCompare)
 {
     return((Latitude == _locCompare.Latitude) && (Longitude == _locCompare.Longitude));
 }
示例#17
0
 public void Copy(GpsLocation _point)
 {
     Latitude  = _point.Latitude;
     Longitude = _point.Longitude;
 }