Ticket #207 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

ST_Buffer with style options for partial buffer

Reported by: robe Owned by: strk
Priority: medium Milestone: PostGIS 1.5.0
Component: postgis Version: trunk
Keywords: Cc:

Description

This is to support partial buffers.

As of #r4198.

Requires postgis_upgrade.sql or segfaults are around the corner (old SQL signature points to a now changed C version now interpreting 3rd arg as cstring rather than numeric).

postgis_upgrade.sql in turn will fail due to those types... So you'll need to manually drop CREATE TYPE statements from it.

When that's all done, any old code using buffer() should still work fine, but in addition you should now be able to specify parameters as key=value pairs separated by space. Supported params:

endcap=round|flat|square join=round|mitre|bevel mitre_limit=<float> (only makes sense with join=mitre) quad_segs=<int>

Tests welcome. Comments on the naming are also welcome before I move on to automated testing and documentation.

Change History

Changed 3 years ago by robe

Strk, I noticed you are not using dollar quoting.

Since we will not have anything less than 8.2, we should try to use the $$ quoting syntax. Easier to read. So

CREATE OR REPLACE FUNCTION ST_buffer(geometry,float8,integer)

RETURNS geometry AS $$

SELECT _ST_Buffer($1, $2,

CAST('quad_segs='CAST($3 AS text) as cstring))

$$

LANGUAGE 'SQL' IMMUTABLE STRICT;

Changed 3 years ago by robe

  • owner changed from pramsey to strk

Forgot to put in code block also reassigned

CREATE OR REPLACE FUNCTION ST_buffer(geometry,float8,integer)

    RETURNS geometry AS $$

SELECT _ST_Buffer($1, $2,

    CAST('quad_segs='CAST($3 AS text) as cstring))

$$

    LANGUAGE 'SQL' IMMUTABLE STRICT;

Changed 3 years ago by robe

Hmm let me tr again

CREATE OR REPLACE FUNCTION ST_buffer(geometry,float8,integer)
	RETURNS geometry
	AS $$ SELECT _ST_Buffer($1, $2,
		CAST('quad_segs=' || CAST($3 AS text) as cstring))
           $$
	LANGUAGE 'SQL' IMMUTABLE STRICT; 






Changed 3 years ago by mcayland

Yes - strk, please convert to $$ quoting as it is much easier to work with. Do we need to update the style guide at http://trac.osgeo.org/postgis/browser/trunk/STYLE to reflect this? It seems reasonably obvious looking at the rest of the file...

ATB,

Mark.

Changed 3 years ago by strk

r4199 uses $$ quoting.

Changed 3 years ago by mcayland

Looks good to me on a quick visual inspection; thanks strk. I'll let robe test before we close this...

ATB,

Mark.

Changed 3 years ago by mcayland

Actually I've just noticed that you forgot to update the uninstall script:

postgis/uninstall_postgis.sql.in.c

Could you add the relevant DROP FUNCTION statements to this file as well please?

ATB,

Mark.

Changed 3 years ago by strk

Done in r4207.

Changed 3 years ago by strk

Can this be closed now Robe ?

Changed 3 years ago by robe

Not sure. That is one thing I didn't touch since I've been so busy with 1.4 haven't really moved on too compiling 1.5. So I suspect this can not be closed.

Changed 3 years ago by robe

  • status changed from new to closed
  • resolution set to fixed

Ah never mind I misread this. Yah this is all done.

Note: See TracTickets for help on using tickets.