I am finding three neighbors of value (6,33).what is the best way to do that. am using json-Simple for reading file.if the origin is (6,33), then the first item in the output would be the coordinate closest to(6,33), then the second closest, then third closest, and so on for all 26 input coordinates:
[
{"id":"a","value":[31,49]},
{"id":"b","value":[44,67]},
{"id":"c","value":[93,6]},
{"id":"d","value":[20,16]},
{"id":"e","value":[68,53]},
{"id":"f","value":[71,8]},
....,
{"id":"y","value":[75,92]},
{"id":"z","value":[32,33]}
]
public class readData {
public static void main(String[] args) throws FileNotFoundException,
IOException, ParseException {
Scanner xInput = new Scanner(System.in);
System.out.println("Enter your X value");
int x = xInput.nextInt();
Scanner yInput = new Scanner(System.in);
System.out.println("Enter your Y value");
int y = yInput.nextInt();
JSONParser parser = new JSONParser();
JSONArray jsonArray = (JSONArray) parser.parse(new FileReader("E:\\data\\coordinates.json"));
for (Object o : jsonArray) {
JSONObject data = (JSONObject) o;
String id = (String) data.get("id");
System.out.print("id:" + id+"\t");
JSONArray value = (JSONArray) data.get("value");
for(Object v: value){
System.out.print(v+ " ");
}
System.out.println("\n");
}
xInput.close();
yInput.close();
}
}