Is This Content Helpful?
We're glad to know this article was helpful.
One type of frequently executed spatial operation is to identify the nearest feature or nearest features with respect to an existing feature or specific location. For example, find the nearest gas station based upon my current location.
Presently, the st_geometry implementation for Oracle does not provide a nearest operator to provide this information.
Instructions provided in this knowledge base article describe how a SQL statement can be written to identify the nearest feature or features with respect to an existing feature or specific location.
If the objective is to find the nearest restaurant to a specific address, the question can be answered by writing a SQL statement with the st_buffer, st_intersects operator, and Oracle rownum function.
SQL> SELECT name
3 (SELECT a.name NAME
4 FROM restaurants a, address_pnt b
5 WHERE b.id = 9482
6 AND sde.st_intersects(a.shape, sde.st_buffer(b.shape, 1000)) = 1
7 ORDER BY sde.st_distance(a.shape,b.shape))
8 WHERE ROWNUM = 1;