Shapefile DataStore 中的多个简单 FeatureType 或属性中的列表类型

Multiple SimpleFeatureType in ShapefileDataStore or List type in atributes

我有一个导出 ArcGIS 地图点的应用程序。 Spring MVC 控制器中的接收点。

我的 Pointer 有一个可以可变的属性列表。属性是具有两个值的字符串列表,名称和值。代码:

public class PointDTO {
    private String type;
    private Double x;
    private Double y;
    private Integer wkid;
    private List<String[]> atributtes = new ArrayList<String[]>();
    //Getters & Setters
}

他想知道您是否可以在 SimpleFeatureType 中使用列表类型或类似的东西:

SimpleFeatureType type = DataUtilities.createType ("Location", "the_geom: Point: srid = 25829"
                 + "Type: String"
                 + "X: double," + "And: double,"
                 + "Atributes: List");

现在我要做的是 'Attribute' 字符串类型。我连接了所有属性,但最大长度为 250 个字符。

另一种解决方案是声明多个 SimpleFeatureType,但我认为您不能使用相同的 ShapefileDataStore。

我在在线 ArcgisExporer 中导入带有重音符号的单词时也遇到了问题。

您应该能够使用类似下面的内容为您的每种类型创建您的 FeatureType 和特征。然后就是生成一个ShapefileDatastore来写出每一个集合的简单案例。

package spike;

import java.util.ArrayList;
import java.util.List;

import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.geotools.geometry.jts.GeometryBuilder;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;

import com.vividsolutions.jts.geom.Point;

public class ShpFileBuilder {
    static final GeometryBuilder GEOMBUILDER = new GeometryBuilder();

    public SimpleFeatureType buildType(PointDTO dto) {
        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
        builder.setName(dto.type);
        builder.setNamespaceURI("http://www.geotools.org/");
        builder.setSRS("EPSG:25829");
        builder.add("the_geom", Point.class);
        for (String[] att : dto.atributtes) {
            builder.add(att[0], String.class);
        }
        SimpleFeatureType featureType = builder.buildFeatureType();
        return featureType;

    }

    public SimpleFeature buildFeature(PointDTO dto, SimpleFeatureType schema) {
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(schema);
        Point p = GEOMBUILDER.point(dto.x.doubleValue(), dto.y.doubleValue());
        builder.set("the_geom", p);
        for (String[] att : dto.atributtes) {
            builder.set(att[0], att[1]);
        }
        return builder.buildFeature(dto.wkid.toString());
    }

    public class PointDTO {
        private String type;
        private Double x;
        private Double y;
        private Integer wkid;
        private List<String[]> atributtes = new ArrayList<String[]>();
        // Getters & Setters
    }
}