A NURBS (non-uniform rational B-spline) curve allows the representation of free-form shapes with arbitrary shapes. NURBS representation allows control over the shape of the curve because control points and knots guide the shape of the curve, and they allow complex shapes to be represented with little data. For an explanation of NURBS curves and the requirements for defining a NURBS curve geometry, see NURBS Curve Support in Oracle Spatial and Graph.
Example 2-15 shows a SQL statement that inserts a NURBS curve geometry into the database.
In the SDO_GEOMETRY definition of the geometry illustrated in Example 2-15:
SDO_GTYPE = 2002. The first 2 indicates two-dimensional, and the second 2
indicates a single line string.
SDO_SRID = NULL. Note that geodetic NURBS curves are not permitted in Oracle Spatial and Graph.
SDO_POINT = NULL.
SDO_ELEM_INFO_ARRAY = (1,2,3). The SDO_INTERPRETATION value of 3 indicates a NURBS curve.
In the SDO_ORDINATE_ARRAY, 3 is the degree of the NURBS curve, 7 is the number of weighted control points, and 11 in the number of knot values.
Example 2-15 SQL Statement to Insert a NURBS Curve Geometry
CREATE TABLE nurbs_test (gid integer, geom sdo_geometry); INSERT INTO nurbs_test values( 1, SDO_GEOMETRY( 2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 3), /* Element type 2 = SDO_ETYPE_CURVE and Interpretation value 3 = NURBS curve */ SDO_ORDINATE_ARRAY (3, /* Degree of the NURBS curve */ 7, /* Number of weighted Control Points */ 0, 0, 1, /* x1, y1, w1 where w1 denotes the weight of the control point and x1, y1 are weighted values. Implies the actual coordinate values have been multiplied by w1 */ -0.5, 1, 1, 0.2, 2, 1, 0.5, 3.5, 1, 0.8, 2, 1, 0.9, 1, 1, 0.3, 0, 1, 11, /* Number of knot values = Number of control points + degree + 1 */ 0, 0, 0, 0, 0.25, 0.5, 0.75, 1.0, 1.0, 1.0, 1.0))); /* Normalized knot vector; values start at zero and end at 1. Clamped at end points as multiplicity of zero and one is 4, which is equal to the degree of the curve + 1 */
Example 2-16 SQL Statement to Insert a NURBS Compound Curve Geometry
Example 2-16 shows the insertion of a compound curve geometry that has a NURBS segment. It uses the same NURBS_TEST table created in Example 2-15 .
INSERT INTO nurbs_test VALUES( 1, SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 4, 2, 1, 2, 1, 5, 2, 3), SDO_ORDINATE_ARRAY(-1, -1, 0, 0, 3, 7, 0, 0, 1, -0.5, 1, 1, 0.2, 2, 1, 0.5, 3.5, 1, 0.8, 2, 1, 0.9, 1, 1, 0.3, 0, 1, 11, 0, 0, 0, 0, 0.25, 0.5, 0.75, 1.0, 1.0, 1.0, 1.0) ));
In the SDO_GEOMETRY definition of the geometry illustrated in Example 2-16:
SDO_GTYPE = 2002. The first 2 indicates two-dimensional, and the second 2
indicates a single line string.
SDO_SRID = NULL. Note that geodetic NURBS curves are not permitted in Oracle Spatial and Graph.
SDO_POINT = NULL.
SDO_ELEM_INFO_ARRAY = (1, 4, 2, 1, 2, 1, 5, 2, 3). The first triplet indicates a compound line string (interpretation = 4) with two elements. The next two triplets define the segments of the compound line string: the first segment is a line string beginning at offset 1; the second segment is a NURBS segment beginning at offset 5.
In the SDO_ORDINATE_ARRAY, the first 4 values define the first segment, which is a simple line string. For compound line strings containing at least one NURBS segment, the common vertices will be repeated across segments. In this example, the last point of the line string (0,0) must be equal to the first "clamped" point of the NURBS curve (0,0). The NURBS segment is defined beginning at offset 5 and the first control point is (0,0), which follows the degree (3) and the number of control points (7). The NURBS segment has 11 knot values.