generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 132
Add STLength support for geography and geometry types #4468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Gopalverma062
wants to merge
12
commits into
babelfish-for-postgresql:BABEL_5_X_DEV
Choose a base branch
from
Gopalverma062:BABEL_6310_STLENGTH
base: BABEL_5_X_DEV
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
09630f7
Add STLength support for geography and geometry types
9c5c286
Add missing test files for STLength spatial function
e855e8e
empty commit
9c5883f
Merge remote-tracking branch 'upstream/BABEL_5_X_DEV' into BABEL_6310…
3a998f5
updated code
82888f0
Fix CI: Add missing fi and enable PostGIS extension for spatial tests
22808fd
Fix precision and add STLength functions to upgrade validation
1aedcc3
Update
b82a16f
Update fix
7ddecc2
unnecessary change
15e1ca4
fix in testcases
8a6544d
fix changes in testcase
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
66 changes: 66 additions & 0 deletions
66
contrib/babelfishpg_common/sql/upgrades/spatial_types--5.5.0--5.6.0.sql
This file contains hidden or 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,69 @@ | ||
| ------------------------------------------------------- | ||
| ---- Include changes related to spatial types here ---- | ||
| ------------------------------------------------------- | ||
| -- STLength | ||
| CREATE OR REPLACE FUNCTION sys.STLength(geom sys.GEOMETRY) | ||
| RETURNS float8 | ||
| AS $$ | ||
| DECLARE | ||
| geom_type text; | ||
| BEGIN | ||
| IF sys.STIsEmpty(geom)=1 THEN | ||
| RETURN 0; | ||
| END IF; | ||
|
|
||
| geom_type := sys.ST_GeometryType(geom); | ||
| -- Polygon types - use ST_Perimeter (sum of all ring lengths) | ||
| IF geom_type IN ('ST_Polygon', 'ST_MultiPolygon') THEN | ||
| RETURN sys.STPerimeter_helper(geom); | ||
| ELSE | ||
| RETURN sys.STLength_helper(geom); | ||
| END IF; | ||
| END; | ||
| $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; | ||
|
|
||
| CREATE OR REPLACE FUNCTION sys.STLength_helper(geom sys.GEOMETRY) | ||
| RETURNS float8 | ||
| AS '$libdir/postgis-3', 'LWGEOM_length2d_linestring' | ||
| LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; | ||
|
|
||
| CREATE OR REPLACE FUNCTION sys.STPerimeter_helper(sys.GEOMETRY) | ||
| RETURNS float8 | ||
| AS '$libdir/postgis-3','LWGEOM_perimeter2d_poly' | ||
| LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; | ||
|
|
||
| CREATE OR REPLACE FUNCTION sys.STLength(geom sys.GEOGRAPHY) | ||
| RETURNS float8 | ||
| AS $$ | ||
| DECLARE | ||
| geom_type text; | ||
| BEGIN | ||
| -- EMPTY → 0 | ||
| IF sys.STIsEmpty(geom) = 1 THEN | ||
| RETURN 0; | ||
| END IF; | ||
|
|
||
| IF sys.STIsValid(geom) = 0 THEN | ||
| RAISE EXCEPTION 'The geography instance is not valid'; | ||
| END IF; | ||
| -- Get the geometry type | ||
| geom_type := sys.ST_GeometryType(geom); | ||
|
|
||
| -- Polygon types - use ST_Perimeter (sum of all ring lengths) | ||
| IF geom_type IN ('ST_Polygon', 'ST_MultiPolygon') THEN | ||
| RETURN sys.STPerimeter_helper(sys.Geography__STFlipCoordinates(geom)); | ||
| ELSE | ||
| RETURN sys.STLength_helper(sys.Geography__STFlipCoordinates(geom)); | ||
| END IF; | ||
| END; | ||
| $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; | ||
|
|
||
| CREATE OR REPLACE FUNCTION sys.STLength_helper(geom sys.GEOGRAPHY) | ||
| RETURNS float8 | ||
| AS '$libdir/postgis-3', 'geography_length' | ||
| LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; | ||
|
|
||
| CREATE OR REPLACE FUNCTION sys.STPerimeter_helper(geom sys.GEOGRAPHY) | ||
| RETURNS float8 | ||
| AS '$libdir/postgis-3', 'geography_perimeter' | ||
| LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we verified whether it is float4 or float8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes i have verified it