<?xml version="1.0" encoding="UTF-8"?>
<!--
Example in response to the mail from Carl Reed, August 11th 2009 to SWE.WG@lists.opengeospatial.org

Any comments or thoughts? The GeoPRIV community is discussing filters on measurements taken for moving objects. Sounds like something we can provide guidance on. Definitely an alerting application
 
>A fundamental thing that you would like to be able to control
>about location is how fast you get updates.  If an entity has
>a variable rate of speed, and you set a motion filter, you
>also need to limit the rate.  So "send me a notification when
>the target moves by 30 meters, but don't send more than one
>update per 10 seconds".  So, there is an implied interaction
>between the movement filter and the rate filter.
Thanks!
 
Carl Reed, PhD
CTO and Executive Director Specification Program
OGC
-->

<!--
Imagine the incoming events have an attribute stating the distance traveled.

First use two simple patterns to connect to the input stream.

Then use complex pattern to check the distance traveled between two events and resuce output to one event per 10 seconds.
-->
<eml:EML xsi:schemaLocation="http://www.opengis.net/eml/0.0 C:/Arbeit/SCHEMAS_OPENGIS_NET/eml/0.0.1/emlPatterns.xsd" xmlns:eml="http://www.opengis.net/eml/0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:swe="http://www.opengis.net/swe/1.0.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc">
	<eml:SimplePatterns>
		<eml:SimplePattern inputName="input" patternID="simple1">
			<!-- select the whole event for further computing -->
			<eml:SelectFunctions>
				<eml:SelectFunction newEventName="inputEvent1">
					<eml:SelectEvent eventName="input"/>
				</eml:SelectFunction>
			</eml:SelectFunctions>
			<eml:View>
				<eml:LengthView>
					<eml:EventCount>1</eml:EventCount>
				</eml:LengthView>
			</eml:View>
			<eml:PropertyRestrictions/>
		</eml:SimplePattern>
		<eml:SimplePattern inputName="input" patternID="simple2">
			<!-- select the whole event for further computing -->
			<eml:SelectFunctions>
				<eml:SelectFunction newEventName="inputEvent2">
					<eml:SelectEvent eventName="input"/>
				</eml:SelectFunction>
			</eml:SelectFunctions>
			<eml:View>
				<eml:LengthView>
					<eml:EventCount>1</eml:EventCount>
				</eml:LengthView>
			</eml:View>
			<eml:PropertyRestrictions/>
		</eml:SimplePattern>
	</eml:SimplePatterns>
	<eml:ComplexPatterns>
		<eml:ComplexPattern patternID="complex1">
			<eml:SelectFunctions>
				<!-- select the result event -->
				<eml:SelectFunction newEventName="result" outputName="output">
					<eml:SelectEvent eventName="inputEvent2"/>
				</eml:SelectFunction>
			</eml:SelectFunctions>
			<eml:View>
				<!-- this view activates the select function every 10 seconds-->
				<eml:TimeView isBatch="true">
					<eml:Duration>PT0H0M10S</eml:Duration>
				</eml:TimeView>
			</eml:View>
			<eml:Guard>
				<!-- check if (event1.distance + 30m) > event2.distance -->
				<ogc:Filter>
					<ogc:PropertyIsGreaterThanOrEqualTo>
						<ogc:Add>
							<ogc:PropertyName>inputEvent1</ogc:PropertyName>
							<ogc:Literal>
								<swe:Quantity>
									<swe:uom code="m"/> <!-- UCUM code for meter -->
									<swe:value>30</swe:value>
								</swe:Quantity>
							</ogc:Literal>
						</ogc:Add>
						<ogc:PropertyName>inputEvent2</ogc:PropertyName>
					</ogc:PropertyIsGreaterThanOrEqualTo>
				</ogc:Filter>
			</eml:Guard>
			<!-- only accept pairs where the first event was received before the second -->
			<eml:StructuralOperator>
				<eml:BEFORE/>
			</eml:StructuralOperator>
			<!--work on output of pattern simple1-->
			<eml:FirstPattern>
				<eml:PatternReference>simple1</eml:PatternReference>
				<eml:SelectFunctionNumber>0</eml:SelectFunctionNumber>
			</eml:FirstPattern>
			<eml:SecondPattern>
				<eml:PatternReference>simple2</eml:PatternReference>
				<eml:SelectFunctionNumber>0</eml:SelectFunctionNumber>
			</eml:SecondPattern>
		</eml:ComplexPattern>
	</eml:ComplexPatterns>
	<eml:TimerPatterns/>
	<eml:RepetitivePatterns/>
</eml:EML>


