1:      public class LocationAverage extends Aggregate {
2:
3:     private GPSData gps;
4:        double sum_x, sum_y;
5:        int count_x, count_y;
6:
7:  public void initializer() {
8:       try {
9:    gps = (GPSData)TagSpace.readTag(gps);
10:      sum_x = gps.latitude;
11:      sum_y = gps.longitude;
12:      count_x = 1;
13:    count_y = 1;
14:     } catch (Exception e) { }
15:   }
16:
17:     public void merger(Aggregate agg) {
18:         sum_x = sum_x+agg.sum_x;
19:    sum_y = sum_y+agg.sum_y;
20:  count_x = count_x+agg.count_x;
21:        count_y = count_y+agg.count_y;
22: }
23:
24:  public Object evaluator() {
25:          try  {
26:return new Location(sum_x/count_x, sum_y/count_y);
27:        } catch (Exception e) {
28:     return null;
29:        }
30:   }
31: }
Listing 3: LocationAverage class for in-network processing.