Class HMModel

    • Field Detail

      • 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.

    • Constructor Detail

      • HMModel

        public HMModel()
    • 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() or checkCancel() instead.
        Check on the progress monitor to see if the process was stopped.

        Modules can use that internally to exit, if necessary.

        Parameters:
        pm - the progress 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 Exception is 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 Exception is 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 Exception
        Fast default writing of raster to source.

        Mind that if either raster or source are null, the method will return without warning.

        Parameters:
        raster - the GridCoverage2D to write.
        source - the source to which to write to.
        Throws:
        Exception
      • dumpVector

        public void dumpVector​(org.geotools.data.simple.SimpleFeatureCollection vector,
                               String source)
                        throws Exception
        Fast default writing of vector to source.

        Mind that if either vector or source are null, the method will return without warning.

        Parameters:
        vector - the SimpleFeatureCollection to write.
        source - the source to which to write to.
        Throws:
        Exception