public static List<ProfilePoint> doProfile( RandomIter mapIter, GridGeometry2D gridGeometry, Coordinate... coordinates )
            throws TransformException {
        List<ProfilePoint> profilePointsList = new ArrayList<ProfilePoint>();

        GridEnvelope2D gridRange = gridGeometry.getGridRange2D();
        int rows = gridRange.height;
        int cols = gridRange.width;
        AffineTransform gridToCRS = (AffineTransform) gridGeometry.getGridToCRS();
        double xres = XAffineTransform.getScaleX0(gridToCRS);
        double yres = XAffineTransform.getScaleY0(gridToCRS);

        double step = Math.min(xres, yres);

        LineString line = GeometryUtilities.gf().createLineString(coordinates);
        double lineLength = line.getLength();
        LengthIndexedLine indexedLine = new LengthIndexedLine(line);

        double progressive = 0.0;
        GridCoordinates2D gridCoords;
        while( progressive < lineLength + step ) { // run over by a step to make sure we get the
                                                   // last coord back from the extractor
            Coordinate c = indexedLine.extractPoint(progressive);
            gridCoords = gridGeometry.worldToGrid(new DirectPosition2D(c.x, c.y));
            double value = HMConstants.doubleNovalue;
            if (// envelope2d.contains(c.x, c.y) &&
            isInside(cols - 1, rows - 1, gridCoords)) {
                value = mapIter.getSampleDouble(gridCoords.x, gridCoords.y, 0);
            }
            ProfilePoint profilePoint = new ProfilePoint(progressive, value, c.x, c.y);
            profilePointsList.add(profilePoint);
            progressive = progressive + step;
        }
        return profilePointsList;
    }
public static List < ProfilePoint > doProfile ( RandomIter mapIter , GridGeometry2D gridGeometry , Coordinate ... coordinates ) throws TransformException { List < ProfilePoint > profilePointsList = new ArrayList < ProfilePoint > ( ) ; GridEnvelope2D gridRange = gridGeometry . getGridRange2D ( ) ; int rows = gridRange . height ; int cols = gridRange . width ; AffineTransform gridToCRS = ( AffineTransform ) gridGeometry . getGridToCRS ( ) ; double xres = XAffineTransform . getScaleX0 ( gridToCRS ) ; double yres = XAffineTransform . getScaleY0 ( gridToCRS ) ; double step = Math . min ( xres , yres ) ; LineString line = GeometryUtilities . gf ( ) . createLineString ( coordinates ) ; double lineLength = line . getLength ( ) ; LengthIndexedLine indexedLine = new LengthIndexedLine ( line ) ; double progressive = 0.0 ; GridCoordinates2D gridCoords ; while ( progressive < lineLength + step ) { Coordinate c = indexedLine . extractPoint ( progressive ) ; gridCoords = gridGeometry . worldToGrid ( new DirectPosition2D ( c . x , c . y ) ) ; double value = HMConstants . doubleNovalue ; if ( isInside ( cols - 1 , rows - 1 , gridCoords ) ) { value = mapIter . getSampleDouble ( gridCoords . x , gridCoords . y , 0 ) ; } ProfilePoint profilePoint = new ProfilePoint ( progressive , value , c . x , c . y ) ; profilePointsList . add ( profilePoint ) ; progressive = progressive + step ; } return profilePointsList ; }
Calculates the profile of a raster map between given {@link Coordinate coordinates}.

<p>Note that novalues and points outside of the given raster region are
added to the list with a {@link HMConstants#doubleNovalue novalue} elevation.

@param mapIter the {@link RandomIter map iterator}.
@param gridGeometry the gridgeometry of the map.
@param coordinates the {@link Coordinate}s to create the profile on.
@return the list of {@link ProfilePoint}s.
@throws TransformException