Openlayers 和地理服务器 - 没有这样的 property:bbox

Openlayers and geoserver - No such property:bbox

我是 Openlayers 的新手,我正在尝试使用 geoserver 从 postgres 数据库编辑和保存多边形;我基于这个例子:openlayers3 wfs-t save drawing

我的table定义是这样的:

CREATE TABLE myschema.mytable
(
  id_mytable serial NOT NULL,
  element character varying(20) NOT NULL,
  description character varying(50),
  observation character varying(50),
  date_created timestamp without time zone,
  status boolean NOT NULL,
  geometry geometry(Polygon,4326),
  CONSTRAINT id_circuito_pk PRIMARY KEY (id_mytable),
  CONSTRAINT cod_cir_uniq UNIQUE (element),
)

问题是,当编辑按钮被触发时,我得到这个错误:

<ows:ExceptionReport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/ows http://myserver:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd">
<ows:Exception exceptionCode="OperationProcessingFailed">
<ows:ExceptionText>No such property: bbox</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>

当我尝试获取已编辑的元素并将其发送到地理服务器的编辑事务时,这是我的代码的一部分

var select = new ol.interaction.Select({
    style: new ol.style.Style({
        stroke: new ol.style.Stroke({
            color: '#FF2828'
        })
    })
});
....
select.getFeatures().on('remove', function(e) {
        var f = e.element;
        console.log(f);
        if (dirty[f.getId()]){
            delete dirty[f.getId()];
            var featureProperties = f.getProperties();
            delete featureProperties.boundedBy;
            var clone = new ol.Feature(featureProperties);
            clone.setId(f.getId());
            transactWFS('update',clone);
            }
        });

console.log(f);控制台中的 returns 行:

{…}
S: {…}
bbox: Array(4) [ -57.5871151158136, -25.30012166784802, -57.57902551943073, … ]
element: "CIRVILLA001"
description: "CIRVILLA001"
​​state: true
date_creation: "2020-03-12T14:53:35.213Z"
geometry: Object { i: 8, Vo: 1888, v: 8, … }
id_mytable: 1853
observation: null
<prototype>: Object { … }
Ua: Object {  }
Vo: 1889
a: "mytable.1853"
c: "geometry"
f: Object { lh: {…}, nh: false, type: "change", … }
fb: Object { "change:geometry": (1) […], change: (3) […], propertychange: (1) […] }
g: null
i: 9
j: undefined
oa: Object { "change:geometry": (1) […], change: (3) […], propertychange: (1) […] }
ra: Object {  }
<prototype>: Object { constructor: H(a), clone: clone(), V: V(), … }

这个特定部分是'S'变量;我不确定为什么我得到 'bbox' 变量以及其他 table 元素;我认为这就是我收到错误消息的原因,但我不确定原因

bbox: Array(4) [ -57.5871151158136, -25.30012166784802, -57.57902551943073, … ]
element: "CIRVILLA001"
description: "CIRVILLA001"
​​state: true
date_creation: "2020-03-12T14:53:35.213Z"
geometry: Object { i: 8, Vo: 1888, v: 8, … }
id_mytable: 1853
observation: null

这是对地理服务器的最后一次请愿;包含 bbox 变量

<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Update typeName="feature:mytable" xmlns:undefined="myfeature.com"><Property><Name>geometry</Name><Value><Polygon xmlns="http://www.opengis.net/gml" srsName="EPSG:4326"><exterior><LinearRing srsName="EPSG:4326"><posList>-25.29069838125067 -57.5871151158136 -25.294262176413937 -57.57902551943073 -25.300648657126356 -57.56431000423576 -25.30012166784802 -57.58149612589361 -25.29069838125067 -57.5871151158136</posList></LinearRing></exterior></Polygon></Value></Property><Property><Name>id_mytable</Name><Value>1853</Value></Property><Property><Name>element</Name><Value>CIRVILLA001</Value></Property><Property><Name>description</Name><Value>CIRVILLA001</Value></Property><Property><Name>observation</Name></Property><Property><Name>date_creation/Name><Value>2020-03-12T14:53:35.213Z</Value></Property><Property><Name>state</Name><Value>true</Value></Property><Property><Name>bbox</Name><Value>-57.5871151158136,-25.30012166784802,-57.57902551943073,-25.29069838125067</Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId fid="mytable.1853"/></Filter></Update></Transaction>

有什么我想念的吗?我添加了 WFS 矢量定义,以防万一:

sourceVector = new ol.source.Vector({
    format: new ol.format.GeoJSON(),
        url: function(extent) {
          return 'http://myserver:8080/geoserver/wfs?service=WFS&' +
              'version=1.1.0&request=GetFeature&typename=MYWORKSPACE:mytable&' +
              'outputFormat=application/json&srsname=EPSG:4326&';
        },
    });

我明白了,但仍然不确定为什么,但我进行了这些更改并且更新事务有效:

1) 在将特征发送到 writeTransaction 之前,我执行了一个 unset 来删除 de bbox 属性(这只是为了编辑现有的多边形)

    f.unset('bbox', true);
    node = formatWFS.writeTransaction(null,[f],null,formatGML);

2) 这是我 xml 生成的请愿书的一部分:

<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Update typeName="feature:mytable"

typeName配置为feature:mytable,应该有我的geoserver工作空间;我必须执行替换:

var data_=str.replace("typeName=\"feature:","typeName=\"myworkspace:");

并且 POST 请求工作正常,我从

得到了替换想法