public void rotateWay(final Way way,final float angle,final int direction,final float pivotX,final float pivotY,int w,int h,BoundingBox v){
  if (way.getNodes() == null) {
    Log.d("StorageDelegator","rotateWay way " + way.getOsmId() + " has no nodes!");
    return;
  }
  dirty=true;
  try {
    HashSet<Node> nodes=new HashSet<Node>(way.getNodes());
    for (    Node nd : nodes) {
      undo.save(nd);
      apiStorage.insertElementSafe(nd);
      float nodeX=GeoMath.lonE7ToX(w,v,nd.getLon());
      float nodeY=GeoMath.latE7ToY(h,w,v,nd.getLat());
      float newX=pivotX + (nodeX - pivotX) * (float)Math.cos(angle) - direction * (nodeY - pivotY) * (float)Math.sin(angle);
      float newY=pivotY + direction * (nodeX - pivotX) * (float)Math.sin(angle) + (nodeY - pivotY) * (float)Math.cos(angle);
      int lat=GeoMath.yToLatE7(h,w,v,newY);
      int lon=GeoMath.xToLonE7(w,v,newX);
      nd.setLat(lat);
      nd.setLon(lon);
      nd.updateState(OsmElement.STATE_MODIFIED);
    }
    recordImagery();
  }
 catch (  StorageException e) {
    e.printStackTrace();
  }
}

public void rotateWay ( final Way way , final float angle , final int direction , final float pivotX , final float pivotY , int w , int h , BoundingBox v ) { if ( way . getNodes ( ) == null ) { Log . d ( "StorageDelegator" , "rotateWay way " + way . getOsmId ( ) + " has no nodes!" ) ; return ; } dirty = true ; try { HashSet < Node > nodes = new HashSet < Node > ( way . getNodes ( ) ) ; for ( Node nd : nodes ) { undo . save ( nd ) ; apiStorage . insertElementSafe ( nd ) ; float nodeX = GeoMath . lonE7ToX ( w , v , nd . getLon ( ) ) ; float nodeY = GeoMath . latE7ToY ( h , w , v , nd . getLat ( ) ) ; float newX = pivotX + ( nodeX - pivotX ) * ( float ) Math . cos ( angle ) - direction * ( nodeY - pivotY ) * ( float ) Math . sin ( angle ) ; float newY = pivotY + direction * ( nodeX - pivotX ) * ( float ) Math . sin ( angle ) + ( nodeY - pivotY ) * ( float ) Math . cos ( angle ) ; int lat = GeoMath . yToLatE7 ( h , w , v , newY ) ; int lon = GeoMath . xToLonE7 ( w , v , newX ) ; nd . setLat ( lat ) ; nd . setLon ( lon ) ; nd . updateState ( OsmElement . STATE_MODIFIED ) ; } recordImagery ( ) ; } catch ( StorageException e ) { e . printStackTrace ( ) ; } }
rotate all nodes in a way , since the nodes keep their ids , the way itself doesn ' t change and doesn ' t need to be saved apply translation only once to the first node if way is closed . rotation is done in screen coords
