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

Friday December 22 2017 at 17:25

Keywordsscale mysql geometry function
Summary

A scaling function for MySQL geometry objects.

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

Function Declaration

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

Function Testing

  1. -- Point
  2. SELECT ST_AsText(ST_Scale(ST_PointFromText('POINT(0 1)',0), 5.0, 3.1, 2)) AS scaledGeom;
  3. # scaledGeom
  4. 'POINT(0 3.1)'
  5. -- Linestring
  6. SELECT ST_AsText(ST_Scale(ST_GeomFromText('LINESTRING(0.1 0.2,1.4 45.2)',0),-5.0,3.2, 3)) AS scaledGeom;
  7. # scaledGeom
  8. 'LINESTRING(-0.5 0.32,-7 4.48)'
  9. -- Polygon
  10. SELECT ST_AsText(ST_Scale(ST_GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0))',0),-5.0,30.1, 3)) AS scaledGeom;
  11. # scaledGeom
  12. 'POLYGON((-0 0,-50 301,-50 301,-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