1616
1717class PolygonFilter (Filter ):
1818
19- field_class = forms .PolygonField
19+ field_class = forms .CharField
2020
2121 def __init__ (self , * args , ** kwargs ):
2222 kwargs .setdefault ('field_name' , app_settings ['GEOM_FIELD_NAME' ])
@@ -32,13 +32,11 @@ def _compute_pixel_size(self, zoom):
3232 return circumference / tile_pixel_size / 2 ** int (zoom )
3333
3434 def get_polygon_from_value (self , value ):
35- if not value :
36- ParseError ('Invalid tile string supplied' )
3735 # Parse coordinates from parameter
3836 try :
39- z , x , y = (int (n ) for n in value .split ('/ ' ))
37+ z , x , y = (int (n ) for n in value .split (', ' ))
4038 except ValueError :
41- raise ParseError ( 'Invalid tile string supplied for parameter {0}' . format ( self . value ))
39+ return ""
4240
4341 # define bounds from x y z and create polygon from bounds
4442 bounds = mercantile .bounds (int (x ), int (y ), int (z ))
@@ -59,7 +57,8 @@ def filter(self, qs, value):
5957 if not value :
6058 return qs
6159 bbox = self .get_polygon_from_value (value )
62- qs = qs .filter (geom__intersects = bbox )
60+ if bbox :
61+ qs = qs .filter (geom__intersects = bbox )
6362 return qs .annotate (simplified_geom = Func ('geom' , 2 * self .tolerance , function = 'ST_SimplifyPreserveTopology' ))
6463
6564
0 commit comments