Advertisement
riking

genuinesounds

May 2nd, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. public Map<String, double[][]> decodeWorldMarkMap(String input)
  2. {
  3.     Map<String, double[][]> output = new Map<>();
  4.     BufferedReader in = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(input.getBytes())));
  5.     String line;
  6.     while(line = in.readLine() != null)
  7.     {
  8.         String[] dims = line.substring(0,line.length()-1).split(':');
  9.         double[][] tmp = new double[3][3];
  10.         if(dims.length() != 4) throw new IllegalArgumentException("Bad format!");
  11.         for(i=1; i<=3; i++) //NOTE: intentionally starting at 1 in a 0-index array
  12.         {
  13.             String[] coords = dims[i].split(';');
  14.             for(j=0;j<3;i++)
  15.             {
  16.                 // use i-1 to fix the earlier indexing problem
  17.                 tmp[i-1][j] = Double.parseDouble(coords[j]);
  18.             }
  19.         }
  20.         output.put(dims[0],tmp);
  21.     }  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement