Go to content Go to navigation and search

Home

Current MySQL Spatial Blog Articles

    Spatial Functions for MySQL
    ST_Round for MySQL Spatial
    ST_Scale for MySQL Spatial
    ST_Rotate for MySQL Spatial
    ST_Move for MySQL Spatial

Search

    Browse

RSS / Atom

Email me

textpattern

Creative Commons License
All Blog Articles, Data Models and Free Source Code by Simon Greener, The SpatialDB Advisor is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

ST_Rotate for MySQL Spatial

Friday December 22 2017 at 10:32

Keywordsrotate geometry mysql spatial
Summary

A Rotate geometry function for MySQL.

A version of my Rotate function for SQL Server Spatial and Oracle Spatial is available for MySQL.

Function Declaration

  1. DELIMITER $$
  2. CREATE FUNCTION `ST_Rotate`
  3. (
  4.   p_geometry geometry,
  5.   p_X        DOUBLE,
  6.   p_Y        DOUBLE,
  7.   p_rotation DOUBLE,
  8.   p_round    INT
  9. )
  10. RETURNS geometry
  11. BEGIN
  12.   -- Processing
  13.   RETURN geometry;
  14. END;
  15. DELIMITER ;

Function Testing

  1. SELECT ST_AsText(ST_Rotate(ST_PointFromText('POINT(10 10)',0), 0.0, 0.0, 90, 1)) AS rotatedGeom;
  2. # rotatedGeom
  3. 'POINT(-10 10)'
  4. --
  5. SELECT ST_AsText(ST_Rotate(ST_GeomFromText('LINESTRING(0.1 0.2,1.4 45.2)',0),0.0,0.0,125,2)) AS rotatedGeom;
  6. # rotatedGeom
  7. 'LINESTRING(-0.14 -0.17,-1.95 -2.4)'
  8. --
  9. SELECT ST_AsText(ST_Rotate(ST_GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0))',0),0.0,0.0,300,2)) AS rotatedGeom;
  10. # rotatedGeom
  11. 'POLYGON((0 0,13.66 -6.83,13.66 -6.83,0 0,0 0))'

If you think this is of use to you, make a donation and I will release the code to you along with any other MySQL functions I have created.

Creative Commons License

post this at del.icio.uspost this at Diggpost this at Technoratipost this at Redditpost this at Farkpost this at Yahoo! my webpost this at Windows Livepost this at Google Bookmarkspost this to Twitter

Comment