Examples of JNCSFile


Examples of com.ermapper.ecw.JNCSFile

    private Envelope myWorldEnvelope = null;
   
    /** Returns the bounding rectangle of all the shapes in the Data Source. */
    public Envelope readEnvelope() throws Exception {
        if (myWorldEnvelope == null){
            JNCSFile tempECWFile = new JNCSFile(getFileLocation(), false);

            // find the coordinates of the file.
            Envelope tempECWFileEnvelope = new Envelope(
                tempECWFile.originX,
                tempECWFile.originY,
                tempECWFile.originX+tempECWFile.cellIncrementX*(tempECWFile.width-1),
                tempECWFile.originY+tempECWFile.cellIncrementY*(tempECWFile.height-1));
            myWorldEnvelope = tempECWFileEnvelope;
           
            // close the file, free the image cache.
            tempECWFile.close(true);
        }
        return myWorldEnvelope;
    }
View Full Code Here

Examples of com.ermapper.ecw.JNCSFile

    protected GISDataset readShapes(Envelope inEnvelope) throws Exception {
        // ensure there is an overlap
        if (!inEnvelope.overlaps(readEnvelope())) return new GISDataset();
       
        // create the new file, in nonprogressive mode.
        JNCSFile tempECWFile = new JNCSFile(getFileLocation(), false);

        // trim the envelope to the one in view.
        Envelope tempEnvelope = inEnvelope.getOverlap(readEnvelope());

        // figure out how big this image needs to be (the JNCSFile does not do subsampling);
        int width = getImageWidth();
        int height = getImageHeight();
               
        // find the required width and height.
        if (tempECWFile.cellIncrementX > (tempEnvelope.getWidth()/width)){
            width = (int) (tempEnvelope.getWidth()/tempECWFile.cellIncrementX);
        }
        if (Math.abs(tempECWFile.cellIncrementY) > (tempEnvelope.getHeight()/height)){
            height = (int) (tempEnvelope.getHeight()/Math.abs(tempECWFile.cellIncrementY));
        }

        // go about generating the data
        double dWorldTLX, dWorldTLY, dWorldBRX, dWorldBRY;
        int bandlist[];
        int line, pRGBArray[] = null;
       
        // Create an image of the ecw file.
        BufferedImage ecwImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        pRGBArray = new int[width];
       
        // Setup the view parameters for the ecw file.
        bandlist = new int[tempECWFile.numBands];
        for (int i=0; i< tempECWFile.numBands; i++) {
            bandlist[i] = i;
        }
        dWorldTLX = tempEnvelope.getMinX();
        dWorldTLY = tempEnvelope.getMaxY();
        dWorldBRX = tempEnvelope.getMaxX();
        dWorldBRY = tempEnvelope.getMinY();
       
        // Set the view
        tempECWFile.setView(tempECWFile.numBands, bandlist, dWorldTLX, dWorldTLY, dWorldBRX, dWorldBRY, width, height);
       
        // Read the scan lines
        for (line=0; line < height; line++) {
            tempECWFile.readLineRGBA(pRGBArray);
            ecwImage.setRGB(0, line, width, 1, pRGBArray, 0, width);
        }
       
        // close the file
        tempECWFile.close(true);
       
        // return the graphics object
        RasterShape tempShape = new RasterShape(tempEnvelope, ecwImage);
        Record tempRecord = new Record();
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.