Openlayers中Feature與WKT之間的轉換,Feature座標系的轉換
阿新 • • 發佈:2018-12-14
1、Feature 轉WKT 且帶座標系的轉換
var strwkt = new ol.format.WKT().writeFeature(feature, { dataProjection: targetcrs,//目標座標系 featureProjection:crs //當前座標系 });
2、WKT轉Feature
var newfeature = new ol.format.WKT().readFeature(strwkt);
3、Feature 座標系轉換(支援所有圖形)
var geom = feature.getGeometry().transform(crs, targetcrs); feature.setGeometry(geom);
4、利用WKT轉換Feature座標系(這種不支援GEOMETRY不為Circle)
var strwkt = new ol.format.WKT().writeFeature(feature, { dataProjection: targetcrs, featureProjection:crs }); var newfeature = new ol.format.WKT().readFeature(strwkt);
注意:方法4得到的Feature 會沒有原始Feature對應的Properties