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