示例#1
0
        public async Task Geo()
        {
            LCObject   obj      = new LCObject("Todo");
            LCGeoPoint location = new LCGeoPoint(39.9, 116.4);

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

            // near
            LCQuery <LCObject> query = new LCQuery <LCObject>("Todo");
            LCGeoPoint         point = new LCGeoPoint(39.91, 116.41);

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

            Assert.Greater(results.Count, 0);

            // in box
            query = new LCQuery <LCObject>("Todo");
            LCGeoPoint southwest = new LCGeoPoint(30, 115);
            LCGeoPoint northeast = new LCGeoPoint(40, 118);

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

            Assert.Greater(results.Count, 0);
        }