Skip to content

Commit f8f928a

Browse files
authored
feat: add geo::latLng() (#128)
1 parent 37df252 commit f8f928a

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

spec/14-extensions.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,30 @@ global_geo_validate(args):
107107
- If the length of {args} is not 1:
108108
- Report an error.
109109

110+
### geo::latLng()
111+
112+
Takes latitude and longitude as arguments and returns a Geo Point.
113+
114+
geo_latLng(args, scope):
115+
116+
- Let {latNode} be the first element of {args}.
117+
- Let {lngNode} be the second element of {args}.
118+
- Let {lat} be the result of {Evaluate(latNode, scope)}.
119+
- Let {lng} be the result of {Evaluate(lngNode, scope)}.
120+
- If {lat} or {lng} is not a number:
121+
- Return {null}.
122+
- If {lat} is not in the range of -90 to 90:
123+
- Return {null}.
124+
- If {lng} is not in the range of -180 to 180:
125+
- Return {null}.
126+
- Otherwise:
127+
- Return a GeoJSON Point with {lat} and {lng} as coordinates, in lng, lat order.
128+
129+
geo_latLng_validate(args):
130+
131+
- If the length of {args} is not 2:
132+
- Report an error.
133+
110134
### geo::contains()
111135

112136
Returns true if first geo argument completely contains the second one, using a planar (non-spherical) coordinate system. Both geo argument can be any geo value. A geo value is considered contained if all its points are within the boundaries of the first geo value. For `MultiPolygon`, it's sufficient that only one of the polygons contains the first geo value.

spec/GROQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ _Current Working Draft_
55
This is the specification for GROQ (**G**raph-**R**elational **O**bject **Q**ueries), a query language and execution engine made at Sanity, Inc, for filtering and projecting JSON documents. The work started in 2015. The development of this open standard started in 2019.
66

77
GROQ is authored by [Alexander Staubo](https://twitter.com/purefiction) and [Simen Svale Skogsrud](https://twitter.com/svale).
8-
Additional follow up work by [Erik Grinaker](https://twitter.com/erikgrinaker), [Magnus Holm](https://twitter.com/judofyr), [Radhe](https://github.com/j33ty), [Israel Roldan](https://github.com/israelroldan), [Sindre Gulseth](https://github.com/sgulseth), [Matt Craig](https://github.com/codebymatt).
8+
Additional follow up work by [Erik Grinaker](https://twitter.com/erikgrinaker), [Magnus Holm](https://twitter.com/judofyr), [Radhe](https://github.com/j33ty), [Israel Roldan](https://github.com/israelroldan), [Sindre Gulseth](https://github.com/sgulseth), [Matt Craig](https://github.com/codebymatt), [Espen Hovlandsdal](https://github.com/rexxars).
99

1010
This specification should be considered _work in progress_ until the first release.
1111

0 commit comments

Comments
 (0)