Search in sources :

Example 6 with TriangulatedIrregularNetwork

use of com.revolsys.elevation.tin.TriangulatedIrregularNetwork in project com.revolsys.open by revolsys.

the class TriangulationVisualization method tinVisualLas.

public static void tinVisualLas() {
    final PathResource sourceFile = new PathResource("/data/dem/elevation/las/bc_093g057c_xl2m_2015_dem_ground.las");
    final TriangulatedIrregularNetwork tin;
    try (final LasPointCloud pointCloud = PointCloud.newPointCloud(sourceFile)) {
        tin = pointCloud.newTriangulatedIrregularNetwork();
    }
    if (writeFile) {
        tin.writeTriangulatedIrregularNetwork(new PathResource("/data/elevation/tin/093/g/093g057.tin"));
    }
    displayTin(tin);
}
Also used : TriangulatedIrregularNetwork(com.revolsys.elevation.tin.TriangulatedIrregularNetwork) PathResource(com.revolsys.spring.resource.PathResource) LasPointCloud(com.revolsys.elevation.cloud.las.LasPointCloud)

Example 7 with TriangulatedIrregularNetwork

use of com.revolsys.elevation.tin.TriangulatedIrregularNetwork in project com.revolsys.open by revolsys.

the class TriangulatedIrregularNetworkLayer method setTin.

public void setTin(final TriangulatedIrregularNetwork elevationModel) {
    final TriangulatedIrregularNetwork old = this.tin;
    Property.removeListener(this.tin, this);
    this.tin = elevationModel;
    if (elevationModel == null) {
        setExists(false);
    } else {
        setExists(true);
        Property.addListener(elevationModel, this);
    }
    firePropertyChange("elevationModel", old, this.tin);
}
Also used : TriangulatedIrregularNetwork(com.revolsys.elevation.tin.TriangulatedIrregularNetwork)

Example 8 with TriangulatedIrregularNetwork

use of com.revolsys.elevation.tin.TriangulatedIrregularNetwork in project com.revolsys.open by revolsys.

the class TriangulatedIrregularNetworkLayer method propertyChange.

@Override
public void propertyChange(final PropertyChangeEvent event) {
    super.propertyChange(event);
    final String propertyName = event.getPropertyName();
    if ("hasChanges".equals(propertyName)) {
        final TriangulatedIrregularNetwork image = getTin();
        if (event.getSource() == image) {
            image.writeTriangulatedIrregularNetwork();
        }
    }
}
Also used : TriangulatedIrregularNetwork(com.revolsys.elevation.tin.TriangulatedIrregularNetwork)

Example 9 with TriangulatedIrregularNetwork

use of com.revolsys.elevation.tin.TriangulatedIrregularNetwork 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;
}
Also used : TriangulatedIrregularNetwork(com.revolsys.elevation.tin.TriangulatedIrregularNetwork) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) QuadEdgeDelaunayTinBuilder(com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)

Example 10 with TriangulatedIrregularNetwork

use of com.revolsys.elevation.tin.TriangulatedIrregularNetwork in project com.revolsys.open by revolsys.

the class TriangulatedIrregularNetworkLayer method revertDo.

protected void revertDo() {
    if (this.resource != null) {
        TriangulatedIrregularNetwork tin = null;
        try {
            this.tin = null;
            final Resource resource = Resource.getResource(this.url);
            if (resource.exists()) {
                tin = TriangulatedIrregularNetwork.newTriangulatedIrregularNetwork(resource);
                if (tin == null) {
                    Logs.error(TriangulatedIrregularNetworkLayer.class, "Cannot load TIN: " + this.url);
                }
            } else {
                Logs.error(TriangulatedIrregularNetworkLayer.class, "TIN does not exist: " + this.url);
            }
        } catch (final Throwable e) {
            Logs.error(TriangulatedIrregularNetworkLayer.class, "Unable to load TIN: " + this.url, e);
        } finally {
            setTin(tin);
        }
        firePropertyChange("hasChanges", true, false);
    }
}
Also used : TriangulatedIrregularNetwork(com.revolsys.elevation.tin.TriangulatedIrregularNetwork) Resource(com.revolsys.spring.resource.Resource)

Aggregations

TriangulatedIrregularNetwork (com.revolsys.elevation.tin.TriangulatedIrregularNetwork)11 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)5 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 LasPointCloud (com.revolsys.elevation.cloud.las.LasPointCloud)2 BoundingBox (com.revolsys.geometry.model.BoundingBox)2 Point (com.revolsys.geometry.model.Point)2 Triangle (com.revolsys.geometry.model.Triangle)2 PathResource (com.revolsys.spring.resource.PathResource)2 WebColors (com.revolsys.awt.WebColors)1 PointCloud (com.revolsys.elevation.cloud.PointCloud)1 IntArrayScaleGriddedElevationModel (com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel)1 Geometry (com.revolsys.geometry.model.Geometry)1 Circle (com.revolsys.geometry.model.impl.Circle)1 BaseCloseable (com.revolsys.io.BaseCloseable)1 Resource (com.revolsys.spring.resource.Resource)1 BasicStroke (java.awt.BasicStroke)1 BorderLayout (java.awt.BorderLayout)1 Graphics (java.awt.Graphics)1 Graphics2D (java.awt.Graphics2D)1 AffineTransform (java.awt.geom.AffineTransform)1