Error when posting features to postgis by openlayers and geoserver

无人久伴 提交于 2019-12-02 09:28:17

问题


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);

回答1:


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);


来源:https://stackoverflow.com/questions/35648061/error-when-posting-features-to-postgis-by-openlayers-and-geoserver

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!