[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0-465-gbb68502dc

git at osgeo.org git at osgeo.org
Wed Feb 2 14:02:10 PST 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  bb68502dccd855b78c46eea6b4c1b02136275afd (commit)
      from  ef7cf315d1819536dbb374e535a264dd2b25f232 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit bb68502dccd855b78c46eea6b4c1b02136275afd
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Feb 2 14:01:48 2022 -0800

    Reduce the number of function parameters and recommend use of scale/translate for the st_letters function.

diff --git a/doc/reference_constructor.xml b/doc/reference_constructor.xml
index 5daa9d598..ac561142a 100644
--- a/doc/reference_constructor.xml
+++ b/doc/reference_constructor.xml
@@ -1210,8 +1210,6 @@ FROM admin0 WHERE name = 'Canada'
           <funcprototype>
             <funcdef>geometry <function>ST_Letters</function></funcdef>
             <paramdef><type>text</type> <parameter> letters</parameter></paramdef>
-            <paramdef choice="opt"><type>double precision</type> <parameter> text_height=100.0</parameter></paramdef>
-            <paramdef choice="opt"><type>geometry</type> <parameter> start_position=POINT(0 0)</parameter></paramdef>
             <paramdef choice="opt"><type>json</type> <parameter> font</parameter></paramdef>
           </funcprototype>
          </funcsynopsis>
@@ -1223,6 +1221,8 @@ FROM admin0 WHERE name = 'Canada'
             <para>Uses a built-in font to render out a string as a multipolygon geometry. The default text height is 100.0, the distance from the bottom of a descender to the top of a capital. The default start position places the start of the baseline at the origin. Over-riding the font involves passing in a json map, with a character as the key, and base64 encoded TWKB for the font shape, with the fonts having a height of 1000 units from the bottom of the descenders to the tops of the capitals.
             </para>
 
+            <para>The text is generated at the origin by default, so to reposition and resize the text, first apply the <code>ST_Scale</code> function and then apply the <code>ST_Translate</code> function.
+
             <para>Availability: 3.3.0</para>
         </refsection>
 
@@ -1238,9 +1238,13 @@ FROM admin0 WHERE name = 'Canada'
             </mediaobject>
             </informalfigure>
         </refsection>
+        <refsection>
+            <title>Example: Scaling and moving words</title>
+            <programlisting>SELECT ST_Translate(ST_Scale(ST_Letters('Yo'), 10, 10), 100,100);</programlisting>
+        </refsection>
         <refsection>
             <title>See Also</title>
-            <para><xref linkend="ST_AsTWKB" /></para>
+            <para><xref linkend="ST_AsTWKB" />, <xref linkend="ST_Scale" />, <xref linkend="ST_Translate" /></para>
         </refsection>
     </refentry>
 
diff --git a/postgis/postgis_letters.sql b/postgis/postgis_letters.sql
index c8d66f944..da57f9edb 100644
--- a/postgis/postgis_letters.sql
+++ b/postgis/postgis_letters.sql
@@ -1,4 +1,4 @@
-CREATE OR REPLACE FUNCTION ST_Letters(letters text, text_height double precision DEFAULT 100, start_position geometry DEFAULT 'POINT(0 0)', font json DEFAULT NULL)
+CREATE OR REPLACE FUNCTION ST_Letters(letters text, font json DEFAULT NULL)
 RETURNS geometry
 AS
 $$
@@ -9,6 +9,7 @@ DECLARE
   prevgeom geometry = NULL;
   adjustment float8 = 0.0;
   position float8 = 0.0;
+  text_height float8 = 100.0;
   width float8;
   m_width float8;
   spacing float8;
@@ -138,9 +139,9 @@ BEGIN
   END LOOP;
   -- apply the start point and scaling options
   wordgeom := ST_CollectionExtract(ST_Collect(wordarr));
-  wordgeom := ST_Translate(ST_Scale(wordgeom, 
-                text_height/font_default_height, text_height/font_default_height),
-                ST_XMin(start_position), ST_YMin(start_position));
+  wordgeom := ST_Scale(wordgeom,
+                text_height/font_default_height,
+                text_height/font_default_height);
   return wordgeom;
 END;
 $$

-----------------------------------------------------------------------

Summary of changes:
 doc/reference_constructor.xml | 10 +++++++---
 postgis/postgis_letters.sql   |  9 +++++----
 2 files changed, 12 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list