通过openlayers和geoserver将要素发布到postgis时出错 [英] Error when posting features to postgis by openlayers and geoserver

查看:235
本文介绍了通过openlayers和geoserver将要素发布到postgis时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当由openlayers和geoserver将要素发布到postgis时,我发现了一个错误.该代码在下面列出.错误是XMLSerializer从var'node'转换的var'data'是错误的,X和Y的顺序是相反的,就像"28.795251846313476 116.4409589767456".因此,地理服务器拒绝了该请求,因为Y的坐标在(-90,90)之外.

I found an error when posting features to postgis by openlayers and geoserver. The code is listed below. And the error was that the var 'data' which was converted from the var 'node' by XMLSerializer was wrong, the order of X and Y in it was reverse, just like "28.795251846313476 116.4409589767456 ". So geoserver rejected the request, because the coordinates of Y were outside of (-90,90).

var feature = evt.feature;
var node = format.writeTransaction([feature], null, null, {
                gmlOptions: {srsName: "EPSG:4326"},
                featureNS: "ucoc.zhtx.com",
                featureType: "landblock"     
            });             
var data=new XMLSerializer().serializeToString(node);

推荐答案

欢迎来到有关轴定向问题的美好世界.幸运的是,GeoServer对于[lon,lat]订单有替代的SRS代码,它是"CRS:84"而不是"EPSG:4326":

Welcome to the wonderful world of axis orientation trouble. Fortunately, GeoServer has an alternative SRS code for [lon, lat] order, which is "CRS:84" instead of "EPSG:4326":

var feature = evt.feature;
var node = format.writeTransaction([feature], null, null, {
  gmlOptions: {srsName: "CRS:84"},
  featureNS: "ucoc.zhtx.com",
  featureType: "landblock"     
});             
var data = new XMLSerializer().serializeToString(node);

这篇关于通过openlayers和geoserver将要素发布到postgis时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆