Coder Social home page Coder Social logo

Comments (2)

gpotts avatar gpotts commented on August 20, 2024

Ooops made a mistalke. Wanted the else to be less restrictive.

and allow all other object types to pass. Removed the instance InputStream.

static Format getFormat(Object input) {

if(input instanceof File)
{
    File file = input as File
    if (file.exists()) {
        AbstractGridFormat format = GridFormatFinder.findFormat(file);
        if (format == null || format instanceof UnknownFormat) {
            return null
        }
        if (format instanceof GeoTiffFormat) {
            return new GeoTIFF(file)
        } else if (format instanceof ArcGridFormat) {
            return new ArcGrid(file)
        } else if (format instanceof GrassCoverageFormat) {
            return new Grass(file)
        } else if (format instanceof GTopo30Format) {
            return new GTopo30(file)
        } else if (format instanceof ImagePyramidFormat) {
            return new ImagePyramid(file)
        } else if (format instanceof ImageMosaicFormat) {
            return new Mosaic(file)
        } else if (format instanceof MrSIDFormat) {
            return new MrSID(file)
        } else if (format instanceof WorldImageFormat) {
            return new WorldImage(file)
        } else if (format instanceof NetCDFFormat) {
            return new NetCDF(file)
        } else {
            return new Format(format, file)
        }
    } else {
        String ext = file.name.substring(file.name.lastIndexOf(".") + 1).toLowerCase()
        if (ext in ["tif"]) {
            return new GeoTIFF(file)
        } else if (ext in ["png","jpg","jpeg","gif"]) {
            return new WorldImage(file)
        } else if (ext in ["arx"]) {
            return new Grass(file)
        } else if (ext in ["sid"]) {
            return new MrSID(file)
        } else if (ext in ["asc"]) {
            return new ArcGrid(file)
        } else if (ext in ["nc"]) {
            return new NetCDF(file)
        } else {
            return null
        }
    }
}
else
{
    AbstractGridFormat format = GridFormatFinder.findFormat(input);
    if (format == null || format instanceof UnknownFormat) {
        return null
    }else{
        return new Format(format, input)
    }
}

}

from geoscript-groovy.

jericks avatar jericks commented on August 20, 2024

This looks like an excellent idea! I will get this in soon (before we cut the 1.5 release).

from geoscript-groovy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.