Пример #1
0
        internal bool IsUserInValidSector()
        {
            SheredClasses.Point currLoc = GetUserLocation();
            //Very specific to BGU!!! TODO CHANGE
            //List<SheredClasses.Point> points = new List<SheredClasses.Point>()
            //{
            //    new SheredClasses.Point(31.265372, 34.798240),
            //    new SheredClasses.Point(31.261009, 34.798178),
            //    new SheredClasses.Point(31.260975, 34.805906),
            //    new SheredClasses.Point(31.263513, 34.805998),
            //    new SheredClasses.Point(31.265315, 34.803155)
            //};


            //xMin, xMax, yMin, yMax
            //double[] relevantValues = GetRelevantValuesFromPolygonSector(points);

            double[] relevantValues = GetRelevantValuesFromPolygonSector(appSettings.boundaries);
            if (
                currLoc.x > relevantValues[0] &&
                currLoc.x <relevantValues[1] &&
                           currLoc.y> relevantValues[2] &&
                currLoc.y < relevantValues[3])
            {
                return(true);
            }
            return(false);
        }
Пример #2
0
 public void ContinueToLongerTrack()
 {
     currentTrip.track = extendTrack;
     SheredClasses.Point currLoc = GetUserLocation();
     isFinishTrip = currentTrip.DoneMyAttraction(currLoc.x, currLoc.y);
     UpdateTrip();
 }
Пример #3
0
 internal void FinishAttraction()
 {
     isAttractionDone = true;
     SheredClasses.Point currLoc = GetUserLocation();
     isFinishTrip = this.currentTrip.DoneMyAttraction(currLoc.x, currLoc.y);
     UpdateTrip();
 }
Пример #4
0
        public void AddPointToMap(trumpeldor.SheredClasses.Point p, Attraction attraction)
        {
            Pin toAdd = new Pin
            {
                Type     = PinType.Place,
                Position = new Position(p.x, p.y),
                Label    = gc.GetCurrentLanguageText(attraction.name)
            };

            hintedAttraction = attraction;
            hintedPin        = toAdd;
            map.Pins.Add(toAdd);
        }
Пример #5
0
        public void AddCurrlocationToMap(trumpeldor.SheredClasses.Point location)
        {
            //var locator = CrossGeolocator.Current;
            //Plugin.Geolocator.Abstractions.Position position =await locator.GetPositionAsync();

            //trumpeldor.SheredClasses.Point p = gc.GetUserLocation();
            Pin currLocationPin = new Pin
            {
                Type     = PinType.Place,
                Position = new Position(location.x, location.y),
                Label    = "current location"
            };

            previous = currLocationPin;
            currLat  = location.x;
            currLong = location.y;
            map.Pins.Add(currLocationPin);
        }
Пример #6
0
        public MapPage()
        {
            InitializeComponent();
            gc             = GameController.getInstance();
            lc             = LocationController.GetInstance();
            nextAttraction = gc.currentTrip.GetCurrentAttraction();
            p = new trumpeldor.SheredClasses.Point(nextAttraction.x, nextAttraction.y);
            //-------------------------------------------------------------------
            map = new CustomMap
            {
                MapType         = MapType.Street,
                WidthRequest    = 100,
                HeightRequest   = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            Content = map;
            map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(31.262820, 34.802352), Distance.FromKilometers(3)).WithZoom(10));

            //-------------------------------------------------------------------

            /*
             * List<SheredClasses.Attraction> visitedTrackPoints = gc.GetVisitedAttractions();
             * foreach (SheredClasses.Attraction attraction in visitedTrackPoints)
             * {
             *  Pin pin = new Pin
             *  {
             *      Type = PinType.Place,
             *      Position = new Position(attraction.x, attraction.y),
             *      Label = gc.GetCurrentLanguageText(attraction.name),
             *  };
             *  map.Pins.Add(pin);
             * }
             * AddCurrlocationToMap(map);
             *
             *
             * Content = map;
             * DrawPastPath(map);
             * map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(31.262820, 34.802352), Distance.FromKilometers(3)).WithZoom(10));
             */
        }
Пример #7
0
        public NavigationPage()
        {
            InitializeComponent();
            gc = GameController.getInstance();
            leftArrow.Source           = ServerConection.URL_MEDIA + "leftArrow.jpg";
            rightArrow.Source          = ServerConection.URL_MEDIA + "rightArrow.jpg";
            temperature.Source         = ServerConection.URL_MEDIA + "thermometer.jpg";
            v.Source                   = ServerConection.URL_MEDIA + "v.png";
            odometer.Maximum           = 1;
            odometer.Minimum           = 0;
            odometer.MinimumTrackColor = Color.FromHex("#0066ff");
            odometer.MaximumTrackColor = Color.FromHex("#0066ff");
            odometer.Value             = 0;
            odometer.WidthRequest      = temperature.HeightRequest;
            //hintBtn.Padding = 0;
            //hintBtn.WidthRequest = hintFrame.Width;
            //hintBtn.Margin = new Thickness(
            //    leftArrow.Width + hintFrame.Margin.Left + hintFrame.Padding.Left - 5,
            //    10,
            //    hintFrame.Margin.Right + hintFrame.Padding.Right,
            //    10);
            nextAttraction = gc.currentTrip.GetCurrentAttraction();
            myMap          = MapPage.GetInstance();
            mapBtn.Source  = ServerConection.URL_MEDIA + "map.png";
            //mapBtn = myMap.map;
            AttachHint(0);

            lc            = LocationController.GetInstance();
            attractionLoc = new trumpeldor.SheredClasses.Point(nextAttraction.x, nextAttraction.y);
            if (isFirst)
            {
                isFirst = false;
                //Task.Run(() => TimerCheck()).ConfigureAwait(false);
                //TimerCheck();
            }
            myMap.AddCurrlocationToMap(gc.GetUserLocation());
            TimerCheck();
        }
Пример #8
0
        private void FindUserLocation()
        {
            //Task.Run(async () =>
            //{
            Timer locationTimer = new Timer();

            locationTimer.Interval = DESIRED_SECONDS * 1000;
            locationTimer.Elapsed += async(o, e) =>
            {
                waitHandle.Reset();
                //Task.Run(async () =>
                //{
                var locator = CrossGeolocator.Current;
                Plugin.Geolocator.Abstractions.Position position = await locator.GetPositionAsync(TimeSpan.FromSeconds(DESIRED_SECONDS));

                myLocation = new SheredClasses.Point(position.Latitude, position.Longitude);
                waitHandle.Set();
                //});
            };
            locationTimer.Start();

            //timeOfLocation = DateTime.Now;
            //});
        }
Пример #9
0
        internal Track GetExtendedTrack(Track track, SheredClasses.Point userLocation)
        {
            string jsonResponse = SendToServerAndGetResponseBack(new { trackId = track.id, x = userLocation.x, y = userLocation.y, }, "getExtendedTrack/");

            return(GetFullTrack(JsonConvert.DeserializeObject <Track>(jsonResponse)));
        }
Пример #10
0
        //public bool isCurrentLocation()
        //{
        //    return timeOfLocation != null &&
        //        DateTime.Now.Subtract((DateTime)timeOfLocation).TotalSeconds < DESIRED_SECONDS;
        //}

        //get y.png for example return http://IP:PORT/media/y.png
        //public string GetMediaURLFromName(string pictureName)
        //{
        //    return "http://" + ServerConection.IP + ":" + ServerConection.PORT + "/media/" + pictureName;
        //}

        public bool CanContinueToLongerTrack()
        {
            SheredClasses.Point currLoc = GetUserLocation();
            this.extendTrack = conn.GetExtendedTrack(this.currentTrip.track, currLoc);
            return(this.extendTrack != null);
        }
Пример #11
0
 public void CreateTrip(string groupName, List <int> playersAges, int trackLength)
 {
     SheredClasses.Point currLoc = GetUserLocation();
     currentTrip = conn.CreateTrip(currentUser, groupName, playersAges, trackLength, currLoc.x, currLoc.y);
 }