This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, go to https://wso2.com/documentation/.

Geo GPL Extension

This extension provides geo data related functionality such as checking whether a given geo coordinate is within a predefined geo-fence, etc. Following are the functions of the Geo extension.

Intersects function

Syntax<bool> geo:intersects (<string> geoJSONGeometry , <string> geoJSONGeometryFence )
Extension TypeFunction
DescriptionReturns true if the  geoJSONGeometry  incoming event intersects the given string (i.e., geoJSONGeometryFence ). Returns false otherwise.
Exampleintersects( {'type':'Polygon','coordinates':[[[0.5, 0.5],[0.5, 1.5],[1.5, 1.5],[1.5, 0.5],[0.5, 0.5]]]} , {'type':'Polygon','coordinates':[[[0, 0],[0, 1],[1, 1],[1, 0],[0, 0]]]} ), returns true because geoJSONGeometry intersects geoJSONGeometryFence.
Syntax<bool> geo: intersects (<double> longitude , <double> latitude , <string> geoJSONGeometryFence )
Extension TypeFunction
DescriptionReturns true if the location specified in terms of longitude and latitude intersects the given  geoJSONGeometryFence . Returns false otherwise.
Exampleintersects(0.5. 0.5 , {'type':'Polygon','coordinates':[[[0, 0],[0, 1],[1, 1],[1, 0],[0, 0]]]}), returns true because the location specified in terms of longitude and latitude intersects geoJSONGeometryFence.


Within function

Syntax<bool> geo: within (<double> longitude , <double> latitude, <string> geoJSONGeometryFence )
Extension TypeFunction
DescriptionReturns true if the location specified in terms of longitude and latitude is within the  geoJSONGeometryFence .
Examples
  • within(0.5, 0.5, {'type':'Polygon','coordinates':[[[0,0],[0,2],[1,2],[1,0],[0,0]]]} ) returns true.
  • within(2, 2, {'type':'Polygon','coordinates':[[[0,0],[0,2],[1,2],[1,0],[0,0]]]} ) returns false.
Syntax<bool> geo: within (<string> geoJSONGeometry , <string> geoJSONGeometryFence  )
Extension TypeFunction
DescriptionReturns true if the  geoJSONGeometry  is within the  geoJSONGeometryFence . Returns false otherwise.
Example
  • within( {'type': 'Circle', 'radius': 110575, 'coordinates':[1.5, 1.5]} , {'type':'Polygon','coordinates':[[[0,0],[0,4],[3,4],[3,0],[0,0]]]} ) returns true.
  • within( {'type': 'Circle', 'radius': 110575, 'coordinates':[0.5, 1.5]} , {'type':'Polygon','coordinates':[[[0,0],[0,4],[3,4],[3,0],[0,0]]]} ) returns false.


Within Distance function

Syntax<bool> geo: withindistance (<double> longitude , <double> latitude, <string> geoJSONGeometryFence )
Extension TypeFunction
DescriptionReturns true if the location specified in terms of longitude and latitude is within distance of the  geoJSONGeometryFence . Returns false otherwise.
Examplewithindistance( 0.5 , 0.5, {'type':'Polygon','coordinates':[[[0, 0],[0, 1],[1, 1],[1, 0],[0, 0]]]}, 110574.61087757687) returns true because the location specified in terms of longitude and latitude is within the distance of the geoJSONGeometryFence.
Syntax<bool> geo: withindistance (<string> geoJSONGeometry , <string> geoJSONGeometryFence , <double> distance )
Extension TypeFunction
DescriptionReturns true if the area given by  geoJSONGeometry  is within distance of the  geoJSONGeometryFence .
Examplewithindistance( {'type':'Polygon','coordinates':[[[0.5, 0.5],[0.5, 1.5],[1.5, 1.5],[1.5, 0.5],[0.5, 0.5]]]} , {'type':'Polygon','coordinates':[[[0, 0],[0, 1],[1, 1],[1, 0],[0, 0]]]}, 110574.61087757687) returns true because geoJSONGeometry is within the distance of geoJSONGeometryFence.


Crosses function

Syntax<bool> geo: crosses (<string> id , <double> longitude, <double> latitude , <string> geoJSONGeometryFence )
Extension TypeFunction
DescriptionReturns true when the  the specified object of which the location is specified  in terms of  longitude   and  latitude  crosses the geographic location specified in  geoJSONGeometryFence . Returns false when the object crosses out of the location specified in  geoJSONGeometryFence .
Example
  • crosses(km-4354, -0.5, 0.5, {'type':'Polygon','coordinates':[[[0, 0],[2, 0],[2, 1],[0, 1],[0, 0]]]} ) returns true.
  • km-4354, 1.5, 0.5, {'type':'Polygon','coordinates':[[[0, 0],[2, 0],[2, 1],[0, 1],[0, 0]]]} ) returns true.
Syntax<bool> geo: crosses (<string> id , <string> geoJSONGeometry , <string> geoJSONGeometryFence )
Extension TypeStreamProcessor
DescriptionReturns true when the object (i.e.  geoJSONGeometry ) crosses the specified geographic location (i.e.  geoJSONGeometryFence ). Returns false when the object crosses out of geoJSONGeometryFence

 

Stationary function

Syntax<bool> geo: stationary (<string> id , <double> longitude, <double> latitude , <string> geoJSONGeometryFence , <double> radius )
Extension TypeStreamProcessor
DescriptionReturns true when the object (defined in terms of   longitude   and  latitude ) becomes stationary within the specified  radius . Returns false when the object moves out of the specified radius.
Example
  • stationary(km-4354,0,0, 110574.61087757687) returns true.
  • stationary(km-4354,1,1, 110574.61087757687) returns  true.
  • stationary(km-4354,1,1.5, 110574.61087757687) returns true.
Syntax<bool> geo: stationary (<string> id , <string> geoJSONGeometry , <string> geoJSONGeometryFence , <double>  radius )
Extension TypeStreamProcessor
DescriptionReturns true when the object (i.e.  geoJSONGeometry ) becomes stationary within the specified  radius Returns false when the objects moves out of the specified radius.

Proximity function

Syntax<bool,string> geo:proximity (<string> id , <double> longitude, <double> latitude , <string> geoJSONGeometryFence , <double> radius )
Extension TypeStreamProcessor
DescriptionReturns true when two objects (specified in terms of  longitude  and  latitudeare within the specified  radius  to another object. Returns false when the specified object moves out of the specified  radius . The proximityWith optional attribute indicates the ID of the object that the object specified is in close proximity with. proximityID is a unique ID for the two objects in close proximity.
Example

The following return true with  id 3.

  • proximity(1, 0, 0, 110574.61087757687)
  • proximity(2, 1, 1, 110574.61087757687)
  • proximity(3, 2, 2, 110574.61087757687)
  • proximity(1, 1.5, 1.5, 110574.61087757687)
Syntax<bool> proximity (<string> id , <string> geoJSONGeometry , <string> geoJSONGeometryFence , <double>  radius )
Extension TypeStreamProcessor
DescriptionReturns true when an object (i.e.  geoJSONGeometry ) is within the specified  radius  from another object. Returns false when one or both objects move away from each other and are no longer within the specified  radiu s of each other. The proximityWith optional attribute indicates the ID of the object that the object specified is in close proximity with. proximityID is a unique ID for the two objects in close proximity.