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
+22-14Lines changed: 22 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,15 +13,23 @@ ms.date: 09/04/2018
13
13
14
14
# Introduction to Stream Analytics geospatial functions
15
15
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.
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 complex scenarios.
17
17
18
-
Stream Analytics Query Language has seven built-in geospatial functions: `CreateLineString`, `CreatePoint`, `CreatePolygon`, `ST_DISTANCE`, `ST_OVERLAPS`, `ST_INTERSECTS`, and `ST_WITHIN`.
18
+
Examples of scenarios that can benefit from geospatial functions include:
19
+
20
+
* Ride-sharing
21
+
* Fleet management
22
+
* Asset tracking
23
+
* Geo-fencing
24
+
* Phone tracking across cell sites
25
+
26
+
Stream Analytics Query Language has seven built-in geospatial functions: **CreateLineString**, **CreatePoint**, **CreatePolygon**, **ST_DISTANCE**, **ST_OVERLAPS**, **ST_INTERSECTS**, and **ST_WITHIN**.
19
27
20
28
## CreateLineString
21
29
22
30
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
31
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.
32
+
The following query uses `CreateLineString` to create a LineString using three points. The first point is created from streaming input data, while the other two are created manually.
25
33
26
34
```SQL
27
35
SELECT
@@ -48,7 +56,7 @@ To learn more, visit the [CreateLineString](https://msdn.microsoft.com/en-us/azu
48
56
49
57
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
58
51
-
The following example query uses `CreatePoint` to create a point using latitudes and longitudes from streaming input data:
59
+
The following example query uses `CreatePoint` to create a point using latitudes and longitudes from streaming input data.
52
60
53
61
```SQL
54
62
SELECT
@@ -73,9 +81,9 @@ To learn more, visit the [CreatePoint](https://msdn.microsoft.com/en-us/azure/st
73
81
74
82
## CreatePolygon
75
83
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.
84
+
The `CreatePolygon` function accepts points and returns a GeoJSON polygon record. The order of points must follow right-hand ring orientation, or counter-clockwise. Imagine walking from one point to another in the order they were declared. The center of the polygon would be to your left the entire time.
77
85
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:
86
+
The following example query uses `CreatePolygon` to create a polygon from three points. The first two points are created manually, and the last point is created from input data.
79
87
80
88
```SQL
81
89
SELECT
@@ -102,7 +110,7 @@ To learn more, visit the [CreatePolygon](https://msdn.microsoft.com/en-us/azure/
102
110
## ST_DISTANCE
103
111
The `ST_DISTANCE` function returns the distance between two points in meters.
104
112
105
-
The following query uses `ST_DISTANCE` to generate an event when a gas station is less than 10 km from the car:
113
+
The following query uses `ST_DISTANCE` to generate an event when a gas station is less than 10 km from the car.
106
114
107
115
```SQL
108
116
SELECTCars.Location, Station.Location
@@ -113,17 +121,17 @@ JOIN Station s ON ST_DISTANCE(c.Location, s.Location) < 10 * 1000
113
121
To learn more, visit the [ST_DISTANCE](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-distance) reference.
114
122
115
123
## 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.
124
+
The `ST_OVERLAPS` function compares two polygons. If the polygons overlap, the function returns a 1. The function returns 0 if the polygons don't overlap.
117
125
118
-
The following query uses `ST_OVERLAPS` to generate an event when a building is within a possible flooding zone:
126
+
The following query uses `ST_OVERLAPS` to generate an event when a building is within a possible flooding zone.
119
127
120
128
```SQL
121
129
SELECTBuilding.Polygon, Building.Polygon
122
130
FROM Building b
123
131
JOIN Flooding f ON ST_OVERLAPS(b.Polygon, b.Polygon)
124
132
```
125
133
126
-
The following example query generates an event when a storm is heading towards a car:
134
+
The following example query generates an event when a storm is heading towards a car.
127
135
128
136
```SQL
129
137
SELECTCars.Location, Storm.Course
@@ -134,9 +142,9 @@ JOIN Storm s ON ST_OVERLAPS(c.Location, s.Course)
134
142
To learn more, visit the [ST_OVERLAPS](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-overlaps) reference.
135
143
136
144
## 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.
145
+
The `ST_INTERSECTS` function compares two LineString. If the LineString intersect, then the function returns 1. The function returns 0 if the LineString don't intersect.
138
146
139
-
The following example query uses `ST_INTERSECTS` to determine whether or not a paved road intersects a dirt road:
147
+
The following example query uses `ST_INTERSECTS` to determine if a paved road intersects a dirt road.
140
148
141
149
```SQL
142
150
SELECT
@@ -160,9 +168,9 @@ FROM input
160
168
To learn more, visit the [ST_INTERSECTS](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-intersects) reference.
161
169
162
170
## 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.
171
+
The `ST_WITHIN` function determines whether a point or polygon is within a polygon. If the polygon contains the point or polygon, the function will return 1. The function will return 0 if the point or polygon isn't located within the declared polygon.
164
172
165
-
The following example query uses `ST_WITHIN` to determine whether the delivery destination point is within the given warehouse polygon:
173
+
The following example query uses `ST_WITHIN` to determine whether the delivery destination point is within the given warehouse polygon.
0 commit comments