Schema
Owner
postgres
Descriptions
There is no description for function _asgmlface
Options
Option | Value |
---|---|
Returns |
text |
Language |
|
Parameters |
toponame text face_id integer visitedtable pg_catalog.regclass nsprefix_in text prec integer options integer idprefix text gmlver integer |
Definition
CREATE OR REPLACE FUNCTION topology._asgmlface (
toponame text,
face_id integer,
visitedtable pg_catalog.regclass,
nsprefix_in text,
prec integer,
options integer,
idprefix text,
gmlver integer
)
RETURNS text AS
$span$
DECLARE
visited bool;
nsprefix text;
gml text;
rec RECORD;
rec2 RECORD;
bounds geometry;
BEGIN
nsprefix := 'gml:';
IF nsprefix_in IS NOT NULL THEN
IF nsprefix_in = '' THEN
nsprefix = nsprefix_in;
ELSE
nsprefix = nsprefix_in || ':';
END IF;
END IF;
gml := '<' || nsprefix || 'Face ' || nsprefix
|| 'id="' || idprefix || 'F' || face_id || '">';
-- Construct the face geometry, then for each polygon:
FOR rec IN SELECT (ST_DumpRings((ST_Dump(ST_ForceRHR(
topology.ST_GetFaceGeometry(toponame, face_id)))).geom)).geom
LOOP
-- Contents of a directed face are the list of edges
-- that cover the specific ring
bounds = ST_Boundary(rec.geom);
FOR rec2 IN EXECUTE
'SELECT e.*, ST_LineLocatePoint($1'
|| ', ST_LineInterpolatePoint(e.geom, 0.2)) as pos'
|| ', ST_LineLocatePoint($1'
|| ', ST_LineInterpolatePoint(e.geom, 0.8)) as pos2 FROM '
|| quote_ident(toponame)
|| '.edge e WHERE ( e.left_face = $2'
|| ' OR e.right_face = $2'
|| ') AND ST_Covers($1'
|| ', e.geom) ORDER BY pos'
USING bounds, face_id
LOOP
gml = gml || '<' || nsprefix || 'directedEdge';
-- if this edge goes in same direction to the
-- ring bounds, make it with negative orientation
IF rec2.pos2 > rec2.pos THEN -- edge goes in same direction
gml = gml || ' orientation="-"';
END IF;
-- Do visited bookkeeping if visitedTable was given
IF visitedTable IS NOT NULL THEN
EXECUTE 'SELECT true FROM '
|| visitedTable::text
|| ' WHERE element_type = 2 AND element_id = '
|| rec2.edge_id LIMIT 1 INTO visited;
IF visited THEN
-- Use xlink:href if visited
gml = gml || ' xlink:href="#' || idprefix || 'E'
|| rec2.edge_id || '" />';
CONTINUE;
ELSE
-- Mark as visited otherwise
EXECUTE 'INSERT INTO ' || visitedTable::text
|| '(element_type, element_id) VALUES (2, '
|| rec2.edge_id || ')';
END IF;
END IF;
gml = gml || '>';
gml = gml || topology._AsGMLEdge(rec2.edge_id, rec2.start_node,
rec2.end_node, rec2.geom,
visitedTable, nsprefix_in,
prec, options, idprefix, gmlver);
gml = gml || '</' || nsprefix || 'directedEdge>';
END LOOP;
END LOOP;
gml = gml || '</' || nsprefix || 'Face>';
RETURN gml;
END
$span$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;
This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 13/03/2014 13:23 |