File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -705,6 +705,44 @@ The following sections document the most commonly used functions:
705705 Create a geometry from its WKT representation.
706706
707707
708+ Example
709+ =======
710+
711+ Here's a simple example showing how to create and query geometric data:
712+
713+ .. code-block :: esdl
714+
715+ # Create a spatial table
716+ type Location {
717+ required name: str;
718+ required position: ext::postgis::geometry;
719+ }
720+
721+ .. code-block :: edgeql
722+
723+ # Insert some data
724+ INSERT Location {
725+ name := 'Central Park',
726+ position := ext::postgis::geomfromtext(
727+ 'POLYGON((-73.968285 40.785091, -73.981457 40.768930,
728+ -73.958798 40.764891, -73.968285 40.785091))'
729+ )
730+ };
731+
732+ # Find locations within 5km of a point
733+ SELECT Location {
734+ name,
735+ distance := ext::postgis::distance(
736+ .position,
737+ ext::postgis::makepoint(-73.935242, 40.730610)
738+ )
739+ } FILTER ext::postgis::dwithin(
740+ .position,
741+ ext::postgis::makepoint(-73.935242, 40.730610),
742+ 5000 # 5km radius
743+ );
744+
745+
708746 For more information about PostGIS extension, refer to
709747the `PostGIS documentation <postgis _>`_.
710748
You can’t perform that action at this time.
0 commit comments