Skip to content

Commit e756240

Browse files
committed
Use ST_Point
1 parent ba95540 commit e756240

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

demo/functions.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ BEGIN
143143
SELECT c.name::text, c.abbrev::text, c.postal::text
144144
FROM ne.admin_0_countries c
145145
WHERE ST_Intersects(c.geom,
146-
ST_SetSRID( ST_MakePoint(lon, lat), 4326))
146+
ST_Point(lon, lat, 4326))
147147
LIMIT 1;
148148
END;
149149
$$
@@ -167,7 +167,7 @@ BEGIN
167167
SELECT n.name::text, n.geom
168168
FROM (SELECT c.geom FROM ne.admin_0_countries c
169169
WHERE ST_Intersects(c.geom,
170-
ST_SetSRID( ST_MakePoint(lon, lat), 4326))
170+
ST_Point(lon, lat, 4326))
171171
LIMIT 1) AS t
172172
JOIN LATERAL (SELECT * FROM ne.admin_0_countries n
173173
WHERE ST_Touches(t.geom, n.geom)) AS n ON true;
@@ -188,7 +188,7 @@ RETURNS TABLE(name text, dist double precision, geom geometry)
188188
AS $$
189189
BEGIN
190190
RETURN QUERY
191-
SELECT gn.name, gn.geom <-> ST_SetSRID( ST_MakePoint(pt_lon, pt_lat), 4326) AS dist, gn.geom
191+
SELECT gn.name, gn.geom <-> ST_Point(pt_lon, pt_lat, 4326) AS dist, gn.geom
192192
FROM geonames gn
193193
ORDER BY dist LIMIT k;
194194
END;

demo/hexagon.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ cx float8 := 1.5*i*edge;
1010
cy float8 := h*(2*j+abs(i%2));
1111
BEGIN
1212
RETURN ST_MakePolygon(ST_MakeLine(ARRAY[
13-
ST_MakePoint(cx - 1.0*edge, cy + 0),
14-
ST_MakePoint(cx - 0.5*edge, cy + -1*h),
15-
ST_MakePoint(cx + 0.5*edge, cy + -1*h),
16-
ST_MakePoint(cx + 1.0*edge, cy + 0),
17-
ST_MakePoint(cx + 0.5*edge, cy + h),
18-
ST_MakePoint(cx - 0.5*edge, cy + h),
19-
ST_MakePoint(cx - 1.0*edge, cy + 0)
13+
ST_Point(cx - 1.0*edge, cy + 0),
14+
ST_Point(cx - 0.5*edge, cy + -1*h),
15+
ST_Point(cx + 0.5*edge, cy + -1*h),
16+
ST_Point(cx + 1.0*edge, cy + 0),
17+
ST_Point(cx + 0.5*edge, cy + h),
18+
ST_Point(cx - 0.5*edge, cy + h),
19+
ST_Point(cx - 1.0*edge, cy + 0)
2020
]));
2121
END;
2222
$$

hugo/content/examples/ex_query_functions_locate_country.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ BEGIN
2525
SELECT c.name::text, c.abbrev::text, c.postal::text
2626
FROM ne.countries c
2727
WHERE ST_Intersects(c.geom,
28-
ST_SetSRID(ST_MakePoint(lon, lat), 4326))
28+
ST_Point(lon, lat, 4326))
2929
LIMIT 1;
3030
END;
3131
$$
@@ -37,7 +37,7 @@ IS 'Finds the country at a geographic location';
3737

3838
Notes:
3939

40-
* The function generates a [Point](https://postgis.net/docs/ST_MakePoint.html) based on the longitude and latitude values provided in the parameters.
40+
* The function generates a [Point](https://postgis.net/docs/ST_Point.html) based on the longitude and latitude values provided in the parameters.
4141
* The `ne.countries` table is filtered based on whether the point [intersects](https://postgis.net/docs/ST_Intersects.html) a country polygon.
4242
* It's possible that a point lies exactly on the boundary between two countries. Both country records will be included in the query result set, but `LIMIT 1` restricts the result to a single record.
4343

0 commit comments

Comments
 (0)