com.supermap.services.util.cache

Class ImageCacheHelperImpl

  • java.lang.Object
    • com.supermap.services.util.cache.ImageCacheHelperImpl
  • All Implemented Interfaces:
    ImageCacheHelper


    public final class ImageCacheHelperImpl
    extends java.lang.Object
    implements ImageCacheHelper
    

    Cache image tool class, to provide image cache directory calculation way.

    • Constructor Summary

      Constructors 
      Constructor and Description
      ImageCacheHelperImpl(java.lang.String outputDir, java.lang.String outputSite)
      Image cache tool class, used to obtain the file path to the temporary cache.
      ImageCacheHelperImpl(java.lang.String outputDir, java.lang.String outputSite, java.lang.String tmpFolder)
      Image cache tool class, used to obtain the file path to the temporary cache.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void clearCache(java.lang.String mapName)
      Delete all cached images of the map.
      void clearCache(java.lang.String mapName, java.lang.String cachePath)
      Delete all cached images of the map.
      java.lang.String getCacheKey(MapParameter mapParam, ImageOutputOption outputOption)
      Get the cache keyword, excluding the range center point and image size and other factors.
      java.lang.String getImageFileName(MapParameter mapParam, ImageOutputOption outputOption)
      According to the map parameters and image output settings, get the cache file name.
      java.lang.String getImageURL(MapParameter mapParameter, ImageOutputOption outputOption)
      According to the map parameters and image output settings, get the full URL of the cache image.
      java.lang.String getTempImageFileName(MapParameter mapParam, ImageOutputOption outputOption)
      According to the map parameters and image output settings, get the cache file name.
      java.lang.String getTempKey(MapParameter mapParam, ImageOutputOption outputOption)
      Get the temporary cache keyword, excluding the range center point and image size and other factors.
      java.lang.String pathToUrl(java.lang.String path) 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ImageCacheHelperImpl

        public ImageCacheHelperImpl(java.lang.String outputDir,
                            java.lang.String outputSite)
        

        Image cache tool class, used to obtain the file path to the temporary cache.

        Parameters:
        outputDir -
        outputSite -
      • ImageCacheHelperImpl

        public ImageCacheHelperImpl(java.lang.String outputDir,
                            java.lang.String outputSite,
                            java.lang.String tmpFolder)
        

        Image cache tool class, used to obtain the file path to the temporary cache.

        Parameters:
        outputDir -
        outputSite -
    • Method Detail

      • getImageFileName

        public java.lang.String getImageFileName(MapParameter mapParam,
                                        ImageOutputOption outputOption)
        

        According to the map parameters and image output settings, get the cache file name.

        Cache file name format: {centerIndex}_{imageCacheKey}.{postfix} (image center point index _ cache picture keyword. Image file format). Default cache image in PNG format.

        Specified by:
        getImageFileName in interface ImageCacheHelper
        Parameters:
        mapParam - map parameters.
        outputOption - Picture output settings.
        Returns:
        the file name of the cache image.
        See Also:
        DefaultUGCCachePolicy#getCenterIndex(MapParameter), DefaultUGCCachePolicy#getImageCacheKey(MapParameter,ImageOutputOption)
      • getTempImageFileName

        public java.lang.String getTempImageFileName(MapParameter mapParam,
                                            ImageOutputOption outputOption)
        

        According to the map parameters and image output settings, get the cache file name.

        Note: the method will get different image file name every time it restarts the service; if you want to get a unchanged file name, please use getCacheKey(MapParameter,ImageOutputOption)

        Cache file name format: {centerIndex}_{imageCacheKey}.{postfix} (image center point index _ cache picture keyword. Image file format). Default cache image in PNG format.

        Specified by:
        getTempImageFileName in interface ImageCacheHelper
        Parameters:
        mapParam - map parameters.
        outputOption - Picture output settings.
        Returns:
        the file name of the cache image.
        See Also:
        DefaultUGCCachePolicy#getCenterIndex(MapParameter), DefaultUGCCachePolicy#getImageCacheKey(MapParameter,ImageOutputOption)
      • getImageURL

        public java.lang.String getImageURL(MapParameter mapParameter,
                                   ImageOutputOption outputOption)
        

        According to the map parameters and image output settings, get the full URL of the cache image.

        The full URL format of the cache image is: {outputSite}/{cache}/{mapName}_{picWidth}x{picHeight}/{scaleRatio}/{regionInfo}/{centerIndex}_{imageCacheKey}.{postfix}.

        Where:

        1. outputSite is the root directory of the image access address. The default is: "http://localhost:8090/output".
        2. Cache is the total directory of the map image cache that is generated using the caching policy, whose default is "cache".
        3. mapName is the hash code that is generated after the map name is sorted (the leading spaces and trailing spaces in the map name are deleted).
        4. picWidth and picHeight are the cache image width (16 hexadecimal) and height (16 hexadecimal), e.g., when the directory name is **_200×200, it means the cache image size is 512×512, the unit is pixel.
        5. ScaleRatio is the scale level, the same scale of pictures are generated in the same scale level directory. When the scale is greater than 0 or less than or equal to 1, the directory name is {[1/mapScale]}, [] rounding; when the scale is greater than 1, the directory name is {N+mapScale}.
        6. RegionInfo refers to the spatial region, the spatial region refers to that the map will be divided into a number of blocks in accordance with the grid algorithm, where each block represents a spatial region. The form of the spatial area is X * Y, the directory with the same X value contains the same column of pictures, the directory with the same Y value contains the same row of pictures. The value of X gradually increases from the left to the right, and the value of Y increases gradually from bottom to top.
        7. CenterIndex is the center index of the cache image.
        8. imageCacheKey the cache image keyword.
        9. Postfix is a file suffix, which means the image file format.
        Specified by:
        getImageURL in interface ImageCacheHelper
        Parameters:
        mapParameter - map parameters
        outputOption - Picture output settings.
        Returns:
        The full URL format of the cache image.
      • getCacheKey

        public java.lang.String getCacheKey(MapParameter mapParam,
                                   ImageOutputOption outputOption)
        
        Get the cache keyword, excluding the range center point and image size and other factors.

        After the service is restarted, the keyword will not change.

        Specified by:
        getCacheKey in interface ImageCacheHelper
        Parameters:
        mapParam -
        outputOption -
        Returns:
      • getTempKey

        public java.lang.String getTempKey(MapParameter mapParam,
                                  ImageOutputOption outputOption)
        
        Get the temporary cache keyword, excluding the range center point and image size and other factors.

        After the service is restarted, the keyword will change.

        Specified by:
        getTempKey in interface ImageCacheHelper
        Parameters:
        mapParam -
        outputOption -
        Returns:
      • clearCache

        public void clearCache(java.lang.String mapName)
        

        Delete all cached images of the map.

        Specified by:
        clearCache in interface ImageCacheHelper
        Parameters:
        mapName -
      • clearCache

        public void clearCache(java.lang.String mapName,
                      java.lang.String cachePath)
        

        Delete all cached images of the map.

        Specified by:
        clearCache in interface ImageCacheHelper
        Parameters:
        mapName - Map name
        cachePath - Cache directory