Openlayers中Feature與WKT之間的轉換,Feature坐標系的轉換


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
           


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM