ST_Aggr_ConvexHull

ПримечаниеПримечание:

Только Oracle и SQLite

Определение

Функция ST_Aggr_ConvexHull создает одну геометрию, представляющую выпуклую оболочку геометрии, полученной при объединении всех входных геометрий. По результату функция ST_Aggr_ConvexHull эквивалентна функции ST_ConvexHull(ST_Aggr_Union(geometries)).

Синтаксис

Oracle

sde.st_aggr_convexhull (geometry sde.st_geometry)

SQLite

st_aggr_convexhull (geometry st_geometry)

Тип возврата

Oracle

ST_Geometry

SQLite

Geometryblob

Пример:

В этом примере создается таблица service_territories и выполняется инструкция SELECT, которая объединяет все геометрии, тем самым создавая единую геометрию, представляющую собой выпуклую оболочку, объединяющую все элементы.

Oracle

CREATE TABLE service_territories 
 (ID integer not null, UNITS number, SHAPE sde.st_geometry);

INSERT INTO service_territories (id, units, shape) VALUES (
 1, 
 1250, 
 sde.st_polygon ('polygon ((20 30, 30 30, 30 40, 20 40, 20 30))', 4326)
);
 
INSERT INTO service_territories (id, units, shape) VALUES (
 2, 
 875, 
 sde.st_polygon ('polygon ((30 30, 30 50, 50 50, 50 30, 30 30))', 4326)
);
 
INSERT INTO service_territories (id, units, shape) VALUES (
 3, 
 1700, 
 sde.st_polygon ('polygon ((40 40, 40 60, 60 60, 60 40, 40 40))', 4326)
);

SELECT sde.st_astext(sde.st_aggr_convexhull(shape)) CONVEX_HULL
 FROM service_territories 
 WHERE units >= 1000;

CONVEX_HULL

POLYGON  (( 20.00000000 40.00000000, 20.00000000 30.00000000, 30.00000000 30.00000000, 
60.00000000 40.00000000, 60.00000000 60.00000000, 40.00000000 60.00000000, 20.00000000 40.00000000))

SQLite

CREATE TABLE service_territories (
  ID integer primary key autoincrement not null, 
  UNITS numeric
);

SELECT AddGeometryColumn(
 NULL,
 'service_territories',
 'shape',
 4326,
 'polygon',
 'xy',
 'null'
);

INSERT INTO service_territories (units, shape) VALUES (
 1250, 
 st_polygon ('polygon ((20 30, 30 30, 30 40, 20 40, 20 30))', 4326)
);
 
INSERT INTO service_territories (units, shape) VALUES (
 875, 
 st_polygon ('polygon ((30 30, 30 50, 50 50, 50 30, 30 30))', 4326)
);
 
INSERT INTO service_territories (units, shape) VALUES (
 1700, 
 st_polygon ('polygon ((40 40, 40 60, 60 60, 60 40, 40 40))', 4326)
);

SELECT st_astext(st_aggr_convexhull(shape)) AS "CONVEX HULL"
 FROM service_territories 
 WHERE units >= 1000;

CONVEX HULL

POLYGON  (( 20.00000000 40.00000000, 20.00000000 30.00000000, 30.00000000 30.00000000, 
60.00000000 40.00000000, 60.00000000 60.00000000, 40.00000000 60.00000000, 20.00000000 40.00000000))

Связанные темы

5/25/2014