Openlayers 和 geoserver - 没有这样的属性:bbox
Posted
技术标签:
【中文标题】Openlayers 和 geoserver - 没有这样的属性:bbox【英文标题】:Openlayers and geoserver - No such property:bbox 【发布时间】:2020-05-17 22:17:14 【问题描述】:我是 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>
这是我尝试获取已编辑元素并将其发送到地理服务器的编辑事务时的代码的一部分
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&';
,
);
【问题讨论】:
如果您使用 CURL(或类似方法)发布 XML 是否可以工作? GeoServer 日志文件说明问题是什么? @IanTurton 请在下面查看我的回答 【参考方案1】:我想通了,仍然不知道为什么,但我做了这些更改并且更新事务有效:
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 请求工作正常,我从here 得到了替换的想法
【讨论】:
以上是关于Openlayers 和 geoserver - 没有这样的属性:bbox的主要内容,如果未能解决你的问题,请参考以下文章
Openlayers 和 geoserver - 没有这样的属性:bbox
Geoserver 2.10 Openlayers 3 TextSymbolizer 标签未显示
如何使用 OpenLayers 和 Geoserver 使用 TileWMS 进行统计
请教各位用Openlayers+geoserver怎么实现这种效果