Class HMModel
- java.lang.Object
-
- org.hortonmachine.gears.libs.modules.HMModel
-
- Direct Known Subclasses:
AdigeBoundaryConditionReader,AdigeBoundaryConditionWriter,DatabaseLasWriter,ExifGpsWriter,ExifReader,HMModelIM,IdValuesArray2IdValuesConverter,LasIndexer,Mapurl2MbtilesConverter,MultiProcessing,OmsAreaOfInterestGridCoverage,OmsBiasedSigmaFilter,OmsBobTheBuilder,OmsBuffer,OmsCannyEdgeDetector,OmsCarver,OmsContourExtractor,OmsContourLinesLabeler,OmsCoverageLister,OmsCoverageViewer,OmsCsvMatrixReader,OmsDateTime2ValueMapReader,OmsDateTime2ValueMapWriter,OmsDbfTableReader,OmsDelaunayTriangulation,OmsDownSlopeConnectivity,OmsDwgConverter,OmsDxfConverter,OmsEIAltimetryReader,OmsEIAltimetryWriter,OmsEIAreasReader,OmsEIAreasWriter,OmsEIEnergyReader,OmsEIEnergyWriter,OmsFeaturesLister,OmsFileIterator,OmsGeopaparazzi3Converter,OmsGeopaparazzi4Converter,OmsGeopaparazziProject3To4Converter,OmsGridGeometryReader,OmsGridsGenerator,OmsHoleFiller,OmsHoughCirclesRaster,OmsHoughCirclesRasterCleaner,OmsId2ValueArrayReader,OmsId2ValueArrayWriter,OmsImageMosaicCreator,OmsIntersectionFinder,OmsJsonFeatureReader,OmsKernelFilter,OmsLabeler,OmsLasConverter,OmsLasIndexReader,OmsLineIntersectionCorrector,OmsLineSmootherJaitools,OmsLineSmootherMcMaster,OmsLinesPolygonizer,OmsLinesRasterizer,OmsMapcalc,OmsMapsViewer,OmsMarchingSquaresVectorializer,OmsMorpher,OmsMosaic,OmsMosaic12,OmsNmeaFeatureReader,OmsOnlineTilesDownloader,OmsPlainId2ValueReader,OmsPointDirectionCalculator,OmsPointsRasterizer,OmsPointsVectorizer,OmsPolygonSmootherJaitools,OmsProfile,OmsPropertiesFeatureReader,OmsRangeLookup,OmsRaster2Xyz,OmsRasterCatToFeatureAttribute,OmsRasterConverter,OmsRasterCorrector,OmsRasterDiff,OmsRasterGenerator,OmsRasterNormalizer,OmsRasterReader,OmsRasterReprojector,OmsRasterResizer,OmsRasterResolutionResampler,OmsRasterSummary,OmsRasterTransformer,OmsRasterValueRounder,OmsRasterVectorIntersector,OmsRasterWriter,OmsScanLineRasterizer,OmsShapefileFeatureReader,OmsShapefileFeatureWriter,OmsShp2DxfConverter,OmsSigmaFilterPlus,OmsSurfaceInterpolator,OmsTimeSeriesIteratorReader,OmsTimeSeriesIteratorWriter,OmsTimeSeriesReader,OmsTimeSeriesWriter,OmsTmsGenerator,OmsVectorClipper,OmsVectorConverter,OmsVectorFieldRounder,OmsVectorFilter,OmsVectorIntersector,OmsVectorizer,OmsVectorMerger,OmsVectorOverlayOperators,OmsVectorReader,OmsVectorReprojector,OmsVectorReshaper,OmsVectorSimplifier,OmsVectorTableJoiner,OmsVectorTransformer,OmsVectorWriter,OmsVoronoiDiagram,OmsWindowSampler,OmsXyz2Raster,OmsZonalStats,TmsWms2Geotiff,VegetationLibraryReader
public class HMModel extends Object
Superclass for modules.- Author:
- Andrea Antonello (www.hydrologis.com)
-
-
Field Summary
Fields Modifier and Type Field Description booleandoProcessVariable that defines if time is still available or run out.booleandoResetA switch that can enable module resetting.org.locationtech.jts.geom.GeometryFactorygfThe default geometry factory.IHMProgressMonitorpm
-
Constructor Summary
Constructors Constructor Description HMModel()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcheckCancel()Check if the process has been canceled.protected voidcheckFileExists(String... existingFilePath)Checks if passed path strings exist on the filesystem.protected voidcheckNull(Object... objects)Checks if the passed objects are all != null and if one is null, throws Exception.protected StringcheckWorkingFolderInPath(String filePath)Checks if a passed path contains the workingfolder constant.protected booleanconcatOr(boolean... statements)Utility method to concatenate conditions with or.voiddumpRaster(org.geotools.coverage.grid.GridCoverage2D raster, String source)Fast default writing of raster to source.voiddumpVector(org.geotools.data.simple.SimpleFeatureCollection vector, String source)Fast default writing of vector to source.static intgetDefaultThreadsNum()Get the default number of threads.org.geotools.coverage.grid.GridCoverage2DgetRaster(String source)Fast default reading of raster from definition.org.geotools.data.simple.SimpleFeatureCollectiongetVector(String source)Fast default reading of vector from definition.voidhelp()protected booleanisCanceled(IHMProgressMonitor pm)Deprecated.use directly the pm.isCanceled() orcheckCancel()instead.voidtemplate()
-
-
-
Field Detail
-
pm
public IHMProgressMonitor pm
-
gf
public org.locationtech.jts.geom.GeometryFactory gf
The default geometry factory.
-
doProcess
public boolean doProcess
Variable that defines if time is still available or run out.This variable should be set by modules that "lead" the time chain:
- true, when the simulation starts
- false, when the simulation should end, regardless for which reason (data finished, end date reached...)
-
doReset
public boolean doReset
A switch that can enable module resetting.This variable might be useful in the case in which NON-timedependent modules at a certain point should anyways re-read or re-process the data. For example in the case in which a map was already calculated but at a certain point should be recalculated.
-
-
Method Detail
-
getDefaultThreadsNum
public static int getDefaultThreadsNum()
Get the default number of threads.At the moment this gives the number of processors.
- Returns:
- the default number of threads.
-
isCanceled
protected boolean isCanceled(IHMProgressMonitor pm)
Deprecated.use directly the pm.isCanceled() orcheckCancel()instead.Check on the progress monitor to see if the process was stopped.Modules can use that internally to exit, if necessary.
- Parameters:
pm- theprogress monitor.- Returns:
- true if the process was stopped.
-
checkCancel
public void checkCancel()
Check if the process has been canceled.If canceled a ModelsUserCancelException will be thrown.
-
concatOr
protected boolean concatOr(boolean... statements)
Utility method to concatenate conditions with or.This can be useful for readability (in case of negation).
- Parameters:
statements- a list of statements.- Returns:
- the final boolean from the or concatenation.
-
checkNull
protected void checkNull(Object... objects)
Checks if the passed objects are all != null and if one is null, throws Exception.- Parameters:
objects- the objects to check.
-
checkFileExists
protected void checkFileExists(String... existingFilePath)
Checks if passed path strings exist on the filesystem. If not, an Exception is thrown.- Parameters:
existingFilePath- one or more file paths that need to exist.
-
checkWorkingFolderInPath
protected String checkWorkingFolderInPath(String filePath)
Checks if a passed path contains the workingfolder constant. If yes it is set to null.- Parameters:
filePath- the path to check.- Returns:
- the path or null.
-
getRaster
public org.geotools.coverage.grid.GridCoverage2D getRaster(String source) throws Exception
Fast default reading of raster from definition.If the source format is not supported, and
Exceptionis thrown.If the source is
null, null will be returned.- Parameters:
source- the definition for the raster source.- Returns:
- the read
GridCoverage2D. - Throws:
Exception
-
getVector
public org.geotools.data.simple.SimpleFeatureCollection getVector(String source) throws Exception
Fast default reading of vector from definition.If the source format is not supported, and
Exceptionis thrown.If the source is
null, null will be returned.- Parameters:
source- the definition to the vector source.- Returns:
- the read
GridCoverage2D. - Throws:
Exception
-
dumpRaster
public void dumpRaster(org.geotools.coverage.grid.GridCoverage2D raster, String source) throws ExceptionFast default writing of raster to source.Mind that if either raster or source are
null, the method will return without warning.- Parameters:
raster- theGridCoverage2Dto write.source- the source to which to write to.- Throws:
Exception
-
dumpVector
public void dumpVector(org.geotools.data.simple.SimpleFeatureCollection vector, String source) throws ExceptionFast default writing of vector to source.Mind that if either vector or source are
null, the method will return without warning.- Parameters:
vector- theSimpleFeatureCollectionto write.source- the source to which to write to.- Throws:
Exception
-
-