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


Java SimpleFeatureBuilder类代码示例

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


SimpleFeatureBuilder类属于org.geotools.feature.simple包,在下文中一共展示了SimpleFeatureBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSampleFeature

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
/**
 * Creates a sample Feature instance in the hope that it can be used in the rendering of the
 * legend graphic.
 * 
 * @param schema the schema for which to create a sample Feature instance
 * 
 *
 * 
 * @throws ServiceException
 */
private Feature createSampleFeature(FeatureType schema) throws ServiceException {
    Feature sampleFeature;
    try {
        if (schema instanceof SimpleFeatureType) {
            if (hasMixedGeometry((SimpleFeatureType) schema)) {
                // we can't create a sample for a generic Geometry type
                sampleFeature = null;
            } else {
                sampleFeature = SimpleFeatureBuilder.template((SimpleFeatureType) schema, null);
            }
        } else {
            sampleFeature = DataUtilities.templateFeature(schema);
        }
    } catch (IllegalAttributeException e) {
        throw new ServiceException(e);
    }
    return sampleFeature;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:29,代码来源:SLDEditorBufferedImageLegendGraphicBuilder.java

示例2: createFeature

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
public static SimpleFeature createFeature(SimpleFeatureBuilder builder, int i, String visibility) {
    final String[] PEOPLE_NAMES = {"James", "John", "Peter", "Hannah", "Claire", "Gabriel"};
    final Random random = new Random();

    Double lat = random.nextDouble() * 180 - 90;

    builder.reset();
    builder.add(PEOPLE_NAMES[i % PEOPLE_NAMES.length]); // name

    builder.add((int) Math.round(random.nextDouble()*110)); // age
    builder.add(random.nextDouble());
    builder.add(lat);
    builder.add(new Date()); // dtg
    builder.add(WKTUtils$.MODULE$.read("POINT(" + -180.0 + " " + lat + ")")); // geom
    SimpleFeature feat = builder.buildFeature(Integer.toString(i));
    if (visibility != null) {
        feat.getUserData().put("geomesa.feature.visibility", visibility);
    }
    return feat;
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:21,代码来源:KafkaLoadTester.java

示例3: addDeleteNewFeature

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
public static void addDeleteNewFeature(SimpleFeatureType sft, FeatureStore producerFS)
        throws InterruptedException, IOException {
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(sft);
    DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
    final Random random = new Random();

    String id = "1000";

    builder.add("Antoninus"); // name
    builder.add((int) Math.round(random.nextDouble()*110)); // age
    builder.add(new Date()); // dtg
    builder.add(WKTUtils$.MODULE$.read("POINT(-1 -1)")); // geom
    SimpleFeature feature = builder.buildFeature(id);

    featureCollection.add(feature);
    producerFS.addFeatures(featureCollection);

    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
    Filter idFilter = ff.id(ff.featureId(id));
    producerFS.removeFeatures(idFilter);
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:22,代码来源:KafkaQuickStart.java

示例4: createFeatureLayerFromMapObject

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
/**
 * Creates a feature layer based on a map object.
 */
public static Layer createFeatureLayerFromMapObject( InternalMapObject mapObject )
{
    Style style = mapObject.getStyle();
    
    SimpleFeatureType featureType = mapObject.getFeatureType();
    SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder( featureType );
    DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
    
    featureBuilder.add( mapObject.getGeometry() );
    SimpleFeature feature = featureBuilder.buildFeature( null );

    featureCollection.add( feature );

    return new FeatureLayer( featureCollection, style );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:19,代码来源:MapUtils.java

示例5: convert

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
@Override
public SimpleFeature convert( OrganisationUnit organisationUnit )
{
    SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder( featureType );

    if ( organisationUnit.getCoordinates() != null && !organisationUnit.getCoordinates().isEmpty() )
    {
        GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( organisationUnit.getCoordinates(), GeoUtils.CoordinateOrder.COORDINATE_LNGLAT );

        if ( coordinates.lng == null || coordinates.lat == null )
        {
            return null;
        }

        Coordinate coordinate = new Coordinate( coordinates.lng, coordinates.lat );
        Point point = geometryFactory.createPoint( coordinate );
        featureBuilder.add( point );

        featureBuilder.add( organisationUnit.getUid() );
        featureBuilder.add( organisationUnit.getName() );

        return featureBuilder.buildFeature( null );
    }

    return null;
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:27,代码来源:OrganisationUnitToSimpleFeature.java

示例6: buildSimpleFeature

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
/**
 * The purpose of this method is to build a SimpleFeature by assigning
 * properties from the FitActivity to the properties defined in the SimpleFeatureType.
 * @param fitActivity
 * @return
 */
public SimpleFeature buildSimpleFeature(final FitActivity fitActivity) {
    final SimpleFeatureType featureSchema = getFeatureSchema();
    final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureSchema);
    builder.set("activityId", fitActivity.getActivityId());
    builder.set("name", fitActivity.getName());
    builder.set("sport", fitActivity.getSport());
    builder.set("startTime", fitActivity.getStartTime());
    builder.set("totalMeters", fitActivity.getTotalMeters());
    builder.set("totalSeconds", fitActivity.getTotalSeconds());
    final Coordinate[] polyline = fitActivity.getPolyline().toArray(new Coordinate[fitActivity.getPolyline().size()]);
    final Geometry geometry = simplifyLineString(polyline);
    builder.add(geometry);
    final Coordinate[] boundingBox = generateBoundingBox(geometry);
    builder.set("minLat", boundingBox[0].y);
    builder.set("minLon", boundingBox[0].x);
    builder.set("maxLat", boundingBox[1].y);
    builder.set("maxLon", boundingBox[1].x);
    return builder.buildFeature(fitActivity.getActivityId().toString());
}
 
开发者ID:smitchell,项目名称:garmin-fit-geojson,代码行数:26,代码来源:GarminFitService.java

示例7: OSMInfo

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
public OSMInfo(final URL url, final long modificationStamp) {
	super(modificationStamp);
	CoordinateReferenceSystem crs = null;
	ReferencedEnvelope env2 = new ReferencedEnvelope();

	int number = 0;
	try {
		final File f = new File(url.toURI());
		final GamaOsmFile osmfile = new GamaOsmFile(null, f.getAbsolutePath());
		attributes.putAll(osmfile.getOSMAttributes(GAMA.getRuntimeScope()));

		final SimpleFeatureType TYPE = DataUtilities.createType("geometries", "geom:LineString");
		final ArrayList<SimpleFeature> list = new ArrayList<SimpleFeature>();
		for (final IShape shape : osmfile.iterable(null)) {
			list.add(SimpleFeatureBuilder.build(TYPE, new Object[] { shape.getInnerGeometry() }, null));
		}
		final SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, list);
		final SimpleFeatureSource featureSource = DataUtilities.source(collection);

		env2 = featureSource.getBounds();
		number = osmfile.nbObjects;
		crs = osmfile.getOwnCRS(null);
	} catch (final Exception e) {
		System.out.println("Error in reading metadata of " + url);
		hasFailed = true;

	} finally {

		// approximation of the width and height in meters.
		width = env2 != null ? env2.getWidth() * (FastMath.PI / 180) * 6378137 : 0;
		height = env2 != null ? env2.getHeight() * (FastMath.PI / 180) * 6378137 : 0;
		itemNumber = number;
		this.crs = crs;
	}

}
 
开发者ID:gama-platform,项目名称:gama,代码行数:37,代码来源:GamaOsmFile.java

示例8: createAggregationFeatures

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的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;
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:TestUtil.java

示例9: createCollection

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
/**
 * Create a SimpleFeatureCollection with a Geometry
 * 
 * @param all
 * @return
 * @throws SchemaException
 */
public static SimpleFeatureCollection createCollection(Geometry g) throws SchemaException {

  SimpleFeatureCollection collection = FeatureCollections.newCollection();
  SimpleFeatureType TYPE = DataUtilities.createType("MBB", "location:Polygon:srid=4326"); // 4326
                                                                                          // =
                                                                                          // srid
                                                                                          // of
                                                                                          // wgs84
  SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE);

  featureBuilder.add(g);
  SimpleFeature feature = featureBuilder.buildFeature(null);
  collection.add(feature);

  return collection;
}
 
开发者ID:esarbanis,项目名称:strabon,代码行数:24,代码来源:GeonamesParser.java

示例10: getBuilder

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的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

示例11: createFeatureBuilder

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
public static SimpleFeatureBuilder createFeatureBuilder( CoordinateReferenceSystem crs, boolean hasUserTotalMean ) {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("stats");
    b.setCRS(crs);
    b.add("the_geom", Polygon.class);
    b.add(MIN, Double.class);
    b.add(MAX, Double.class);
    b.add(AVG, Double.class);
    b.add(VAR, Double.class);
    b.add(SDEV, Double.class);
    if (hasUserTotalMean)
        b.add(AVGABSDEV, Double.class);
    b.add(ACTCELLS, Integer.class);
    b.add(INVCELLS, Integer.class);
    SimpleFeatureType type = b.buildFeatureType();
    return new SimpleFeatureBuilder(type);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:18,代码来源:OmsZonalStats.java

示例12: substituteGeometry

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
/**
 * @param newGeometry new geometry to insert.
 */
public void substituteGeometry( Geometry newGeometry ) {
    if (toRemove) {
        return;
    }
    if (newGeometry.getLength() < lengthThreshold) {
        feature = null;
        geometry = null;
        toRemove = true;
        return;
    }

    Object[] attributes = feature.getAttributes().toArray();
    Object[] newAttributes = new Object[attributes.length];
    System.arraycopy(attributes, 0, newAttributes, 0, attributes.length);
    newAttributes[0] = newGeometry;

    SimpleFeatureType featureType = feature.getFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
    builder.addAll(newAttributes);
    feature = builder.buildFeature(feature.getID());
    geometry = newGeometry;
    bufferPolygon = geometry.buffer(buffer);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:27,代码来源:FeatureElevationComparer.java

示例13: buildGeoWaveDataInstance

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
private static GeoWaveData<SimpleFeature> buildGeoWaveDataInstance(
		final String id,
		final Collection<ByteArrayId> primaryIndexIds,
		final ByteArrayId key,
		final SimpleFeatureBuilder builder,
		final Map<String, String> additionalDataSet ) {

	if (additionalDataSet != null) {
		for (final Map.Entry<String, String> entry : additionalDataSet.entrySet()) {
			builder.set(
					entry.getKey(),
					entry.getValue());
		}
	}
	return new GeoWaveData<SimpleFeature>(
			key,
			primaryIndexIds,
			builder.buildFeature(id));
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:20,代码来源:GPXConsumer.java

示例14: create

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
private SimpleFeature create(
		final String pid,
		final Set<String> set ) {
	final List<AttributeDescriptor> descriptors = schema.getAttributeDescriptors();
	final Object[] defaults = new Object[descriptors.size()];
	int p = 0;
	for (final AttributeDescriptor descriptor : descriptors) {
		defaults[p++] = descriptor.getDefaultValue();
	}

	final SimpleFeature newFeature = SimpleFeatureBuilder.build(
			schema,
			defaults,
			UUID.randomUUID().toString());

	newFeature.setAttribute(
			"pid",
			pid);

	set.add(pid);

	return newFeature;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:24,代码来源:FeatureHyperLogLogStaticticsTest.java

示例15: buildFeature

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
public static SimpleFeature buildFeature(
		final SimpleFeatureType featureType,
		final Pair<String, Object>[] entries ) {

	final List<AttributeDescriptor> descriptors = featureType.getAttributeDescriptors();
	final Object[] defaults = new Object[descriptors.size()];
	int p = 0;
	for (final AttributeDescriptor descriptor : descriptors) {
		defaults[p++] = descriptor.getDefaultValue();
	}
	final SimpleFeature newFeature = SimpleFeatureBuilder.build(
			featureType,
			defaults,
			UUID.randomUUID().toString());
	for (final Pair<String, Object> entry : entries) {
		newFeature.setAttribute(
				entry.getKey(),
				entry.getValue());
	}
	return newFeature;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:22,代码来源:FeatureDataUtils.java


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