-
Notifications
You must be signed in to change notification settings - Fork 3
fix(tsql): add GEOGRAPHY/GEOMETRY static method support #56
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
Merged
Merged
Changes from 2 commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| -- Spatial Static Method Test Cases | ||
| -- Testing GEOGRAPHY::method() and GEOMETRY::method() static method calls | ||
|
|
||
| -- Basic geography static methods | ||
| SELECT geography::STGeomFromText('POINT(1 2)', 4326); | ||
| SELECT geography::STPointFromText('POINT(-122.34900 47.65100)', 4326); | ||
| SELECT geography::STLineFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326); | ||
| SELECT geography::STPolyFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326); | ||
| SELECT geography::Point(47.65100, -122.34900, 4326); | ||
| SELECT geography::Parse('POINT(-122.34900 47.65100)'); | ||
|
|
||
| -- Basic geometry static methods | ||
| SELECT geometry::STGeomFromText('POINT(1 2)', 0); | ||
| SELECT geometry::STGeomFromText('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))', 0); | ||
| SELECT geometry::STPointFromText('POINT(3 4)', 0); | ||
| SELECT geometry::STLineFromText('LINESTRING(0 0, 1 1, 2 1, 2 2)', 0); | ||
| SELECT geometry::STPolyFromText('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))', 0); | ||
| SELECT geometry::Parse('LINESTRING(0 0, 1 1)'); | ||
| SELECT geometry::STGeomFromWKB(0x0101000000000000000000F03F0000000000000040, 0); | ||
|
|
||
| -- Multi-geometry methods | ||
| SELECT geometry::STMPointFromText('MULTIPOINT((1 1), (2 2), (3 3))', 0); | ||
| SELECT geometry::STMLineFromText('MULTILINESTRING((0 0, 1 1), (2 2, 3 3))', 0); | ||
| SELECT geometry::STMPolyFromText('MULTIPOLYGON(((0 0, 1 0, 1 1, 0 1, 0 0)), ((2 2, 3 2, 3 3, 2 3, 2 2)))', 0); | ||
| SELECT geometry::STGeomCollFromText('GEOMETRYCOLLECTION(POINT(1 1), LINESTRING(0 0, 1 1))', 0); | ||
|
|
||
| -- Spatial methods in variable assignments | ||
| DECLARE @g geography = geography::STGeomFromText('POINT(1 2)', 4326); | ||
| DECLARE @point geometry = geometry::Point(3, 4, 0); | ||
|
|
||
| -- Spatial methods in INSERT statements | ||
| INSERT INTO GeoTable (Location) VALUES (geography::STGeomFromText('POINT(-122.34900 47.65100)', 4326)); | ||
| INSERT INTO GeoTable (Shape) VALUES (geometry::STGeomFromText('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))', 0)); | ||
|
|
||
| -- Spatial methods in UPDATE statements | ||
| UPDATE GeoTable SET Location = geography::STGeomFromText('POINT(-122.35 47.65)', 4326) WHERE ID = 1; | ||
| UPDATE GeoTable SET Shape = geometry::Parse('POINT(5 5)') WHERE ID = 2; | ||
|
|
||
| -- Multiple spatial calls in single statement | ||
| SELECT | ||
| geography::Point(47.65, -122.35, 4326) AS Point1, | ||
| geography::Point(47.66, -122.36, 4326) AS Point2, | ||
| geometry::STGeomFromText('POINT(0 0)', 0) AS Origin; | ||
|
|
||
| -- Spatial methods in expressions | ||
| SELECT 1 WHERE geography::STGeomFromText('POINT(1 2)', 4326) IS NOT NULL; | ||
|
|
||
| -- Spatial methods in CASE expressions | ||
| SELECT CASE WHEN 1=1 THEN geography::Point(1, 2, 4326) ELSE geography::Point(0, 0, 4326) END; | ||
|
|
||
| -- Spatial methods with variables | ||
| DECLARE @lat float = 47.65; | ||
| DECLARE @lon float = -122.35; | ||
| DECLARE @srid int = 4326; | ||
| SELECT geography::Point(@lat, @lon, @srid); | ||
|
|
||
| -- Spatial methods in subqueries | ||
| SELECT * FROM (SELECT geography::Point(1, 2, 4326) AS Location) AS sub; | ||
|
|
||
| -- Spatial methods with column references in function arguments | ||
| SELECT geography::STGeomFromText(WKTColumn, SRIDColumn) FROM GeoTable; |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.