-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supported STContains, STEquals, STArea PostGIS functions for Geospati…
…al datatypes (#2803) Implemented Some of the GeoSpatial datatypes like STContains, STEquals, STArea and STSrid. STSrid was important as it was important to cover the edge cases of STContains and STEquals as STContains or STEquals is performed with Geometry/Geography gives Null as per documentation but Was giving error in our case. So to check the SRID of the Object to cover the edge cases STSrid was implemented. Issues Resolved Task: BABEL-5101 Signed-off-by: yashneet vinayak <[email protected]> Co-authored-by: yashneet vinayak <[email protected]>
- Loading branch information
1 parent
f7aac56
commit 37a7838
Showing
15 changed files
with
2,647 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
contrib/babelfishpg_common/sql/upgrades/spatial_types--4.2.0--4.3.0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,147 @@ | ||
------------------------------------------------------- | ||
---- Include changes related to spatial types here ---- | ||
------------------------------------------------------- | ||
CREATE OR REPLACE FUNCTION sys.STArea(sys.GEOMETRY) | ||
RETURNS float8 | ||
AS '$libdir/postgis-3','ST_Area' | ||
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.STSrid(sys.GEOMETRY) | ||
RETURNS integer | ||
AS '$libdir/postgis-3','LWGEOM_get_srid' | ||
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.STEquals(geom1 sys.GEOMETRY, geom2 sys.GEOMETRY) | ||
RETURNS sys.BIT | ||
AS $$ | ||
BEGIN | ||
IF STSrid(geom1) != STSrid(geom2) THEN | ||
RETURN NULL; | ||
ELSE | ||
Return sys.STEquals_helper($1,$2); | ||
END IF; | ||
END; | ||
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.STContains(geom1 sys.GEOMETRY, geom2 sys.GEOMETRY) | ||
RETURNS sys.BIT | ||
AS $$ | ||
DECLARE | ||
BEGIN | ||
IF STSrid(geom1) != STSrid(geom2) THEN | ||
RETURN NULL; | ||
ELSE | ||
Return sys.STContains_helper($1,$2); | ||
END IF; | ||
END; | ||
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.ST_Equals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) | ||
RETURNS boolean | ||
AS $$ | ||
DECLARE | ||
Result integer; | ||
BEGIN | ||
Result := STEquals(leftarg,rightarg); | ||
IF Result IS NULL THEN | ||
RETURN false; | ||
END IF; | ||
RETURN Result; | ||
END; | ||
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.ST_NotEquals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) | ||
RETURNS boolean | ||
AS $$ | ||
DECLARE | ||
Result integer; | ||
BEGIN | ||
Result := STEquals(leftarg,rightarg); | ||
IF Result IS NULL THEN | ||
RETURN true; | ||
END IF; | ||
RETURN 1 - Result; | ||
END; | ||
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.STContains_helper(geom1 sys.GEOMETRY, geom2 sys.GEOMETRY) | ||
RETURNS sys.BIT | ||
AS '$libdir/postgis-3','within' | ||
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.STEquals_helper(geom1 sys.GEOMETRY, geom2 sys.GEOMETRY) | ||
RETURNS sys.BIT | ||
AS '$libdir/postgis-3','ST_Equals' | ||
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.STArea(sys.GEOGRAPHY) | ||
RETURNS float8 | ||
AS '$libdir/postgis-3','ST_Area' | ||
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.STSrid(sys.GEOGRAPHY) | ||
RETURNS integer | ||
AS '$libdir/postgis-3','LWGEOM_get_srid' | ||
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.STEquals(geom1 sys.GEOGRAPHY, geom2 sys.GEOGRAPHY) | ||
RETURNS sys.BIT | ||
AS $$ | ||
BEGIN | ||
IF STSrid(geom1) != STSrid(geom2) THEN | ||
RETURN NULL; | ||
ELSE | ||
Return sys.STEquals_helper($1,$2); | ||
END IF; | ||
END; | ||
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.STContains(geom1 sys.GEOGRAPHY, geom2 sys.GEOGRAPHY) | ||
RETURNS sys.BIT | ||
AS $$ | ||
BEGIN | ||
IF STSrid(geom1) != STSrid(geom2) THEN | ||
RETURN NULL; | ||
ELSE | ||
Return sys.STContains_helper($1,$2); | ||
END IF; | ||
END; | ||
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.ST_Equals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) | ||
RETURNS boolean | ||
AS $$ | ||
DECLARE | ||
Result integer; | ||
BEGIN | ||
Result := STEquals(leftarg,rightarg); | ||
IF Result IS NULL THEN | ||
RETURN false; | ||
END IF; | ||
RETURN Result; | ||
END; | ||
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.ST_NotEquals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) | ||
RETURNS boolean | ||
AS $$ | ||
DECLARE | ||
Result integer; | ||
BEGIN | ||
Result := STEquals(leftarg,rightarg); | ||
IF Result IS NULL THEN | ||
RETURN true; | ||
END IF; | ||
RETURN 1 - Result; | ||
END; | ||
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.STEquals_helper(geom1 sys.GEOGRAPHY, geom2 sys.GEOGRAPHY) | ||
RETURNS sys.BIT | ||
AS '$libdir/postgis-3','ST_Equals' | ||
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; | ||
|
||
CREATE OR REPLACE FUNCTION sys.STContains_helper(geom1 sys.GEOGRAPHY, geom2 sys.GEOGRAPHY) | ||
RETURNS sys.BIT | ||
AS '$libdir/postgis-3','within' | ||
LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; |
Oops, something went wrong.