1.1 --- a/macros/EventAggregator.py Mon May 09 00:38:13 2011 +0200
1.2 +++ b/macros/EventAggregator.py Wed May 11 00:45:47 2011 +0200
1.3 @@ -1542,18 +1542,33 @@
1.4 # Get events by position.
1.5
1.6 events_by_location = {}
1.7 + event_locations = {}
1.8
1.9 for event in all_shown_events:
1.10 event_details = event.getDetails()
1.11
1.12 location = event_details.get("location")
1.13
1.14 - # Use a normalised location if possible.
1.15 -
1.16 - location = location and getNormalisedLocation(location) or location
1.17 + if not event_locations.has_key(location):
1.18 +
1.19 + # Look up the position of a location using the locations page.
1.20 +
1.21 + latitude, longitude = getLocationPosition(location, locations)
1.22 +
1.23 + # Use a normalised location if necessary.
1.24 +
1.25 + if latitude is None and longitude is None:
1.26 + normalised_location = getNormalisedLocation(location)
1.27 + if normalised_location is not None:
1.28 + latitude, longitude = getLocationPosition(normalised_location, locations)
1.29 + if latitude is not None and longitude is not None:
1.30 + location = normalised_location
1.31 +
1.32 + event_locations[location] = latitude, longitude
1.33
1.34 if not events_by_location.has_key(location):
1.35 events_by_location[location] = []
1.36 +
1.37 events_by_location[location].append(event)
1.38
1.39 # Get the map image URL.
1.40 @@ -1578,24 +1593,14 @@
1.41 output.append(fmt.number_list(on=1))
1.42
1.43 unpositioned_events = []
1.44 - event_locations = events_by_location.keys()
1.45 + event_locations = event_locations.items()
1.46 event_locations.sort()
1.47
1.48 # Show the events in the map.
1.49
1.50 - for location in event_locations:
1.51 + for location, (latitude, longitude) in event_locations:
1.52 events = events_by_location[location]
1.53
1.54 - # Look up the position of a location using the locations page.
1.55 -
1.56 - latitude, longitude = None, None
1.57 -
1.58 - if location is not None:
1.59 - try:
1.60 - latitude, longitude = map(getMapReference, locations[location].split())
1.61 - except (KeyError, ValueError):
1.62 - pass
1.63 -
1.64 # Skip unpositioned locations and locations outside the map.
1.65
1.66 if latitude is None or longitude is None or \