Revision 26996

View differences:

tags/tmp_build/libraries/libProjection/config/text_cs.properties
1
#Translations for language [cs]
2
#Mon Nov 06 09:04:31 CET 2006
3
Aceptar=Budi\u017e
4
Aplicar=Pou\u017e\u00edt
5
Block_Size_=
6
Cancelar=Zru\u0161it
7
Compression_=
8
datum=Datum
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=Projekce
14
reference_system=Prostorov\u00fd referen\u010dn\u00ed syst\u00e9m
15
zone=Z\u00f3na
0 16

  
tags/tmp_build/libraries/libProjection/config/text_fr.properties
1
#Translations for language [fr]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Accepter
4
Aplicar=Appliquer
5
Block_Size_=
6
Cancelar=Annuler
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/tmp_build/libraries/libProjection/config/text_de.properties
1
#Translations for language [de]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=OK
4
Aplicar=Anwenden
5
Block_Size_=
6
Cancelar=Abbrechen
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/tmp_build/libraries/libProjection/config/text_eu.properties
1
#Translations for language [eu]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Ados
4
Aplicar=Aplikatu
5
Block_Size_=
6
Cancelar=Utzi
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/tmp_build/libraries/libProjection/config/text_it.properties
1
#Translations for language [it]
2
#Tue Nov 07 12:30:01 CET 2006
3
Aceptar=Accetta
4
Aplicar=Applica
5
Block_Size_=Dimensioni blocco\:
6
Cancelar=Cancella
7
Compression_=Compressione
8
datum=Datum
9
Generate_Tfw_=Genera Tfw\:
10
Interleave_=Interlacciato\:
11
Photometric_=Fotometrica\:
12
Progressive_=Progressivo\:
13
projection=Proiezione
14
reference_system=Sistema di riferimento
15
zone=Fuso
0 16

  
tags/tmp_build/libraries/libProjection/config/text.properties
1
#Translations for language [es]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Aceptar
4
Aplicar=Aplicar
5
Block_Size_=Tama\u00f1o de bloque\:
6
Cancelar=Cancelar
7
Compression_=Compresi\u00f3n\:
8
datum=Datum
9
Generate_Tfw_=Generar Tfw\:
10
Interleave_=Entrelazado\:
11
Photometric_=Fotom\u00e9trica\:
12
Progressive_=Progresivo\:
13
projection=Proyecci\u00f3n
14
reference_system=Sistema de Referencia
15
zone=Huso
0 16

  
tags/tmp_build/libraries/libProjection/config/text_en.properties
1
#Translations for language [en]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Accept
4
Aplicar=Apply
5
Block_Size_=Block Size\:
6
Cancelar=Cancel
7
Compression_=Compression\:
8
datum=Datum
9
Generate_Tfw_=Generate Tfw\:
10
Interleave_=Interleave\:
11
Photometric_=Photometric\:
12
Progressive_=Progressive\:
13
projection=Projection
14
reference_system=Reference System
15
zone=Zone
0 16

  
tags/tmp_build/libraries/libProjection/config/text_gl.properties
1
#Translations for language [gl]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Aceptar
4
Aplicar=Aplicar
5
Block_Size_=
6
Cancelar=Cancelar
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/tmp_build/libraries/libProjection/config/text_ca.properties
1
#Translations for language [ca]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Acceptar
4
Aplicar=Aplicar
5
Block_Size_=
6
Cancelar=Cancel\u00b7lar
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=Projecci\u00f3
14
reference_system=Sistema de refer\u00e8ncia
15
zone=
0 16

  
tags/tmp_build/libraries/libProjection/config/text_pt.properties
1
#Translations for language [pt]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Aceitar
4
Aplicar=Aplicar
5
Block_Size_=
6
Cancelar=Cancelar
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/tmp_build/libraries/libProjection/src/org/cresques/geo/Orthographic.java
1
/*
2
 * OrthographicMapProjection.java
3
 *
4
 * Copyright (c) 2002, 2003, Raben Systems, Inc.
5
 * All rights reserved.
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions are met:
9
 *
10
 *    Redistributions of source code must retain the above copyright notice,
11
 *    this list of conditions and the following disclaimer.
12
 *
13
 *    Redistributions in binary form must reproduce the above copyright notice,
14
 *    this list of conditions and the following disclaimer in the documentation
15
 *    and/or other materials provided with the distribution.
16
 *
17
 *    Neither the name of Raben Systems, Inc. nor the names of its contributors
18
 *    may be used to endorse or promote products derived from this software
19
 *    without specific prior written permission.
20
 *
21
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
 * POSSIBILITY OF SUCH DAMAGE.
32
 *
33
 * Created on June 7, 2002, 4:31 PM
34
*/
35
package org.cresques.geo;
36

  
37
import java.awt.geom.GeneralPath;
38

  
39
//package com.raben.projection.map;
40
import java.awt.geom.Point2D;
41

  
42

  
43
/***
44
 * Orthographic Map projection computation
45
 * @author  Vern Raben
46
 * @version $Revision$ $Date$
47
 * Copyright (c) Raben Systems, Inc., 2002
48
 * All rights reserved
49
 */
50
public final class Orthographic { //extends AbstractMapProjection { 
51

  
52
    /*** Creates new OrthographicMapProjection */
53
    public Orthographic() {
54
    }
55

  
56
    /***
57
     * Get Screen location for specified coordinate in radians
58
     * @param coordinate Point2D Longitude and latitude of coordinate in radians
59
     * @return Point2D Screen location of the coordinate
60
     */
61
    public Point2D getLocationForCoordinate(Point2D coordinate) {
62
        Point2D.Double loc = new Point2D.Double(Double.NaN, Double.NaN);
63

  
64
        /*                Point2D centerPoint = getCenterPoint();
65
                        Point2D centerCoordinate = getCenterCoordinate();
66
                        double radius = getRadius();
67
                        double cosLatCenter = getCosLatCenter();
68
                        double sinLatCenter = getSinLatCenter();
69

  
70
                        if ((!Double.isNaN(coordinate.getX()))
71
                                && (!Double.isNaN(coordinate.getY()))) {
72
                                double latitude = coordinate.getY();
73
                                double longitude = coordinate.getX();
74

  
75
                                double sinLat = Math.sin(normalizeLatitude(latitude));
76
                                double cosLat = Math.cos(latitude);
77
                                double lonDiff = normalizeLongitude(longitude
78
                                        - centerCoordinate.getX());
79
                                double cosLonDiff = Math.cos(lonDiff);
80
                                double cosC = (sinLatCenter * sinLat)
81
                                        + (cosLatCenter * cosLat * cosLonDiff);
82

  
83
                                if (cosC >= 0.0) {
84
                                        double sinLonDiff = Math.sin(lonDiff);
85
                                        double x = (radius * cosLat * sinLonDiff) + centerPoint.getX();
86
                                        double y = (radius * ((cosLatCenter * sinLat)
87
                                                - (sinLatCenter * cosLat * cosLonDiff)))
88
                                                + centerPoint.getY();
89
                                        loc.setLocation(x, y);
90
                                }
91
                        }
92
        */
93
        return loc;
94
    }
95

  
96
    /***
97
     * Get coordinate for a given point on the screen
98
     * @param loc Point2D Screen location of the point
99
     * @return Point2D Coordinate of the point in radians
100
     */
101
    public Point2D getCoordinateForLocation(Point2D loc) {
102
        Point2D.Double coordinate = new Point2D.Double(Double.NaN, Double.NaN);
103

  
104
        /*                Point2D centerPoint = getCenterPoint();
105
                        Point2D centerCoordinate = getCenterCoordinate();
106
                        double sinLatCenter = getSinLatCenter();
107
                        double cosLatCenter = getCosLatCenter();
108
                        double radius = getRadius();
109

  
110
                        if ((!Double.isNaN(loc.getX()))
111
                                && (!Double.isNaN(loc.getY()))) {
112
                                double x = loc.getX() - centerPoint.getX();
113
                                double y = loc.getY() - centerPoint.getY();
114
                                double rho = Math.sqrt((x * x) + (y * y));
115

  
116
                                if ((rho > 0.0) & (rho <= radius)) {
117
                                        double sinC = rho / radius;
118
                                        double cosC = Math.sqrt(1.0 - (sinC * sinC));
119
                                        double latitude = Math.asin(cosC * sinLatCenter)
120
                                                + (y * sinC * cosLatCenter / rho);
121
                                        double longitude = Double.NaN;
122

  
123
                                        if (centerCoordinate.getY()
124
                                                        == MapProjectionConstants.PI_OVER_2) {
125
                                                longitude = centerCoordinate.getX()
126
                                                        + Math.atan2(x, -y);
127
                                        } else if (centerCoordinate.getY()
128
                                                        == -MapProjectionConstants.PI_OVER_2) {
129
                                                longitude = centerCoordinate.getX() + Math.atan2(x, y);
130
                                        } else {
131
                                                longitude = centerCoordinate.getX()
132
                                                        + Math.atan2((x * sinC), (rho * cosLatCenter * cosC)
133
                                                        - (y * sinLatCenter * sinC));
134
                                        }
135

  
136
                                        longitude = normalizeLongitude(longitude);
137
                                        latitude = normalizeLatitude(latitude);
138
                                        coordinate.setLocation(longitude, latitude);
139
                                } else if (rho == 0.0) {
140
                                        coordinate.setLocation(centerCoordinate.getX(),
141
                                                centerCoordinate.getY());
142
                                }
143

  
144
                        }
145
        */
146
        return coordinate;
147
    }
148

  
149
    /***
150
     * Get overlay grid for map as a path
151
     * @return GeneralPath to draw mapOverlay.
152
     */
153
    public GeneralPath getOverlayGridPath() {
154
        GeneralPath overlayGridPath = new GeneralPath();
155

  
156
        /*                double sinLat = 0.0;
157
                        double cosLat = 0.0;
158
                        double cosLonDiff = 0.0;
159
                        double sinLonDiff = 0.0;
160
                        double lonDiff = 0.0;
161
                        double cosC = 0.0;
162
                        float x, y;
163
                        float mark = (float) getRadius() / 360.0F;
164
                        Point2D centerPoint = getCenterPoint();
165
                        Point2D centerCoordinate = getCenterCoordinate();
166
                        double radius = getRadius();
167
                        double cosLatCenter = getCosLatCenter();
168
                        double sinLatCenter = getSinLatCenter();
169
                        double overlayGridIncrement = getOverlayGridIncrement();
170
                        double overlayGridLongitudeIncrement
171
                                = getOverlayGridLongitudeIncrement();
172
                        double overlayGridLatitudeIncrement = getOverlayGridLatitudeIncrement();
173

  
174
                        // Create latitude lines
175
                        for (double lat = -MapProjectionConstants.PI_OVER_2;
176
                                        lat <= MapProjectionConstants.PI_OVER_2;
177
                                        lat += overlayGridLatitudeIncrement) {
178
                                sinLat = Math.sin(lat);
179
                                cosLat = Math.cos(lat);
180

  
181

  
182
                                for (double lon = -Math.PI; lon <= Math.PI;
183
                                                lon += overlayGridIncrement) {
184
                                        lonDiff = lon - centerCoordinate.getX();
185
                                        cosLonDiff = Math.cos(lonDiff);
186
                                        cosC = (sinLatCenter * sinLat)
187
                                                + (cosLatCenter * cosLat * cosLonDiff);
188

  
189
                                        if (cosC >= 0.0) {
190
                                                sinLonDiff = Math.sin(lonDiff);
191
                                                x = (float) ((radius * cosLat * sinLonDiff)
192
                                                        + centerPoint.getX());
193
                                                y = (float) ((radius * ((cosLatCenter * sinLat)
194
                                                        - (sinLatCenter * cosLat * cosLonDiff)))
195
                                                        + centerPoint.getY());
196
                                                overlayGridPath.moveTo(x - mark, y);
197
                                                overlayGridPath.lineTo(x + mark, y);
198
                                                overlayGridPath.moveTo(x, y - mark);
199
                                                overlayGridPath.lineTo(x, y + mark);
200
                                        }
201
                                }
202
                        }
203

  
204
                        // Create longitude lines
205
                        for (double lon = -Math.PI; lon <= Math.PI;
206
                                        lon += overlayGridLongitudeIncrement) {
207
                                lonDiff = lon - centerCoordinate.getX();
208
                                cosLonDiff = Math.cos(lonDiff);
209

  
210
                                for (double lat = -MapProjectionConstants.PI_OVER_2;
211
                                                lat <= MapProjectionConstants.PI_OVER_2;
212
                                                lat += overlayGridIncrement) {
213
                                        sinLat = Math.sin(lat);
214
                                        cosLat = Math.cos(lat);
215
                                        cosC = (sinLatCenter * sinLat)
216
                                                + (cosLatCenter * cosLat * cosLonDiff);
217

  
218
                                        if (cosC >= 0.0) {
219
                                                sinLonDiff = Math.sin(lonDiff);
220
                                                x = (float) ((radius * cosLat * sinLonDiff)
221
                                                        + centerPoint.getX());
222
                                                y = (float) ((radius * ((cosLatCenter * sinLat)
223
                                                        - (sinLatCenter * cosLat * cosLonDiff)))
224
                                                        + centerPoint.getY());
225
                                                overlayGridPath.moveTo(x - mark, y);
226
                                                overlayGridPath.lineTo(x + mark, y);
227
                                                overlayGridPath.moveTo(x, y - mark);
228
                                                overlayGridPath.lineTo(x, y + mark);
229
                                        }
230
                                }
231
                        }
232
        */
233
        return overlayGridPath;
234
    }
235

  
236
    /***
237
     * Get projection name
238
     * @return ProjectionName
239
     */
240

  
241
    //public ProjectionName getProjectionName() {
242
    //	return ProjectionName.ORTHOGRAPHIC;
243
    //}
244
}
0 245

  
tags/tmp_build/libraries/libProjection/src/org/cresques/geo/CCLambert.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.geo;
25

  
26
import org.cresques.cts.ICoordTrans;
27
import org.cresques.cts.IDatum;
28
import org.cresques.cts.IProjection;
29

  
30
import org.cresques.px.Extent;
31

  
32
import java.awt.Graphics2D;
33
import java.awt.geom.AffineTransform;
34
import java.awt.geom.Point2D;
35
import java.awt.geom.Rectangle2D;
36

  
37

  
38
/**
39
 * Proyeccion de Conica Comforme Lambert
40
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
41
 */
42
public class CCLambert extends Projection {
43
    static String name = "Conica Comforme Lambert";
44
    static String abrev = "CCLam";
45

  
46
    public CCLambert(Ellipsoid eli) {
47
        super(eli);
48
        grid = new Graticule(this);
49
    }
50

  
51
    public ICoordTrans getCT(IProjection dest) {
52
		// TODO Auto-generated method stub
53
		return null;
54
	}
55

  
56
	public String getAbrev() {
57
        return abrev;
58
    }
59

  
60
    public static CCLambert getProjection(Ellipsoid eli) {
61
        return new CCLambert(eli);
62
    }
63

  
64
    /**
65
     *
66
     */
67
    public static IProjection getProjectionByName(IDatum eli, String name) {
68
        if (name.indexOf("CCL") < 0) {
69
            return null;
70
        }
71

  
72
        return getProjection((Ellipsoid) eli);
73
    }
74

  
75
    /**
76
     *
77
     */
78
    public Point2D createPoint(double x, double y) {
79
        return new Point2D.Double(x, y);
80
    }
81

  
82
    /**
83
     *
84
     * @param uPt
85
     * @return
86
     */
87
    public Point2D toGeo(Point2D lPt) {
88
        GeoPoint gPt = new GeoPoint();
89

  
90
        return toGeo(lPt, gPt);
91
    }
92

  
93
    /**
94
     *
95
     * @param uPt
96
     * @param gPt
97
     * @return
98
     */
99
    public GeoPoint toGeo(Point2D lPt, GeoPoint gPt) {
100
        return gPt;
101
    }
102

  
103
    /**
104
     *
105
     * @param gPt
106
     * @param uPt
107
     * @return
108
     */
109
    public Point2D fromGeo(Point2D gPt, Point2D lPt) {
110
        return lPt;
111
    }
112

  
113
    private void generateGrid(Graphics2D g, Extent extent, AffineTransform mat) {
114
        grid = new Graticule(this);
115
    }
116

  
117
    public void drawGrid(Graphics2D g, ViewPortData vp) {
118
        generateGrid(g, vp.getExtent(), vp.getMat());
119
        grid.setColor(gridColor);
120
        grid.draw(g, vp);
121
    }
122

  
123
    /* (non-Javadoc)
124
     * @see org.cresques.cts.IProjection#getScale(double, double, double, double)
125
     */
126
    public double getScale(double minX, double maxX, double width, double dpi) {
127
        // TODO Auto-generated method stub
128
        return -1D;
129
    }
130

  
131
	/* (non-Javadoc)
132
	 * @see org.cresques.cts.IProjection#getExtent(java.awt.geom.Rectangle2D, double, double, double, double, double, double)
133
	 */
134
	public Rectangle2D getExtent(Rectangle2D extent, double scale, double wImage, double hImage, double mapUnits, double distanceUnits, double dpi) {
135
		return null;
136
	}
137

  
138
	/* (non-Javadoc)
139
	 * @see org.cresques.cts.IProjection#getFullCode()
140
	 */
141
	public String getFullCode() {
142
		return getAbrev();
143
	}
144
}
0 145

  
tags/tmp_build/libraries/libProjection/src/org/cresques/geo/.cvsignore
1
*.dfPackage
2
*.wmf
0 3

  
tags/tmp_build/libraries/libProjection/src/org/cresques/geo/cover/Hoja.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.geo.cover;
25

  
26
import org.cresques.cts.ICoordTrans;
27
import org.cresques.cts.IProjection;
28

  
29
import org.cresques.geo.Projected;
30

  
31
import org.cresques.px.Extent;
32

  
33
import java.awt.geom.Point2D;
34

  
35
import java.io.InputStream;
36
import java.io.OutputStream;
37

  
38
import java.util.Vector;
39

  
40

  
41
/**
42
 * @author Luis W. Sevilla <sevilla_lui@gva.es>
43
 */
44
public class Hoja implements Projected {
45
    IProjection proj;
46
    String code = null;
47
    String name = null;
48
    Extent extent = null;
49
    Point2D tl;
50
    Point2D tr;
51
    Point2D bl;
52
    Point2D br;
53

  
54
    public Hoja(IProjection proj, String code, String name) {
55
        this.proj = proj;
56
        this.code = code;
57
        this.name = name;
58
        tl = tr = bl = br = null;
59
    }
60

  
61
    public Hoja(String cod, Point2D p1, Point2D p2, Point2D p3, Point2D p4,
62
                String name) {
63
        code = cod;
64
        tl = p1;
65
        tr = p2;
66
        bl = p3;
67
        br = p4;
68

  
69
        if (name != null) {
70
            this.name = name;
71
        }
72

  
73
        setExtent();
74
    }
75

  
76
    public Hoja(String cod, Point2D[] pt, String name) {
77
        code = cod;
78
        tl = pt[0];
79
        tr = pt[1];
80
        br = pt[2];
81
        bl = pt[3];
82

  
83
        if (name != null) {
84
            this.name = name;
85
        }
86

  
87
        setExtent();
88
    }
89

  
90
    public Hoja(String cod, Vector pt, String name) {
91
        code = cod;
92
        tl = (Point2D) pt.get(0);
93
        tr = (Point2D) pt.get(1);
94
        br = (Point2D) pt.get(2);
95
        bl = (Point2D) pt.get(3);
96

  
97
        if (name != null) {
98
            this.name = name;
99
        }
100

  
101
        setExtent();
102
    }
103

  
104
    public Hoja(String cod, Hoja h, String name) {
105
        code = cod;
106
        tl = h.tl;
107
        tr = h.tr;
108
        br = h.br;
109
        bl = h.bl;
110

  
111
        if (name != null) {
112
            this.name = name;
113
        }
114

  
115
        setExtent();
116
    }
117

  
118
    public IProjection getProjection() {
119
        return proj;
120
    }
121

  
122
    public void setProjection(IProjection p) {
123
        proj = p;
124
    }
125

  
126
    public void reProject(ICoordTrans rp) {
127
        // TODO metodo reProject pendiente de implementar
128
    }
129

  
130
    public Point2D getTL() {
131
        return tl;
132
    }
133

  
134
    public void setTL(Point2D pt) {
135
        tl = pt;
136
        extent.add(pt);
137
    }
138

  
139
    public Point2D getTR() {
140
        return tr;
141
    }
142

  
143
    public void setTR(Point2D pt) {
144
        tr = pt;
145
        extent.add(pt);
146
    }
147

  
148
    public Point2D getBL() {
149
        return bl;
150
    }
151

  
152
    public void setBL(Point2D pt) {
153
        bl = pt;
154
        extent.add(pt);
155
    }
156

  
157
    public Point2D getBR() {
158
        return br;
159
    }
160

  
161
    public void setBR(Point2D pt) {
162
        br = pt;
163
        extent.add(pt);
164
    }
165

  
166
    public Extent getExtent() {
167
        return extent;
168
    }
169

  
170
    private void setExtent() {
171
        extent = new Extent(tl, br);
172
        extent.add(tr);
173
        extent.add(bl);
174
    }
175

  
176
    public String getCode() {
177
        return code;
178
    }
179

  
180
    public String getName() {
181
        return name;
182
    }
183

  
184
    public Point2D[] getVertex() {
185
        Point2D[] v = { tl, tr, br, bl };
186

  
187
        return v;
188
    }
189

  
190
    public void toXml(OutputStream os) {
191
    }
192

  
193
    public void fromXml(InputStream is) {
194
    }
195
}
0 196

  
tags/tmp_build/libraries/libProjection/src/org/cresques/geo/cover/.cvsignore
1
*.dfPackage
2
*.wmf
0 3

  
tags/tmp_build/libraries/libProjection/src/org/cresques/geo/cover/package.html
1
<html>
2
	<body>Clases relacionadas con coverturas espaciales.
3
</body>
4
</html>
0 5

  
tags/tmp_build/libraries/libProjection/src/org/cresques/geo/UtmZone.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.geo;
25

  
26
import geojava.GeoUtm;
27
import geojava.Ra2De;
28
import geojava.UtmGeo;
29

  
30
import org.cresques.cts.ICoordTrans;
31
import org.cresques.cts.IDatum;
32
import org.cresques.cts.IProjection;
33

  
34
import org.cresques.px.Extent;
35

  
36
import java.awt.Graphics2D;
37
import java.awt.geom.AffineTransform;
38
import java.awt.geom.Point2D;
39
import java.awt.geom.Rectangle2D;
40

  
41

  
42
public class UtmZone extends Projection {
43
    static String name = "UTM";
44
    static String abrev = "UTM";
45
    private final static UtmZone ed5028N = new UtmZone(Ellipsoid.ed50, 28, 0,
46
                                                       0.0);
47
    private final static UtmZone ed5029N = new UtmZone(Ellipsoid.ed50, 29, 0,
48
                                                       0.0);
49
    private final static UtmZone ed5030N = new UtmZone(Ellipsoid.ed50, 30, 0,
50
                                                       0.0);
51
    private final static UtmZone ed5031N = new UtmZone(Ellipsoid.ed50, 31, 0,
52
                                                       0.0);
53
    private final static UtmZone hayford28N = new UtmZone(Ellipsoid.hayford,
54
                                                          28, 0, 0.0);
55
    private final static UtmZone hayford29N = new UtmZone(Ellipsoid.hayford,
56
                                                          29, 0, 0.0);
57
    private final static UtmZone hayford30N = new UtmZone(Ellipsoid.hayford,
58
                                                          30, 0, 0.0);
59
    private final static UtmZone hayford31N = new UtmZone(Ellipsoid.hayford,
60
                                                          31, 0, 0.0);
61
    static GeoUtm geoutm = new GeoUtm();
62
    static UtmGeo utmgeo = new UtmGeo();
63
    public int Zone = 30;
64
    public int Hemisphere = 0;
65
    public double H = 0.0;
66

  
67
    public UtmZone(Ellipsoid eli, int zone, int hemisphere, double h) {
68
        super(eli);
69
        Zone = zone;
70
        Hemisphere = hemisphere;
71
        H = h;
72
        grid = new Graticule(this);
73
    }
74

  
75
    public String getAbrev() {
76
        return abrev + Zone;
77
    }
78

  
79
    public static UtmZone getProjection(Ellipsoid eli, int zone, int hemisphere) {
80
        if ((eli == Ellipsoid.hayford) && (hemisphere == 0)) {
81
            switch (zone) {
82
            case 28:
83
                return hayford28N;
84

  
85
            case 29:
86
                return hayford29N;
87

  
88
            case 30:
89
                return hayford30N;
90

  
91
            case 31:
92
                return hayford31N;
93
            }
94
        } else if ((eli == Ellipsoid.ed50) && (hemisphere == 0)) {
95
            switch (zone) {
96
            case 28:
97
                return ed5028N;
98

  
99
            case 29:
100
                return ed5029N;
101

  
102
            case 30:
103
                return ed5030N;
104

  
105
            case 31:
106
                return ed5031N;
107
            }
108
        }
109

  
110
        System.err.println("UtmZone.getProjection(): new " + zone);
111

  
112
        return new UtmZone(eli, zone, hemisphere, 0.0);
113
    }
114

  
115
    /**
116
     *
117
     */
118
    public static IProjection getProjectionByName(IDatum eli, String name) {
119
        int zone;
120
        int hemisphere = NORTH;
121

  
122
        if (name.indexOf("UTM") < 0) {
123
            return null;
124
        }
125

  
126
        if (name.substring(0, 1).compareTo("S") == 0) {
127
            hemisphere = SOUTH;
128
        }
129

  
130
        zone = Integer.parseInt(name.substring(name.length() - 2));
131

  
132
        return getProjection((Ellipsoid) eli, zone, hemisphere);
133
    }
134

  
135
    /**
136
     *
137
     */
138
    public Point2D createPoint(double x, double y) {
139
        return new UtmPoint(this, x, y);
140
    }
141

  
142
    /**
143
     *
144
     * @param uPt
145
     * @return
146
     */
147
    public Point2D toGeo(Point2D uPt) {
148
        GeoPoint gPt = new GeoPoint();
149

  
150
        return toGeo((UtmPoint) uPt, gPt);
151
    }
152

  
153
    /**
154
     *
155
     * @param uPt
156
     * @param gPt
157
     * @return
158
     */
159
    public GeoPoint toGeo(UtmPoint uPt, GeoPoint gPt) {
160
        int[] ai = new int[3];
161
        double[] ad = new double[3];
162
        ai[1] = ((UtmZone) uPt.proj).Zone;
163
        ai[2] = ((UtmZone) uPt.proj).Hemisphere;
164
        ad[1] = uPt.X;
165
        ad[2] = uPt.Y;
166

  
167
        utmgeo.set(((Projection) uPt.proj).getElliPar(), ai, ad);
168
        utmgeo.go();
169

  
170
        gPt.Longitude = Ra2De.go(utmgeo.Ge[1]);
171
        gPt.Latitude = Ra2De.go(utmgeo.Ge[2]);
172
        gPt.proj = Geodetic.getProjection(((Projection) uPt.proj).eli);
173

  
174
        return gPt;
175
    }
176

  
177
    /**
178
     *
179
     * @param gPt
180
     * @param uPt
181
     * @return
182
     */
183
    public Point2D fromGeo(Point2D gPt, Point2D uPt) {
184
        int[] ai = { 0, 0, 2 };
185

  
186
        return fromGeo((GeoPoint) gPt, (UtmPoint) uPt, ai);
187
    }
188

  
189
    /**
190
     *
191
     * @param gPt
192
     * @param uPt
193
     * @param proj
194
     * @return
195
     */
196
    public UtmPoint fromGeo(GeoPoint gPt, UtmPoint uPt, UtmZone proj) {
197
        int[] ai = { 0, proj.Zone, proj.Hemisphere };
198

  
199
        return fromGeo(gPt, uPt, ai);
200
    }
201

  
202
    /**
203
     *
204
     * @param gPt
205
     * @param uPt
206
     * @param ai
207
     * @return
208
     */
209
    public UtmPoint fromGeo(GeoPoint gPt, UtmPoint uPt, int[] ai) {
210
        double[] ad = new double[4];
211
        ad[1] = gPt.Longitude.ToRadians();
212
        ad[2] = gPt.Latitude.ToRadians();
213
        geoutm.set(((Projection) gPt.proj).getElliPar(), ai, ad);
214
        geoutm.go();
215

  
216
        if (geoutm.Ier != 0) {
217
            return null;
218
        }
219

  
220
        uPt.setLocation(geoutm.Pr[1], geoutm.Pr[2]);
221

  
222
        if ((((UtmZone) uPt.proj).Zone != geoutm.Iopar[1]) ||
223
                (((UtmZone) uPt.proj).Hemisphere != geoutm.Iopar[2])) {
224
            uPt.proj = UtmZone.getProjection(((Projection) uPt.proj).eli,
225
                                             geoutm.Iopar[1], geoutm.Iopar[2]);
226
        }
227

  
228
        return uPt;
229
    }
230

  
231
    // Calcula el step en funci?n del zoom
232
    private void generateGrid(Graphics2D g, Extent extent, AffineTransform mat) {
233
        // calculo del step en funci?n del zoom
234
        Point2D pt1 = extent.getMin();
235

  
236
        double step = 1.0;
237
        double x = (int) pt1.getX();
238
        double dist = 0.0;
239

  
240
        /*        GeoPoint gp1, gp2;
241
                gp1 = (GeoPoint) createPoint( x, (int) pt1.getY());
242
                mat.transform(gp1, gp1);
243
                gp2 = (GeoPoint) createPoint(gp1.getX()+100, gp1.getY()-100);
244
                try {
245
                        mat.inverseTransform(gp2, gp2);
246
                } catch (NoninvertibleTransformException e) {
247
                        // TODO Auto-generated catch block
248
                        e.printStackTrace();
249
                }
250
                dist = (gp2.getX()-x);
251
                System.err.println("distX = " + dist);
252

  
253
                if (dist > 30.0) {                         step = 30.0;
254
                } else if (dist > 18.0) {         step = 18.0;
255
                } else if (dist > 12.0) {        step = 12.0;
256
                } else if (dist > 6.0) {        step = 6.0;
257
                } else if (dist > 3.0) {        step = 3.0;
258
                } else if (dist > 2.0) {        step = 2.0;
259
                } else if (dist > 1.0) {        step = 1.0;
260
                } else if (dist > .5) {                step =.5;
261
                } else if (dist > .25) {        step =.25;
262
                } else if (dist > 1.0/60*5.0) { step = 1.0/60*5.0;
263
                } else {                                        step = 1.0/60*2.0;
264
                }
265
                        //step = 1.0;
266
                */
267
        generateGrid(g, extent, mat, step);
268
    }
269

  
270
    private void generateGrid(Graphics2D g, Extent extent, AffineTransform mat,
271
                              double step) {
272
        grid = new Graticule(this);
273

  
274
        Point2D pt1 = extent.getMin();
275
        Point2D pt2 = extent.getMax();
276
        GeoPoint gp1;
277
        GeoPoint gp2;
278
        UtmPoint up1 = (UtmPoint) createPoint(0, 0);
279
        UtmPoint up2 = (UtmPoint) createPoint(0, 0);
280
        Point2D.Double mp1 = new Point2D.Double(0.0, 0.0);
281
        Point2D.Double mp2 = new Point2D.Double(0.0, 0.0);
282
        Geodetic geoProj = Geodetic.getProjection((Ellipsoid) getDatum());
283
        boolean esUso = false;
284

  
285
        System.err.println(name + ": ViewPort Extent = (" + pt1 + "," + pt2 +
286
                           ")");
287
        gp1 = (GeoPoint) toGeo(new UtmPoint(pt1.getX(), pt2.getY()));
288
        gp2 = (GeoPoint) toGeo(new UtmPoint(pt2));
289

  
290
        double xMin = (int) gp1.getX() - 1.0;
291
        double xMax = (int) gp2.getX() + 1.0;
292
        gp1 = (GeoPoint) toGeo(new UtmPoint(pt1.getX() +
293
                                            ((pt2.getX() - pt1.getX()) / 2.0),
294
                                            pt2.getY()));
295

  
296
        double yMax = (int) gp1.getY() + 2.0;
297
        gp1 = (GeoPoint) toGeo(new UtmPoint(pt1));
298

  
299
        double yMin = (int) gp1.getY() - 1.0;
300
        xMin = -30.0;
301
        xMax = 30.0;
302
        yMin = 20.0;
303
        yMax = 60.0;
304

  
305
        for (double x = xMin; x <= xMax; x += step) {
306
            up1 = null;
307

  
308
            if (Math.abs((x) % 6) < .001) {
309
                esUso = true;
310
            }
311

  
312
            for (double y = yMin; y <= yMax; y += step) {
313
                gp2 = (GeoPoint) geoProj.createPoint(x, y);
314
                fromGeo(gp2, up2, this);
315

  
316
                if ((up1 != null) && (extent.isAt(up1) || extent.isAt(up2))) {
317
                    mat.transform(up2, mp2);
318

  
319
                    if (up1 != null) {
320
                        if (esUso) {
321
                            grid.addLine(mp1, mp2, 1);
322
                        } else {
323
                            grid.addLine(mp1, mp2);
324
                        }
325
                    }
326
                } else {
327
                    mat.transform(up2, mp2);
328
                }
329

  
330
                up1 = (UtmPoint) up2.clone();
331
                mp1 = (Point2D.Double) mp2.clone();
332
            }
333

  
334
            esUso = false;
335
        }
336

  
337
        for (double y = yMin; y <= yMax; y += step) {
338
            up1 = null;
339

  
340
            for (double x = xMin; x <= xMax; x += step) {
341
                gp2 = (GeoPoint) geoProj.createPoint(x, y);
342
                fromGeo(gp2, up2, this);
343

  
344
                if ((up1 != null) && (extent.isAt(up1) || extent.isAt(up2))) {
345
                    mat.transform(up2, mp2);
346

  
347
                    if (up1 != null) {
348
                        grid.addLine(mp1, mp2);
349
                    }
350
                } else {
351
                    mat.transform(up2, mp2);
352
                }
353

  
354
                up1 = (UtmPoint) up2.clone();
355
                mp1 = (Point2D.Double) mp2.clone();
356
            }
357
        }
358
    }
359

  
360
    public void drawGrid(Graphics2D g, ViewPortData vp) {
361
        generateGrid(g, vp.getExtent(), vp.getMat());
362
        grid.setColor(gridColor);
363
        grid.draw(g, vp);
364
    }
365

  
366
    /* (non-Javadoc)
367
     * @see org.cresques.cts.IProjection#getScale(double, double, double, double)
368
     */
369
    public double getScale(double minX, double maxX, double width, double dpi) {
370
        double scale = ((maxX - minX) * // metros
371
                       (dpi / 2.54 * 100.0)) / // px / metro
372
                       width; // pixels
373

  
374
        return scale;
375
    }
376

  
377
	public ICoordTrans getCT(IProjection dest) {
378
		// TODO Auto-generated method stub
379
		return null;
380
	}
381

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff