Пример #1
0
def snapshot(request):
    querystring = ''
    remoteUrl = request.registry.settings['geoadminhost']
    install_directory = request.registry.settings['install_directory']
    build_query_string = lambda x: ''.join((x, '=', request.params.get(x), '&'))
    for key in request.params.keys():
        if (key != '_escaped_fragment_') and (key != 'snapshot'):
            querystring += build_query_string(key)
    querystring += 'snapshot=true'

    try:
        content = subprocess.check_output(['phantomjs',
                                           install_directory + '/chsdi/templates/load_page_until.js',
                                           'http://' + remoteUrl + '/?' + remove_accents(querystring),
                                           'seo-load-end',
                                           '10'])

    except (subprocess.CalledProcessError, OSError, ValueError) as e:
        raise exc.HTTPInternalServerError(e)

    if content.startswith('error'):
        raise exc.HTTPInternalServerError('Internal error in PhantomJS snapshot ' +
                                          'script or wrong parameters passed to the script.')
    elif content.startswith('timeout'):
        raise exc.HTTPGatewayTimeout('Page could not be loaded in time by PhantomJS')

    return Response(body=content, content_type='text/html', request=request)
Пример #2
0
 def search(self):
     # create a quadindex if the bbox is defined
     if self.bbox is not None and self.typeInfo != 'layers':
         self._get_quad_index()
     if self.typeInfo == 'layers':
         # search all layers
         self.searchText = remove_accents(
             self.request.params.get('searchText')
         )
         self._layer_search()
     if self.typeInfo in ('features', 'featureidentify'):
         # search all features within bounding box
         self._feature_bbox_search()
     if self.typeInfo == 'locations':
         # search all features with text and bounding box
         self.searchText = remove_accents(
             self.request.params.get('searchText')
         )
         self._feature_search()
         # swiss search
         self._swiss_search(self.LIMIT)
     return self.results
Пример #3
0
    def __init__(self, request):
        super(Search, self).__init__()
        self.quadtree = msk.QuadTree(msk.BBox(420000,30000,900000,510000),20)
        self.sphinx = sphinxapi.SphinxClient()
        self.sphinx.SetServer("localhost", 3312)
        self.sphinx.SetMatchMode(sphinxapi.SPH_MATCH_EXTENDED)

        self.mapName = request.matchdict.get('map')
        self.searchText = remove_accents(request.params.get('searchText'))
        self.lang = str(locale_negotiator(request))
        self.cbName = request.params.get('callback')
        self.bbox =  request.params.get('bbox')
        self.quadindex = None
        self.featureIndexes = request.params.get('features')
        self.request = request
        self.results = {'locations': [], 'map_info': []}
Пример #4
0
 def test_remove_accents(self):
     testinput_str = None
     result = remove_accents(testinput_str)
     self.assertEqual(result, None)
Пример #5
0
 def test_remove_accents(self):
     testinput_str = None
     result = remove_accents(testinput_str)
     self.assertEqual(result, None)