首页 > 其他分享 >geotools:LineString转SimpleFeature

geotools:LineString转SimpleFeature

时间:2023-02-28 17:48:36浏览次数:52  
标签:instanceof geotools geometry clone resultList simpleFeature SimpleFeature LineSt

public static List<SimpleFeature> toSimpleFeature(List<SimpleFeature> simpleFeatureList){
        List<SimpleFeature> resultList = new ArrayList<>();
        for (SimpleFeature simpleFeature: simpleFeatureList) {
            Geometry geometry = (Geometry) simpleFeature.getDefaultGeometry();
            if (geometry instanceof MultiLineString || geometry instanceof MultiPolygon || geometry instanceof MultiPoint) {
                for (int i = 0; i < geometry.getNumGeometries(); i += 1) {
                    SimpleFeature clone = SimpleFeatureBuilder.deep(simpleFeature);
                    clone.setDefaultGeometry(geometry.getGeometryN(i));
                    resultList.add(clone);
                }
            } else if (geometry instanceof LineString || geometry instanceof Polygon || geometry instanceof Point) {
                resultList.add(simpleFeature);
            }
        }
        return resultList;
    }

参考:https://blog.csdn.net/qq_18298439/article/details/119798641

标签:instanceof,geotools,geometry,clone,resultList,simpleFeature,SimpleFeature,LineSt
From: https://www.cnblogs.com/2008nmj/p/17165306.html

相关文章

  • geotools画地图
    给一串featurecollection 画出地图 对每个geometry上不同的颜色,并在每个geometry的中心点贴上属性 这个需求 没完成完成到画出地图,给featurecollection上颜色 ......
  • geotools读取shp文件中文乱码???
    在读取shp文件之前,先要手动调用一下ShapefileDataStore的setStringCharset方法即可dataStore.setStringCharset(Charset.forName("UTF-8"));参考:https://www.osgeo.cn/p......
  • geotools和geoserver的关系
    基于geotools,你可以快速地开发出一个java应用。当然,众所周知,java主要是用来开发服务器程序。所以,不难理解,geoserver会选择geotools了。例如,geoserver中的wfs服务和wms服务......
  • geotools求多边形的面积 单位米(地理坐标系转投影坐标系)
    参考:根据wkt或geometry计算面积(平方米):https://blog.csdn.net/wuxiaowu123/article/details/118153835>>如何利用PostGIS正确计算距离和面积:https://blog.csdn.net/qq_3066......
  • st_linemerge::将输入的MultiLineString连接成一个或多个LineString。
    DescriptionReturnsaLineStringorMultiLineStringformedbyjoiningtogetherthelineelementsofaMultiLineString.Linesarejoinedattheirendpointsat2......
  • geotools:Array2tif()
    txt->shp得到x,y,v列(在线micaps是从低到高排列的。。arcgis的txt是从高到低)//二维数组,已知行列数Double[][]a=newDouble[401][661];//读取txt.......当知道......