Я надеялся на простое решение в духе функции sdo_nn_distance, но мне не повезло, поэтому мне пришлось положиться на какое-то обходное решение.Я тестировал с использованием полигона острова Нью-Йорк, и он работал довольно быстро.Мне все еще нужно увидеть, как быстро он возвращается, когда я переключаюсь на полигон материковой части Северной Америки.
select * from
(select
sdo_geom.sdo_distance(sdo_geometry(2001,4326,null,sdo_elem_info_array(1, 1, 1),sdo_ordinate_array(/*selected coordinates*/-72.883398, 40.895885)),
sdo_geometry(2001,4326,null,sdo_elem_info_array(1, 1, 1),sdo_ordinate_array(X,Y)),1,'unit=Mile') distance_mile
from
ABPROD.ABT_COASTLINE_SHAPE_DATA CSD,
--Above line identifies the table that contains all of the polygons
table(SDO_UTIL.GETVERTICES(CSD.CSD_LOC_GEO)) t
--Above line creates a list of all of the coordinates (X,Y) that make up the polygon that the selected coordinates fall within
where
SDO_RELATE(CSD_LOC_GEO, sdo_geometry(2001,8307,sdo_point_type(/*selected coordinates*/-72.883398, 40.895885, null),null, null), 'mask=touch+contains') = 'TRUE'
--Above line finds the polygon that the selected coordinates fall within
and CSD_LEVEL_NBR = 1
--Above line limits results to land shapes, rivers and lakes are excluded
order by 1 asc
--Above line orders results by distance_mile so that row #1 is the closest distance
)
where rownum = 1
--Above line limits results to only the closest distance