Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Map<String, double[][]> decodeWorldMarkMap(String input)
- {
- Map<String, double[][]> output = new Map<>();
- BufferedReader in = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(input.getBytes())));
- String line;
- while(line = in.readLine() != null)
- {
- String[] dims = line.substring(0,line.length()-1).split(':');
- double[][] tmp = new double[3][3];
- if(dims.length() != 4) throw new IllegalArgumentException("Bad format!");
- for(i=1; i<=3; i++) //NOTE: intentionally starting at 1 in a 0-index array
- {
- String[] coords = dims[i].split(';');
- for(j=0;j<3;i++)
- {
- // use i-1 to fix the earlier indexing problem
- tmp[i-1][j] = Double.parseDouble(coords[j]);
- }
- }
- output.put(dims[0],tmp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement