nebsar / openmap

Automatically exported from code.google.com/p/openmap
Other
0 stars 0 forks source link

DTEDFrameCache index out of bound - with all DTED frames ! #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Import DTED0 Files from 
http://geoengine.nga.mil/geospatial/SW_TOOLS/NIMAMUSE/webinter/rast_roam.html
2. IN DTEDFrameCache try:

public static void main(String[] args) {
        Debug.init();
        //if (args.length < 1) {
        //    Debug.output("DTEDFrameCache:  Need a path/filename");
        //    System.exit(0);
        //}

        //Debug.output("DTEDFrameCache: " + args[0]);
        DTEDDirectoryHandler directorHandlerDTED0 = new DTEDDirectoryHandler();
        StandardDTEDNameTranslator standDTED = new StandardDTEDNameTranslator();
        standDTED.setDTEDDir("/data/terrain/dted0");
        directorHandlerDTED0.setDirectoryPath("/data/terrain/dted0");
        directorHandlerDTED0.setTranslator(standDTED);
        Vector handlers = new Vector();
        handlers.addElement(directorHandlerDTED0);

        DTEDFrameCache dfc = new DTEDFrameCache(10);
        dfc.setDTEDDirectoryHandlers(handlers);

        // 35.965065 -121.198715
        // 35.998 36.002 lon -121.002 -120.998
        float ullat = 56.3956761006288f; //37.002f;
        float ullon = 14.7773809523808f; //-121.002f;
        float lrlat = 48.8873427672958f; //35.998f;
        float lrlon = 29.7940476190478f; //-119.998f;

        // System.out.println("Getting elevations for " +
        // ullat + ", " + ullon + ", " +
        // lrlat + ", " + lrlon);
        short[][] e = dfc.getElevations(ullat, ullon, lrlat, lrlon, 0);
        if (e != null) {
            for (int i = e[0].length - 1; i >= 0; i--) {
                int col = 0;
                System.out.print("r" + i + "-");
                for (int j = 0; j < e.length; j++) {
                    System.out.print(e[j][i] + " ");
                    col++;
                }
                System.out.println(" - " + col);
            }
        }

    }
3. index out of bound error on 
System.arraycopy(es[x][y][i],
                                0,
                                matrix[i + xspacer],
                                yspacer,
                                es[x][y][i].length);

Solution: short[][] matrix = new short[xLength + 47][yLength]; //TODO why 47 ?

What is the expected output? What do you see instead?

index out of bound error on 
System.arraycopy(es[x][y][i],
                                0,
                                matrix[i + xspacer],
                                yspacer,
                                es[x][y][i].length);

What version of the product are you using? On what operating system?
5.01 - Windows

Please provide any additional information below.

Original issue reported on code.google.com by guerreiro.nma on 27 Oct 2013 at 6:50