Skip to content

Commit ce2e089

Browse files
committed
update geo doc
1 parent cc7e064 commit ce2e089

File tree

1 file changed

+40
-13
lines changed

1 file changed

+40
-13
lines changed

articles/stream-analytics/stream-analytics-geospatial-functions.md

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,21 @@ manager: kfile
88
ms.reviewer: mamccrea
99
ms.service: stream-analytics
1010
ms.topic: conceptual
11-
ms.date: 08/20/2018
11+
ms.date: 09/04/2018
1212
---
1313

1414
# Introduction to Stream Analytics geospatial functions
1515

1616
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.
1717

18-
Stream Analytics Query Language has seven built-in geospatial functions:
19-
20-
- [CreateLineString](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/createlinestring)
21-
- [CreatePoint](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/createpoint)
22-
- [CreatePolygon](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/createpolygon)
23-
- [ST_DISTANCE](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-distance)
24-
- [ST_OVERLAPS](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-overlaps)
25-
- [ST_INTERSECTS](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-intersects)
26-
- [ST_WITHIN](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-within)
18+
Stream Analytics Query Language has seven built-in geospatial functions: `CreateLineString`, `CreatePoint`, `CreatePolygon`, `ST_DISTANCE`, `ST_OVERLAPS`, `ST_INTERSECTS`, and `ST_WITHIN`.
2719

2820
## CreateLineString
2921

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.
25+
3026
```SQL
3127
SELECT
3228
CreateLineString(CreatePoint(input.latitude, input.longitude), CreatePoint(10.0, 10.0), CreatePoint(10.5, 10.5))
@@ -46,8 +42,14 @@ FROM input
4642

4743
{"type" : "LineString", "coordinates" : [ [20.2321, -87.33], [10.0, 10.0], [10.5, 10.5] ]}
4844

45+
To learn more, visit the [CreateLineString](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/createlinestring) reference.
46+
4947
## CreatePoint
5048

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:
52+
5153
```SQL
5254
SELECT
5355
CreatePoint(input.latitude, input.longitude)
@@ -67,8 +69,14 @@ FROM input
6769

6870
{"type" : "Point", "coordinates" : [20.2321, -87.33]}
6971

72+
To learn more, visit the [CreatePoint](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/createpoint) reference.
73+
7074
## CreatePolygon
7175

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:
79+
7280
```SQL
7381
SELECT
7482
CreatePolygon(CreatePoint(input.latitude, input.longitude), CreatePoint(10.0, 10.0), CreatePoint(10.5, 10.5), CreatePoint(input.latitude, input.longitude))
@@ -88,35 +96,47 @@ FROM input
8896

8997
{"type" : "Polygon", "coordinates" : [[ [20.2321, -87.33], [10.0, 10.0], [10.5, 10.5], [20.2321, -87.33] ]]}
9098

99+
To learn more, visit the [CreatePolygon](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/createpolygon) reference.
100+
101+
91102
## ST_DISTANCE
103+
The `ST_DISTANCE` function returns the distance between two points in meters.
92104

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:
94106

95107
```SQL
96108
SELECT Cars.Location, Station.Location
97109
FROM Cars c
98110
JOIN Station s ON ST_DISTANCE(c.Location, s.Location) < 10 * 1000
99111
```
100112

113+
To learn more, visit the [ST_DISTANCE](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-distance) reference.
114+
101115
## 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.
102117

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:
104119

105120
```SQL
106121
SELECT Building.Polygon, Building.Polygon
107122
FROM Building b
108123
JOIN Flooding f ON ST_OVERLAPS(b.Polygon, b.Polygon)
109124
```
110125

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:
112127

113128
```SQL
114129
SELECT Cars.Location, Storm.Course
115130
FROM Cars c, Storm s
116131
JOIN Storm s ON ST_OVERLAPS(c.Location, s.Course)
117132
```
118133

134+
To learn more, visit the [ST_OVERLAPS](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-overlaps) reference.
135+
119136
## 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:
120140

121141
```SQL
122142
SELECT
@@ -137,7 +157,12 @@ FROM input
137157

138158
0
139159

160+
To learn more, visit the [ST_INTERSECTS](https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/st-intersects) reference.
161+
140162
## 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:
141166

142167
```SQL
143168
SELECT
@@ -157,3 +182,5 @@ FROM input
157182
0
158183

159184
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

Comments
 (0)