Пример #1
0
 def test_create_bbox_filter(self):
     self.assertEqual(create_bbox_filter(''), None)
     self.assertEqual(create_bbox_filter('a,b,c,d'), None)
     self.assertEqual(create_bbox_filter('1,2,3'), None)
     self.assertEqual(create_bbox_filter('1,2,3,d'), None)
     self.assertBboxFilterEqual(
         create_bbox_filter('699398,5785365,699498,5785465').to_dict(),
         GeoBoundingBox(geom={
             'left': 6.28279913,
             'bottom': 46.03129072,
             'right': 6.28369744,
             'top': 46.03191439
         },
                        type='indexed').to_dict())
Пример #2
0
 def test_build_query_bbox(self):
     params = {
         'q': 'search word',
         'walt': '1500',
         'bbox': '699398,5785365,699498,5785465'
     }
     meta_params = {'limit': 10, 'offset': 0}
     query = build_query(params, meta_params, 'w')
     expected_query = create_search('w'). \
         query(get_text_query_on_title('search word')). \
         filter(Range(elevation={'gte': 1500})). \
         filter(GeoBoundingBox(
             geom={
                 'left': 6.28279913, 'bottom': 46.03129072,
                 'right': 6.28369744, 'top': 46.03191439},
             type='indexed')).\
         fields([]).\
         extra(from_=0, size=10)
     self.assertQueryEqual(query, expected_query)
Пример #3
0
def create_bbox_filter(query_term):
    query_terms = query_term.split(',')
    bbox3857 = list(map(parse_num, query_terms))
    if len(bbox3857) != 4 or not all(bbox3857):
        return None

    # transform the bbox from 3857 to 4326
    xmin, ymin = transformer.transform(bbox3857[0], bbox3857[1])
    xmax, ymax = transformer.transform(bbox3857[2], bbox3857[3])

    if xmin == xmax or ymin == ymax:
        return None

    return GeoBoundingBox(geom={
        'left': xmin,
        'bottom': ymin,
        'right': xmax,
        'top': ymax
    },
                          type='indexed')