gpt4 book ai didi

java - Shapefile 数据存储中的多个简单特征类型或属性中的列表类型

转载 作者:行者123 更新时间:2023-11-30 07:50:57 29 4
gpt4 key购买 nike

我有一个导出 ArcGIS map 点的应用程序。 Spring MVC Controller 中的接收点。

我的指针有一个可变的属性列表。属性是具有两个值(名称和值)的字符串列表。代码:

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 中导入带有重音符号的单词时遇到问题。

最佳答案

您应该能够使用类似以下内容的内容来为每种类型创建功能类型和功能。然后是生成 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
}
}

关于java - Shapefile 数据存储中的多个简单特征类型或属性中的列表类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33350066/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com