Package gistoolkit.common

Examples of gistoolkit.common.Node


        }
    }
    /** Set up the configuration of this server. */
    public Node getNode()throws Exception{
        // There may be several services involved in a single server.
        Node tempNode = new Node(SERVER_TAG);
        for (int i=0; i<myServices.size(); i++){
            tempNode.addChild( ((Service) myServices.elementAt(i)).getNode());
        }
        return tempNode;
    }
View Full Code Here


       
        try{
            // if the index file exists, then use it.
            boolean tempReadIndex = false;
            if (tempIndexFile.exists()){
                Node tempRoot = gistoolkit.config.Configurator.readConfig(tempIndexFile.getAbsolutePath());
                if (tempRoot == null) throw new Exception("Can not read configuration file.");
               
                // read the envelope.
                double tempMinX = 0;
                if (tempRoot != null){
                    try{
                        String tempString = tempRoot.getAttribute("MinX");
                        tempMinX = Double.parseDouble(tempString);
                    }
                    catch (Exception e){
                        throw new Exception("Error parsing MinX from RasterCatalog Index File");
                    }
                }
                double tempMinY = 0;
                if (tempRoot != null){
                    try{
                        String tempString = tempRoot.getAttribute("MinY");
                        tempMinY = Double.parseDouble(tempString);
                    }
                    catch (Exception e){
                        throw new Exception("Error parsing MinY from RasterCatalog Index File");
                    }
                }
                double tempMaxX = 0;
                if (tempRoot != null){
                    try{
                        String tempString = tempRoot.getAttribute("MaxX");
                        tempMaxX = Double.parseDouble(tempString);
                    }
                    catch (Exception e){
                        throw new Exception("Error parsing MaxX from RasterCatalog Index File");
                    }
                }
                double tempMaxY = 0;
                if (tempRoot != null){
                    try{
                        String tempString = tempRoot.getAttribute("MaxY");
                        tempMaxY = Double.parseDouble(tempString);
                    }
                    catch (Exception e){
                        throw new Exception("Error parsing MaxY from RasterCatalog Index File");
                    }
                }
                // Create the envelope
                Envelope tempEnvelope = new Envelope(tempMinX, tempMinY, tempMaxX, tempMaxY);
               
                // read the resolutions.
                int[] tempResolutions = null;
                String[] tempResolutionNames = null;
                try{
                    String tempString = tempRoot.getAttribute("Resolutions");
                    if (tempString == null) throw new Exception("Unable to read Resolutions configuration information.");
                    ArrayList tempList = new ArrayList();
                    StringTokenizer st = new StringTokenizer(tempString);
                    while (st.hasMoreElements()){
                        tempList.add(st.nextToken(","));
                    }
                   
                    tempResolutions = new int[tempList.size()];
                    tempResolutionNames = new String[tempList.size()];
                    for (int i=0; i<tempList.size(); i++){
                        tempResolutionNames[i] = (String) tempList.get(i);
                        tempResolutions[i] = Integer.parseInt(tempResolutionNames[i]);
                    }
                    if (tempResolutions.length == 0) throw new Exception("No Resolutions found in Index File!");
                    myResolutions = tempResolutions;
                }
                catch (Exception e){
                    e.printStackTrace();
                    throw new Exception("Error parsing Resolutions from index file.");
                }
               
                // Read the file extension of the tiles.
                String tempExtension = tempRoot.getAttribute("Extension");
                if (tempExtension == null) tempExtension = "jpg";
               
                // read the source information.
                Node[] tempSourceNodes = tempRoot.getChildren("SourceImage");
                for (int i=0; i<tempSourceNodes.length; i++){
                    // read the envelope.
                    String tempString = tempSourceNodes[i].getAttribute("MinX");
                    tempMinX = Double.parseDouble(tempString);
                    tempString = tempSourceNodes[i].getAttribute("MinY");
View Full Code Here

    }
   
    /** write the index file. */
    private void writeIndex(Envelope tempEnvelope) throws Exception{
        // write the XML file for these nodes.
        Node tempRoot = new Node("TilesColection");
        tempRoot.addAttribute("MinX", ""+tempEnvelope.getMinX());
        tempRoot.addAttribute("MinY", ""+tempEnvelope.getMinY());
        tempRoot.addAttribute("MaxX", ""+tempEnvelope.getMaxX());
        tempRoot.addAttribute("MaxY", ""+tempEnvelope.getMaxY());
        tempRoot.addAttribute("TileWidth", ""+myMaxWidth);
        tempRoot.addAttribute("Extension", ""+myOutputType.toLowerCase());
        StringBuffer sb = new StringBuffer();
        for (int i=0; i<myResolutions.length; i++){
            if (i>0) sb.append(",");
            sb.append(""+myResolutions[i]);
        }
        tempRoot.addAttribute("Resolutions", sb.toString());
       
        /** Save the source information. */
        for (int i=0; i<mySourceList.size(); i++){
            ImageTile tempImageTile = (ImageTile) mySourceList.get(i);
            Node tempImageNode = new Node("SourceImage");
            Envelope tempImageEnvelope = tempImageTile.getEnvelope();
            tempImageNode.addAttribute("MinX", ""+tempImageEnvelope.getMinX());
            tempImageNode.addAttribute("MinY", ""+tempImageEnvelope.getMinY());
            tempImageNode.addAttribute("MaxX", ""+tempImageEnvelope.getMaxX());
            tempImageNode.addAttribute("MaxY", ""+tempImageEnvelope.getMaxY());
            tempImageNode.addAttribute("ImageWidth", ""+tempImageTile.getWidth());
            tempImageNode.addAttribute("ImageHeight", ""+tempImageTile.getHeight());
            tempImageNode.addAttribute("ImageFileName", ""+tempImageTile.getfileName());
            tempRoot.addChild(tempImageNode);
        }
       
        // write the index file
        gistoolkit.config.Configurator.writeConfig(tempRoot, myDestinationImageDirectory.getAbsolutePath()+File.separatorChar+"Index.xml");
View Full Code Here

TOP

Related Classes of gistoolkit.common.Node

Copyright © 2018 www.massapicom. 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.