Java Code Examples for org.geotools.feature.simple.SimpleFeatureBuilder#buildFeature()

The following examples show how to use org.geotools.feature.simple.SimpleFeatureBuilder#buildFeature() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapUtils.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 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 );
}
 
Example 2
Source File: OmsLW04_BankfullWidthAnalyzer.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
private DefaultFeatureCollection getWidthLines( CoordinateReferenceSystem crs,
        ConcurrentLinkedQueue<Object[]> validPointsLineList ) throws Exception {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("net");
    b.setCRS(crs);
    b.add("the_geom", LineString.class);
    b.add(PFAF, String.class);
    b.add(LINKID, Integer.class);
    b.add(ARiverSectionsExtractor.FIELD_SECTION_ID, Integer.class);
    b.add(ARiverSectionsExtractor.FIELD_PROGRESSIVE, Double.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);

    DefaultFeatureCollection newCollection = new DefaultFeatureCollection();

    for( Object[] objects : validPointsLineList ) {
        builder.addAll(objects);
        SimpleFeature feature = builder.buildFeature(null);
        newCollection.add(feature);
    }

    return newCollection;
}
 
Example 3
Source File: SplitsProviderIT.java    From geowave with Apache License 2.0 6 votes vote down vote up
public static void createUniformFeatures(
    final SimpleFeatureBuilder pointBuilder,
    final Writer<SimpleFeature> writer,
    final int firstFeatureId) {

  int featureId = firstFeatureId;
  for (int longitude = -180; longitude <= 180; longitude += 1) {
    for (int latitude = -90; latitude <= 90; latitude += 1) {
      pointBuilder.set(
          "geometry",
          GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(longitude, latitude)));
      pointBuilder.set("TimeStamp", new Date());
      pointBuilder.set("Latitude", latitude);
      pointBuilder.set("Longitude", longitude);
      // Note since trajectoryID and comment are marked as nillable we
      // don't need to set them (they default ot null).

      final SimpleFeature sft = pointBuilder.buildFeature(String.valueOf(featureId));
      writer.write(sft);
      featureId++;
    }
  }
}
 
Example 4
Source File: OmsGridsGenerator.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
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);
    }
}
 
Example 5
Source File: TestScanLineRasterizer.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
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;
    }
 
Example 6
Source File: ImportTrackAction.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static SimpleFeature createFeature(SimpleFeatureType type, GeoCoding geoCoding, int pointIndex, float lat, float lon, double data) {
    PixelPos pixelPos = geoCoding.getPixelPos(new GeoPos(lat, lon), null);
    if (!pixelPos.isValid()) {
        return null;
    }
    SimpleFeatureBuilder fb = new SimpleFeatureBuilder(type);
    GeometryFactory gf = new GeometryFactory();
    /*0*/
    fb.add(gf.createPoint(new Coordinate(pixelPos.x, pixelPos.y)));
    /*1*/
    fb.add(gf.createPoint(new Coordinate(lon, lat)));
    /*2*/
    fb.add(data);
    return fb.buildFeature(String.format("ID%08d", pointIndex));
}
 
Example 7
Source File: GeoWaveGTQueryTest.java    From rya with Apache License 2.0 5 votes vote down vote up
private static SimpleFeature buildSimpleFeature(final String locationName, final Coordinate coordinate) {
    final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(getPointSimpleFeatureType());
    builder.set("locationName", locationName);
    builder.set("geometry", GeometryUtils.GEOMETRY_FACTORY.createPoint(coordinate));

    return builder.buildFeature(locationName);
}
 
Example 8
Source File: GeometryTranslator.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Builds a line feature from a dwg arc.
 */
public SimpleFeature convertDwgArc( String typeName, String layerName, DwgArc arc, int id ) {
    double[] c = arc.getCenter();
    Point2D center = new Point2D.Double(c[0], c[1]);
    double radius = (arc).getRadius();
    double initAngle = Math.toDegrees((arc).getInitAngle());
    double endAngle = Math.toDegrees((arc).getEndAngle());
    Point2D[] ptos = GisModelCurveCalculator.calculateGisModelArc(center, radius, initAngle,
            endAngle);
    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);
}
 
Example 9
Source File: GeoDbTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void testCreate() throws GeomajasException, ParseException {
	// test creating a 5th geometry, expect auto-generated id
	WKTReader wktReader = new WKTReader();
	Point geometry = (Point) wktReader.read("POINT (0 0)");
	SimpleFeatureBuilder build = new SimpleFeatureBuilder(pointLayer.getSchema());
	SimpleFeature feature = build.buildFeature(null, new Object[] { "point5", geometry });
	SimpleFeature created = (SimpleFeature) pointLayer.create(feature);
	Assert.assertNotNull(created);
	Assert.assertEquals("POINT.5", created.getID());
}
 
Example 10
Source File: GPXConsumer.java    From geowave with Apache License 2.0 5 votes vote down vote up
private static GeoWaveData<SimpleFeature> buildGeoWaveDataInstance(
    final String id,
    final String[] indexNames,
    final String 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<>(key, indexNames, builder.buildFeature(id));
}
 
Example 11
Source File: SpatialTemporalQueryExample.java    From geowave with Apache License 2.0 5 votes vote down vote up
private static SimpleFeature buildSimpleFeature(
    final String locationName,
    final Coordinate coordinate,
    final Date startTime,
    final Date endTime) {

  final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(getPointSimpleFeatureType());
  builder.set("locationName", locationName);
  builder.set("geometry", GeometryUtils.GEOMETRY_FACTORY.createPoint(coordinate));
  builder.set("startTime", startTime);
  builder.set("endTime", endTime);

  return builder.buildFeature(locationName);
}
 
Example 12
Source File: SimpleFeatureFigureFactoryTest.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    final SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder();
    sftb.setName("someName");
    sftb.add(PlainFeatureFactory.ATTRIB_NAME_STYLE_CSS, String.class);
    SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(sftb.buildFeatureType());
    simpleFeature = sfb.buildFeature("someId");
}
 
Example 13
Source File: CustomIndexExample.java    From geowave with Apache License 2.0 5 votes vote down vote up
private SimpleFeature buildSimpleFeature(
    final String featureId,
    final Coordinate coordinate,
    final String uuid) {

  final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(simpleFeatureType);
  builder.set("geometry", GeometryUtils.GEOMETRY_FACTORY.createPoint(coordinate));
  builder.set("uuid", uuid);

  return builder.buildFeature(featureId);
}
 
Example 14
Source File: OmsLinesPolygonizer.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
@Execute
public void process() throws Exception {
    checkNull(inMap);

    outMap = new DefaultFeatureCollection();

    EGeometryType geometryType = EGeometryType.forGeometryDescriptor(inMap.getSchema().getGeometryDescriptor());
    switch( geometryType ) {
    case LINESTRING:
    case MULTILINESTRING:
        break;
    default:
        throw new ModelsIllegalargumentException("The module only works with line layers.", this, pm);
    }

    List<Geometry> linesList = FeatureUtilities.featureCollectionToGeometriesList(inMap, true, null);

    // Polygonization
    final Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(linesList);
    @SuppressWarnings("unchecked")
    final Collection<Polygon> polygonizedLines = polygonizer.getPolygons();

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("polygonized");
    b.setCRS(inMap.getSchema().getCoordinateReferenceSystem());
    b.add("the_geom", Polygon.class);
    b.add(fNewId, String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);

    List<Geometry> pointGeometries = new ArrayList<Geometry>();
    if (inPoints != null) {
        fId = FeatureUtilities.findAttributeName(inPoints.getSchema(), fId);
        pointGeometries = FeatureUtilities.featureCollectionToGeometriesList(inPoints, false, fId);
    }

    pm.beginTask("Generating polygon features...", polygonizedLines.size());
    int index = 0;
    for( Polygon polygon : polygonizedLines ) {
        String attribute = String.valueOf(index++);
        if (inPoints != null) {
            attribute = "-";
            for( Geometry point : pointGeometries ) {
                if (polygon.contains(point)) {
                    attribute = point.getUserData().toString();
                    break;
                }
            }
        }

        Object[] values = new Object[]{polygon, attribute};
        builder.addAll(values);
        SimpleFeature feature = builder.buildFeature(null);
        ((DefaultFeatureCollection) outMap).add(feature);

        pm.worked(1);
    }
    pm.done();
}
 
Example 15
Source File: DxfLINE.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public static DxfGroup readEntity( RandomAccessFile raf,
        DefaultFeatureCollection entities ) throws IOException {

    double x1 = Double.NaN, y1 = Double.NaN, z1 = Double.NaN;
    double x2 = Double.NaN, y2 = Double.NaN, z2 = Double.NaN;
    DxfGroup group;

    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(DxfFile.DXF_LINESCHEMA);
    String layer = "";
    String ltype = "";
    Double elevation = new Double(0.0);
    Double thickness = new Double(0.0);
    Integer color = new Integer(256);
    String text = "";
    Double text_height = new Double(0.0);
    String text_style = "";

    while( null != (group = DxfGroup.readGroup(raf)) && group.getCode() != 0 ) {
        if (group.getCode() == 8)
            layer = group.getValue();
        else if (group.getCode() == 6)
            ltype = group.getValue();
        else if (group.getCode() == 39)
            thickness = new Double(group.getDoubleValue());
        else if (group.getCode() == 62)
            color = new Integer(group.getIntValue());
        else if (group.getCode() == 10)
            x1 = group.getDoubleValue();
        else if (group.getCode() == 20)
            y1 = group.getDoubleValue();
        else if (group.getCode() == 30)
            z1 = group.getDoubleValue();
        else if (group.getCode() == 11)
            x2 = group.getDoubleValue();
        else if (group.getCode() == 21)
            y2 = group.getDoubleValue();
        else if (group.getCode() == 31)
            z2 = group.getDoubleValue();
        else {
        }
    }
    if (!Double.isNaN(x1) && !Double.isNaN(y1) && !Double.isNaN(x2) && !Double.isNaN(y2)) {
        Object[] values = new Object[]{
                gF.createLineString(new Coordinate[]{new Coordinate(x1, y1, z1),
                        new Coordinate(x2, y2, z2)}), layer, ltype, elevation, thickness,
                color, text, text_height, text_style};
        builder.addAll(values);
        StringBuilder featureId = new StringBuilder();
        featureId.append(DxfFile.DXF_LINESCHEMA.getTypeName());
        featureId.append(".");
        featureId.append(DxfFile.getNextFid());
        SimpleFeature feature = builder.buildFeature(featureId.toString());
        entities.add(feature);
    }
    return group;
}
 
Example 16
Source File: TestVectorReader.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public void testShapefileReader() 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();
        for( int i = 0; i < 2; i++ ) {
            SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);

            Point point = GeometryUtilities.gf().createPoint(new Coordinate(i, i));
            Object[] values = new Object[]{point, i};
            builder.addAll(values);
            SimpleFeature feature = builder.buildFeature(type.getTypeName() + "." + i);
            newCollection.add(feature);
        }

        File tmpShape = File.createTempFile("testshp", ".shp");
        if (tmpShape.exists()) {
            if (!tmpShape.delete())
                throw new IOException();
        }
        OmsVectorWriter writer = new OmsVectorWriter();
        writer.file = tmpShape.getAbsolutePath();
        writer.inVector = newCollection;
        writer.process();

        // now read it again
        OmsVectorReader reader = new OmsVectorReader();
        reader.file = tmpShape.getAbsolutePath();
        reader.process();
        SimpleFeatureCollection readFC = reader.outVector;

        FeatureIterator<SimpleFeature> featureIterator = readFC.features();
        while( featureIterator.hasNext() ) {
            SimpleFeature f = featureIterator.next();

            int id = ((Number) f.getAttribute("id")).intValue();
            Geometry geometry = (Geometry) f.getDefaultGeometry();
            Coordinate coordinate = geometry.getCoordinate();

            if (id == 0) {
                assertEquals(coordinate.x, 0.0);
                assertEquals(coordinate.y, 0.0);
            }
            if (id == 1) {
                assertEquals(coordinate.x, 1.0);
                assertEquals(coordinate.y, 1.0);
            }
            if (id == 2) {
                assertEquals(coordinate.x, 2.0);
                assertEquals(coordinate.y, 2.0);
            }
        }

        if (tmpShape.exists()) {
            tmpShape.deleteOnExit();
        }
    }
 
Example 17
Source File: SpatialQueryExample.java    From geowave with Apache License 2.0 4 votes vote down vote up
private void ingestPolygonFeature() throws ParseException {
  log.info("Ingesting polygon data");
  // First, we'll build our third kind of SimpleFeature, which we'll call
  // "polygon-feature"
  // We need the type builder to build the feature type
  final SimpleFeatureTypeBuilder sftBuilder = new SimpleFeatureTypeBuilder();
  // AttributeTypeBuilder for the attributes of the SimpleFeature
  final AttributeTypeBuilder attrBuilder = new AttributeTypeBuilder();
  // Here we're setting the SimpleFeature name. Later on, we'll be able to
  // query GW just by this particular feature.
  sftBuilder.setName("polygon-feature");
  // Add the attributes to the feature
  // Add the geometry attribute, which is mandatory for GeoWave to be able
  // to construct an index out of the SimpleFeature
  // Will be any arbitrary geometry; in this case, a polygon.
  sftBuilder.add(attrBuilder.binding(Geometry.class).nillable(false).buildDescriptor("geometry"));
  // Add another attribute just to be able to filter by it in CQL
  sftBuilder.add(attrBuilder.binding(String.class).nillable(false).buildDescriptor("filter"));

  // Create the SimpleFeatureType
  final SimpleFeatureType sfType = sftBuilder.buildFeatureType();
  // We need the adapter for all our operations with GeoWave
  final FeatureDataAdapter sfAdapter = new FeatureDataAdapter(sfType);

  // Now we build the actual features. We'll create one polygon.
  // First point
  final SimpleFeatureBuilder sfBuilder = new SimpleFeatureBuilder(sfType);

  // For ease of use, we'll create the polygon geometry with WKT format.
  final String polygonDefinition =
      "POLYGON (( "
          + "-80.3045654296875 25.852426562716428, "
          + "-80.123291015625 25.808545671771615, "
          + "-80.19195556640625 25.7244467526159, "
          + "-80.34233093261719 25.772068899816585, "
          + "-80.3045654296875 25.852426562716428"
          + "))";
  final Geometry geom =
      new WKTReader(JTSFactoryFinder.getGeometryFactory()).read(polygonDefinition);
  sfBuilder.set("geometry", geom);
  sfBuilder.set("filter", "Polygon");
  // When calling buildFeature, we need to pass an unique id for that
  // feature, or it will be overwritten.
  final SimpleFeature polygon = sfBuilder.buildFeature("1");

  final ArrayList<SimpleFeature> features = new ArrayList<>();
  features.add(polygon);

  // Ingest the data. For that purpose, we need the feature adapter,
  // the index type (the default spatial index is used here),
  // and an iterator of SimpleFeature
  ingest(sfAdapter, new SpatialIndexBuilder().createIndex(), features);
  log.info("Polygon data ingested");
}
 
Example 18
Source File: SLDUtils.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
public static SimpleFeature createStyledFeature(SimpleFeatureType type, SimpleFeature feature, String styleCSS) {
    SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(type);
    sfb.init(feature);
    sfb.set(PlainFeatureFactory.ATTRIB_NAME_STYLE_CSS, styleCSS);
    return sfb.buildFeature(feature.getID());
}
 
Example 19
Source File: SqlResultsWriter.java    From geowave with Apache License 2.0 4 votes vote down vote up
public void writeResults(String typeName) {
  if (typeName == null) {
    typeName = DEFAULT_TYPE_NAME;
    LOGGER.warn(
        "Using default type name (adapter id): '" + DEFAULT_TYPE_NAME + "' for SQL output");
  }

  final StructType schema = results.schema();
  final SimpleFeatureType featureType = SchemaConverter.schemaToFeatureType(schema, typeName);

  final SimpleFeatureBuilder sfBuilder = new SimpleFeatureBuilder(featureType);

  final FeatureDataAdapter featureAdapter = new FeatureDataAdapter(featureType);

  final DataStore featureStore = outputDataStore.createDataStore();
  final Index featureIndex =
      new SpatialDimensionalityTypeProvider().createIndex(new SpatialOptions());
  featureStore.addType(featureAdapter, featureIndex);
  try (Writer writer = featureStore.createWriter(featureAdapter.getTypeName())) {

    final List<Row> rows = results.collectAsList();

    for (int r = 0; r < rows.size(); r++) {
      final Row row = rows.get(r);

      for (int i = 0; i < schema.fields().length; i++) {
        final StructField field = schema.apply(i);
        final Object rowObj = row.apply(i);
        if (rowObj != null) {
          if (field.name().equals("geom")) {
            final Geometry geom = (Geometry) rowObj;

            sfBuilder.set("geom", geom);
          } else if (field.dataType() == DataTypes.TimestampType) {
            final long millis = ((Timestamp) rowObj).getTime();
            final Date date = new Date(millis);

            sfBuilder.set(field.name(), date);
          } else {
            sfBuilder.set(field.name(), rowObj);
          }
        }
      }

      final SimpleFeature sf = sfBuilder.buildFeature("result-" + nf.format(r));

      writer.write(sf);
    }
  }
}
 
Example 20
Source File: Las2RasterInterpolator.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
@Execute
public void process() throws Exception {
    checkNull(inIndexFile, inDtm);

    GridCoverage2D inDtmGC = getRaster(inDtm);
    Polygon polygon = CoverageUtilities.getRegionPolygon(inDtmGC);
    CoordinateReferenceSystem crs = inDtmGC.getCoordinateReferenceSystem();

    try (ALasDataManager lasData = ALasDataManager.getDataManager(new File(inIndexFile), inDtmGC, pThreshold, crs)) {
        lasData.open();
        if (pImpulse != null) {
            lasData.setImpulsesConstraint(new double[]{pImpulse});
        }

        List<LasRecord> lasPoints = lasData.getPointsInGeometry(polygon, false);
        if (lasPoints.size() == 0) {
            pm.message("No points foudn in the given area. Check your input.");
            return;
        }

        RegionMap regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inDtmGC);
        double north = regionMap.getNorth();
        double south = regionMap.getSouth();
        double east = regionMap.getEast();
        double west = regionMap.getWest();
        if (pXres == null) {
            pXres = regionMap.getXres();
        }
        if (pYres == null) {
            pYres = regionMap.getYres();
        }

        int newRows = (int) round((north - south) / pYres);
        int newCols = (int) round((east - west) / pXres);

        DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
        final SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName("lasdata");
        b.setCRS(crs);
        b.add("the_geom", Point.class);
        b.add("elev", Double.class);
        final SimpleFeatureType featureType = b.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);

        pm.beginTask("Prepare points collection for interpolation...", lasPoints.size());
        for( LasRecord r : lasPoints ) {
            final Point point = gf.createPoint(new Coordinate(r.x, r.y));
            final Object[] values = new Object[]{point, r.z,};
            builder.addAll(values);
            final SimpleFeature feature = builder.buildFeature(null);
            newCollection.add(feature);
            pm.worked(1);
        }
        pm.done();

        OmsRasterGenerator omsRasterGenerator = new OmsRasterGenerator();
        omsRasterGenerator.pNorth = north;
        omsRasterGenerator.pSouth = south;
        omsRasterGenerator.pWest = west;
        omsRasterGenerator.pEast = east;
        omsRasterGenerator.pXres = (east - west) / newCols;
        omsRasterGenerator.pYres = (north - south) / newRows;
        omsRasterGenerator.inCrs = crs;
        omsRasterGenerator.doRandom = false;
        omsRasterGenerator.process();

        OmsSurfaceInterpolator idwInterpolator = new OmsSurfaceInterpolator();
        idwInterpolator.inVector = newCollection;
        idwInterpolator.inGrid = omsRasterGenerator.outRaster;
        idwInterpolator.inMask = null;
        idwInterpolator.fCat = "elev";
        idwInterpolator.pMode = Variables.IDW;
        idwInterpolator.pMaxThreads = getDefaultThreadsNum();
        idwInterpolator.pBuffer = 10.0;
        idwInterpolator.pm = pm;
        idwInterpolator.process();
        GridCoverage2D outRasterGC = idwInterpolator.outRaster;
        dumpRaster(outRasterGC, outRaster);

    }
}