diff --git a/CHANGELOG.md b/CHANGELOG.md index 37a791f..c4e3da2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ This file documents any relevant changes done to ViUR server since version 2. ## [develop] - Current development version +### Fixed +- spatialGuaranteedCorrectness of bones/spatial on very sparse maps ([#167](https://github.com/viur-framework/server/pull/167)) + + ## [2.4.0] Agung - 2019-05-17 diff --git a/bones/spatialBone.py b/bones/spatialBone.py index ef49943..04b5bb4 100644 --- a/bones/spatialBone.py +++ b/bones/spatialBone.py @@ -238,14 +238,15 @@ def customMultiQueryMerge(self, name, lat, lng, dbFilter, result, targetAmount): # If a result further away than this distance there might be missing results before that result # If there are no results in a give lane (f.e. because we are close the border and there is no point # in between) we choose a arbitrary large value for that lower bound + expectedAmount = self.calculateInternalMultiQueryAmount(targetAmount) # How many items we expect in each direction limits = [ - haversine(latRight[-1][name+".lat.val"], lng, lat, lng) if latRight else 2^31, # Lat - Right Side - haversine(latLeft[-1][name+".lat.val"], lng, lat, lng) if latLeft else 2^31, # Lat - Left Side - haversine(lat, lngBottom[-1][name+".lng.val"], lat, lng) if lngBottom else 2^31, # Lng - Bottom - haversine(lat, lngTop[-1][name+".lng.val"], lat, lng) if lngTop else 2^31, # Lng - Top - haversine(lat+gridSizeLat,lng,lat,lng), - haversine(lat,lng+gridSizeLng,lat,lng) - ] + haversine(latRight[-1][name + ".lat.val"], lng, lat, lng) if latRight and len(latRight) == expectedAmount else 2 ** 31, # Lat - Right Side + haversine(latLeft[-1][name + ".lat.val"], lng, lat, lng) if latLeft and len(latLeft) == expectedAmount else 2 ** 31, # Lat - Left Side + haversine(lat, lngBottom[-1][name + ".lng.val"], lat, lng) if lngBottom and len(lngBottom) == expectedAmount else 2 ** 31, # Lng - Bottom + haversine(lat, lngTop[-1][name + ".lng.val"], lat, lng) if lngTop and len(lngTop) == expectedAmount else 2 ** 31, # Lng - Top + haversine(lat + gridSizeLat, lng, lat, lng), + haversine(lat, lng + gridSizeLng, lat, lng) + ] dbFilter.customQueryInfo["spatialGuaranteedCorrectness"] = min(limits) logging.debug("SpatialGuaranteedCorrectness: %s", dbFilter.customQueryInfo["spatialGuaranteedCorrectness"]) # Filter duplicates