Revision 472 org.gvsig.proj/trunk/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/gvsig/proj/cts/DefaultIProjection.java

View differences:

DefaultIProjection.java
38 38
import org.gvsig.proj.CoordinateTransformation;
39 39

  
40 40
/**
41
 * Java Map CoordinateReferenceSystem Library based implementation. It works
42
 * as a facade over a {@link CoordinateReferenceSystem} object.
43
 * 
41
 * Java Map CoordinateReferenceSystem Library based implementation. It works as
42
 * a facade over a {@link CoordinateReferenceSystem} object.
43
 *
44 44
 * @author gvSIG Team
45 45
 */
46 46
public class DefaultIProjection implements IProjection {
......
49 49

  
50 50
    /**
51 51
     * Creates a {@link DefaultIProjection} with an authority name and CRS code.
52
     * 
53
     * @param authorityName
54
     *            name of the authority which defined the CRS.
55
     * @param code
56
     *            of the defined CRS represented by this object
57
     * @throws CoordinateReferenceSystemNotFoundException
58
     *             if a CRS with the
59
     *             given authority name and code could not be found in the
60
     *             system
52
     *
53
     * @param authorityName name of the authority which defined the CRS.
54
     * @param code of the defined CRS represented by this object
55
     * @throws CoordinateReferenceSystemNotFoundException if a CRS with the
56
     * given authority name and code could not be found in the system
61 57
     */
62 58
    public DefaultIProjection(String authorityName, String code)
63
        throws CoordinateReferenceSystemNotFoundException {
59
            throws CoordinateReferenceSystemNotFoundException {
64 60
        this(CoordinateReferenceSystemLocator.getManager()
65
            .getCoordinateReferenceSystem(authorityName, code));
61
                .getCoordinateReferenceSystem(authorityName, code));
66 62
    }
67 63

  
68 64
    /**
69
     * 
65
     *
70 66
     * @param crs
71 67
     */
72 68
    public DefaultIProjection(CoordinateReferenceSystem crs) {
......
78 74

  
79 75
            public double getEIFlattening() {
80 76
                return getCoordinateReferenceSystem().getDatum().getEllipsoid()
81
                    .getReciprocalFlattening();
77
                        .getReciprocalFlattening();
82 78
            }
83 79

  
84 80
            public double getESemiMajorAxis() {
85 81
                return getCoordinateReferenceSystem().getDatum().getEllipsoid()
86
                    .getSemiMajorAxis();
82
                        .getSemiMajorAxis();
87 83
            }
88 84

  
89 85
        };
......
120 116
    public Point2D toGeo(Point2D pt) {
121 117
        CoordinateReferenceSystem geographic = crs.createGeographic();
122 118

  
123
        CoordinateTransformation transfToGeo =
124
            crs.getTransformation(geographic);
119
        CoordinateTransformation transfToGeo
120
                = crs.getTransformation(geographic);
125 121

  
126
        double[] coords = new double[] { pt.getX(), pt.getY() };
122
        double[] coords = new double[]{pt.getX(), pt.getY()};
127 123
        transfToGeo.convert(coords);
128 124
        return new Point2D.Double(coords[0], coords[1]);
129 125
    }
......
131 127
    public Point2D fromGeo(Point2D gPt, Point2D mPt) {
132 128
        CoordinateReferenceSystem geographic = crs.createGeographic();
133 129

  
134
        CoordinateTransformation transfFromGeo =
135
            geographic.getTransformation(crs);
130
        CoordinateTransformation transfFromGeo
131
                = geographic.getTransformation(crs);
136 132

  
137
        double[] coords = new double[] { gPt.getX(), gPt.getY() };
133
        double[] coords = new double[]{gPt.getX(), gPt.getY()};
138 134
        transfFromGeo.convert(coords);
139 135
        mPt.setLocation(coords[0], coords[1]);
140 136
        return mPt;
......
142 138

  
143 139
    public double getScale(double minX, double maxX, double width, double dpi) {
144 140
        double scale = ((maxX - minX) * // metros
145
            (dpi / 2.54 * 100.0))
146
            / // px / metro
147
            width; // pixels
141
                (dpi / 2.54 * 100.0))
142
                / // px / metro
143
                width; // pixels
148 144
        return scale;
149 145
    }
150 146

  
151 147
    public Rectangle2D getExtent(Rectangle2D extent, double scale,
152
        double wImage, double hImage, double mapUnits, double distanceUnits,
153
        double dpi) {
148
            double wImage, double hImage, double mapUnits, double distanceUnits,
149
            double dpi) {
154 150

  
155 151
        // Code copied from the org.gvsig.crs.Crs class.
156 152
        // I think this calculation might be moved outside the projection
......
162 158

  
163 159
        double xExtent = extent.getCenterX() - wExtent / 2;
164 160
        double yExtent = extent.getCenterY() - hExtent / 2;
165
        Rectangle2D rec =
166
            new Rectangle2D.Double(xExtent, yExtent, wExtent, hExtent);
161
        Rectangle2D rec
162
                = new Rectangle2D.Double(xExtent, yExtent, wExtent, hExtent);
167 163
        return rec;
168 164
    }
169 165

  
......
173 169

  
174 170
    public Object clone() throws CloneNotSupportedException {
175 171
        DefaultIProjection cloned = (DefaultIProjection) super.clone();
176
        cloned.crs =
177
            (CoordinateReferenceSystem) this.getCoordinateReferenceSystem()
172
        cloned.crs
173
                = (CoordinateReferenceSystem) this.getCoordinateReferenceSystem()
178 174
                .clone();
179 175
        return cloned;
180 176
    }
......
186 182
    public String toString() {
187 183
        return crs.toString();
188 184
    }
185

  
186
    public String export(String format) {
187
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
188
    }
189

  
190
    public boolean equals(Object obj) {
191
        if (this == obj) {
192
            return true;
193
        }
194
        if (!(obj instanceof DefaultIProjection)) {
195
            return false;
196
        }
197
        return this.getFullCode().equalsIgnoreCase(((DefaultIProjection) obj).getFullCode());
198
    }
199

  
200
    public int hashCode() {
201
        return this.getFullCode().hashCode();
202
    }
189 203
}

Also available in: Unified diff