Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public async Task <bool> LoadNearPhotos()
        {
            try
            {
                // User's location
                var userGeoPoint = new ParseGeoPoint(this.Lat, this.Lon); //MyCoordinate.Latitude, MyCoordinate.Longitude
                // Create a query for places
                var query = ParseObject.GetQuery("AssistPhoto");
                //Interested in locations near user.
                query = query.WhereNear("latlon", userGeoPoint);
                // Limit what could be a lot of points.
                query = query.Limit(80);

                IEnumerable <ParseObject> results = await query.FindAsync();

                PhotoItems    = new ObservableCollection <AssistsPhoto>();
                NearestImages = new Collection <string>();
                foreach (var item in results)
                {
                    AddPlaceFromParseObject(item);
                }
                ;

                /*if (PhotoItems.Count < 1)
                 * {
                 *  await LoadSomePlaces();
                 * };*/
            }
            catch { };
            return(true);
        }
Esempio n. 2
0
        private async void GetVetsRequest()
        {
            progress.IsIndeterminate = true;

            try
            {
                ParseGeoPoint geo = new ParseGeoPoint()
                {
                    Latitude  = currentLocation.Position.Latitude,
                    Longitude = currentLocation.Position.Longitude
                };

                vets = await DataClient.Instance.Vets(geo, limit);

                foreach (var vet in vets)
                {
                    PinToMap(vet);
                }
            }

            catch (Exception)
            {
            }

            progress.IsIndeterminate = false;
        }
Esempio n. 3
0
        /// <summary>
        /// Search places
        /// </summary>
        /// <returns></returns>
        public async Task <bool> LoadSearchPlaces()
        {
            this.Loading = true;
            try
            {
                // User's location
                var userGeoPoint = new ParseGeoPoint(MyCoordinate.Latitude, MyCoordinate.Longitude);
                // Create a query for places
                var query = from place in ParseObject.GetQuery("AssistPhoto")
                            where (place.Get <string>("title").Contains(SearchQuery) || place.Get <string>("title").Contains(SearchQuery.ToLower())) ||
                            (place.Get <string>("comment").Contains(SearchQuery) || place.Get <string>("comment").Contains(SearchQuery.ToLower()))

                            select place;
                query = query.Limit(80);

                IEnumerable <ParseObject> results = await query.FindAsync();

                SearchPlaceItems = new ObservableCollection <AssistsPhoto>();
                //NearestImages = new Collection<string>();
                foreach (var item in results)
                {
                    AddPlaceFromParseObject(item, "search");
                }
                ;
            }
            catch (Exception ex) {
                Debug.WriteLine(ex.ToString());
            };
            this.Loading = false;

            return(true);
        }
Esempio n. 4
0
        public async Task Geo()
        {
            ParseObject   obj      = new ParseObject("Todo");
            ParseGeoPoint location = new ParseGeoPoint(39.9, 116.4);

            obj["location"] = location;
            await obj.Save();

            // near
            ParseQuery <ParseObject> query = new ParseQuery <ParseObject>("Todo");
            ParseGeoPoint            point = new ParseGeoPoint(39.91, 116.41);

            query.WhereNear("location", point);
            ReadOnlyCollection <ParseObject> results = await query.Find();

            Assert.Greater(results.Count, 0);

            // in box
            query = new ParseQuery <ParseObject>("Todo");
            ParseGeoPoint southwest = new ParseGeoPoint(30, 115);
            ParseGeoPoint northeast = new ParseGeoPoint(40, 118);

            query.WhereWithinGeoBox("location", southwest, northeast);
            results = await query.Find();

            Assert.Greater(results.Count, 0);
        }
 public Items(ParseGeoPoint pgp, int timeStamp, string nameZone, string sURL)
 {
     this.pgp       = pgp;
     this.timeStamp = timeStamp;
     this.nameZone  = nameZone;
     this.sURL      = sURL;
 }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        double result  = Convert.ToDouble(geo_x);
        double result2 = Convert.ToDouble(geo_y);
        var    point   = new ParseGeoPoint(result2, result);


        ParseQuery <ParseObject> query = ParseObject.GetQuery("POST")
                                         .WhereWithinDistance("Post_Geo", point, ParseGeoDistance.FromKilometers(2.5));

        query.FindAsync().ContinueWith(t => {
            IEnumerable <ParseObject> nearbyLocations = t.Result;

            foreach (var obj in nearbyLocations)
            {
                string text  = obj ["postfield"].ToString();
                string place = obj["geo_place"].ToString();
                //string post = obj ["postfield"].ToString ();
                //labeltext.Add(post);
                Debug.Log(text);

                Debug.Log("資料庫傳回:" + place);
            }
            // nearbyLocations contains PlaceObjects within 5 miles of the user's location
        });
    }
Esempio n. 7
0
    IEnumerator  Start()
    {
        string geo_x = null;
        string geo_y = null;
        string geo_name;
        string CMD;
        string post = "台北101購物中心";
        string url  = "http://egis.moea.gov.tw/innoserve/toolLoc/GetFastLocData.aspx?cmd=searchLayer2&group=0&db=ALL&param=" + post + "&coor=84";

        WWW www = new WWW(url);

        //Load the data and yield (wait) till it's ready before we continue executing the rest of this method.
        yield return(www);

        if (www.error == null)
        {
            //Sucessfully loaded the XML
            Debug.Log("Loaded following XML " + www.data);
            //geo_name=xl2.GetAttribute("Addr") + ": " + xl2.InnerText;
            //Create a new XML document out of the loaded data
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(www.data);

            XmlNode provinces = xmlDoc.SelectSingleNode("result");
            Debug.Log("readxml");

            /*
             * XmlNodeList nodeList = xmlDoc.SelectNodes("result");
             * int numGoods = nodeList.Count;
             * Debug.Log(numGoods);*/

            foreach (XmlNode province in provinces)
            {
                XmlElement _province = (XmlElement)province;


                geo_name = _province.GetAttribute("Addr");
                geo_x    = _province.GetAttribute("Cx");
                geo_y    = _province.GetAttribute("Cy");
                //获取实际城市名
                CMD = _province.GetAttribute("CMD");
                Debug.Log(geo_name);
                Debug.Log(geo_x);
                Debug.Log(geo_y);
            }
        }
        double result  = Convert.ToDouble(geo_x);
        double result2 = Convert.ToDouble(geo_y);

        ParseObject POST  = new ParseObject("POST");
        var         point = new ParseGeoPoint(result2, result);

        POST ["post_geo"] = point;

        POST.SaveAsync().ContinueWith(t =>
        {
            Debug.Log("文章內容:" + point);
        });
    }
Esempio n. 8
0
 public static object EncodeGeoPoint(ParseGeoPoint geoPoint)
 {
     return(new Dictionary <string, object> {
         { "__type", "GeoPoint" },
         { "latitude", geoPoint.Latitude },
         { "longitude", geoPoint.Longitude }
     });
 }
        public static ParseGeoPoint DecodeGeoPoint(IDictionary data)
        {
            double        latitude  = Convert.ToDouble(data["latitude"]);
            double        longitude = Convert.ToDouble(data["longitude"]);
            ParseGeoPoint geoPoint  = new ParseGeoPoint(latitude, longitude);

            return(geoPoint);
        }
        public void TestGeoDistanceInRadians()
        {
            var d2r    = Math.PI / 180.0;
            var pointA = new ParseGeoPoint();
            var pointB = new ParseGeoPoint();

            // Zero
            Assert.AreEqual(0.0, pointA.DistanceTo(pointB).Radians, 0.00001);
            Assert.AreEqual(0.0, pointB.DistanceTo(pointA).Radians, 0.00001);

            // Wrap Long
            pointA.Longitude = 179.0;
            pointB.Longitude = -179.0;
            Assert.AreEqual(2 * d2r, pointA.DistanceTo(pointB).Radians, 0.00001);
            Assert.AreEqual(2 * d2r, pointB.DistanceTo(pointA).Radians, 0.00001);

            // North South Lat
            pointA.Latitude  = 89.0;
            pointA.Longitude = 0;
            pointB.Latitude  = -89.0;
            pointB.Longitude = 0;
            Assert.AreEqual(178 * d2r, pointA.DistanceTo(pointB).Radians, 0.00001);
            Assert.AreEqual(178 * d2r, pointB.DistanceTo(pointA).Radians, 0.00001);

            // Long wrap Lat
            pointA.Latitude  = 89.0;
            pointA.Longitude = 0;
            pointB.Latitude  = -89.0;
            pointB.Longitude = 179.999;
            Assert.AreEqual(180 * d2r, pointA.DistanceTo(pointB).Radians, 0.00001);
            Assert.AreEqual(180 * d2r, pointB.DistanceTo(pointA).Radians, 0.00001);

            pointA.Latitude  = 79.0;
            pointA.Longitude = 90.0;
            pointB.Latitude  = -79.0;
            pointB.Longitude = -90.0;
            Assert.AreEqual(180 * d2r, pointA.DistanceTo(pointB).Radians, 0.00001);
            Assert.AreEqual(180 * d2r, pointB.DistanceTo(pointA).Radians, 0.00001);

            // Wrap near pole - somewhat ill conditioned case due to pole proximity
            pointA.Latitude  = 85.0;
            pointA.Longitude = 90.0;
            pointB.Latitude  = 85.0;
            pointB.Longitude = -90.0;
            Assert.AreEqual(10 * d2r, pointA.DistanceTo(pointB).Radians, 0.00001);
            Assert.AreEqual(10 * d2r, pointB.DistanceTo(pointA).Radians, 0.00001);

            // Reference cities

            // Sydney, Australia
            pointA.Latitude  = -34.0;
            pointA.Longitude = 151.0;
            // Buenos Aires, Argentina
            pointB.Latitude  = -34.5;
            pointB.Longitude = -58.35;
            Assert.AreEqual(1.85, pointA.DistanceTo(pointB).Radians, 0.01);
            Assert.AreEqual(1.85, pointB.DistanceTo(pointA).Radians, 0.01);
        }
Esempio n. 11
0
        public void TestEncodeParseGeoPoint()
        {
            ParseGeoPoint point = new ParseGeoPoint(3.22, 32.2);
            IDictionary <string, object> value = ParseEncoderTestClass.Instance.Encode(point) as IDictionary <string, object>;

            Assert.AreEqual("GeoPoint", value["__type"]);
            Assert.AreEqual(3.22, value["latitude"]);
            Assert.AreEqual(32.2, value["longitude"]);
        }
        public void WhereWithinGeoBox(string key, ParseGeoPoint southwest, ParseGeoPoint northeast)
        {
            Dictionary <string, object> value = new Dictionary <string, object> {
                { "$box", new List <object> {
                      southwest, northeast
                  } }
            };

            AddOperation(key, "$within", value);
        }
        public async void Cadastrar()
        {
            DateTime?_datetime = time_abre.Value;
            string   hr_abre   = _datetime.Value.Hour + ":" + _datetime.Value.Minute;

            _datetime = time_fecha.Value;
            string hr_fecha = _datetime.Value.Hour + ":" + _datetime.Value.Minute;

            ListPickerItem selectedItem = (ListPickerItem)lst_segmento.SelectedItem;
            string         segmento_lst = (string)selectedItem.Content;

            ParseObject cadastro = new ParseObject("Foodtruck");

            try {
                cadastro["idUser"]         = Id;
                cadastro["Foodtruck_nome"] = txt_foodtruck_nome.Text;
                cadastro["Segmento"]       = segmento_lst;
                cadastro["Hr_abre"]        = hr_abre;
                cadastro["Hr_Fecha"]       = hr_fecha;
                cadastro["Preco"]          = txt_preco.Text;
                cadastro["Telefone"]       = txt_telefone.Text;

                GeocodeQuery geocodeQuery = new GeocodeQuery();
                geocodeQuery.GeoCoordinate = new GeoCoordinate();
                geocodeQuery.SearchTerm    = txt_local.Text;

                IList <MapLocation> locations = await geocodeQuery.GetMapLocationsAsync();

                foreach (var local in locations)
                {
                    var point = new ParseGeoPoint(local.GeoCoordinate.Latitude, local.GeoCoordinate.Longitude);
                    cadastro["localizacao"] = point;
                    MessageBoxResult resultado6 = MessageBox.Show("latitude: " + point.Latitude + " longitude: " + point.Longitude, "Foodtruck Show", MessageBoxButton.OK);
                }
                await
                cadastro.SaveAsync();
            }
            catch (Exception ex) {
                MessageBox.Show("Erro: " + ex);
            }

            MessageBoxResult resultado0 = MessageBox.Show("ID : " + Id, "Foodtruck Show", MessageBoxButton.OK);
            MessageBoxResult resultado1 = MessageBox.Show("Nome : " + txt_foodtruck_nome.Text, "Foodtruck Show", MessageBoxButton.OK);
            MessageBoxResult resultado2 = MessageBox.Show("Segmento : " + segmento_lst, "Foodtruck Show", MessageBoxButton.OK);
            MessageBoxResult resultado3 = MessageBox.Show(hr_abre + " " + hr_fecha, "Foodtruck Show", MessageBoxButton.OK);
            MessageBoxResult resultado4 = MessageBox.Show("Preco : " + txt_preco.Text, "Foodtruck Show", MessageBoxButton.OK);
            MessageBoxResult resultado5 = MessageBox.Show("tel : " + txt_telefone.Text, "Foodtruck Show", MessageBoxButton.OK);
            MessageBoxResult resultado  = MessageBox.Show("Informacoes cadastradas com sucesso", "Foodtruck Show", MessageBoxButton.OK);

            if (resultado == MessageBoxResult.OK)
            {
                NavigationService.GoBack();
            }
        }
Esempio n. 14
0
 public ChallengeViewModel()
 {
     User                 = new UserViewModel();
     Title                = "some challenge";
     Image                = new Uri("http://farm8.staticflickr.com/7343/11914204134_8de5a28ff7_z.jpg");
     Location             = new ParseGeoPoint(34, 34);
     Distance             = "3 miles";
     DistanceCount        = 5;
     SolvedCount          = 12;
     Created              = DateTime.Now;
     CommentListViewModel = new CommentListViewModel();
 }
Esempio n. 15
0
        public async Task <List <VetModel> > Vets(ParseGeoPoint geo, int limit)
        {
            List <VetModel> list = new List <VetModel>();

            try
            {
                var query = ParseObject.GetQuery("UserVets").WhereNear("location", geo).Limit(limit);

                var final = await query.FindAsync();

                foreach (ParseObject obj in final)
                {
                    var model = new VetModel()
                    {
                        Address             = (obj.ContainsKey("address") == true) ? obj.Get <string>("address") : null,
                        CellNumber          = (obj.ContainsKey("cellNumber") == true) ? obj.Get <string>("cellNumber") : null,
                        City                = (obj.ContainsKey("city") == true) ? obj.Get <string>("city") : null,
                        Town                = (obj.ContainsKey("town") == true) ? obj.Get <string>("town") : null,
                        Email               = (obj.ContainsKey("email") == true) ? obj.Get <string>("email") : null,
                        FacebookPage        = (obj.ContainsKey("facebookPage") == true) ? obj.Get <string>("facebookPage") : null,
                        InstagramAccount    = (obj.ContainsKey("instagramAccount") == true) ? obj.Get <string>("instagramAccount") : null,
                        TwitterAccount      = (obj.ContainsKey("twitterAccount") == true) ? obj.Get <string>("twitterAccount") : null,
                        WebAddress          = (obj.ContainsKey("webAddress") == true) ? obj.Get <string>("webAddress") : null,
                        webURLAddress       = (obj.ContainsKey("webURLAddress") == true) ? obj.Get <string>("webURLAddress") : null,
                        IsActive            = (obj.ContainsKey("isActive") == true) ? obj.Get <bool>("isActive") : false,
                        IsConfirmed         = (obj.ContainsKey("isConfirmed") == true) ? obj.Get <bool>("isConfirmed") : false,
                        IsMember            = (obj.ContainsKey("isMember") == true) ? obj.Get <bool>("isMember") : false,
                        IsNew               = (obj.ContainsKey("isNew") == true) ? obj.Get <bool>("isNew") : false,
                        Location            = obj.Get <ParseGeoPoint>("location"),
                        Name                = (obj.ContainsKey("name") == true) ? obj.Get <string>("name") : null,
                        PhoneNumber         = (obj.ContainsKey("phoneNumber") == true) ? obj.Get <string>("phoneNumber") : null,
                        Services            = (obj.ContainsKey("services") == true) ? (IList <object>)obj.Get <object>("services") : null,
                        WorkingDaysAndHours = (obj.ContainsKey("workingDaysAndHours") == true) ? (IList <object>)obj.Get <object>("workingDaysAndHours") : null,
                        Logo                = (obj.ContainsKey("logo") == true) ? obj.Get <ParseFile>("logo").Url.AbsoluteUri : "ms-appx:///Assets/Logos/flyoutLogo.png",
                        Images              = (obj.ContainsKey("images") == true) ? (IList <object>)obj.Get <object>("images") : null
                    };

                    model.Color  = VetHelper.setColor(model);
                    model.Status = VetHelper.setStatus(model);
                    model.MapPin = "ms-appx:///Assets/MapPins/" + model.Color + ".png";
                    model.Style  = VetHelper.setStyle(model);

                    list.Add(model);
                }

                return(list);
            }

            catch (Exception)
            {
                return(list);
            }
        }
Esempio n. 16
0
        public static string RelativeDistanceTo(this ParseGeoPoint position1, ParseGeoPoint position2)
        {
            var distance = position1.DistanceTo(position2).Miles;

            if (distance < 0.5)
            {
                return(Math.Round((distance * 5280), 0) + " feet");
            }
            else if (distance < 1)
            {
                return(Math.Round(distance, 2) + " miles");
            }
            return(Math.Round(distance) == 1 ? Math.Round(distance) + " mile" : Math.Round(distance) + " miles");
        }
Esempio n. 17
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            planitem = e.Parameter as PlanItem;
            plan     = planitem.obj;

            editNombre.Text      = plan.Get <string>("nombre");
            editDescripcion.Text = plan.Get <string>("descripcion");
            char[]   delimeter = { '/', ' ', ':' };
            string[] fechaCom  = plan.Get <string>("fecha").Split(delimeter);

            string fec = fechaCom[1] + "/" + fechaCom[0] + "/" + fechaCom[2];

            editFecha.Date = DateTime.Parse(fec);

            string hor    = fechaCom[3];
            string minute = fechaCom[4];
            string am_pm  = fechaCom[5];

            string horaOrga = organizarHora(hor, minute, am_pm);

            //editFecha.Date = DateTime.Parse(fechaCom[0]);

            editHora.Time = TimeSpan.Parse(horaOrga);

            ParseFile   file = plan.Get <ParseFile>("imagen");
            Uri         ur   = file.Url;
            BitmapImage img  = new BitmapImage(ur);

            editImage.Source = img;

            NombreLugarTxt.Text = plan.Get <string>("direccion");

            gPoint = plan.Get <ParseGeoPoint>("lugar");

            // Specify a known location

            BasicGeoposition posicion = new BasicGeoposition()
            {
                Latitude = gPoint.Latitude, Longitude = gPoint.Longitude
            };
            Geopoint point = new Geopoint(posicion);

            // Set map location
            editMap.Center           = point;
            editMap.ZoomLevel        = 17.0f;
            editMap.LandmarksVisible = true;


            AddIcons(gPoint);
        }
Esempio n. 18
0
        public void TestDecodeGeoPoint()
        {
            ParseGeoPoint point1 = (ParseGeoPoint)ParseDecoder.Instance.Decode(new Dictionary <string, object> {
                ["__type"] = "GeoPoint", ["latitude"] = 0.9, ["longitude"] = 0.3
            });

            Assert.IsNotNull(point1);
            Assert.AreEqual(0.9, point1.Latitude);
            Assert.AreEqual(0.3, point1.Longitude);

            Assert.ThrowsException <KeyNotFoundException>(() => ParseDecoder.Instance.Decode(new Dictionary <string, object> {
                ["__type"] = "GeoPoint", ["latitude"] = 0.9
            }));
        }
Esempio n. 19
0
        private async void findNearbyToilets(ParseGeoPoint location, Boolean shouldSkip)
        {
            currentLocation = location;

            if (shouldSkip)
            {
                await parseHelper.getNearbyToilets(location, shouldSkip);
            }
            else
            {
                await parseHelper.getNearbyToilets(location, shouldSkip);

                LoosNearbyList.ItemsSource = parseHelper.parseToilets;
            }
        }
Esempio n. 20
0
        private async void AddIcons(ParseGeoPoint lugarPlanEdit)
        {
            ParseQuery <ParseObject>  query   = ParseObject.GetQuery("Lugares");
            IEnumerable <ParseObject> results = await query.FindAsync();

            ParseObject      lugar;
            ParseGeoPoint    ubicacion;
            BasicGeoposition position;
            Geopoint         point;
            MapIcon          mapIcon;

            //posicion actual
            getPosicionActual();

            // Agregarlos al mapa
            int tamanio = results.Count <ParseObject>();


            for (int i = 0; i < tamanio; i++)
            {
                lugar     = results.ElementAt <ParseObject>(i);
                ubicacion = lugar.Get <ParseGeoPoint>("ubicacion");

                position = new BasicGeoposition()
                {
                    Latitude = ubicacion.Latitude, Longitude = ubicacion.Longitude
                };
                point = new Geopoint(position);

                // MapIcon
                mapIcon          = new MapIcon();
                mapIcon.Location = point;
                mapIcon.NormalizedAnchorPoint = new Point(0.5, 1.0);
                mapIcon.Title = lugar.Get <string>("direccion");

                if (ubicacion.Latitude == lugarPlanEdit.Latitude && ubicacion.Longitude == lugarPlanEdit.Longitude)
                {
                    mapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/posicionPlan.png"));
                }
                else
                {
                    mapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/bus.png"));
                }
                mapIcon.ZIndex = 0;

                editMap.MapElements.Add(mapIcon);
            }
        }
        public void TestGeoPointConstructor()
        {
            var point = new ParseGeoPoint();

            Assert.AreEqual(0.0, point.Latitude);
            Assert.AreEqual(0.0, point.Longitude);

            point = new ParseGeoPoint(42, 36);
            Assert.AreEqual(42.0, point.Latitude);
            Assert.AreEqual(36.0, point.Longitude);

            point.Latitude  = 12;
            point.Longitude = 24;
            Assert.AreEqual(12.0, point.Latitude);
            Assert.AreEqual(24.0, point.Longitude);
        }
        private Presentation parseToPresentation(ParseObject obj)
        {
            ParseGeoPoint geoPoint = obj.Get <ParseGeoPoint> ("location");
            ParseFile     image    = obj.Get <ParseFile> ("image");

            return(new Presentation(
                       obj.ObjectId,
                       obj.Get <string> ("name"),
                       obj.Get <string> ("description"),
                       obj.Get <DateTime> ("start"),
                       obj.Get <DateTime> ("end"),
                       geoPoint.Latitude,
                       geoPoint.Longitude,
                       image.Url
                       ));
        }
        public void TestGeoPointCultureInvariantParsing()
        {
            CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;

            foreach (CultureInfo c in CultureInfo.GetCultures(CultureTypes.AllCultures))
            {
                Thread.CurrentThread.CurrentCulture = c;
                ParseGeoPoint point      = new ParseGeoPoint(1.234, 1.234);
                string        serialized = Json.Encode(new Dictionary <string, object> {
                    { "point", NoObjectsEncoder.Instance.Encode(point) }
                });
                IDictionary <string, object> deserialized = ParseDecoder.Instance.Decode(Json.Parse(serialized)) as IDictionary <string, object>;
                ParseGeoPoint pointAgain = (ParseGeoPoint)deserialized["point"];
                Assert.AreEqual(1.234, pointAgain.Latitude);
                Assert.AreEqual(1.234, pointAgain.Longitude);
            }
        }
Esempio n. 24
0
        private async void GetGeocodedSearch()
        {
            if (previousText != LocationSearchbox.Text && LocationSearchbox.Text.Length > 0)
            {
                previousText = LocationSearchbox.Text;
                MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync(
                    LocationSearchbox.Text,
                    null,
                    1
                    );

                if (result.Status == MapLocationFinderStatus.Success)
                {
                    ParseGeoPoint location = new ParseGeoPoint(result.Locations[0].Point.Position.Latitude, result.Locations[0].Point.Position.Longitude);
                    findNearbyToilets(location, false);
                }
            }
        }
Esempio n. 25
0
        public async Task <IList <Site> > GetNearbySites(double latitude, double longitude, double distanceRadians = 0)
        {
            if (distanceRadians == 0)
            {
                distanceRadians = 0.5;
            }
            var pos        = new ParseGeoPoint(latitude, longitude);
            var sitesQuery = new ParseQuery <ApParseSite>()
                             .WhereWithinDistance("location", pos, new ParseGeoDistance(distanceRadians))
                             .Limit(100);

            var sites = await sitesQuery.FindAsync();

            return(sites
                   .Select(s => ConvertToSite(s, pos))
                   .OrderByDescending(s => s.DistanceKm)
                   .ToList());
        }
Esempio n. 26
0
        public void CaParseulate()
        {
            ParseGeoPoint p1         = new ParseGeoPoint(20.0059, 110.3665);
            ParseGeoPoint p2         = new ParseGeoPoint(20.0353, 110.3645);
            double        kilometers = p1.KilometersTo(p2);

            TestContext.WriteLine(kilometers);
            Assert.Less(kilometers - 3.275, 0.01);

            double miles = p1.MilesTo(p2);

            TestContext.WriteLine(miles);
            Assert.Less(miles - 2.035, 0.01);

            double radians = p1.RadiansTo(p2);

            TestContext.WriteLine(radians);
            Assert.Less(radians - 0.0005, 0.0001);
        }
Esempio n. 27
0
        public void TestGeoPointCultureInvariantParsing()
        {
            CultureInfo initialCulture = Thread.CurrentThread.CurrentCulture;

            foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.AllCultures))
            {
                Thread.CurrentThread.CurrentCulture = culture;

                ParseGeoPoint point = new ParseGeoPoint(1.234, 1.234);
                IDictionary <string, object> deserialized = Client.Decoder.Decode(JsonUtilities.Parse(JsonUtilities.Encode(new Dictionary <string, object> {
                    [nameof(point)] = NoObjectsEncoder.Instance.Encode(point, Client)
                })), Client) as IDictionary <string, object>;
                ParseGeoPoint pointAgain = (ParseGeoPoint)deserialized[nameof(point)];

                Assert.AreEqual(1.234, pointAgain.Latitude);
                Assert.AreEqual(1.234, pointAgain.Longitude);
            }

            Thread.CurrentThread.CurrentCulture = initialCulture;
        }
        private async void AddLocation(object sender, RoutedEventArgs e)
        {
            if (checkInput(txtLatitute.Text, txtLongtitute.Text))
            {
                //txtLocation.Text = (string)txtLatitute.Text + " : " + (string)txtLongtitute.Text;
                ParseObject locations  = new ParseObject("Locations");
                double      latitude   = Double.Parse(txtLatitute.Text);
                double      longtitute = Double.Parse(txtLongtitute.Text);

                var point = new ParseGeoPoint(latitude, longtitute);

                locations["locGPS"] = point;
                await locations.SaveAsync();

                LoadItems();
            }
            else
            {
                txtLocation.Text = "Invalid Input";
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Begins loading new challenges asynchronously.
        /// </summary>
        /// <param name="skipCount">The number of challenges to skip.</param>
        /// <returns>An awaitable task.</returns>
        protected async override Task LoadDataImpl(bool forceReload = false)
        {
            var geoposition = await Utilities.GeoLocationHelper.GetLocation();

            var geoPoint = new ParseGeoPoint(geoposition.Coordinate.Latitude, geoposition.Coordinate.Longitude);
            var query    = ParseObject.GetQuery("Challenge");

            query.WhereNear("location", geoPoint).Limit(20).Skip(CurrentlyLoaded);

            List <Task> challengeTasks = new List <Task>();

            foreach (var challenge in await query.FindAsync())
            {
                var challengeViewModel = new ChallengeViewModel(challenge);
                Challenges.Add(challengeViewModel);
                challengeTasks.Add(challengeViewModel.LoadData());
            }
            await Task.WhenAll(challengeTasks.ToArray());

            CurrentlyLoaded += 20;
        }
        private async void LoadItems()
        {
            IEnumerable <ParseObject> results = await query.FindAsync();

            string SURL = "https://maps.googleapis.com/maps/api/timezone/json?location=";
            int    time = DateTime.Now.Millisecond;

            foreach (var item in results)
            {
                resetData();
                ParseGeoPoint pgp = (ParseGeoPoint)item["locGPS"];

                string str = SURL + pgp.Latitude + "," + pgp.Longitude + "&timestamp=" + time.ToString() + "&sensor=false";
                //tbResult_Copy.Text = str;

                var webReq = (HttpWebRequest)WebRequest.Create(str);

                using (WebResponse response = await webReq.GetResponseAsync())

                {
                    using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
                    {
                        dataResponse = streamReader.ReadToEnd();
                    }
                }

                //tbResult.Text = ">|" + dataResponse + "|<";

                string timeName = getTimeZoneName(dataResponse);

                //tbResult_Copy1.Text = timeName;
                //itemList.Add(pgp.Latitude + " : " + pgp.Longitude + " : " + timeName);

                item["locTimeZoneName"] = timeName;
                await item.SaveAsync();

                txtLocation.Text = "Data Saved";
            }
            //listTimeZone.ItemsSource = itemList;
        }
Esempio n. 31
0
 static Tuple<double, double> GeopointToTuple(ParseGeoPoint geoPoint)
 {
     return Tuple.Create (geoPoint.Latitude, geoPoint.Longitude);
 }