public static Geometry lineIntersector(Geometry inputLines, Geometry clipper) throws IllegalArgumentException {
        if(inputLines == null||clipper == null){
            return null;
        }
        if(inputLines.getDimension()==1){
        MCIndexNoder mCIndexNoder = new MCIndexNoder();
        mCIndexNoder.setSegmentIntersector(new IntersectionAdder(ROBUST_INTERSECTOR));        
        mCIndexNoder.computeNodes(getSegments(inputLines, clipper));
        Collection nodedSubstring = mCIndexNoder.getNodedSubstrings();
        GeometryFactory gf = inputLines.getFactory();
        ArrayList<LineString> linestrings = new ArrayList<LineString>(nodedSubstring.size());
        for (Iterator it = nodedSubstring.iterator(); it.hasNext();) {
            SegmentString segment = (SegmentString) it.next();
            //We keep only the segments of the input geometry
            if((Integer)segment.getData()==0){
                Coordinate[] cc = segment.getCoordinates();
                cc = CoordinateArrays.atLeastNCoordinatesOrNothing(2, cc);
                if (cc.length > 1) {
                    linestrings.add(gf.createLineString(cc));
                }
            }
        }
        if (linestrings.isEmpty()) {
            return inputLines;
        } else {
            return gf.createMultiLineString(linestrings.toArray(new LineString[0]));
        }}
        throw new IllegalArgumentException("Split a " + inputLines.getGeometryType() + " by a " + clipper.getGeometryType() + " is not supported.");
    }
public static Geometry lineIntersector ( Geometry inputLines , Geometry clipper ) throws IllegalArgumentException { if ( inputLines == null || clipper == null ) { return null ; } if ( inputLines . getDimension ( ) == 1 ) { MCIndexNoder mCIndexNoder = new MCIndexNoder ( ) ; mCIndexNoder . setSegmentIntersector ( new IntersectionAdder ( ROBUST_INTERSECTOR ) ) ; mCIndexNoder . computeNodes ( getSegments ( inputLines , clipper ) ) ; Collection nodedSubstring = mCIndexNoder . getNodedSubstrings ( ) ; GeometryFactory gf = inputLines . getFactory ( ) ; ArrayList < LineString > linestrings = new ArrayList < LineString > ( nodedSubstring . size ( ) ) ; for ( Iterator it = nodedSubstring . iterator ( ) ; it . hasNext ( ) ; ) { SegmentString segment = ( SegmentString ) it . next ( ) ; if ( ( Integer ) segment . getData ( ) == 0 ) { Coordinate [ ] cc = segment . getCoordinates ( ) ; cc = CoordinateArrays . atLeastNCoordinatesOrNothing ( 2 , cc ) ; if ( cc . length > 1 ) { linestrings . add ( gf . createLineString ( cc ) ) ; } } } if ( linestrings . isEmpty ( ) ) { return inputLines ; } else { return gf . createMultiLineString ( linestrings . toArray ( new LineString [ 0 ] ) ) ; } } throw new IllegalArgumentException ( "Split a " + inputLines . getGeometryType ( ) + " by a " + clipper . getGeometryType ( ) + " is not supported." ) ; }
Split a lineal geometry by a another geometry
@param inputLines
@param clipper
@return