use of gaiasky.scenegraph.ConstellationBoundaries in project gaiasky by langurmonkey.
the class ConstelBoundariesLoader method loadData.
@Override
public Array<? extends SceneGraphNode> loadData() {
Array<ConstellationBoundaries> boundaries = new Array<ConstellationBoundaries>();
int n = 0;
for (String f : files) {
try {
// load boundaries
FileHandle file = Settings.settings.data.dataFileHandle(f);
BufferedReader br = new BufferedReader(new InputStreamReader(file.read()));
try {
// Skip first line
String line;
ConstellationBoundaries boundary = new ConstellationBoundaries();
boundary.ct = new ComponentTypes(ComponentType.Boundaries);
List<List<Vector3d>> list = new ArrayList<>();
List<Vector3d> buffer = new ArrayList<>(4);
String lastName = "";
int interp = 0;
while ((line = br.readLine()) != null) {
if (!line.startsWith("#")) {
String[] tokens = line.split(separator);
String name = tokens[2];
String type = tokens.length > 3 ? tokens[3] : "O";
if (!name.equals(lastName)) {
// New line
list.add(buffer);
buffer = new ArrayList<>(20);
lastName = name;
}
if (type.equals("I")) {
interp++;
}
if ((type.equals("I") && LOAD_INTERPOLATED && interp % INTERPOLATED_MOD == 0) || type.equals("O")) {
// Load the data
double ra = Parser.parseDouble(tokens[0].trim()) * 15d;
double dec = Parser.parseDouble(tokens[1].trim());
double dist = 10 * Constants.AU_TO_U;
Vector3d point = Coordinates.sphericalToCartesian(Math.toRadians(ra), Math.toRadians(dec), dist, new Vector3d());
buffer.add(point);
n++;
}
}
}
list.add(buffer);
boundary.setBoundaries(list);
boundaries.add(boundary);
} catch (IOException e) {
Logger.getLogger(this.getClass()).error(e);
}
} catch (Exception e) {
Logger.getLogger(this.getClass()).error(e);
}
}
Logger.getLogger(this.getClass()).info(I18n.txt("notif.boundaries.init", n));
return boundaries;
}
Aggregations