Example #1
0
  /**
   * This is a method splits way into smaller parts, using the prepared nodes list as split points.
   * Uses SplitWayAction.splitWay for the heavy lifting.
   *
   * @return list of split ways (or original ways if no splitting is done).
   */
  private List<Way> splitWayOnNodes(Way way, Set<Node> nodes) {

    List<Way> result = new ArrayList<Way>();
    List<List<Node>> chunks = buildNodeChunks(way, nodes);

    if (chunks.size() > 1) {
      SplitWayResult split =
          SplitWayAction.splitWay(
              Main.main.getEditLayer(), way, chunks, Collections.<OsmPrimitive>emptyList());

      // execute the command, we need the results
      cmds.add(split.getCommand());
      commitCommands(marktr("Split ways into fragments"));

      result.add(split.getOriginalWay());
      result.addAll(split.getNewWays());
    } else {
      // nothing to split
      result.add(way);
    }

    return result;
  }