Statistics
| Revision:

root / trunk / extensions / extWCS / src / es / uji / lsi / wcs / XmlWcsParsing / GMLRectifiedGrid.java @ 1877

History | View | Annotate | Download (3.04 KB)

1
package es.uji.lsi.wcs.XmlWcsParsing;
2
/*
3
 * GMLRectifiedGrid.java
4
 *
5
 * Created on 3 de enero de 2005, 15:10
6
 */
7
import java.util.*;
8
/**
9
 *
10
 * @author  jaume
11
 */
12
public class GMLRectifiedGrid {
13
    private int dimension;
14
    private GMLLimits gmlLimits;
15
    private ArrayList axisNames = new ArrayList();
16
    private double[] origin;
17
    private ArrayList offsetVectorList = new ArrayList();
18
    
19
    /** Creates a new instance of GMLRectifiedGrid */
20
    public GMLRectifiedGrid(XMLNode node) {
21
        dimension = Integer.parseInt(node.getAttribute("dimension"));
22
        for (int i=0; i<node.getNumSubNodes();i++){
23
            XMLNode subnode = node.getSubNode(i);
24
            if (WCSToolkit.isWCSTab(subnode, "gml:limits")) gmlLimits = new GMLLimits(subnode, dimension);
25
            if (WCSToolkit.isWCSTab(subnode, "gml:axisName")) axisNames.add(subnode.getText());
26
            if (WCSToolkit.isWCSTab(subnode, "gml:origin")) setOrigin(subnode, dimension);
27
            if (WCSToolkit.isWCSTab(subnode, "gml:offsetVector")) {
28
                String[] s = subnode.getText().split(" ");
29
                int [] aux = new int[dimension];
30
                for (int j=0; j<dimension; j++){
31
                    aux[j] = new Integer(s[j]).intValue();
32
                }
33
                offsetVectorList.add(aux);
34
            }
35
            
36
        }
37
        
38
    }
39
    
40
    public void setOrigin(XMLNode node, int dimension){
41
        origin = new double[dimension];
42
        for (int i=0; i<node.getNumSubNodes(); i++){
43
            XMLNode subnode = node.getSubNode(i);
44
            if (WCSToolkit.isWCSTab(subnode, "gml:pos")){
45
                String[] s = subnode.getText().split(" ");
46
                for (int j=0; j<dimension; j++){
47
                    origin[j] = new Double(s[j]).doubleValue();
48
                }
49
            }
50
        }
51
    }
52
    
53
    public int getDimension(){
54
        return dimension;
55
    }
56
    
57
    public GMLLimits getGMLLimits(){
58
        return gmlLimits;
59
    }
60
    
61
    public ArrayList getAxisNames(){
62
        return axisNames;
63
    }
64
    
65
    public String getAxisName(int index){
66
        return (String) axisNames.get(index);
67
    }
68
    
69
    public int[] getOffsetVector(int index){
70
        return (int[]) offsetVectorList.get(index);
71
    }
72
    
73
    public ArrayList getOffsetVectorList(){
74
        return offsetVectorList;
75
    }
76
    
77
    public double[] getOrigin(){
78
        return origin;
79
    }
80
    
81
    public String toString(){
82
        Iterator it ;
83
        String s, s2, s3;
84
        s ="";
85
        s2 ="";
86
        s3 ="";
87
        if (axisNames !=null){
88
            it = axisNames.iterator();
89
            while (it.hasNext()){
90
                s += it.next()+" ";
91
            }
92
        }
93
        
94
        if (origin != null){
95
            for (int i=0; i<origin.length; i++){
96
                s3 += origin[i]+" ";
97
            }
98
        }
99
        return "\nGML Rectified Grid"+
100
               "\ndimension: "+dimension+
101
               "\ngml limits: "+gmlLimits+
102
               "\nAxis names: "+s
103
               +"\nOffset vector: ["+s2+"]"+
104
               "\nOrigin: ("+s3+")";
105
    }
106
}
107