我正在尝试使用GeoServer通过WFS-T保存更改:
这是我从geoserver获取特性的代码
var sourceWFS = new ol.source.Vector({
loader: function (extent) {
$.ajax('http://127.0.0.1:8080/geoserver/kairosDB/ows', {
type: 'GET',
data: {
service: 'WFS',
version: '1.1.0',
request: 'getFeature',
typename: 'wfs_geom',
srsname: 'EPSG:3857',
bbox: extent.join(',') + ',EPSG:3857'
}
}).done(function (response) {
sourceWFS.addFeatures(formatWFS.readFeatures(response));
});
},
// strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ()),
strategy: ol.loadingstrategy.bbox,
projection: 'EPSG:3857'
});
这是将功能保存到服务器的代码
var formatGML = new ol.format.GML({
featureNS: 'http://127.0.0.1:8080/geoserver/kairosDB',
featureType: 'wfs_geom',
srsName: 'EPSG:3857'
});
但当我将功能保存到服务器时,发生了此错误
2017-02-01 14:30:02,339 ERROR [geoserver.ows] -
org.geoserver.wfs.WFSTransactionException: {http://127.0.0.1:8080/geoserver/kairosDB}wfs_geom is read-only
at org.geoserver.wfs.Transaction.execute(Transaction.java:269)
at org.geoserver.wfs.Transaction.transaction(Transaction.java:106)
at org.geoserver.wfs.DefaultWebFeatureService.transaction(DefaultWebFeatureService.java:172)
at sun.reflect.GeneratedMethodAccessor195.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
wfs_geom表已经有一个主键,创建脚本:
CREATE TABLE public.wfs_geom
(
id bigint NOT NULL,
geometry geometry,
CONSTRAINT wfs_geom_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.wfs_geom
OWNER to postgres;
GRANT ALL ON TABLE public.wfs_geom TO postgres;
-- Index: sidx_wfs_geom
-- DROP INDEX public.sidx_wfs_geom;
CREATE INDEX sidx_wfs_geom
ON public.wfs_geom USING gist
(geometry)
TABLESPACE pg_default;
你能帮我吗?
最佳答案
这很有魅力:http://osgeo-org.1560.x6.nabble.com/Read-only-error-when-editing-a-WFS-T-td5284537.html
“数据安全”部分中有一条规则允许写入
但不允许匿名写入
所有工作区(…w)的用户的奇怪行为是
昨天我可以用客户端编辑图层。。我不知道
明白为什么,而且使用QGIS我不能编辑图层,但是QGIS
支持WFS-T