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_Move for MySQL Spatial

Friday December 22 2017 at 10:10

Keywordsmove geometry mysql spatial
Summary

Move function for MySQL Spatial

A version of my Move functions for SQL Server Spatial and Oracle Spatial is available.

Function Declaration

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

Function Testing

  1. SELECT ST_AsText(ST_Move(ST_PointFromText('POINT(0 0)',0), -5.0, 30.1, 1)) AS movedGeom;
  2. # movedGeom
  3. 'POINT(-5 -5)'
  4. --
  5. SELECT ST_AsText(ST_Move(ST_GeomFromText('LINESTRING(0.1 0.2,1.4 45.2)',0),-5.0,30.1, 1)) AS movedGeom;
  6. # movedGeom
  7. 'LINESTRING(-4.9 30.2,-3.6 31.5)'
  8. --
  9. SELECT ST_AsText(ST_Move(ST_GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0))',0),-5.0,30.1, 2)) AS movedGeom;
  10. # movedGeom
  11. 'POLYGON((-5 30.1,5 40.1,5 40.1,-5 30.1,-5 30.1))'

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