AddFace — フェイスプリミティブをトポロジに登録し、その識別番号を得ます。
integer AddFace(
varchar toponame, geometry apolygon, boolean force_new=false)
;
フェイスプリミティブをトポロジに登録し、その識別番号を得ます。
新しく追加されたフェイスのために、境界を形成するエッジとフェイスに含まれるエッジはleft_faceとright_faceフィールドに正しい値を持つよう更新されます。フェイスに含まれる孤立ノードも正しいcontaining_faceフィールド値を持つよう更新されます。
この関数はエッジテーブルのnext_left_edgeとnext_right_edgeフィールドの読み書きを行いません。 |
対象トポロジは妥当(自己インタセクトするエッジが無い)と仮定しています。ポリゴンの境界が既存のエッジでは完全には定義されない場合や、ポリゴンが既存のフェイスにオーバラップする場合には、例外が投げられます。
If the apolygon
geometry already exists as a face, then: if force_new
is false (the default) the face id of the existing face is returned; if force_new
is true a new id will be assigned to the newly registered face.
When a new registration of an existing face is performed (force_new=true), no action will be taken to resolve dangling references to the existing face in the edge, node an relation tables, nor will the MBR field of the existing face record be updated. It is up to the caller to deal with that. |
|
初出: 2.0.0
-- まずgenerate_seriesを使って繰り返しを発生させてエッジを追加します -- (次に示すものは最大値10000ポイント以下のポリゴンでのみ動作します。 -- generate_seriesの上限になるためです)。SELECT topology.AddEdge('ma_topo', ST_MakeLine(ST_PointN(geom,i), ST_PointN(geom, i + 1) )) As edgeid FROM (SELECT ST_NPoints(geom) AS npt, geom FROM (SELECT ST_Boundary(ST_GeomFromText('POLYGON((234896.5 899456.7,234914 899436.4,234946.6 899356.9,234872.5 899328.7, 234891 899285.4,234992.5 899145, 234890.6 899069,234755.2 899255.4, 234612.7 899379.4,234776.9 899563.7,234896.5 899456.7))', 26986) ) As geom ) As geoms) As facen CROSS JOIN generate_series(1,10000) As i WHERE i < npt; -- 結果 -- edgeid -------- 3 4 5 6 7 8 9 10 11 12 (10 rows) -- 次にフェイスの追加 -- SELECT topology.AddFace('ma_topo', ST_GeomFromText('POLYGON((234896.5 899456.7,234914 899436.4,234946.6 899356.9,234872.5 899328.7, 234891 899285.4,234992.5 899145, 234890.6 899069,234755.2 899255.4, 234612.7 899379.4,234776.9 899563.7,234896.5 899456.7))', 26986) ) As faceid; -- 結果 -- faceid -------- 1