Openlayers和geoserver - 没有这样的属性:bbox

问题描述 投票:0回答:1

我是Openlayers的新手,我想用geoserver从postgres数据库中编辑并保存一个多边形;我基于这个例子。openlayers3 wfs-t save drawing

我的表定义是这样的。

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>

这是我的部分代码,当我试图获取编辑后的元素 并将其发送到一个编辑事务到geoserver上的时候

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);一行在控制台中返回这个。

{…}
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 "变量 和其他表格元素一起; 我想这是我得到错误信息的原因,但我不确定为什么。

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

这是最后一次向geoserver请愿,包括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&';
        },
    });
javascript openlayers openlayers-3 geoserver
1个回答
0
投票

我想明白了,仍然不知道为什么,但我做了这些改变,更新事务工作。

1) 就在发送功能到writeTransaction之前,我执行了一个... ... 解除 删除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请求也能正常工作,我的替换想法来自于: 此处

© www.soinside.com 2019 - 2024. All rights reserved.