Professional Documents
Culture Documents
LDB Master Week 4 Spatial Indexing and Querying
LDB Master Week 4 Spatial Indexing and Querying
Large Databases
Week 6
Māra Pudāne
Mara.Pudane@rtu.lv
10.10.2023.
1
Geometry validation
3
General procedure
▪ Loading data
▪ Running
SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT or
SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT
▪ Use SDO_MIGRATE.TO_CURRENT to rectify geometry
according to current version
▪ Use SDO_UTIL.RECTIFY_GEOMETRY to fix geometries
▪ However, most work must be done manually
4
Checks type consistency and geometry
consisency
▪ For type consistency, the function checks
– It the SDO_GTYPE is valid
– If the SDO_ETYPE values are consistent with the SDO_GTYPE value
– If the SDO_ELEM_INFO_ARRAY has valid triplet values
▪ For geometry consistency, the function checks
– Polygons have at least four points, which includes the point that closes the poly
– Polygons are not self-crossing
– No two vertices on a line or polygon are the same
– Polygons are oriented correctly
– Points on an arc are not colinear
– Geometries are within the specified bounds of the applicable DIMINFO column value
– etc
10
Spatial data indexes
Space-oriented
indexing Data-oriented
indexing
Grid
R-tree
Quadtree
Etc.
etc.
▪ Tesselation rules:
– If an object completely covers a cell, that cell is said to be covered by the object.
– The extent of tessellation of each object depends primarily on the cells-per-object limit of
the spatial index. This limit defines the maximum number of cells that tessellation can
count per object.
– The deepest-cell rule exploits the fact that every lower-level cell belongs to the cell above
it. Therefore, only the deepest-level cells need to be recorded in the index,
minimizing the information that the index needs to store
12
The most common index
▪ B-trees, short for balanced
trees, are the most common
type of database index
▪ B-tree index is an ordered list
of values divided into ranges
20
Several perspectives
▪ One can query:
– Primary filter
– Secondary filter...
▪ ...and retrieve
– Topological information
– Information on geometries (such as area)
▪ Additionally:
– Querying the non-geometric data
21
Spatial query window
22
Data retrieval from the
primary filter
SDO_FILTER
(geometry1 SDO_GEOMETRY,
geometry2 SDO_GEOMETRY,
param VARCHAR2)
C.NUM C.TITLE
--------------------------------------
5 Geom 5
7 Geom 7
SELECT A.Title
FROM Layer_1 A, Layer_2 B
WHERE B.Title = ‘G1’ AND SDO_FILTER(A.Geometry,
B.Geometry) = 'TRUE';
28
Secondary filter methods
▪ SDO_JOIN: Performs a spatial join based on one or more topological relationships.
▪ SDO_NN: Determines the nearest neighbour geometries to a geometry.
▪ SDO_NN_DISTANCE: Returns the distance of an object returned by the SDO_NN
operator.
▪ SDO_RELATE: Determines whether or not two geometries interact in a specified way.
▪ SDO_WITHIN_DISTANCE: Determines if two geometries are within a specified distance
from one another.
+
More specific filters, such as SDO_EQUAL, etc.
30
Binary topological relationships
'mask=inside+touch'
SDO_ANYINTERACT(geometry1, geometry2);
SDO_WITHIN_DISTANCE
(geometry1 SDO_GEOMETRY,
aGeom SDO_GEOMETRY,
params VARCHAR2);
SDO_NN
(geometry1 SDO_GEOMETRY,
geometry2 SDO_GEOMETRY,
param VARCHAR2 [, number NUMBER]);
43
SDO_GEOM functions
44
Operations
▪ Relationship (True/False) between two objects: RELATE,
WITHIN_DISTANCE
▪ Validation: VALIDATE_GEOMETRY_WITH_CONTEXT,
VALIDATE_LAYER_WITH_CONTEXT
▪ Single-object operations: SDO_ALPHA_SHAPE,
SDO_ARC_DENSIFY, SDO_AREA, SDO_BUFFER,
SDO_CENTROID, SDO_CONVEXHULL, SDO_CONCAVEHULL,
SDO_CONCAVEHULL_BOUNDARY, SDO_LENGTH,
SDO_MAX_MBR_ORDINATE, SDO_MIN_MBR_ORDINATE,
SDO_MBR, SDO_POINTONSURFACE, SDO_TRIANGULATE,
SDO_VOLUME
▪ Two-object operations: SDO_CLOSEST_POINTS, SDO_DISTANCE,
SDO_DIFFERENCE, SDO_INTERSECTION, SDO_UNION,
SDO_XOR
45
SDO_GEOM.SDO_AREA
51
Geometry validation in a tool
52
Simple visualization
60