You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/stream-analytics/stream-analytics-geospatial-functions.md
+40-13Lines changed: 40 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,25 +8,21 @@ manager: kfile
8
8
ms.reviewer: mamccrea
9
9
ms.service: stream-analytics
10
10
ms.topic: conceptual
11
-
ms.date: 08/20/2018
11
+
ms.date: 09/04/2018
12
12
---
13
13
14
14
# Introduction to Stream Analytics geospatial functions
15
15
16
16
Geospatial functions in Azure Stream Analytics enable real-time analytics on streaming geospatial data. With just a few lines of code, you can develop a production grade solution for scenarios such as ride-sharing, fleet management, asset tracking, geo-fencing, and phone tracking across cell sites. The ability to join multiple streams of data with geospatial data can be used to answer complex questions on streaming data. Stream Analytics has adopted the GeoJSON standard for geospatial data.
17
17
18
-
Stream Analytics Query Language has seven built-in geospatial functions:
Stream Analytics Query Language has seven built-in geospatial functions: `CreateLineString`, `CreatePoint`, `CreatePolygon`, `ST_DISTANCE`, `ST_OVERLAPS`, `ST_INTERSECTS`, and `ST_WITHIN`.
27
19
28
20
## CreateLineString
29
21
22
+
The `CreateLineString` function accepts points and returns a GeoJSON LineString, which can be plotted as a line on a map. You must have at least two points to create a LineString. The LineString points will be connected in order.
23
+
24
+
The following query uses `CreateLineString` to create a LinString using three points, one of which is created from streaming input data, while the other two are created manually.
To learn more, visit the [CreateLineString](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/createlinestring) reference.
46
+
49
47
## CreatePoint
50
48
49
+
The `CreatePoint` function accepts a latitude and longitude and returns a GeoJSON point, which can be plotted on a map. Your latitudes and longitudes must be a **float** datatype.
50
+
51
+
The following example query uses `CreatePoint` to create a point using latitudes and longitudes from streaming input data:
To learn more, visit the [CreatePoint](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/createpoint) reference.
73
+
70
74
## CreatePolygon
71
75
76
+
The `CreatePolygon` function accepts points and returns a GeoJSON polygon record. The order of points must follow right-hand ring orientation. If you imagine yourself walking from one point to another in the order they were declared, the inside of the polygon would be to your left the entire time.
77
+
78
+
The following example query uses `CreatePolygon` to create a polygon from three points, two of which are created manually, while the final point is created from input data:
To learn more, visit the [CreatePolygon](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/createpolygon) reference.
100
+
101
+
91
102
## ST_DISTANCE
103
+
The `ST_DISTANCE` function returns the distance between two points in meters.
92
104
93
-
Generate an event when a gas station is less than 10 km from the car:
105
+
The following query uses `ST_DISTANCE` to generate an event when a gas station is less than 10 km from the car:
94
106
95
107
```SQL
96
108
SELECTCars.Location, Station.Location
97
109
FROM Cars c
98
110
JOIN Station s ON ST_DISTANCE(c.Location, s.Location) <10*1000
99
111
```
100
112
113
+
To learn more, visit the [ST_DISTANCE](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-distance) reference.
114
+
101
115
## ST_OVERLAPS
116
+
The `ST_OVERLAPS` function compares two polygons. If the polygons overlap, the function returns a 1. If the polygons do not overlap, the function returns a 0.
102
117
103
-
Generate an event when building is within a possible flooding zone:
118
+
The following query uses `ST_OVERLAPS` to generate an event when a building is within a possible flooding zone:
104
119
105
120
```SQL
106
121
SELECTBuilding.Polygon, Building.Polygon
107
122
FROM Building b
108
123
JOIN Flooding f ON ST_OVERLAPS(b.Polygon, b.Polygon)
109
124
```
110
125
111
-
Generate an event when a storm is heading towards a car:
126
+
The following example query generates an event when a storm is heading towards a car:
112
127
113
128
```SQL
114
129
SELECTCars.Location, Storm.Course
115
130
FROM Cars c, Storm s
116
131
JOIN Storm s ON ST_OVERLAPS(c.Location, s.Course)
117
132
```
118
133
134
+
To learn more, visit the [ST_OVERLAPS](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-overlaps) reference.
135
+
119
136
## ST_INTERSECTS
137
+
The `ST_INTERSECTS` function compares two LineString. If the LineString intersect, then the function returns 1. If the LineString do not intersect, the function returns 0.
138
+
139
+
The following example query uses `ST_INTERSECTS` to determine whether or not a paved road intersects a dirt road:
120
140
121
141
```SQL
122
142
SELECT
@@ -137,7 +157,12 @@ FROM input
137
157
138
158
0
139
159
160
+
To learn more, visit the [ST_INTERSECTS](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-intersects) reference.
161
+
140
162
## ST_WITHIN
163
+
The `ST_WITHIN` function determines whether a point or polygon is contained within a polygon. If the polygon contains the point or polygon, the function will return 1. If the point or polygon is not located within the declared polygon, then the function will return 0.
164
+
165
+
The following example query uses `ST_WITHIN` to determine whether the delivery destination point is within the given warehouse polygon:
141
166
142
167
```SQL
143
168
SELECT
@@ -157,3 +182,5 @@ FROM input
157
182
0
158
183
159
184
1
185
+
186
+
To learn more, visit the [ST_WITHIN](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-within) reference.
0 commit comments