Extending tile source info

Feedback


Tile source info class defines the storage information, tile est type (UserDefined), specific tile storage type, etc. of the tile.

The extension is as follows:

public class NationalCacheStandardTileSourceInfo extends TileSourceInfo {
...
}

Methods need to be implemented:

Field/Method Description
public NationalCacheStandardTileSourceInfo(NationalCacheStandardTileSourceInfo
 info)
Implement the copy constructor
public TileSourceInfo copy() Implement copy method
public TileSourceType getType()
public void setType(TileSourceType type)
Specify the storage type, which must be set to "UserDefined"
public TileType[] getSupportedTileTypes() Specify the tile type supported by the storage, tile type for map tile must be specified as "image".
public int hashCode()
public boolean equals(Object obj)
Implement the hashCode and equals methods
 

Implement copy constructor and copy method

Method for implementing the copy constructor is as follows:

    public NationalCacheStandardTileSourceInfo(NationalCacheStandardTileSourceInfo info) {
        super(info);
        this.setOutputPath(info.getOutputPath());
    }

Implement copy method:

    Override
    public TileSourceInfo copy() {
        return new NationalCacheStandardTileSourceInfo(this);
    }

Specify storage type

Type for extended tileset should be specified. Tile type for all extended formats should be specified as UserDefined.

    public TileSourceType getType() {
        return TileSourceType.UserDefined;
    }
        //Tile type for all extended formats should be specified as UserDefined
    public void setType(TileSourceType type) {
        if (!(TileSourceType.UserDefined.equals(type))) {
            throw new IllegalArgumentException();
        }
        super.setType(type);
    }

Specify tile type

Define the storage format type of the extended tile, for example, storage format of map tile (raster format) needs to be specified as "image"

    @Override
    public TileType[] getSupportedTileTypes() {
        return new TileType[] { TileType.Image };
    }

Implement the hashCode and equals methods

    public int hashCode() {
        HashCodeBuilder builder = new HashCodeBuilder(120000039, 120000041);
        String outputPath = getOutputPath();
        if (outputPath != null) {
            builder.append(Tool.getUniqueAbsoluteFilePath(outputPath));
        }
        if (getType() != null) {
            builder.append(getType());
        }
        return builder.toHashCode();
    }
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof NationalCacheStandardTileSourceInfo)) {
            return false;
        }
        NationalCacheStandardTileSourceInfo rhs = (NationalCacheStandardTileSourceInfo) obj;
        return new EqualsBuilder().append(this.getOutputPath(), rhs.getOutputPath()).append(this.getType(), rhs.getType()).isEquals();
    }

 

The complete extension example class is as follows:

NationalCacheStandardTileSourceInfo.java