use of com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder in project com.revolsys.open by revolsys.
the class TriangulationVisualization method tinVisual.
//
// public static void testDem() throws IOException {
// final GeometryFactory geometryFactory = GeometryFactory.fixed(3005, 1000.0);
// final bcDemConfig config = new bcDemConfig();
// final Path basePath = config.getBasePath();
// final boolean processAll = false;
// final RecordDefinition extentRecordDefinition = new RecordDefinitionBuilder("extents") //
// .addField("LETTER_BLOCK", DataTypes.STRING) //
// .addField("POLYGON", DataTypes.POLYGON) //
// .setGeometryFactory(geometryFactory) //
// .getRecordDefinition();
// final Path trim25kDirectory = config.getTrim25mAlbersDirectory();
// RecordWriter writer = null;
// if (processAll) {
// writer = RecordWriter.newRecordWriter(extentRecordDefinition,
// trim25kDirectory.resolve("extents.shp"));
// }
// try (
// RecordWriter writer2 = writer) {
//
// Files.walk(trim25kDirectory).forEach((demZipFile) -> {
// final String baseName = Paths.getBaseName(demZipFile);
// if (processAll || baseName.equals("92i-albers-elevation.asc")) {
// try {
// final String fileNameExtension = Paths.getFileNameExtension(demZipFile);
// if (fileNameExtension.equals("zip")) {
// final FileSystem fileSystem = FileSystems.newFileSystem(demZipFile, null);
// final String letterBlock = baseName.substring(0, baseName.indexOf('-'));
// final Path demFile = fileSystem.getPath(baseName);
//
// final Map<String, Object> properties = new HashMap<>();
// properties.put(GriddedElevationModel.GEOMETRY_FACTORY, geometryFactory);
// properties.put(EsriAsciiGriddedElevation.PROPERTY_READ_DATA, !processAll);
//
// final GriddedElevationModel sourceModel = GriddedElevationModel
// .newGriddedElevationModel(demFile, properties);
// final BoundingBox sourceBoundingBox = sourceModel.getBoundingBox();
// if (!processAll) {
// for (final RectangularMapTile targetTile : bcDemConfig.GRID_25m
// .getTiles(sourceBoundingBox)) {
// final BoundingBox targetBoundingBox = targetTile.getBoundingBox();
// final boolean contained = sourceBoundingBox.covers(targetBoundingBox);
// if (contained) {
// System.out.println(targetTile);
// } else {
// System.err.println(targetTile);
// }
// final Path targetPath = config.getGriddedElevationModelPath(3005, 25, targetTile,
// "asc");
// final GriddedElevationModel targetModel = config.getGriddedElevationModel(3005,
// 25, targetTile, "asc");
// final int targetHeight = targetModel.getHeight();
// final int targetWidth = targetModel.getWidth();
// for (int targetJ = 0; targetJ < targetHeight; targetJ++) {
// for (int targetI = 0; targetI < targetWidth; targetI++) {
// final double x = targetModel.getX(targetI);
// final double y = targetModel.getY(targetJ);
// final int sourceI = sourceModel.getCellX(x);
// final int sourceJ = sourceModel.getCellY(y);
// if (!sourceModel.isNull(sourceI, sourceJ)) {
// final short elevation = sourceModel.getElevationShort(sourceI, sourceJ);
// targetModel.setElevation(targetI, targetJ, elevation);
// }
// }
// }
// targetModel.writeGriddedElevationModel(targetPath);
// }
// }
//
// if (writer2 != null) {
// final Record record = writer2.newRecord();
// record.setValue("LETTER_BLOCK", letterBlock);
// final BoundingBox boundingBox = sourceModel.getBoundingBox();
// record.setGeometryValue(boundingBox.toPolygon(1));
// writer2.write(record);
// }
// }
// } catch (final Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// });
// }
// }
private static void tinVisual(final GeometryFactory geometryFactory, final List<Point> points) {
final QuadEdgeDelaunayTinBuilder tinBuilder = new QuadEdgeDelaunayTinBuilder(geometryFactory);
tinBuilder.insertVertices(points);
final TriangulatedIrregularNetwork tin = tinBuilder.newTriangulatedIrregularNetwork();
displayTin(tin);
}
use of com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder in project com.revolsys.open by revolsys.
the class DelaunayRobustTest method run.
public void run(final int nPts) {
// System.out.println("Base offset: " + BASE_OFFSET);
final List<Point> pts = randomPointsInGrid(nPts, BASE_OFFSET, BASE_OFFSET);
// System.out.println("# pts: " + pts.size());
final Stopwatch sw = new Stopwatch();
final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(GEOMETRY_FACTORY);
builder.insertVertices(pts);
// Geometry g = builder.getEdges(geomFact);
// don't actually form output geometry, to save time and memory
builder.getSubdivision();
// System.out.println(" -- Time: " + sw.getTimeString() + " Mem: "
// + Memory.usedTotalString());
// System.out.println(g);
}
use of com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder in project com.revolsys.open by revolsys.
the class LasPointCloud method newTriangulatedIrregularNetwork.
@Override
public TriangulatedIrregularNetwork newTriangulatedIrregularNetwork(final Predicate<? super Point> filter) {
final GeometryFactory geometryFactory = getGeometryFactory();
final QuadEdgeDelaunayTinBuilder tinBuilder = new QuadEdgeDelaunayTinBuilder(geometryFactory);
forEachPoint((lasPoint) -> {
if (filter.test(lasPoint)) {
tinBuilder.insertVertex(lasPoint);
}
});
final TriangulatedIrregularNetwork tin = tinBuilder.newTriangulatedIrregularNetwork();
return tin;
}
use of com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder in project com.revolsys.open by revolsys.
the class DelaunayPerfTest method run.
public void run(final int nPts) {
final List<Point> pts = randomPoints(nPts);
// System.out.println("# pts: " + pts.size());
final Stopwatch sw = new Stopwatch();
final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(GEOMETRY_FACTORY);
builder.insertVertices(pts);
// Geometry g = builder.getEdges(geomFact);
// don't actually form output geometry, to save time and memory
builder.getSubdivision();
// System.out.println(" -- Time: " + sw.getTimeString() + " Mem: "
// + Memory.usedTotalString());
// System.out.println(g);
}
use of com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder in project com.revolsys.open by revolsys.
the class VoronoiPerfTest method run.
public void run(final int nPts) {
final List pts = randomPoints(nPts);
final Stopwatch sw = new Stopwatch();
final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(geometryFactory);
builder.insertVertices(pts);
final Geometry g = builder.getEdges();
// System.out.println("# pts: " + pts.size() + " -- " +
// sw.getTimeString());
// System.out.println(g);
}
Aggregations