ST_IsValidDetail — 返回一个 valid_detail
行,指示几何图形是否有效,如果无效,则提供原因和位置。
valid_detail ST_IsValidDetail(
geometry geom, integer flags)
;
返回一个 valid_detail
行,包含一个布尔值 (valid
),指示几何图形是否有效,一个 varchar (reason
),说明无效的原因,以及一个几何图形 (location
),指出无效的位置。
有助于改进 ST_IsValid 和 ST_IsValidReason 的组合,以生成有关无效几何图形的详细报告。
可选的 flags
参数是一个位域。它可以具有以下值
0:使用通常的 OGC SFS 有效性语义。
1:将某些类型的自相交环(反向外壳和反向孔)视为有效。这也称为“ESRI 标志”,因为这是这些工具使用的有效性模型。请注意,这在 OGC 模型下是无效的。
由 GEOS 模块执行。
可用性:2.0.0
--First 3 Rejects from a successful quintuplet experiment SELECT gid, reason(ST_IsValidDetail(geom)), ST_AsText(location(ST_IsValidDetail(geom))) as location FROM (SELECT ST_MakePolygon(ST_ExteriorRing(e.buff), array_agg(f.line)) As geom, gid FROM (SELECT ST_Buffer(ST_Point(x1*10,y1), z1) As buff, x1*10 + y1*100 + z1*1000 As gid FROM generate_series(-4,6) x1 CROSS JOIN generate_series(2,5) y1 CROSS JOIN generate_series(1,8) z1 WHERE x1 > y1*0.5 AND z1 < x1*y1) As e INNER JOIN (SELECT ST_Translate(ST_ExteriorRing(ST_Buffer(ST_Point(x1*10,y1), z1)),y1*1, z1*2) As line FROM generate_series(-3,6) x1 CROSS JOIN generate_series(2,5) y1 CROSS JOIN generate_series(1,10) z1 WHERE x1 > y1*0.75 AND z1 < x1*y1) As f ON (ST_Area(e.buff) > 78 AND ST_Contains(e.buff, f.line)) GROUP BY gid, e.buff) As quintuplet_experiment WHERE ST_IsValid(geom) = false ORDER BY gid LIMIT 3; gid | reason | location ------+-------------------+------------- 5330 | Self-intersection | POINT(32 5) 5340 | Self-intersection | POINT(42 5) 5350 | Self-intersection | POINT(52 5) --simple example SELECT * FROM ST_IsValidDetail('LINESTRING(220227 150406,2220227 150407,222020 150410)'); valid | reason | location -------+--------+---------- t | |