Exemplo n.º 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)
                };
            }
Exemplo n.º 2
0
 public BusRoute_Spatial()
 {
     Map = busRoutes => from busRoute in busRoutes
           select new
     {
         _ = SpatialIndex.Generate(busRoute.Stop.Latitude, busRoute.Stop.Longitude)
     };
 }
Exemplo n.º 3
0
 public MySpatialIndex()
 {
     Map = docs =>
           from doc in docs
           select new
     {
         _ = SpatialIndex.Generate(doc.Latitude, doc.Longitude)
     };
 }
Exemplo n.º 4
0
 public ByVehicle()
 {
     Map = vehicles => from vehicle in vehicles
           select new
     {
         vehicle.Model,
         vehicle.Make,
         _ = SpatialIndex.Generate(vehicle.Latitude, vehicle.Longitude)
     };
 }
Exemplo n.º 5
0
 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)
     };
 }
Exemplo n.º 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
     };
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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)
     };
 }
Exemplo n.º 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
     };
 }
Exemplo n.º 10
0
            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);
            }
Exemplo n.º 11
0
 public EntitiesByLocation()
 {
     Map = entities => from entity in entities
           select new { _ = SpatialIndex.Generate(entity.Latitude, entity.Longitude) };
 }
Exemplo n.º 12
0
 public Restaurants_ByRatingAndLocation()
 {
     Map = restaurants => from r in restaurants
           select new { r.Rating, _ = SpatialIndex.Generate(r.Latitude, r.Longitude) };
 }
Exemplo n.º 13
0
 public Stations_ByLocation()
 {
     Map = stations =>
           from s in stations
           select new { _ = SpatialIndex.Generate(s.Latitude, s.Longitude) };
 }