I. Spatial Relationship Calculation
The above two chapters are essential for storing spatial data in the database and accelerating the acquisition of spatial data through indexing. From this sentence, we can also see that subsequent chapters are not necessary. That is to say, some spatial data-based applications may not need functions such as spatial relationship judgment and geometric object processing. This does not mean that these functions are not needed, but they do not necessarily need to be executed on the database. For example, based on ArcSDE, these spatial algorithms and functions are everywhere in the ArcGIS product line. In many cases, these functions are not stored in the database.
· Oracle Spatial
In Oracle Spatial, the main spatial relationship operations are listed in the following table:
Space Operations |
Description |
Sdo_filter |
Master filter to determine which geometric objects may interwork with the given geometric objects |
Sdo_join |
Table join based on a certain spatial relationship |
Sdo_nn |
Query the geometric objects closest to a geometric object |
Sdo_nn_distance |
Queries the distance between a geometric object closest to a geometric object and the current object. |
Sdo_relate |
Determine whether two geometric objects meet a certain spatial relationship |
Sdo_within_distance |
Determines whether the distance between two geometric objects is smaller than a given value. |
Specifically, the sdo_relate operation is special. It uses the mask parameter to determine whether the ry object satisfies a certain spatial relationship. However, in fact, it is not convenient to use the parameter to specify the spatial relationship. Therefore, oracle Spatial also provides operations for different spatial relationships represented by different sdo_relate parameters, as shown in the following table:
Spatial operations derived from sdo_relate |
Description |
Sdo_anyinteract |
Any part has Intersection |
Sdo_contains |
|
Sdo_coveredby |
Sdo_covers |
Sdo_equal |
Sdo_inside |
Sdo_on |
Sdo_overlapbdydisjoint |
Sdo_overlapbdyintersect |
Sdo_overlaps |
Sdo_touch |
The following describes the general usage of spatial relationship operations. For example, if I use a triangle to query all geometric objects that satisfy the "Inside" relationship, we can perform the following operations in two equal ways:
SQL> select continent from continent where sdo_inside (Geom, sdo_geometry (2003, null, null, sdo_elem_info_array (180, 90,180, 1), sdo_ordinate_array (,-, 90, 0, 0) = 'true ';
Continent
---------------------------------------
Australia
SQL> select continent from continent where sdo_relate (Geom, sdo_geometry (2003, null, null, sdo_elem_info_array (180, 90,180, 1), sdo_ordinate_array (,-, 90, 0, 0), 'mask = inside ') = 'true ';
Continent
---------------------------------------
Australia
Figure 13 geometric objects that determine a certain spatial relationship with the triangle in the figure
Although there are some convenient derivative operations of sdo_relate, sdo_relate supports more flexible spatial relationship judgment, for example, the following SQL statement can be used to query the geometric objects that meet the "overlapbdydisjoint", "inside", and the two relations at the same time:
SQL> select continent from continent where sdo_relate (Geom, sdo_geometry (2003, null, null, sdo_elem_info_array (180, 90,180, 1), sdo_ordinate_array (,-, 90, 0, 0), 'mask = overlapbdydisjoint') = 'true ';
Continent
---------------------------------------
North America
SQL> select continent from continent where sdo_relate (Geom, sdo_geometry (2003, null, null, sdo_elem_info_array (180, 90,180, 1), sdo_ordinate_array (,-, 90, 0, 0), 'mask = inside ') = 'true ';
Continent
---------------------------------------
Australia
SQL> select continent from continent where sdo_relate (Geom, sdo_geometry (2003, null, null, sdo_elem_info_array (180, 90,180, 1), sdo_ordinate_array (,-, 90, 0, 0), 'mask = inside + overlapbdydisjoint') = 'true ';
Continent
---------------------------------------
North America
Australia