public SimpleFeatureCollection toFeatureCollection(
            List<MonitoringPoint> monitoringPointsList ) {

        // create the feature type
        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        // set the name
        b.setName("monitoringpoints");
        // add a geometry property
        b.add("the_geom", Point.class);
        // add some properties
        b.add("id", Integer.class);
        b.add("relatedid", Integer.class);
        b.add("pfaf", String.class);
        // build the type
        SimpleFeatureType type = b.buildFeatureType();
        // create the feature
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);

        GeometryFactory gF = new GeometryFactory();
        /*
         * insert them in inverse order to get them out of the collection in the same order as the
         * list
         */
        DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
        for( int i = 0; i < monitoringPointsList.size(); i++ ) {
            MonitoringPoint mp = monitoringPointsList.get(monitoringPointsList.size() - i - 1);

            Object[] values = new Object[]{gF.createPoint(mp.getPosition()), mp.getID(),
                    mp.getRelatedID(), mp.getPfatstetterNumber().toString()};
            // add the values
            builder.addAll(values);
            // build the feature with provided ID
            SimpleFeature feature = builder.buildFeature(type.getTypeName() + "." + i);
            newCollection.add(feature);
        }

        return newCollection;
    }
public SimpleFeatureCollection toFeatureCollection ( List < MonitoringPoint > monitoringPointsList ) { SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder ( ) ; b . setName ( "monitoringpoints" ) ; b . add ( "the_geom" , Point . class ) ; b . add ( "id" , Integer . class ) ; b . add ( "relatedid" , Integer . class ) ; b . add ( "pfaf" , String . class ) ; SimpleFeatureType type = b . buildFeatureType ( ) ; SimpleFeatureBuilder builder = new SimpleFeatureBuilder ( type ) ; GeometryFactory gF = new GeometryFactory ( ) ; DefaultFeatureCollection newCollection = new DefaultFeatureCollection ( ) ; for ( int i = 0 ; i < monitoringPointsList . size ( ) ; i ++ ) { MonitoringPoint mp = monitoringPointsList . get ( monitoringPointsList . size ( ) - i - 1 ) ; Object [ ] values = new Object [ ] { gF . createPoint ( mp . getPosition ( ) ) , mp . getID ( ) , mp . getRelatedID ( ) , mp . getPfatstetterNumber ( ) . toString ( ) } ; builder . addAll ( values ) ; SimpleFeature feature = builder . buildFeature ( type . getTypeName ( ) + "." + i ) ; newCollection . add ( feature ) ; } return newCollection ; }
Create a featurecollection from a list of monitoringpoints. Based on the position of the
points and some of their attributes.

@param monitoringPointsList
@return the featurecollection