use of org.twak.utils.collections.SuperLoop in project chordatlas by twak.
the class GMLReader method readGML3d.
public static LoopL<Point3d> readGML3d(File in, DefaultGeocentricCRS targetCS, CoordinateReferenceSystem sourceCS) {
LoopL<Point3d> out = new LoopL();
try {
InputSource input = new InputSource(new FileInputStream(in));
new GMLReader(input, targetCS, sourceCS) {
Loop<Point3d> parent, poly;
public void newPoly(String name) {
parent = poly = new SuperLoop<Point3d>(name);
out.add(poly);
}
@Override
public void hole(int n) {
poly = new Loop<Point3d>();
parent.holes.add(poly);
}
public void addLine(double[] s, double[] e) {
poly.append(new Point3d(s[0], s[1], s[2]));
}
};
} catch (Throwable e) {
e.printStackTrace();
}
System.out.println("found " + out.size() + " polygons ");
return out;
}
use of org.twak.utils.collections.SuperLoop in project chordatlas by twak.
the class GISGen method initGML.
public void initGML() {
Closer<Point3d> closer = new Closer<>();
LoopL<Point3d> polies = null;
try {
polies = GMLReader.readGML3d(Tweed.toWorkspace(new File(gmlFile)), DefaultGeocentricCRS.CARTESIAN, CRS.decode(crs));
} catch (NoSuchAuthorityCodeException e) {
e.printStackTrace();
return;
} catch (FactoryException e) {
e.printStackTrace();
return;
}
Optional<Gen> hg = tweed.frame.gens(HeightGen.class).stream().findAny();
if (hg.isPresent())
for (Loop<Point3d> poly : polies) {
if (poly instanceof SuperLoop) {
SuperLoop sl = ((SuperLoop) poly);
sl.properties.putAll(((HeightGen) hg.get()).getProperties((String) sl.properties.get("name")));
}
}
for (Loop<Point3d> poly : polies) {
List<Point3d> points = new ArrayList();
for (Pair<Point3d, Point3d> pair : poly.pairs()) {
TweedSettings.settings.toOrigin.transform(pair.first());
pair.first().y = 0;
points.add(pair.first());
lines.add(new Line3d(pair.first(), pair.second()));
}
if (TweedSettings.settings.flipFootprints)
poly.reverse();
closer.add(points.toArray(new Point3d[points.size()]));
}
createBlocks(closer, polies);
}
Aggregations