Strabon

changeset 793:86d04cea2906 DiffDateTime

A somehow faster query for discovering fires
author George Garbis <ggarbis@di.uoa.gr>
date Mon Dec 10 13:24:21 2012 +0200 (2012-12-10)
parents 5431f2fccf07
children feaee3e3e582
files examples/teleios/discoverFires-start.rq
line diff
     1.1 --- a/examples/teleios/discoverFires-start.rq	Mon Dec 10 13:23:16 2012 +0200
     1.2 +++ b/examples/teleios/discoverFires-start.rq	Mon Dec 10 13:24:21 2012 +0200
     1.3 @@ -20,53 +20,40 @@
     1.4  PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
     1.5  PREFIX gag: <http://geo.linkedopendata.gr/greekadministrativeregion/ontology#>
     1.6  
     1.7 -SELECT (substr(str(?hStartTime), 12, 5) as ?start) (substr(str(max(?hTime)), 12, 5) as ?end) ?geo
     1.8 -WHERE {
     1.9 -	# -- FIND HOTSPOTS THAT DEFINE THE START OF A FIRE (GROUP ALA THEMOS) -- 
    1.10 -	# Retrieve all hotstpots in time range...  
    1.11 -	?hStart	noa:hasAcquisitionTime ?hStartTime ;
    1.12 -            noa:hasGeometry ?geo ;
    1.13 -			noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ;
    1.14 -			noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    1.15 -	FILTER("MIN_ACQUISITION_TIME"^^xsd:dateTime <= ?hStartTime && ?hStartTime <= "MAX_ACQUISITION_TIME"^^xsd:dateTime).
    1.16 -	# ... narrow down results so that any previous hotspots is detected at least PERSISTENCE mins earlier
    1.17 -    OPTIONAL {
    1.18 -        ?hPrevious	noa:hasAcquisitionTime ?hPreviousTime ;
    1.19 -        			noa:hasGeometry ?geo ;
    1.20 -					noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ;
    1.21 -					noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    1.22 -		FILTER("MIN_ACQUISITION_TIME"^^xsd:dateTime <= ?hStartTime && ?hStartTime <= "MAX_ACQUISITION_TIME"^^xsd:dateTime).
    1.23 -        FILTER(strdf-ext:diffDateTime(?hStartTime, ?hPreviousTime) <= PERSISTENCE*60000 && ?hStartTime > ?hPreviousTime).
    1.24 -    } 
    1.25 -    FILTER(!bound(?hPrevious)) .
    1.26 +SELECT ?start (max(?hTime) as ?end) ?geo 
    1.27 +WHERE
    1.28 +{
    1.29 +    {
    1.30 +        SELECT (max(?hStartTime) as ?start) ?hTime ?geo ?h
    1.31 +        WHERE {
    1.32 +	        # -- FIND HOTSPOTS THAT DEFINE THE START OF A FIRE (GROUP ALA THEMOS) -- 
    1.33 +	        # Retrieve all hotstpots in time range...  
    1.34 +	        ?hStart	noa:hasAcquisitionTime ?hStartTime ;
    1.35 +                    noa:hasGeometry ?geo ;
    1.36 +			        noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ;
    1.37 +			        noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    1.38 +	        FILTER("MIN_ACQUISITION_TIME"^^xsd:dateTime <= ?hStartTime && ?hStartTime <= "MAX_ACQUISITION_TIME"^^xsd:dateTime).
    1.39 +	        # ... narrow down results so that any previous hotspots is detected at least PERSISTENCE mins earlier
    1.40 +            OPTIONAL {
    1.41 +                ?hPrevious	noa:hasAcquisitionTime ?hPreviousTime ;
    1.42 +                			noa:hasGeometry ?geo ;
    1.43 +					        noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ;
    1.44 +					        noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    1.45 +		        FILTER("MIN_ACQUISITION_TIME"^^xsd:dateTime <= ?hStartTime && ?hStartTime <= "MAX_ACQUISITION_TIME"^^xsd:dateTime).
    1.46 +                FILTER(strdf-ext:diffDateTime(?hStartTime, ?hPreviousTime) <= PERSISTENCE*60000 && ?hStartTime > ?hPreviousTime).
    1.47 +            } 
    1.48 +            FILTER(!bound(?hPrevious)) .
    1.49  
    1.50 -    # FIND HOTSPOTS AFTER A FIRE STARTING TIME
    1.51 -    ?h  noa:hasAcquisitionTime ?hTime;
    1.52 -        noa:hasGeometry ?hGeo;
    1.53 -		noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ;
    1.54 -		noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    1.55 -	FILTER("MIN_ACQUISITION_TIME"^^xsd:dateTime <= ?hStartTime && ?hStartTime <= "MAX_ACQUISITION_TIME"^^xsd:dateTime).
    1.56 -    FILTER(?hTime >= ?hStartTime).
    1.57 -
    1.58 -    # OPTIONALLY FIND ANOTHER STARTING TIME BEFORE ?h and after ?hStart
    1.59 -    OPTIONAL {
    1.60 -        ?hStart2	noa:hasAcquisitionTime ?hStartTime2 ;
    1.61 -   					noa:hasGeometry ?geo ;		
    1.62 -					noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ;
    1.63 -					noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    1.64 -		FILTER("MIN_ACQUISITION_TIME"^^xsd:dateTime <= ?hStartTime2 && ?hStartTime2 <= "MAX_ACQUISITION_TIME"^^xsd:dateTime).
    1.65 -        OPTIONAL {                        		
    1.66 -            ?hPrevious2	noa:hasAcquisitionTime ?hPreviousTime2 ;
    1.67 -            			noa:hasGeometry ?geo ;
    1.68 -						noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ;
    1.69 -						noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    1.70 -			FILTER("MIN_ACQUISITION_TIME"^^xsd:dateTime <= ?hStartTime2 && ?hStartTime2 <= "MAX_ACQUISITION_TIME"^^xsd:dateTime).
    1.71 -            FILTER( strdf-ext:diffDateTime(?hStartTime2, ?hPreviousTime2) <= PERSISTENCE*60000 && ?hStartTime2 > ?hPreviousTime2).
    1.72 -        } 
    1.73 -        FILTER(!bound(?hPrevious2)) .
    1.74 -        FILTER(?hStartTime < ?hStartTime2 && ?hStartTime2 <= ?hTime).
    1.75 -    }    
    1.76 -    FILTER(!bound(?hStart2))
    1.77 +            # FIND HOTSPOTS AFTER A FIRE STARTING TIME
    1.78 +            ?h  noa:hasAcquisitionTime ?hTime;
    1.79 +                noa:hasGeometry ?hGeo;
    1.80 +		        noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ;
    1.81 +		        noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    1.82 +	        FILTER("MIN_ACQUISITION_TIME"^^xsd:dateTime <= ?hStartTime && ?hStartTime <= "MAX_ACQUISITION_TIME"^^xsd:dateTime).
    1.83 +            FILTER(?hTime >= ?hStartTime).
    1.84 +        }
    1.85 +        group by ?h ?hTime ?geo
    1.86 +    }.
    1.87  }
    1.88 -GROUP BY ?hStartTime ?geo 
    1.89 -HAVING (count(?h) >= REPEAT_IN_PERS)
    1.90 +group by ?start ?geo
    1.91 +having (count(?h) >= 3)