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


Java SimpleFeatureBuilder.addAll方法代码示例

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


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

示例1: testFeatureUtils

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
@SuppressWarnings("nls")
public void testFeatureUtils() throws Exception {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("typename");
    b.setCRS(DefaultGeographicCRS.WGS84);
    b.add("the_geom", Point.class);
    b.add("AttrName", String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Object[] values = new Object[]{GeometryUtilities.gf().createPoint(new Coordinate(0, 0)), "test"};
    builder.addAll(values);
    SimpleFeature feature = builder.buildFeature(type.getTypeName());

    Object attr = FeatureUtilities.getAttributeCaseChecked(feature, "attrname");
    assertEquals("test", attr.toString());
    attr = FeatureUtilities.getAttributeCaseChecked(feature, "attrnam");
    assertNull(attr);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:19,代码来源:TestFeatureUtils.java

示例2: convertDwgPoint

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
/**
 * Builds a point feature from a dwg point.
 */
public SimpleFeature convertDwgPoint( String typeName, String layerName, DwgPoint point, int id ) {
    double[] p = point.getPoint();
    Point2D pto = new Point2D.Double(p[0], p[1]);

    CoordinateList coordList = new CoordinateList();
    Coordinate coord = new Coordinate(pto.getX(), pto.getY(), 0.0);
    coordList.add(coord);

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(typeName);
    b.setCRS(crs);
    b.add(THE_GEOM, MultiPoint.class);
    b.add(LAYER, String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Geometry points = gF.createMultiPoint(coordList.toCoordinateArray());
    Object[] values = new Object[]{points, layerName};
    builder.addAll(values);
    return builder.buildFeature(typeName + "." + id);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:24,代码来源:GeometryTranslator.java

示例3: createPoints

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的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);
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:27,代码来源:OmsGridsGenerator.java

示例4: createBboxGeometry

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

示例5: convertDwgLine

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

示例6: convertDwgPolyline2D

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
/**
 * Builds a line feature from a dwg polyline 2D.
 * 
 */
public SimpleFeature convertDwgPolyline2D( String typeName, String layerName,
        DwgPolyline2D polyline2d, int id ) {
    Point2D[] ptos = polyline2d.getPts();
    CoordinateList coordList = new CoordinateList();
    if (ptos != null) {
        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;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:29,代码来源:GeometryTranslator.java

示例7: doCollection

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private SimpleFeatureCollection doCollection() {
    CoordinateReferenceSystem crs = HMTestMaps.getCrs();
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("typename");
    b.setCRS(crs);
    b.add("the_geom", LineString.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);

    Coordinate one = new Coordinate(westNorth.x + ep.getXres() / 2, centerCoord.y + ep.getYres() / 2);
    Coordinate two = new Coordinate(eastSouth.x - ep.getXres() / 2, centerCoord.y + ep.getYres() / 2);

    LineString lineString = GeometryUtilities.gf().createLineString(new Coordinate[]{one, two});
    Object[] values = new Object[]{lineString};
    builder.addAll(values);
    SimpleFeature feature = builder.buildFeature(null);
    DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
    newCollection.add(feature);
    return newCollection;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:21,代码来源:TestProfile.java

示例8: makeOutletFC

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private void makeOutletFC( Point snappedOutletPoint ) {
    outOutlet = new DefaultFeatureCollection();

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("outlet");
    b.setCRS(crs);
    b.add("the_geom", Point.class);
    b.add(FIELD_BASINAREA, Double.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Object[] values = new Object[]{snappedOutletPoint, -9999.0};
    builder.addAll(values);
    SimpleFeature feature = builder.buildFeature(null);
    ((DefaultFeatureCollection) outOutlet).add(feature);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:16,代码来源:OmsExtractBasin.java

示例9: toFeatureCollection

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
/**
 * Create a {@link SimpleFeatureCollection FeatureCollection} from the current tin triangles
 * with information about the vertexes elevation.
 * 
 * @return the feature collection of the tin.
 */
public SimpleFeatureCollection toFeatureCollection() {
    checkTinGeometries();
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("triangle");
    b.setCRS(crs);

    DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
    b.add("the_geom", Polygon.class);
    b.add("elev0", Double.class);
    b.add("elev1", Double.class);
    b.add("elev2", Double.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    for( Geometry g : tinGeometries ) {
        Coordinate[] coordinates = g.getCoordinates();

        Object[] values;
        int windingRule = GeometryUtilities.getTriangleWindingRule(coordinates[0], coordinates[1], coordinates[2]);
        if (windingRule > 0) {
            // need to reverse the triangle
            values = new Object[]{g, coordinates[0].z, coordinates[2].z, coordinates[1].z};
        } else {
            values = new Object[]{g, coordinates[0].z, coordinates[1].z, coordinates[2].z};
        }

        builder.addAll(values);
        SimpleFeature feature = builder.buildFeature(null);
        newCollection.add(feature);
    }
    return newCollection;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:38,代码来源:TinHandler.java

示例10: substituteGeometry

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
public SimpleFeature substituteGeometry( SimpleFeature oldFeature, Geometry newGeometry, String id ) {
    Object[] attributes = oldFeature.getAttributes().toArray();
    Object[] newAttributes = new Object[attributes.length];
    System.arraycopy(attributes, 0, newAttributes, 0, attributes.length);
    newAttributes[0] = newGeometry;
    // create the feature
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(newFeatureType);
    builder.addAll(newAttributes);
    SimpleFeature f = builder.buildFeature(id);
    return f;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:12,代码来源:FeatureGeometrySubstitutor.java

示例11: convertDwgSolid

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
/**
 * Builds a polygon feature from a dwg solid.
 * 
 */
public SimpleFeature convertDwgSolid( String typeName, String layerName, DwgSolid solid, int id ) {
    double[] p1 = solid.getCorner1();
    double[] p2 = solid.getCorner2();
    double[] p3 = solid.getCorner3();
    double[] p4 = solid.getCorner4();
    Point2D[] ptos = new Point2D[]{new Point2D.Double(p1[0], p1[1]),
            new Point2D.Double(p2[0], p2[1]), new Point2D.Double(p3[0], p3[1]),
            new Point2D.Double(p4[0], p4[1])};
    CoordinateList coordList = new CoordinateList();
    for( int j = 0; j < ptos.length; j++ ) {
        Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY());
        coordList.add(coord);
    }
    coordList.closeRing();

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(typeName);
    b.setCRS(crs);
    b.add(THE_GEOM, Polygon.class);
    b.add(LAYER, String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    LinearRing linearRing = gF.createLinearRing(coordList.toCoordinateArray());
    Geometry polygon = gF.createPolygon(linearRing, null);
    Object[] values = new Object[]{polygon, layerName};
    builder.addAll(values);
    return builder.buildFeature(typeName + "." + id);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:33,代码来源:GeometryTranslator.java

示例12: toDummyFeature

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
public static SimpleFeature toDummyFeature( Geometry geom, CoordinateReferenceSystem crs ) {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("dummy");
    if (crs != null)
        b.setCRS(crs);
    b.add("the_geom", geom.getClass());
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Object[] values = new Object[]{geom};
    builder.addAll(values);
    SimpleFeature feature = builder.buildFeature(null);
    return feature;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:14,代码来源:FeatureUtilities.java

示例13: testVectorTransformer

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
public void testVectorTransformer() throws Exception {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("test");
    b.setCRS(DefaultGeographicCRS.WGS84);
    b.add("the_geom", Point.class);
    b.add("id", Integer.class);

    DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Point point = GeometryUtilities.gf().createPoint(new Coordinate(0, 0));
    Object[] values = new Object[]{point, 1};
    builder.addAll(values);
    SimpleFeature feature = builder.buildFeature(type.getTypeName() + ".0");
    newCollection.add(feature);

    OmsVectorTransformer transformer = new OmsVectorTransformer();
    transformer.inVector = newCollection;
    transformer.pTransX = 1.0;
    transformer.pTransY = -1.0;
    transformer.process();
    SimpleFeatureCollection outFeatures = transformer.outVector;

    Geometry g = FeatureUtilities.featureCollectionToGeometriesList(outFeatures, false, null).get(0);
    Coordinate coord = g.getCoordinate();

    assertEquals(coord.x, 1.0, 0.00001);
    assertEquals(coord.y, -1.0, 0.00001);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:30,代码来源:TestVectorTransformer.java

示例14: dumpLasFolderOverview

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
/**
 * Dump an overview shapefile for a las folder.
 * 
 * @param folder the folder.
 * @param crs the crs to use.
 * @throws Exception
 */
public static void dumpLasFolderOverview( String folder, CoordinateReferenceSystem crs ) throws Exception {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("overview");
    b.setCRS(crs);
    b.add("the_geom", Polygon.class);
    b.add("name", String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);

    DefaultFeatureCollection newCollection = new DefaultFeatureCollection();

    OmsFileIterator iter = new OmsFileIterator();
    iter.inFolder = folder;
    iter.fileFilter = new FileFilter(){
        public boolean accept( File pathname ) {
            return pathname.getName().endsWith(".las");
        }
    };
    iter.process();

    List<File> filesList = iter.filesList;

    for( File file : filesList ) {
        try (ALasReader r = new LasReaderBuffered(file, crs)) {
            r.open();
            ReferencedEnvelope3D envelope = r.getHeader().getDataEnvelope();
            Polygon polygon = GeometryUtilities.createPolygonFromEnvelope(envelope);
            Object[] objs = new Object[]{polygon, r.getLasFile().getName()};
            builder.addAll(objs);
            SimpleFeature feature = builder.buildFeature(null);
            newCollection.add(feature);
        }
    }

    File folderFile = new File(folder);
    File outFile = new File(folder, "overview_" + folderFile.getName() + ".shp");
    OmsVectorWriter.writeVector(outFile.getAbsolutePath(), newCollection);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:46,代码来源:LasUtils.java

示例15: createPointTextFeature

import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private SimpleFeature createPointTextFeature( String typeName, String layerName, int id,
        Coordinate coord, String textString ) {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(typeName);
    b.setCRS(crs);
    b.add(THE_GEOM, Point.class);
    b.add("text", String.class);
    b.add(LAYER, String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Geometry point = gF.createPoint(coord);
    Object[] values = new Object[]{point, textString, layerName};
    builder.addAll(values);
    return builder.buildFeature(typeName + "." + id);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:16,代码来源:GeometryTranslator.java


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