public Intersection splitRoad(Road road,RoadPoint rp){
  RoadPoint[] pointsBefore=road.getPointsBefore(rp);
  RoadPoint[] pointsAfter=road.getPointsAfter(rp);
  Intersection newIntersection=findIntersection(rp.getLocation(),null);
  Intersection firstIntersection=road.getFirstIntersection();
  Intersection secondIntersection=road.getSecondIntersection();
  road.setIntersections(firstIntersection,newIntersection);
  road.setRoadPoints(pointsBefore);
  secondIntersection.removeRoad(road);
  newIntersection.addRoad(road);
  Road newRoad=createRoad(-1,null,newIntersection,secondIntersection,road.getRoadClass());
  newRoad.setRoadPoints(pointsAfter);
  return newIntersection;
}

public Intersection splitRoad ( Road road , RoadPoint rp ) { RoadPoint [ ] pointsBefore = road . getPointsBefore ( rp ) ; RoadPoint [ ] pointsAfter = road . getPointsAfter ( rp ) ; Intersection newIntersection = findIntersection ( rp . getLocation ( ) , null ) ; Intersection firstIntersection = road . getFirstIntersection ( ) ; Intersection secondIntersection = road . getSecondIntersection ( ) ; road . setIntersections ( firstIntersection , newIntersection ) ; road . setRoadPoints ( pointsBefore ) ; secondIntersection . removeRoad ( road ) ; newIntersection . addRoad ( road ) ; Road newRoad = createRoad ( - 1 , null , newIntersection , secondIntersection , road . getRoadClass ( ) ) ; newRoad . setRoadPoints ( pointsAfter ) ; return newIntersection ; }
split a road into two roads at one of its corners . an intersection is created where the corner was and the segments before the corner become the segments of the original road . the segments after the corner become the segments of a new road between the new intersection and the
