예제 #1
0
            public Sales_ByLocation()
            {
                AddMap <Sale>(sales => from sale in sales
                              select new
                {
                    _         = (object)null,
                    SaleId    = sale.Id,
                    Locations = sale.Locations.Select(l => new { l.Lat, l.Lng }).ToArray(),
                    TotalSold = 0
                });

                AddMap <Order>(orders => from order in orders
                               select new
                {
                    _ = (object)null,
                    order.SaleId,
                    Locations = new[] { new { Lat = (double)0, Lng = (double)0 } },
                    TotalSold = 1
                });

                Reduce = sitesales => from sitesale in sitesales
                         group sitesale by sitesale.SaleId
                         into sales
                         let locations = sales.SelectMany(x => x.Locations)
                                         from sale in sales
                                         select new
                {
                    _ = locations.Select(l => SpatialIndex.Generate(l.Lat, l.Lng)),
                    // marking this as empty works
                    sale.SaleId,
                    Locations = locations,
                    TotalSold = sales.Sum(x => x.TotalSold)
                };
            }
예제 #2
0
 public BusRoute_Spatial()
 {
     Map = busRoutes => from busRoute in busRoutes
           select new
     {
         _ = SpatialIndex.Generate(busRoute.Stop.Latitude, busRoute.Stop.Longitude)
     };
 }
예제 #3
0
파일: Spatial.cs 프로젝트: tal952/ravendb
 public MySpatialIndex()
 {
     Map = docs =>
           from doc in docs
           select new
     {
         _ = SpatialIndex.Generate(doc.Latitude, doc.Longitude)
     };
 }
예제 #4
0
 public ByVehicle()
 {
     Map = vehicles => from vehicle in vehicles
           select new
     {
         vehicle.Model,
         vehicle.Make,
         _ = SpatialIndex.Generate(vehicle.Latitude, vehicle.Longitude)
     };
 }
예제 #5
0
파일: chad.cs 프로젝트: xinix00/ravendb
 public Place_ByLocationAndCategoryId()
 {
     Map = places => from p in places
           select
           new
     {
         Categories_Id = p.Categories.Select(x => x.Id),
         _             = SpatialIndex.Generate(p.Location.Lat, p.Location.Lng)
     };
 }
예제 #6
0
 public AccItems_Spatial()
 {
     Map = items =>
           from i in items
           select new
     {
         i,
         __distance = SpatialIndex.Generate((double)i.Lat, (double)i.Lon),
         i.Name,
         i.Bedrooms,
         i.Attributes
     };
 }
예제 #7
0
 public void CanRunSpatialQueriesInMemory()
 {
     using (var documentStore = new EmbeddableDocumentStore {
         RunInMemory = true
     }.Initialize())
     {
         var def = new IndexDefinitionBuilder <Listing>
         {
             Map = listings => from listingItem in listings
                   select new
             {
                 listingItem.ClassCodes,
                 listingItem.Latitude,
                 listingItem.Longitude,
                 _ = SpatialIndex.Generate(listingItem.Latitude, listingItem.Longitude)
             }
         };
         documentStore.DatabaseCommands.PutIndex("RadiusClassifiedSearch", def);
     }
 }
예제 #8
0
 public EventsBySimpleLocation()
 {
     AddMap <EventListing>(eventListings => from e in eventListings
                           select new
     {
         VenueId   = e.VenueId,
         EventId   = e.Id,
         EventName = e.Name,
         VenueName = (string)null,
         Long      = 0,
         Lat       = 0,
         _         = (object)null,
     });
     AddMap <EventVenue>(venues => from v in venues
                         select new
     {
         VenueId   = v.Id,
         EventId   = (string)null,
         EventName = (string)null,
         VenueName = v.Name,
         Long      = v.GeoLocation.Longitude,
         Lat       = v.GeoLocation.Latitude,
         _         = (object)null,
     });
     Reduce = results => from result in results
              group result by result.VenueId
              into g
              let latitude = g.Select(x => x.Lat).FirstOrDefault(t => t != 0)
                             let longitude = g.Select(x => x.Long).FirstOrDefault(t => t != 0)
                                             select new
     {
         VenueId   = g.Key,
         EventId   = g.Select(x => x.EventId).FirstOrDefault(x => x != null),
         VenueName = g.Select(x => x.VenueName).FirstOrDefault(x => x != null),
         EventName = g.Select(x => x.EventName).FirstOrDefault(x => x != null),
         Lat       = latitude,
         Long      = longitude,
         _         = SpatialIndex.Generate(latitude, longitude)
     };
 }
예제 #9
0
 public BusStop_Spatial()
 {
     Map = busRoutes => from busRoute in busRoutes
           select new
     {
         _ = (object)null,
         busRoute.Stop.Id,
         busRoute.Stop.BusStopCode,
         busRoute.Stop.BusStopName,
         busRoute.Stop.Latitude,
         busRoute.Stop.Longitude,
         busRoute.Stop.Easting,
         busRoute.Stop.Northing
     };
     Reduce = busStops => from busStop in busStops
              group busStop by new
     {
         _ = (object)null,
         busStop.Id,
         busStop.BusStopCode,
         busStop.BusStopName,
         busStop.Latitude,
         busStop.Longitude,
         busStop.Easting,
         busStop.Northing
     }
     into g
         select new
     {
         _ = SpatialIndex.Generate(g.Key.Latitude, g.Key.Longitude),
         g.Key.Id,
         g.Key.BusStopCode,
         g.Key.BusStopName,
         g.Key.Latitude,
         g.Key.Longitude,
         g.Key.Easting,
         g.Key.Northing
     };
 }
예제 #10
0
파일: Spatial.cs 프로젝트: tal952/ravendb
            public MyIndex()
            {
                Map = docs =>
                      from doc in docs
                      from item in doc.Items
                      let lat                     = item.Latitude ?? 0
                                          let lng = item.Longitude ?? 0
                                                    select new
                {
                    Id   = doc.Id,
                    Date = item.Date,

                    Latitude  = lat,
                    Longitude = lng,
                    _         = SpatialIndex.Generate(lat, lng)
                };

                Store(x => x.Id, FieldStorage.Yes);
                Store(x => x.Date, FieldStorage.Yes);

                Store(x => x.Latitude, FieldStorage.Yes);
                Store(x => x.Longitude, FieldStorage.Yes);
            }
예제 #11
0
 public EntitiesByLocation()
 {
     Map = entities => from entity in entities
           select new { _ = SpatialIndex.Generate(entity.Latitude, entity.Longitude) };
 }
예제 #12
0
 public Restaurants_ByRatingAndLocation()
 {
     Map = restaurants => from r in restaurants
           select new { r.Rating, _ = SpatialIndex.Generate(r.Latitude, r.Longitude) };
 }
예제 #13
0
 public Stations_ByLocation()
 {
     Map = stations =>
           from s in stations
           select new { _ = SpatialIndex.Generate(s.Latitude, s.Longitude) };
 }