Ignore:
Timestamp:
16/06/12 16:58:29 (7 years ago)
Author:
mnagni
Message:

Implemented the bbox query URL (at least for the CEDA_ObservationCollection)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/HPFos/trunk/src/HPFos/osImpl/myimpl.py

    r8353 r8354  
    11''' 
     2BSD Licence 
     3Copyright (c) 2012, Science & Technology Facilities Council (STFC) 
     4All rights reserved. 
     5 
     6Redistribution and use in source and binary forms, with or without modification,  
     7are permitted provided that the following conditions are met: 
     8 
     9    * Redistributions of source code must retain the above copyright notice,  
     10        this list of conditions and the following disclaimer. 
     11    * Redistributions in binary form must reproduce the above copyright notice, 
     12        this list of conditions and the following disclaimer in the documentation 
     13        and/or other materials provided with the distribution. 
     14    * Neither the name of the Science & Technology Facilities Council (STFC)  
     15        nor the names of its contributors may be used to endorse or promote  
     16        products derived from this software without specific prior written permission. 
     17 
     18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  
     19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,  
     20THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  
     21PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
     22BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,  
     23OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF  
     24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
     25HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
     26OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE  
     27OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     28 
    229Created on 5 May 2012 
    330 
    4 @author: kusanagi 
     31@author: Maurizio Nagni 
    532''' 
    633from xml.etree.ElementTree import tostring, ElementTree 
     
    2047from datetime import datetime 
    2148from markup.opensearch.osquery import OSQuery 
     49from libs.postgisutil import create_st_setSRID 
    2250  
    2351COLLECTION = 'collection' 
    2452OBSERVATION = 'observation' 
    2553RESULT = 'result' 
     54BBOX = 'box' 
    2655 
    2756def calculateStep(**kwargs): 
     
    5079            @param queries: 
    5180            @param ospath:   
     81            @param kwargs:  
    5282        """ 
    5383        id = "" 
     
    6090         
    6191        #configuration level 
    62         #path = "http://mysite.com/" 
    6392        step = calculateStep(**kwargs) 
    6493        root = ElementTree(atomdoc).getroot() 
    65         #extracted from result parameter 
    6694 
    6795        #Generate feed's links 
     
    205233        param_4 = OSParam("q", "searchTerms")            
    206234        param_5 = OSParam("uid", "uid", namespace = "http://a9.com/-/opensearch/extensions/geo/1.0/")         
    207         param_6 = OSParam("box", "box", namespace = "http://a9.com/-/opensearch/extensions/geo/1.0/")         
     235        param_6 = OSParam(BBOX, BBOX, namespace = "http://a9.com/-/opensearch/extensions/geo/1.0/")         
    208236        param_7 = OSParam("start", "start", namespace = "http://a9.com/-/opensearch/extensions/geo/1.0/")         
    209237        param_8 = OSParam("stop", "stop", namespace = "http://a9.com/-/opensearch/extensions/time/1.0/")         
     
    245273         
    246274    def doSearch(self, **kwargs): 
     275        ibbox = None 
     276        if kwargs['params_values'] and kwargs['params_values'].has_key(BBOX): 
     277            coords = kwargs['params_values'][BBOX].split(',') 
     278            try: 
     279                if len(coords) == 4: 
     280                    ibbox = create_st_setSRID(int(coords[0]),int(coords[1]),int(coords[2]),int(coords[3])) 
     281            except Exception as e: 
     282                pass 
     283         
    247284        if kwargs['params_values'] and kwargs['params_values'].has_key(COLLECTION) and kwargs['params_values'].has_key(OBSERVATION): 
    248285            return self.searchObservation(**kwargs)         
     
    251288            return self.searchCollection(**kwargs)         
    252289             
    253         results = kwargs['moles3EPB'].getObservationCollections() 
     290        results = kwargs['moles3EPB'].getObservationCollections(bbox = ibbox) 
     291 
     292                                   
     293                 
     294         
    254295        return self._packResult(results, **kwargs) 
    255296 
Note: See TracChangeset for help on using the changeset viewer.