@@ -2885,6 +2885,9 @@ class Fix(TimeZoneModelMixin, models.Model):
28852885 """
28862886 Location fix uploaded by user.
28872887 """
2888+
2889+ GRID_SIZE = 0.025
2890+
28882891 user_coverage_uuid = models .CharField (blank = True , null = True , max_length = 36 , help_text = 'UUID randomly generated on '
28892892 'phone to identify each unique user, '
28902893 'but only within the coverage data so '
@@ -2903,9 +2906,8 @@ class Fix(TimeZoneModelMixin, models.Model):
29032906 'as ECMA '
29042907 '262 date time string (e.g. "2014-05-17T12:34:56'
29052908 '.123+01:00".' )
2906- masked_lon = models .FloatField (help_text = 'Longitude rounded down to nearest 0.5 decimal degree (floor(lon/.5)*.5)'
2907- '.' )
2908- masked_lat = models .FloatField (help_text = 'Latitude rounded down to nearest 0.5 decimal degree (floor(lat/.5)*.5).' )
2909+ masked_lon = models .FloatField (help_text = f'Longitude rounded down to nearest { GRID_SIZE } decimal degree.' )
2910+ masked_lat = models .FloatField (help_text = f'Latitude rounded down to nearest { GRID_SIZE } decimal degree.' )
29092911 mask_size = models .FloatField (null = True , blank = True , help_text = 'size of location mask used' )
29102912 power = models .FloatField (null = True , blank = True , help_text = 'Power level of phone at time fix recorded, '
29112913 'expressed as proportion of full charge. Range: 0-1.' )
@@ -2923,6 +2925,12 @@ def _get_latitude_for_timezone(self):
29232925 def _get_longitude_for_timezone (self ):
29242926 return self .masked_lon
29252927
2928+ def save (self , * args , ** kwargs ):
2929+ # Force masking of lat/lon
2930+ self .masked_lon = round (floor (self .masked_lon / self .GRID_SIZE ) * self .GRID_SIZE , 5 )
2931+ self .masked_lat = round (floor (self .masked_lat / self .GRID_SIZE ) * self .GRID_SIZE , 5 )
2932+
2933+ super ().save (* args , ** kwargs )
29262934
29272935 class Meta :
29282936 verbose_name = "fix"
0 commit comments