Example #1
0
  @Override
  public void load(PrimitiveData data) {
    boolean locked = writeLock();
    try {
      super.load(data);

      WayData wayData = (WayData) data;

      if (!wayData.getNodes().isEmpty() && getDataSet() == null) {
        throw new AssertionError("Data consistency problem - way without dataset detected");
      }

      List<Node> newNodes = new ArrayList<>(wayData.getNodes().size());
      for (Long nodeId : wayData.getNodes()) {
        Node node = (Node) getDataSet().getPrimitiveById(nodeId, OsmPrimitiveType.NODE);
        if (node != null) {
          newNodes.add(node);
        } else {
          throw new AssertionError("Data consistency problem - way with missing node detected");
        }
      }
      setNodes(newNodes);
    } finally {
      writeUnlock(locked);
    }
  }
Example #2
0
 @Override
 public WayData save() {
   WayData data = new WayData();
   saveCommonAttributes(data);
   for (Node node : nodes) {
     data.getNodes().add(node.getUniqueId());
   }
   return data;
 }