[postgis-tickets] [PostGIS] #472: Missing ST_IsValid for Geography Types
PostGIS
trac at osgeo.org
Thu Feb 4 02:43:28 PST 2021
#472: Missing ST_IsValid for Geography Types
--------------------------+-----------------------------
Reporter: rfcmedia | Owner: pramsey
Type: enhancement | Status: new
Priority: medium | Milestone: PostGIS Fund Me
Component: postgis | Version: master
Resolution: | Keywords:
--------------------------+-----------------------------
Comment (by mschott):
This is how I handle geography validity atm. Being aware that this may be
resource intensive and that it may still fail e.g. if the object was
projected in an st_intersect (where the best_srid is created for both
objects together, afaik) with the respective documentation this might
actually help some users. Be aware though that casting between geog and
geom may introduce errors at a later stage. E.g. st_difference on two
valid geoms casted to geog may produce invalid geogs when the resulting
geom is casted back.
{{{
CREATE OR REPLACE FUNCTION {checkValidGeogFunc}(geography) RETURNS boolean
AS 'SELECT
st_isvalid(
ST_transform(
$1::geometry,
_ST_bestsrid($1)
)
);'
LANGUAGE SQL
IMMUTABLE
RETURNS NULL ON NULL INPUT;
CREATE OR REPLACE FUNCTION {validateGeogFunc}(geography) RETURNS geography
AS 'SELECT
ST_transform(
st_multi(
st_collectionextract(
st_makevalid(
ST_transform(
$1::geometry,
_ST_bestsrid($1)
)
),
3
)
),
4326
)::geography;'
LANGUAGE SQL
IMMUTABLE
RETURNS NULL ON NULL INPUT;
}}}
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/472#comment:5>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list