本文整理汇总了Java中org.geotools.feature.simple.SimpleFeatureTypeBuilder.buildFeatureType方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureTypeBuilder.buildFeatureType方法的具体用法?Java SimpleFeatureTypeBuilder.buildFeatureType怎么用?Java SimpleFeatureTypeBuilder.buildFeatureType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.feature.simple.SimpleFeatureTypeBuilder
的用法示例。
在下文中一共展示了SimpleFeatureTypeBuilder.buildFeatureType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFeatureType
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
public SimpleFeatureType createFeatureType(Geometry newGeometry, String uuid, CoordinateReferenceSystem coordinateReferenceSystem) {
String namespace = "http://www.52north.org/" + uuid;
SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
if (coordinateReferenceSystem == null) {
coordinateReferenceSystem = getDefaultCRS();
}
typeBuilder.setCRS(coordinateReferenceSystem);
typeBuilder.setNamespaceURI(namespace);
Name nameType = new NameImpl(namespace, "Feature-" + uuid);
typeBuilder.setName(nameType);
typeBuilder.add("GEOMETRY", newGeometry.getClass());
SimpleFeatureType featureType;
featureType = typeBuilder.buildFeatureType();
return featureType;
}
示例2: createFeatureType
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
/**
* Here is how you can use a SimpleFeatureType builder to create the schema for your shapefile dynamically.
* <p>
* This method is an improvement on the code used in the main method above (where we used DataUtilities.createFeatureType) because we
* can set a Coordinate Reference System for the FeatureType and a a maximum field length for the 'name' field dddd
*/
private static SimpleFeatureType createFeatureType() {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("Location");
builder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate reference system
// add attributes in order
builder.add("the_geom", Point.class);
builder.length(15).add("Name", String.class); // <- 15 chars width for name field
// build the type
final SimpleFeatureType LOCATION = builder.buildFeatureType();
return LOCATION;
}
示例3: createFeatureType
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
/**
* Here is how you can use a SimpleFeatureType builder to create the schema for your shapefile dynamically.
* <p>
* This method is an improvement on the code used in the main method above (where we used DataUtilities.createFeatureType) because we
* can set a Coordinate Reference System for the FeatureType and a a maximum field length for the 'name' field dddd
*/
@SuppressWarnings("unused")
private static SimpleFeatureType createFeatureType() {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("Location");
builder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate reference system
// add attributes in order
builder.add("Location", Point.class);
builder.length(15).add("Name", String.class); // <- 15 chars width for name field
// build the type
final SimpleFeatureType LOCATION = builder.buildFeatureType();
return LOCATION;
}
示例4: createFeatureType
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
private static SimpleFeatureType createFeatureType(List<Integer> years) {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("FHAES");
builder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate reference system
// add attributes in order
builder.add("the_geom", Point.class);
builder.add("name", String.class);
for (Integer i : years)
{
builder.add(i + "", Integer.class);
}
// build the type
final SimpleFeatureType FHAES = builder.buildFeatureType();
return FHAES;
}
示例5: createStyle2FeatureType
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
private static SimpleFeatureType createStyle2FeatureType() {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("FHAES");
builder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate reference system
// add attributes in order
builder.add("the_geom", Point.class);
builder.add("name", String.class);
builder.add("year", Integer.class);
builder.add("value", Integer.class);
// build the type
final SimpleFeatureType FHAES = builder.buildFeatureType();
return FHAES;
}
示例6: getFeatureSchema
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
/**
* The purpose of this method is to generate the schema definition for the GeoJSON.
* @return SimpleFeatureType defining the the feature properties.
*/
public SimpleFeatureType getFeatureSchema() {
final SimpleFeatureTypeBuilder simpleFeatureType = new SimpleFeatureTypeBuilder();
simpleFeatureType.add("geom", LineString.class, DefaultGeographicCRS.WGS84);
simpleFeatureType.add("name", String.class);
simpleFeatureType.add("activityId", Long.class);
simpleFeatureType.setName("activity");
simpleFeatureType.add("name", String.class);
simpleFeatureType.add("sport", String.class);
simpleFeatureType.add("startTime", String.class);
simpleFeatureType.add("totalMeters", Double.class);
simpleFeatureType.add("totalSeconds", Double.class);
simpleFeatureType.add("minLat", Double.class);
simpleFeatureType.add("minLon", Double.class);
simpleFeatureType.add("maxLat", Double.class);
simpleFeatureType.add("maxLon", Double.class);
return simpleFeatureType.buildFeatureType();
}
示例7: createFeatureType
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
private SimpleFeatureType createFeatureType() {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("GPX");
builder.setCRS(DefaultGeographicCRS.WGS84);
// add attributes in order
builder.add("the_geom", Point.class);
builder.add("gpx_id", Integer.class);
builder.add("trk_id", Integer.class);
builder.add("seg_id", Integer.class);
builder.add("trkpt_id", Integer.class);
builder.add("timestamp", String.class);
builder.add("ele", Double.class);
return builder.buildFeatureType();
}
示例8: createAggregationFeatures
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
public static SimpleFeatureCollection createAggregationFeatures(List<Map<String,Object>> data) {
final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName( "testType" );
builder.add("_aggregation", HashMap.class );
builder.add("aString", String.class );
final SimpleFeatureType featureType = builder.buildFeatureType();
final DefaultFeatureCollection collection = new DefaultFeatureCollection();
final SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
data.stream().forEach(item -> {
item.keySet().stream().forEach(key -> {
featureBuilder.set(key, item.get(key));
});
collection.add(featureBuilder.buildFeature(null));
});
return collection;
}
示例9: getBuilder
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
private SimpleFeatureBuilder getBuilder() {
final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
typeBuilder.setName("test");
typeBuilder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate
// reference
// add attributes in order
typeBuilder.add(
"geom",
Geometry.class);
typeBuilder.add(
"name",
String.class);
typeBuilder.add(
"count",
Long.class);
// build the type
return new SimpleFeatureBuilder(
typeBuilder.buildFeatureType());
}
示例10: convertDwgLwPolyline
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
/**
* Builds a line feature from a dwg polyline 2D.
*
*/
public SimpleFeature convertDwgLwPolyline( String typeName, String layerName,
DwgLwPolyline lwPolyline, int id ) {
Point2D[] ptos = lwPolyline.getVertices();
if (ptos != null) {
CoordinateList coordList = new CoordinateList();
for( int j = 0; j < ptos.length; j++ ) {
Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY(), 0.0);
coordList.add(coord);
}
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName(typeName);
b.setCRS(crs);
b.add(THE_GEOM, LineString.class);
b.add(LAYER, String.class);
SimpleFeatureType type = b.buildFeatureType();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
Geometry lineString = gF.createLineString(coordList.toCoordinateArray());
Object[] values = new Object[]{lineString, layerName};
builder.addAll(values);
return builder.buildFeature(typeName + "." + id);
}
return null;
}
示例11: convertDwgPolyline3D
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
/**
* Builds a line feature from a dwg polyline 3D.
*
* TODO handle these as contourlines
*
*/
public SimpleFeature convertDwgPolyline3D( String typeName, String layerName,
DwgPolyline3D polyline3d, int id ) {
double[][] ptos = polyline3d.getPts();
CoordinateList coordList = new CoordinateList();
if (ptos != null) {
for( int j = 0; j < ptos.length; j++ ) {
Coordinate coord = new Coordinate(ptos[j][0], ptos[j][1], ptos[j][2]);
coordList.add(coord);
}
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName(typeName);
b.setCRS(crs);
b.add(THE_GEOM, LineString.class);
b.add(LAYER, String.class);
SimpleFeatureType type = b.buildFeatureType();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
Geometry lineString = gF.createLineString(coordList.toCoordinateArray());
Object[] values = new Object[]{lineString, layerName};
builder.addAll(values);
return builder.buildFeature(typeName + "." + id);
}
return null;
}
示例12: buildPolygonFeatureType
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
/**
* return a FeatureType like the inputFeatureType just with Polygon as geometrytype
*
* @param inputFeatureType
* @return
*/
private SimpleFeatureType buildPolygonFeatureType(final SimpleFeatureType inputFeatureType) {
final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
typeBuilder.setName("polyonAggregate");
typeBuilder.setCRS(inputFeatureType.getCoordinateReferenceSystem());
final GeometryDescriptor geomDescriptor = inputFeatureType.getGeometryDescriptor();
typeBuilder.add(geomDescriptor.getName().toString(), Polygon.class,
inputFeatureType.getCoordinateReferenceSystem());
for (final AttributeDescriptor descriptor: inputFeatureType.getAttributeDescriptors()) {
if (!(descriptor instanceof GeometryDescriptor)) {
LOGGER.fine("Adding attribute "+descriptor.getName().toString()+" to new SimpleFeatureType");
typeBuilder.add(descriptor);
}
}
typeBuilder.add(POLYGON_WIDTH_ATTRIBUTE_NAME, Double.class);
return typeBuilder.buildFeatureType();
}
开发者ID:geops,项目名称:trafimage-geoserver-transformations,代码行数:26,代码来源:AggregateSimilarLinesAsPolygonsProcess.java
示例13: createPolygons
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
private void createPolygons( CoordinateReferenceSystem crs, GeometryFactory gf, List<Geometry> polygons ) {
outMap = new DefaultFeatureCollection();
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName(POLYGON);
b.setCRS(crs);
b.add("the_geom", Polygon.class);
b.add("id", Long.class);
SimpleFeatureType type = b.buildFeatureType();
SimpleFeatureBuilder fbuilder = new SimpleFeatureBuilder(type);
long index = 0;
int numGeometries = polygons.size();
for( int i = 0; i < numGeometries; i++ ) {
Geometry geometry = polygons.get(i);
Object[] values = new Object[]{geometry, index++};
fbuilder.addAll(values);
SimpleFeature feature = fbuilder.buildFeature(null);
((DefaultFeatureCollection) outMap).add(feature);
}
}
示例14: createPoints
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
private void createPoints( CoordinateReferenceSystem crs, GeometryFactory gf, List<LineString> verticals,
List<LineString> horizontals ) {
outMap = new DefaultFeatureCollection();
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName(POINT);
b.setCRS(crs);
b.add("the_geom", Point.class);
b.add("id", Long.class);
SimpleFeatureType type = b.buildFeatureType();
SimpleFeatureBuilder fbuilder = new SimpleFeatureBuilder(type);
Geometry gVer = gf.createMultiLineString(verticals.toArray(new LineString[0]));
Geometry gHor = gf.createMultiLineString(horizontals.toArray(new LineString[0]));
Geometry intersection = gHor.intersection(gVer);
long index = 0;
int numGeometries = intersection.getNumGeometries();
for( int i = 0; i < numGeometries; i++ ) {
Geometry geometry = intersection.getGeometryN(i);
Object[] values = new Object[]{geometry, index++};
fbuilder.addAll(values);
SimpleFeature feature = fbuilder.buildFeature(null);
((DefaultFeatureCollection) outMap).add(feature);
}
}
示例15: createFeatureType
import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
private static SimpleFeatureType createFeatureType(Class geomClass,AttributesGeometry attr) {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("Location");
builder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate reference system
// add attributes in order
builder.add(geomClass.getSimpleName(), geomClass);
builder.length(15).add("Name", String.class); // <- 15 chars width for name field
builder.add("Number", Integer.class);
//aggiungo tutti gli altri attributi allo schema
if(attr!=null){
String[]schema= attr.getSchema();
for(int i=0;i<schema.length;i++){
Object val=attr.get(schema[i]);
if(val!=null){
if(val.getClass().isArray()){
String valArray=ArrayUtils.toString(val);
builder.add(schema[i],valArray.getClass());
}else{
builder.add(schema[i],val.getClass());
}
}
}
}
// build the type
final SimpleFeatureType ft = builder.buildFeatureType();
return ft;
}