Ejemplo n.º 1
0
        public async Task Query()
        {
            LCObject   geoObj = new LCObject("GeoObj");
            Random     random = new Random();
            LCGeoPoint p1     = new LCGeoPoint(-90 + random.NextDouble() * 180, -180 + random.NextDouble() * 360);

            geoObj["location"] = p1;
            await geoObj.Save();

            LCGeoPoint p2 = new LCGeoPoint(p1.Latitude + 0.01, p1.Longitude + 0.01);

            double km = p1.KilometersTo(p2);

            TestContext.WriteLine($"km: {km}, {Math.Ceiling(km)}");
            LCQuery <LCObject> query = new LCQuery <LCObject>("GeoObj");

            query.WhereWithinKilometers("location", p2, Math.Ceiling(km));
            Assert.Greater((await query.Find()).Count, 0);

            double miles = p1.MilesTo(p2);

            query = new LCQuery <LCObject>("GeoObj");
            query.WhereWithinMiles("location", p2, Math.Ceiling(miles));
            Assert.Greater((await query.Find()).Count, 0);

            double radians = p1.RadiansTo(p2);

            query = new LCQuery <LCObject>("GeoObj");
            query.WhereWithinRadians("location", p2, Math.Ceiling(radians));
            Assert.Greater((await query.Find()).Count, 0);
        }