use of org.hortonmachine.gears.libs.monitor.LogProgressMonitor in project hortonmachine by TheHortonMachine.
the class OpenstreetmapImageCreator method main.
public static void main(String[] args) throws Exception {
String outFile = "/home/hydrologis/Dropbox/hydrologis/lavori/2015_05_bim_sarcamincio/shape_3857/image_output/osm15.png";
String bounds = "/home/hydrologis/Dropbox/hydrologis/lavori/2015_05_bim_sarcamincio/shape_3857/area.shp";
String inServiceUrl = "http://a.tile.opencyclemap.org/cycle/ZZZ/XXX/YYY.png";
// String inServiceUrl = "http://a.tile.openstreetmap.org/ZZZ/XXX/YYY.png";
ReferencedEnvelope env = OmsVectorReader.readVector(bounds).getBounds();
OpenstreetmapImageCreator c = new OpenstreetmapImageCreator(inServiceUrl, 15, env, new File(outFile), new LogProgressMonitor());
c.generate();
}
use of org.hortonmachine.gears.libs.monitor.LogProgressMonitor in project hortonmachine by TheHortonMachine.
the class LasOnDtmBuildingsExtractor method process.
@Execute
public void process() throws Exception {
checkNull(inLas, inDtm, outBuildings);
SimpleFeatureCollection buildingsFC = null;
GridCoverage2D inDtmGC = null;
try (ALasDataManager lasHandler = ALasDataManager.getDataManager(new File(inLas), inDtmGC, 0, null)) {
lasHandler.open();
ReferencedEnvelope3D e = lasHandler.getEnvelope3D();
if (pRasterResolution != null) {
OmsRasterReader reader = new OmsRasterReader();
reader.file = inDtm;
reader.pNorth = e.getMaxY();
reader.pSouth = e.getMinY();
reader.pWest = e.getMinX();
reader.pEast = e.getMaxX();
reader.pXres = pRasterResolution;
reader.pYres = pRasterResolution;
reader.process();
inDtmGC = reader.outRaster;
} else {
inDtmGC = getRaster(inDtm);
RegionMap regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inDtmGC);
pRasterResolution = regionMap.getXres();
}
Envelope2D envelope2d = inDtmGC.getEnvelope2D();
Polygon regionPolygon = FeatureUtilities.envelopeToPolygon(envelope2d);
WritableRaster[] buildingsHolder = new WritableRaster[1];
GridCoverage2D newBuildingsRaster = CoverageUtilities.createCoverageFromTemplate(inDtmGC, 1.0, buildingsHolder);
GridGeometry2D gridGeometry = newBuildingsRaster.getGridGeometry();
java.awt.Point p = new java.awt.Point();
IHMProgressMonitor pm = new LogProgressMonitor();
pm.beginTask("Reading points...", IHMProgressMonitor.UNKNOWN);
List<LasRecord> pointsInGeometry = lasHandler.getPointsInGeometry(regionPolygon, true);
pm.done();
pm.beginTask("Buildings filtering...", (int) pointsInGeometry.size());
for (LasRecord dot : pointsInGeometry) {
Coordinate c = new Coordinate(dot.x, dot.y);
if (!envelope2d.contains(dot.x, dot.y)) {
continue;
}
double dtmValue = CoverageUtilities.getValue(inDtmGC, c);
double height = abs(dot.z - dtmValue);
CoverageUtilities.colRowFromCoordinate(c, gridGeometry, p);
if (height < pDtmThres) {
buildingsHolder[0].setSample(p.x, p.y, 0, doubleNovalue);
}
pm.worked(1);
}
pm.done();
OmsMorpher morpher = new OmsMorpher();
morpher.pm = pm;
morpher.inMap = newBuildingsRaster;
morpher.pMode = Variables.OPEN;
morpher.process();
newBuildingsRaster = morpher.outMap;
OmsVectorizer buildingsVectorizer = new OmsVectorizer();
buildingsVectorizer.pm = pm;
buildingsVectorizer.inRaster = newBuildingsRaster;
buildingsVectorizer.doRemoveHoles = true;
double minAreaInCells = pMinArea / pRasterResolution / pRasterResolution;
buildingsVectorizer.pThres = minAreaInCells;
buildingsVectorizer.fDefault = "rast";
buildingsVectorizer.process();
buildingsFC = buildingsVectorizer.outVector;
dumpVector(buildingsFC, outBuildings);
if (doSmoothing && outCleanBuildings != null) {
// smooth
SimpleFeatureCollection smoothedFC = smoothBuildings(pDensifyResolution, buildingsFC);
// remove trees
DefaultFeatureCollection removedAndSmoothedFC = removeNonBuildings(lasHandler, smoothedFC, inDtmGC, pBuildingsBuffer);
dumpVector(removedAndSmoothedFC, outCleanBuildings);
}
}
}
Aggregations