class IntersectionFeatureCollection implements VectorProcess {

    static double getIntersectionArea(Geometry first, CoordinateReferenceSystem firstCRS,
            Geometry second, CoordinateReferenceSystem secondCRS, boolean divideFirst) {
        // basic checks
        if (firstCRS == null || secondCRS == null)
            throw new IllegalArgumentException("CRS cannot be set to null");
        if (!Polygon.class.isAssignableFrom(first.getClass())
                && !MultiPolygon.class.isAssignableFrom(first.getClass()))
            throw new IllegalArgumentException("first geometry must be poligonal");
        if (!Polygon.class.isAssignableFrom(second.getClass())
                && !MultiPolygon.class.isAssignableFrom(second.getClass()))
            throw new IllegalArgumentException("second geometry must be poligonal");
        try {
            Geometry firstTargetGeometry = reprojectAndDensify(first, firstCRS, null);
            Geometry secondTargetGeometry = reprojectAndDensify(second, firstCRS, null);
            double numeratorArea = (double) (firstTargetGeometry.intersection(secondTargetGeometry))
                    .getArea();
            if (divideFirst) {
                double denom = firstTargetGeometry.getArea();
                if (denom!=0) return numeratorArea / denom;
                return 0;
            }
            double denom = secondTargetGeometry.getArea();
            if (denom!=0) return numeratorArea / denom;
            return 0;
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }

}