Changeset 3093


Ignore:
Timestamp:
03/12/07 14:24:14 (12 years ago)
Author:
lawrence
Message:

Most of the coding for geospatial operators. Improvements
to results display for multiple bounding boxes.

Location:
TI05-delivery/ows_framework/trunk/ows_server/ows_server
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/discovery.py

    r3070 r3093  
    3030        self.__setup() 
    3131        # parse the query string and hand off to a discovery engine 
     32         
    3233        if self.inputs=={} or 'ClearForm' in self.inputs:  
    3334            return self.__advancedPrompt() 
     
    6061         
    6162         
    62         if len(self.inputs)==5: 
     63        if 'geoSearchType' not in self.inputs:self.inputs['geoSearchType']='overlaps' 
     64        if len(self.inputs)==6: 
    6365             
    6466            # now we add the defaults ... 
     
    7880                scope=None 
    7981                 
    80             expected=['bboxN','bboxE','bboxS','bboxW'] 
     82            expected=['bboxN','bboxE','bboxS','bboxW','geoSearchType'] 
    8183            self.__checkform(expected) 
    8284            if self.message!='':  
     
    8688                # default form has a global bounding box, NB, internal to this routine we use bbox=[N,W,E,S], not [W,S,E,N]! 
    8789                bbox=[self.inputs['bboxN'],self.inputs['bboxW'],self.inputs['bboxE'],self.inputs['bboxS']] 
     90                
    8891                self.__checkbox(bbox) 
    8992                if self.message!='':  
     
    113116         
    114117        if 'constrained' in self.inputs:  
    115             con=self.__buildconstraints(dateRange,bbox,scope,self.inputs['searchString']) 
     118            con=self.__buildconstraints(dateRange,bbox,scope,self.inputs['searchString'],self.inputs['geoSearchType']) 
    116119            return self.__advancedPrompt(searchConstraints=con) 
    117120        else: 
    118121            # ------------- ok, now go do the search ----------- 
    119122            response=self.doText(self.inputs['searchString'],self.inputs['textTarget'], 
    120                 self.inputs['start'],self.inputs['howmany'],scope=scope,dateRange=dateRange,bbox=bbox) 
     123                self.inputs['start'],self.inputs['howmany'],scope=scope,dateRange=dateRange,bbox=bbox, 
     124                geoSearch=self.inputs['geoSearchType']) 
    121125            return response 
    122126 
    123     def doText(self,searchString,textTarget,start,howmany,scope=None,dateRange=None,bbox=None): 
     127    def doText(self,searchString,textTarget,start,howmany,scope=None,dateRange=None,bbox=None,geoSearch='overlaps'): 
    124128         
    125129        ''' Carry out a text search for <searchString>  
     
    141145             
    142146        documents=ws.search(searchString,start=start,howmany=howmany,target=textTarget, 
    143                             scope=scope,dateRange=dateRange,bbox=bbox) 
     147                            scope=scope,dateRange=dateRange,bbox=bbox,geoSearchType=geoSearch) 
    144148        if ws.error !=None: 
    145149            m='' 
     
    149153         
    150154        #build constraints info for report 
    151         searchConstraints=self.__buildconstraints(dateRange,bbox,scope,searchString) 
     155        searchConstraints=self.__buildconstraints(dateRange,bbox,scope,searchString,geoSearch) 
    152156         
    153157        hits=ws.hits 
     
    155159         
    156160        if hits<howmany:howmany=hits 
    157         print howmany,hits 
     161         
    158162        c.state=DiscoveryState(id,searchString,request.environ,hits,searchConstraints,start,howmany) 
    159163        c.querystring=request.environ['QUERY_STRING'] 
    160         print c.state 
    161164         
    162165        if hits==0:  
     
    238241        c.searchString='' 
    239242        c.source=['All'] 
     243        c.geoSearchType='overlaps' 
    240244        #constraints 
    241245 
     
    252256            if searchConstraints['scope'] is not None: 
    253257                c.source=searchConstraints['scope'] 
     258            c.geoSearchType=(searchConstraints['geoSearchType'] or 'overlaps') 
    254259                 
    255260        return render_response('advanced') 
     
    279284            self.message='Second date must be after first date' 
    280285         
    281     def __buildconstraints(self,dateRange,bbox,scope,searchString): 
     286    def __buildconstraints(self,dateRange,bbox,scope,searchString,geoSearch): 
    282287        ''' Just build a constraint string ''' 
    283         return constraints(dateRange=dateRange,bbox=bbox,scope=scope,searchString=searchString) 
     288        return constraints(dateRange=dateRange,bbox=bbox,scope=scope,searchString=searchString,geoSearchType=geoSearch) 
    284289         
    285290    #def oneLineSearch(self): 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/DIF.py

    r3092 r3093  
    122122        status=helper.getText(self.tree,'Data_Set_Progress') 
    123123        if e1<>'': 
    124             self.timeCoverage=[TimeCoverage((start,e1,status))] 
    125         else: 
    126             self.timeCoverage=[TimeCoverage((start,e2,status))] 
     124            self.timeCoverage=[(start,e1,status)] 
     125        else: 
     126            self.timeCoverage=[(start,e2,status)] 
    127127         
    128128        #load up those silly paleo keywords 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/DiscoveryService_services.py

    r2615 r3093  
    1414# Locator 
    1515class DiscoveryServiceLocator: 
    16     DiscoveryServicePortType_address = "http://glue.badc.rl.ac.uk/axis2/services/DiscoveryService" 
     16    DiscoveryServicePortType_address = "http://glue.badc.rl.ac.uk:8080/axis2/services/DiscoveryService" 
    1717    def getDiscoveryServicePortTypeAddress(self): 
    1818        return DiscoveryServiceLocator.DiscoveryServicePortType_address 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/DiscoveryService_services_types.py

    r2615 r3093  
    4444        def __init__(self, pname, ofwhat=(), attributes=None, extend=False, restrict=False, **kw): 
    4545            ns = ns0.SearchType_Def.schema 
    46             TClist = [ZSI.TC.String(pname=(ns,"term"), aname="_term", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"termType"), aname="_termType", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.IpositiveInteger(pname=(ns,"start"), aname="_start", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.IpositiveInteger(pname=(ns,"howMany"), aname="_howMany", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"orderBy"), aname="_orderBy", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","orderByDirectionType",lazy=False)(pname=(ns,"orderByDirection"), aname="_orderByDirection", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"scope"), aname="_scope", minOccurs=0, maxOccurs="unbounded", nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","BoundingBoxType",lazy=False)(pname=(ns,"BoundingBox"), aname="_BoundingBox", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","DateRangeType",lazy=False)(pname=(ns,"DateRange"), aname="_DateRange", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))] 
     46            TClist = [ZSI.TC.String(pname=(ns,"term"), aname="_term", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"termType"), aname="_termType", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.IpositiveInteger(pname=(ns,"start"), aname="_start", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.IpositiveInteger(pname=(ns,"howMany"), aname="_howMany", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"orderBy"), aname="_orderBy", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","orderByDirectionType",lazy=False)(pname=(ns,"orderByDirection"), aname="_orderByDirection", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"scope"), aname="_scope", minOccurs=0, maxOccurs="unbounded", nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"spatialOperator"), aname="_spatialOperator", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","BoundingBoxType",lazy=False)(pname=(ns,"BoundingBox"), aname="_BoundingBox", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname=(ns,"temporalOperator"), aname="_temporalOperator", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("urn:DiscoveryServiceAPI","DateRangeType",lazy=False)(pname=(ns,"DateRange"), aname="_DateRange", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))] 
    4747            self.attribute_typecode_dict = attributes or {} 
    4848            if extend: TClist += ofwhat 
     
    6161                    self._orderByDirection = None 
    6262                    self._scope = [] 
     63                    self._spatialOperator = None 
    6364                    self._BoundingBox = None 
     65                    self._temporalOperator = None 
    6466                    self._DateRange = None 
    6567                    return 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/DiscoveryState.py

    r3060 r3093  
    55    def __init__(self, **kw): 
    66        self.values={} 
    7         keys=['dateRange','bbox','scope','textTarget','searchString'] 
     7        keys=['dateRange','bbox','scope','textTarget','searchString','geoSearchType'] 
    88        for key in keys:self.values[key]=None 
    99        print kw 
     
    3131            c+='Global; ' 
    3232        else: 
    33             c+='from latitude %s to %sN and longitude %s to %sE; '%(bbox[3],bbox[0],bbox[1],bbox[2]) 
     33            overlaps=self.values['geoSearchType'] or 'overlaps' 
     34            c+='which %s latitude %s to %sN and longitude %s to %sE; '%( 
     35                overlaps,bbox[3],bbox[0],bbox[1],bbox[2]) 
    3436            #c+='Bounding&nbsp;Box:&nbsp;%sN,%sW,%sE,%sS; '%tuple(bbox) 
    3537        if self.values['scope'] is not None or self.values['textTarget'] is not None: 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/geoUtilities.py

    r3092 r3093  
    6666        return '%s,%s'%(self.nboxes,self.boxes) 
    6767 
    68 class TimeCoverage: 
    69     def __init__(self,tc): 
    70         ''' Takes a tuple of (start date, end date, status) ''' 
    71         copy=[] 
    72         for i in tc: 
    73             if i=='':  
    74                 copy.append('Unknown') 
    75             else: copy.append(i) 
    76         self.data=tuple(copy) 
    77     def __str__(self): 
    78         if self.data==('Unknown','Unknown','Unknown'):  
    79             return 'Unknown' 
    80         else: 
    81             print self.data 
    82             return 'Start Date:%s, End Date:%s<br/>Status:%s'%self.data 
    83     def __getitem__(self,i): 
    84         return self.data[i] 
    8568     
    8669import unittest 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/ndgSearch.py

    r3059 r3093  
    4646        self.status=None 
    4747     
    48     def search(self,term,start=1,howmany=20,target='All',scope=None,bbox=None,dateRange=None,): 
     48    def search(self,term,start=1,howmany=20,target='All',scope=None,bbox=None,dateRange=None,geoSearchType='overlaps'): 
    4949        ''' Get a list of documents for a specific term using a free text search''' 
    5050         
     
    6565            box.LimitNorth,box.LimitWest,box.LimitEast,box.LimitSouth=map(float,bbox) 
    6666            request.BoundingBox=box 
     67            request.SpatialOperator=geoSearchType 
    6768         
    6869        if scope is not None: 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/advanced.kid

    r2882 r3093  
    8484                </div> <!--float wrap --> 
    8585                <div id="innerRight"> 
     86                    <?python 
     87                    #Search Types 
     88                    sps=[['overlaps','overlaps'],['does not overlap','doesNotOverlap'],['is within','within']] 
     89                    ?> 
    8690                    <div class="searchHdr">Spatial coverage <span py:replace="helpIcon('spacov_help')"/></div> 
    8791                    <table> 
     92                    <tr><td colspan="3">Look for data which  
     93                        <select name="geoSearchType">${XML(h.options_for_select(sps,c.geoSearchType))}</select> 
     94                    the search region.</td></tr> 
    8895                        <tr> 
    8996                        <td colspan="3"> 
     
    9198                            <div id="spacov_help" class="hidden"> 
    9299                                <div class="helptxt"> 
    93                                 <p> All datasets which have some data within the bounding box will be returned </p></div> 
     100                                <p> The default search is a global search. You can select a limited geospatial region using either the text boxes or the map. 
     101                                 The default is to limit to datasets which overlap with a search region, but you can also aim to find only the datasets 
     102                                 within the search region, or which <b>don't</b> overlap with the search region too. </p> 
     103                                 <p> Or at least that's what should happen. Right now (December 3, 2007) only "overlaps" works!</p></div> 
    94104                            </div> 
    95105                    </td></tr> 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/meta.kid

    r3092 r3093  
    135135     
    136136    <span py:def="result(i,d)"> 
     137        <?python 
     138        if len(d.timeCoverage)==1: 
     139            tc=d.timeCoverage[0] 
     140            #tc=[(i or '') for i in tc] 
     141        elif len(d.timeCoverage)==0: 
     142            tc=['','',''] 
     143        else: 
     144            tc=d.timeCoverage[0] 
     145            for m in d.timeCoverage: 
     146                if m[0]<tc[0]:tc[0]=m[0] 
     147                if m[1]>tc[1]:tc[1]=m[1] 
     148        ?>     
    137149        <tr class="${i%2 and 'rowhi' or 'rowlo'}"> 
    138150            <td> 
     
    149161                <span py:replace="serviceIcons([d.binding])"/> 
    150162                <span py:replace="serviceIcons(d.services)"/> 
    151             </td><td> 
    152                 <span py:if="d.timeCoverage[0] not in [None,'','Unknown']"> ${d.timeCoverage[0]}</span> 
    153             </td><td> 
    154                 <span py:if="d.timeCoverage[0] not in [None,'','Unknown']"> ${d.timeCoverage[1]}</span> 
    155             </td><td> 
     163                </td><td>${tc[0]}</td><td>${tc[1]}</td><td> 
    156164                <div py:replace="Spatial(d.bbox,0)"/> 
    157165            </td> 
Note: See TracChangeset for help on using the changeset viewer.