2014年2月20日木曜日

36 - GeoEXT を使用した WFS-T 12 - 選択したレイヤの編集 1

36-12-1 akiruno_point と akiruno_line に 属性を追加
Developing OGC Compliant Web Applications with GeoExt の
3.1. Creating a Synchronized Grid and Map View of WFS Features(http://workshops.boundlessgeo.com/geoext/wfs/grid.html)と3.2. Editing Features and Their Attributes(http://workshops.boundlessgeo.com/geoext/wfs/editing.html)の「Bonus Task」を参考に、「Add to Map」で追加したレイヤを tree で選択して編集します。
「ol017-nippon_bmi_akiruno_pgis.html」をコピーして名前を付けて(「ol017bonus-nippon_bmi_akiruno_pgis.html」など)使います。

最初に、akiruno_point と akiruno_line に akiruno_polygon と同じように属性を追加します。

既存の属性
fid
the_geom
追加の属性
id  charactor varying(32)
name  charactor varying(32)
address  charactor varying(32)
createdate  charactor varying(32)
lastupdate  charactor varying(32)
category1  charactor varying(32)
category2  charactor varying(32)
category3  charactor varying(32)

user@debian7-vmw:~$ psql nippon_bmi
psql (9.1.11)
"help" でヘルプを表示します.
nippon_bmi=> ALTER TABLE akiruno_point ADD COLUMN id varchar(32);
---
ALTER TABLE
nippon_bmi=> ALTER TABLE akiruno_line ADD COLUMN id varchar(32);
---

nippon_bmi=> \d akiruno_point
                                 テーブル "public.akiruno_point"
   カラム   |          型           |                           修飾語                           
------------+-----------------------+-------------------------------------------------------------
 fid        | integer               | not null default nextval('akiruno_point_fid_seq'::regclass)
 the_geom   | geometry              | 
 id         | character varying(32) | 
 name       | character varying(32) | 
 address    | character varying(32) | 
 createdate | character varying(32) | 
 lastupdate | character varying(32) | 
 category1  | character varying(32) | 
 category2  | character varying(32) | 
 category3  | character varying(32) | 

インデックス:
    "akiruno_point_pkey" PRIMARY KEY, btree (fid)
    "spatial_akiruno_point_the_geom" gist (the_geom)
CHECK 制約:
    "enforce_dims_the_geom" CHECK (st_ndims(the_geom) = 2)
    "enforce_geotype_the_geom" CHECK (geometrytype(the_geom) = 'MULTIPOINT'::text OR the_geom IS NULL)
    "enforce_srid_the_geom" CHECK (st_srid(the_geom) = 2451)

(END):q


nippon_bmi=> \d akiruno_line
                                 テーブル "public.akiruno_line"
   カラム   |          型           |                           修飾語                           
------------+-----------------------+------------------------------------------------------------
 fid        | integer               | not null default nextval('akiruno_line_fid_seq'::regclass)
 the_geom   | geometry              | 
 id         | character varying(32) | 
 name       | character varying(32) | 
 address    | character varying(32) | 
 createdate | character varying(32) | 
 lastupdate | character varying(32) | 
 category1  | character varying(32) | 
 category2  | character varying(32) | 
 category3  | character varying(32) | 

インデックス:
    "akiruno_line_pkey" PRIMARY KEY, btree (fid)
    "spatial_akiruno_line_the_geom" gist (the_geom)
CHECK 制約:
    "enforce_dims_the_geom" CHECK (st_ndims(the_geom) = 2)
    "enforce_geotype_the_geom" CHECK (geometrytype(the_geom) = 'MULTILINESTRING'::text OR the_geom IS NULL)
    "enforce_srid_the_geom" CHECK (st_srid(the_geom) = 2451)

(END):q


GeoServer で akiruno_point と akiruno_line レイヤの「Feature Type Details」を確認します。表示されないときは「Reload feature type」をクリックします。

仮の属性の値を追加します。

nippon_bmi=> SELECT fid, id, name, createdate, lastupdate, category1, category2, category3 from akiruno_point;
 fid | id | name | createdate | lastupdate | category1 | category2 | category3 
-----+----+------+------------+------------+-----------+-----------+-----------
   2 |    |      |            |            |           |           | 
(1 行)

nippon_bmi=> UPDATE akiruno_point SET id = 'a', name = '点2', address = 'aki', createdate = '2014-2-14', lastupdate = '2014-2-14', category1 = 'c1', category2 = 'c2', category3 = 'c3' where fid = 2;
UPDATE 1
nippon_bmi=> SELECT fid, id, name, address, createdate, lastupdate, category1, category2, category3 from akiruno_line;
 fid | id | name | address | createdate | lastupdate | category1 | category2 | category3 
-----+----+------+---------+------------+------------+-----------+-----------+-----------
   3 |    |      |         |            |            |           |           | 

(1 行)
(stdin):q

nippon_bmi=> UPDATE akiruno_line SET id = 'a', name = '線2', address = 'aki', createdate = '2014-2-14', lastupdate = '2014-2-14', category1 = 'c1', category2 = 'c2', category3 = 'c3' where fid = 3;
UPDATE 1

0 件のコメント: