src/main/java/de/blau/android/osm/StorageDelegator.java
/**
     * Make a copy of the element and store it in the clipboard
     * 
     * @param elements elements to copy
     * @param lat latitude where it was located
     * @param lon longitude where it was located
     */
Make a copy of the element and store it in the clipboard

@param elements elements to copy
@param lat latitude where it was located
@param lon longitude where it was located
Make a copy of the element and store it in the clipboard @param elements elements to copy @param lat latitude where it was located @param lon longitude where it was located
public void copyToClipboard(@NonNull List<OsmElement> elements, int lat, int lon) {
        dirty = true; 
        List<OsmElement> toCopy = new ArrayList<>();
        Map<Long, Node> processedNodes = new HashMap<>();
        for (OsmElement e : elements) {
            if (e instanceof Node) {
                Node newNode = factory.createNodeWithNewId(((Node) e).getLat(), ((Node) e).getLon());
                newNode.setTags(e.getTags());
                toCopy.add(newNode);
                processedNodes.put(e.getOsmId(), newNode);
            } else if (e instanceof Way) {
                Way newWay = factory.createWayWithNewId();
                newWay.setTags(e.getTags());
                for (Node nd : ((Way) e).getNodes()) {
                    Node newNode = processedNodes.get(nd.getOsmId());
                    if (newNode == null) {
                        newNode = factory.createNodeWithNewId(nd.getLat(), nd.getLon());
                        newNode.setTags(nd.getTags());
                        processedNodes.put(nd.getOsmId(), newNode);
                    }
                    newWay.addNode(newNode);
                }
                toCopy.add(newWay);
            }
        }
        if (!toCopy.isEmpty()) {
            clipboard.copyTo(toCopy, lat, lon);
        }
    }
public void copyToClipboard ( @ NonNull List < OsmElement > elements , int lat , int lon ) { dirty = true ; List < OsmElement > toCopy = new ArrayList < > ( ) ; Map < Long , Node > processedNodes = new HashMap < > ( ) ; for ( OsmElement e : elements ) { if ( e instanceof Node ) { Node newNode = factory . createNodeWithNewId ( ( ( Node ) e ) . getLat ( ) , ( ( Node ) e ) . getLon ( ) ) ; newNode . setTags ( e . getTags ( ) ) ; toCopy . add ( newNode ) ; processedNodes . put ( e . getOsmId ( ) , newNode ) ; } else if ( e instanceof Way ) { Way newWay = factory . createWayWithNewId ( ) ; newWay . setTags ( e . getTags ( ) ) ; for ( Node nd : ( ( Way ) e ) . getNodes ( ) ) { Node newNode = processedNodes . get ( nd . getOsmId ( ) ) ; if ( newNode == null ) { newNode = factory . createNodeWithNewId ( nd . getLat ( ) , nd . getLon ( ) ) ; newNode . setTags ( nd . getTags ( ) ) ; processedNodes . put ( nd . getOsmId ( ) , newNode ) ; } newWay . addNode ( newNode ) ; } toCopy . add ( newWay ) ; } } if ( ! toCopy . isEmpty ( ) ) { clipboard . copyTo ( toCopy , lat , lon ) ; } }
Make a copy of the element and store it in the clipboard
Make a copy of the element and store it in the clipboard
// otherwise clipboard will not get saved without other changes