* Deprecated signatures *
* New Features *
+ - TopoGeom_addElement, TopoGeom_remElement (Sando Santilli)
+
PostGIS 2.2.0
2015/10/07
<para>
<xref linkend="GetTopoGeomElements"/>,
<xref linkend="topoelementarray" />,
- <xref linkend="topogeometry" />
+ <xref linkend="topogeometry" />,
+ <xref linkend="TopoGeom_addElement" />,
+ <xref linkend="TopoGeom_remElement" />
</para>
</refsection>
</refentry>
</refsection>
</refentry>
+ <refentry id="TopoGeom_addElement">
+ <refnamediv>
+ <refname>TopoGeom_addElement</refname>
+ <refpurpose>Add an element to the definition of a TopoGeometry</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>topogeometry <function>TopoGeom_addElement</function></funcdef>
+ <paramdef><type>topogeometry </type> <parameter>tg</parameter></paramdef>
+ <paramdef><type>topoelement </type> <parameter>el</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ </refsynopsisdiv>
+
+ <refsection>
+ <title>Description</title>
+
+ <para>
+Adds a <xref linkend="topoelement" /> to the definition of a
+TopoGeometry object. Does not error out if the element is already
+part of the definition.
+ </para>
+
+ <!-- use this format if new function -->
+ <para>Availability: 2.3</para>
+ </refsection>
+ <refsection>
+ <title>Examples</title>
+ <programlisting>
+-- Add edge 5 to TopoGeometry tg
+UPDATE mylayer SET tg = TopoGeom_addElement(tg, '{5,2}');
+ </programlisting>
+ </refsection>
+
+ <!-- Optionally add a "See Also" section -->
+ <refsection>
+ <title>See Also</title>
+ <para>
+<xref linkend="TopoGeom_remElement" />,
+<xref linkend="CreateTopoGeom" />
+ </para>
+ </refsection>
+ </refentry>
+
+ <refentry id="TopoGeom_remElement">
+ <refnamediv>
+ <refname>TopoGeom_remElement</refname>
+
+ <refpurpose>Remove an element from the definition of a TopoGeometry</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>topogeometry <function>TopoGeom_remElement</function></funcdef>
+ <paramdef><type>topogeometry </type> <parameter>tg</parameter></paramdef>
+ <paramdef><type>topoelement </type> <parameter>el</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ </refsynopsisdiv>
+
+ <refsection>
+ <title>Description</title>
+
+ <para>
+Removes a <xref linkend="topoelement" /> from the definition of a
+TopoGeometry object.
+ </para>
+
+ <!-- use this format if new function -->
+ <para>Availability: 2.3</para>
+ </refsection>
+ <refsection>
+ <title>Examples</title>
+ <programlisting>
+-- Remove face 43 from TopoGeometry tg
+UPDATE mylayer SET tg = TopoGeom_remElement(tg, '{43,3}');
+ </programlisting>
+ </refsection>
+
+ <!-- Optionally add a "See Also" section -->
+ <refsection>
+ <title>See Also</title>
+ <para>
+<xref linkend="TopoGeom_addElement" />,
+<xref linkend="CreateTopoGeom" />
+ </para>
+ </refsection>
+ </refentry>
+
<refentry id="toTopoGeom_editor_proxy">
<refnamediv>
<refname>toTopoGeom</refname>
<para>tg_id is the topogeometry id of the topogeometry object in the topology in the layer denoted by <varname>layer_id</varname> in the topology.layer table.</para>
<!-- use this format if new function -->
- <para>Availability: 1.?</para>
+ <para>Availability: 2.0.0</para>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
- <para><xref linkend="GetTopoGeomElementArray"/>, <xref linkend="topoelement"/></para>
+ <para>
+ <xref linkend="GetTopoGeomElementArray"/>,
+ <xref linkend="topoelement"/>,
+ <xref linkend="TopoGeom_addElement" />,
+ <xref linkend="TopoGeom_remElement" />
+ </para>
</refsection>
</refentry>
topology_upgrade.sql: topology_drop_before.sql topology_upgrade.sql.in topology_drop_after.sql
cat $^ > $@
-topology.sql: sql/sqlmm.sql.in sql/populate.sql.in sql/polygonize.sql.in sql/export/gml.sql.in sql/export/TopoJSON.sql.in sql/query/getnodebypoint.sql.in sql/query/getedgebypoint.sql.in sql/query/getfacebypoint.sql.in sql/query/GetRingEdges.sql.in sql/query/GetNodeEdges.sql.in sql/manage/TopologySummary.sql.in sql/manage/CopyTopology.sql.in sql/manage/ManageHelper.sql.in sql/topoelement/topoelement_agg.sql.in sql/topogeometry/type.sql.in sql/topogeometry/totopogeom.sql.in sql/topogeometry/cleartopogeom.sql.in sql/topogeometry/simplify.sql.in sql/predicates.sql.in ../postgis/sqldefines.h ../postgis_svn_revision.h
+topology.sql: \
+ sql/sqlmm.sql.in \
+ sql/populate.sql.in \
+ sql/polygonize.sql.in \
+ sql/export/gml.sql.in \
+ sql/export/TopoJSON.sql.in \
+ sql/query/getnodebypoint.sql.in \
+ sql/query/getedgebypoint.sql.in \
+ sql/query/getfacebypoint.sql.in \
+ sql/query/GetRingEdges.sql.in \
+ sql/query/GetNodeEdges.sql.in \
+ sql/manage/TopologySummary.sql.in \
+ sql/manage/CopyTopology.sql.in \
+ sql/manage/ManageHelper.sql.in \
+ sql/topoelement/topoelement_agg.sql.in \
+ sql/topogeometry/type.sql.in \
+ sql/topogeometry/totopogeom.sql.in \
+ sql/topogeometry/cleartopogeom.sql.in \
+ sql/topogeometry/topogeom_edit.sql.in \
+ sql/topogeometry/simplify.sql.in \
+ sql/predicates.sql.in \
+ ../postgis/sqldefines.h \
+ ../postgis_svn_revision.h
uninstall_topology.sql: topology.sql ../utils/create_undef.pl
$(PERL) ../utils/create_undef.pl $< $(POSTGIS_PGSQL_VERSION) > $@
--- /dev/null
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+--
+-- PostGIS - Spatial Types for PostgreSQL
+-- http://postgis.net
+--
+-- Copyright (C) 2015 Sandro Santilli <strk@keybit.net>
+--
+-- This is free software; you can redistribute and/or modify it under
+-- the terms of the GNU General Public Licence. See the COPYING file.
+--
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+/* #define POSTGIS_TOPOLOGY_DEBUG 1 */
+
+-- {
+-- Add an element to a TopoGeometry definition
+--
+-- }{
+CREATE OR REPLACE FUNCTION topology.TopoGeom_addElement(tg topology.TopoGeometry, el topology.TopoElement)
+ RETURNS topology.TopoGeometry
+AS
+$$
+DECLARE
+ toponame TEXT;
+ sql TEXT;
+BEGIN
+
+ -- Get topology name
+ BEGIN
+ SELECT name
+ FROM topology.topology
+ INTO STRICT toponame WHERE id = topology_id(tg);
+ EXCEPTION
+ WHEN NO_DATA_FOUND THEN
+ RAISE EXCEPTION 'No topology with name "%" in topology.topology',
+ atopology;
+ END;
+
+ -- Insert new element
+ sql := format('INSERT INTO %s.relation'
+ '(topogeo_id,layer_id,element_id,element_type)'
+ ' VALUES($1,$2,$3,$4)', quote_ident(toponame));
+ BEGIN
+ EXECUTE sql USING id(tg), layer_id(tg), el[1], el[2];
+ EXCEPTION
+ WHEN unique_violation THEN
+ -- already present, let go
+ WHEN OTHERS THEN
+ RAISE EXCEPTION 'Got % (%)', SQLERRM, SQLSTATE;
+ END;
+
+ RETURN tg;
+
+END
+$$
+LANGUAGE 'plpgsql' VOLATILE STRICT;
+-- }
+
+-- {
+-- Remove an element from a TopoGeometry definition
+--
+-- }{
+CREATE OR REPLACE FUNCTION topology.TopoGeom_remElement(tg topology.TopoGeometry, el topology.TopoElement)
+ RETURNS topology.TopoGeometry
+AS
+$$
+DECLARE
+ toponame TEXT;
+ sql TEXT;
+BEGIN
+
+ -- Get topology name
+ BEGIN
+ SELECT name
+ FROM topology.topology
+ INTO STRICT toponame WHERE id = topology_id(tg);
+ EXCEPTION
+ WHEN NO_DATA_FOUND THEN
+ RAISE EXCEPTION 'No topology with name "%" in topology.topology',
+ atopology;
+ END;
+
+ -- Delete the element
+ sql := format('DELETE FROM %s.relation WHERE '
+ 'topogeo_id = $1 AND layer_id = $2 AND '
+ 'element_id = $3 AND element_type = $4',
+ quote_ident(toponame));
+ EXECUTE sql USING id(tg), layer_id(tg), el[1], el[2];
+
+ RETURN tg;
+
+END
+$$
+LANGUAGE 'plpgsql' VOLATILE STRICT;
+-- }
regress/topogeo_addlinestring.sql \
regress/topogeo_addpoint.sql \
regress/topogeo_addpolygon.sql \
+ regress/topogeom_edit.sql \
regress/topogeometry_type.sql \
regress/topojson.sql \
regress/topologysummary.sql \
--- /dev/null
+\set VERBOSITY terse
+set client_min_messages to ERROR;
+
+select 'create', createtopology('tt') > 0;
+
+-- Create a line layer (will be layer 1)
+CREATE TABLE tt.f_line(id serial);
+SELECT 'simple_line_layer', AddTopoGeometryColumn('tt', 'tt', 'f_line','g','LINE');
+
+INSERT INTO tt.f_line (g) VALUES
+ ( toTopoGeom('LINESTRING(0 0, 10 0)'::geometry, 'tt', 1) );
+INSERT INTO tt.f_line (g) VALUES
+ ( toTopoGeom('LINESTRING(10 0, 30 0)'::geometry, 'tt', 1) );
+
+-- Sane calls
+SELECT id, 'start', id, ST_Length(g) FROM tt.f_line WHERE id = 1;
+SELECT id, 'add', id, ST_Length(TopoGeom_addElement(g, '{2,2}')) FROM tt.f_line WHERE id = 1;
+SELECT id, 'rem', id, ST_Length(TopoGeom_remElement(g, '{1,2}')) FROM tt.f_line WHERE id = 1;
+SELECT id, 'dup', id, ST_Length(TopoGeom_addElement(g, '{2,2}')) FROM tt.f_line WHERE id = 1;
+SELECT id, 'mis', id, ST_Length(TopoGeom_remElement(g, '{1,2}')) FROM tt.f_line WHERE id = 1;
+
+
+DROP TABLE tt.f_line;
+select droptopology('tt');
--- /dev/null
+create|t
+simple_line_layer|1
+1|start|1|10
+1|add|1|30
+1|rem|1|20
+1|dup|1|20
+1|mis|1|20
+Topology 'tt' dropped
#include "sql/topogeometry/cleartopogeom.sql.in"
#include "sql/topogeometry/simplify.sql.in"
#include "sql/topogeometry/totopogeom.sql.in"
+#include "sql/topogeometry/topogeom_edit.sql.in"
-- Exports
#include "sql/export/gml.sql.in"