当前位置: 首页>>代码示例>>Java>>正文


Java SimpleFeatureTypeBuilder.setCRS方法代码示例

本文整理汇总了Java中org.geotools.feature.simple.SimpleFeatureTypeBuilder.setCRS方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureTypeBuilder.setCRS方法的具体用法?Java SimpleFeatureTypeBuilder.setCRS怎么用?Java SimpleFeatureTypeBuilder.setCRS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.geotools.feature.simple.SimpleFeatureTypeBuilder的用法示例。


在下文中一共展示了SimpleFeatureTypeBuilder.setCRS方法的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;
}
 
开发者ID:52North,项目名称:javaps-geotools-backend,代码行数:20,代码来源:GTHelper.java

示例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;
}
 
开发者ID:petebrew,项目名称:fhaes,代码行数:22,代码来源:Csv2Shape2.java

示例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;
}
 
开发者ID:petebrew,项目名称:fhaes,代码行数:23,代码来源:Csv2Shape.java

示例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;
}
 
开发者ID:petebrew,项目名称:fhaes,代码行数:20,代码来源:ShapeFileDialog.java

示例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;
}
 
开发者ID:petebrew,项目名称:fhaes,代码行数:18,代码来源:ShapeFileDialog.java

示例6: 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();
	}
 
开发者ID:GIScience,项目名称:osmgpxfilter,代码行数:18,代码来源:ShapeFileWriter.java

示例7: convertDwgLine

import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
/**
 * Builds a line feature from a dwg line.
 * 
 */
public SimpleFeature convertDwgLine( String typeName, String layerName, DwgLine line, int id ) {
    double[] p1 = line.getP1();
    double[] p2 = line.getP2();
    Point2D[] ptos = new Point2D[]{new Point2D.Double(p1[0], p1[1]),
            new Point2D.Double(p2[0], p2[1])};
    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);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:28,代码来源:GeometryTranslator.java

示例8: doCollection

import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
private SimpleFeatureCollection doCollection( RegionMap envelopeParams ) {

        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName("typename");
        b.setCRS(crs);
        b.add("the_geom", Polygon.class);
        b.add("cat", Double.class);
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
        Object[] values = new Object[]{polygon, 1.0};
        builder.addAll(values);
        SimpleFeature feature = builder.buildFeature(null);
        DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
        newCollection.add(feature);
        return newCollection;
    }
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:17,代码来源:TestScanLineRasterizer.java

示例9: createFeatureType

import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
private static SimpleFeatureType createFeatureType(
		final String typeName,
		final boolean isPoint ) {

	final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
	builder.setName(typeName);
	builder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate reference
												// system

	// add attributes in order
	builder.add(
			"the_geom",
			isPoint ? Point.class : Polygon.class);
	builder.length(
			15).add(
			"Name",
			String.class); // <- 15 chars width for name field

	// build the type

	return builder.buildFeatureType();
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:23,代码来源:ShapefileTool.java

示例10: createBboxGeometry

import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
private void createBboxGeometry( CoordinateReferenceSystem crs, File lasFile, SimpleFeatureCollection outGeodata )
        throws IOException {
    final ReferencedEnvelope3D envelope = lasReader.getHeader().getDataEnvelope();
    ReferencedEnvelope env2d = new ReferencedEnvelope(envelope);
    final Polygon polygon = FeatureUtilities.envelopeToPolygon(new Envelope2D(env2d));

    final SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("lasdataenvelope");
    b.setCRS(crs);
    b.add("the_geom", Polygon.class);
    b.add("id", String.class);
    final SimpleFeatureType type = b.buildFeatureType();

    final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    final Object[] values = new Object[]{polygon, lasFile.getName()};
    builder.addAll(values);
    final SimpleFeature feature = builder.buildFeature(null);
    ((DefaultFeatureCollection) outGeodata).add(feature);
    OmsVectorWriter.writeVector(outFile, outGeodata);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:21,代码来源:OmsLasConverter.java

示例11: FeatureGeometrySubstitutor

import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
/**
 * @param oldFeatureType the {@link FeatureType} of the existing features.
 * @throws FactoryRegistryException 
 * @throws SchemaException
 */
public FeatureGeometrySubstitutor( SimpleFeatureType oldFeatureType, Class< ? > newGeometryType ) throws Exception {

    List<AttributeDescriptor> oldAttributeDescriptors = oldFeatureType.getAttributeDescriptors();

    // create the feature type
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(oldFeatureType.getName());
    b.setCRS(oldFeatureType.getCoordinateReferenceSystem());

    if (newGeometryType == null) {
        b.addAll(oldAttributeDescriptors);
    } else {
        for( AttributeDescriptor attributeDescriptor : oldAttributeDescriptors ) {
            if (attributeDescriptor instanceof GeometryDescriptor) {
                b.add("the_geom", newGeometryType);
            } else {
                b.add(attributeDescriptor);
            }
        }
    }
    newFeatureType = b.buildFeatureType();
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:28,代码来源:FeatureGeometrySubstitutor.java

示例12: 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());
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:21,代码来源:GeometryDataSetGeneratorTest.java

示例13: buildType

import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
public static SimpleFeatureType buildType() {
	SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
	
	b.setName("Flag");

	//set the name
	b.setName( "Flag" );

	//add some properties
	b.add( "name", String.class );
	b.add( "classification", Integer.class );
	b.add( "height", Double.class );

	//add a geometry property
	b.setCRS( DefaultGeographicCRS.WGS84); // set crs first
	b.add( "location", Point.class ); // then add geometry

	return b.buildFeatureType();
}
 
开发者ID:xandris,项目名称:geoserver-sync,代码行数:20,代码来源:Samples.java

示例14: 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;
    }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:33,代码来源:SimpleShapefile.java

示例15: write

import org.geotools.feature.simple.SimpleFeatureTypeBuilder; //导入方法依赖的package包/类
public static <T> void write(File file,
        Consumer<SimpleFeatureTypeBuilder> fun1,
        BiConsumer<SimpleFeatureBuilder, T> fun2,
        List<T> geometries) {
    try {
        SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
        typeBuilder.setName("MyFeatureType");
        typeBuilder.setCRS(DefaultGeographicCRS.WGS84);
        fun1.accept(typeBuilder);
        SimpleFeatureType type = typeBuilder.buildFeatureType();
        SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(type);
        AtomicInteger id = new AtomicInteger(0);
        List<SimpleFeature> geoms = geometries.stream().map(g -> {
            fun2.accept(featureBuilder, g);
            return featureBuilder.buildFeature(String.valueOf(id.getAndIncrement()));
        }).collect(toList());
        ShapefileDataStoreFactory datastoreFactory = new ShapefileDataStoreFactory();
        Map<String, Serializable> params = newHashMap();
        params.put("url", file.toURI().toURL());
        params.put("create spatial index", Boolean.TRUE);
        ShapefileDataStore datastore = (ShapefileDataStore) datastoreFactory.createNewDataStore(params);
        datastore.createSchema(type);
        Transaction transaction = new DefaultTransaction("create");
        String typeName = datastore.getTypeNames()[0];
        SimpleFeatureSource featureSource = datastore.getFeatureSource(typeName);
        SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
        SimpleFeatureCollection collection = new ListFeatureCollection(type, geoms);
        featureStore.setTransaction(transaction);
        featureStore.addFeatures(collection);
        transaction.commit();
        transaction.close();
        datastore.dispose();
    }
    catch (IOException e) {
        throw propagate(e);
    }
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:38,代码来源:ShapefileWriter.java


注:本文中的org.geotools.feature.simple.SimpleFeatureTypeBuilder.setCRS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。