3.1. Creating a Synchronized Grid and Map View of WFS Features(http://workshops.boundlessgeo.com/geoext/wfs/grid.html)の「Bonus Task」をコピーして貼り付け、一部を修正します。
---
// ここから追加
var rawAttributeData;
var read = OpenLayers.Format.WFSDescribeFeatureType.prototype.read;
OpenLayers.Format.WFSDescribeFeatureType.prototype.read = function() {
rawAttributeData = read.apply(this, arguments);
return rawAttributeData;
};
function reconfigure(store, url) {
var fields = [], columns = [], geometryName, geometryType;
// regular expression to detect the geometry column
var geomRegex = /gml:(Multi)?(Point|Line|Polygon|Surface|Geometry).*/;
var types = {
// mapping of xml schema data types to Ext JS data types
"xsd:int": "int",
"xsd:short": "int",
"xsd:long": "int",
"xsd:string": "string",
"xsd:dateTime": "string",
"xsd:double": "float",
"xsd:decimal": "float",
// mapping of geometry types
"Line": "Path",
"Surface": "Polygon"
};
store.each(function(rec) {
var type = rec.get("type");
var name = rec.get("name");
var match = geomRegex.exec(type);
if (match) {
// we found the geometry column
geometryName = name;
} else {
// we have an attribute column
fields.push({
name: name,
type: types[type]
});
columns.push({
xtype: types[type] == "string" ?
"gridcolumn" :
"numbercolumn",
dataIndex: name,
header: name
});
}
});
app.featureGrid.reconfigure(new GeoExt.data.FeatureStore({
autoLoad: true,
proxy: new GeoExt.data.ProtocolProxy({
protocol: new OpenLayers.Protocol.WFS({
url: url,
version: "1.1.0",
featureType: rawAttributeData.featureTypes[0].typeName,
featureNS: rawAttributeData.targetNamespace,
// srsName: "EPSG:4326",
srsName: "EPSG:2451",
geometryName: geometryName,
maxFeatures: 250
})
}),
fields: fields
}), new Ext.grid.ColumnModel(columns));
app.featureGrid.store.bind(vectorLayer);
app.featureGrid.getSelectionModel().bind(vectorLayer);
}
function setLayer(model, node) {
if(!node || node.layer instanceof OpenLayers.Layer.Vector) {
return;
}
vectorLayer.removeAllFeatures();
app.featureGrid.reconfigure(
new Ext.data.Store(),
new Ext.grid.ColumnModel([])
);
var layer = node.layer;
var url = layer.url.split("?")[0]; // the base url without params
var schema = new GeoExt.data.AttributeStore({
url: url,
// request specific params
baseParams: {
"SERVICE": "WFS",
"REQUEST": "DescribeFeatureType",
"VERSION": "1.1.0",
"TYPENAME": layer.params.LAYERS
},
autoLoad: true,
listeners: {
"load": function(store) {
app.featureGrid.setTitle(layer.name);
reconfigure(store, url);
}
}
});
}
Ext.onReady(function() {
app.tree.getSelectionModel().on(
"selectionchange", setLayer
);
});
// ここまで
</script>---
レイヤの属性の中で、「name」が表示されません。コード中に使用されている「name」に影響されているのかもしれません。属性の「name」を「term」に変更したら表示されるようになりました。
nippon_bmi=> ALTER TABLE akiruno_polygon RENAME name to term; ALTER TABLE nippon_bmi=> ALTER TABLE akiruno_line RENAME name to term; ALTER TABLE nippon_bmi=> ALTER TABLE akiruno_point RENAME name to term; ALTER TABLE
GeoServer で akiruno_polygon akiruno_line akiruno_point レイヤの「Feature Type Details」を確認します。表示されないときは「Reload feature type」をクリックします。



0 件のコメント:
コメントを投稿