Revision 827

View differences:

org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/CRSFactoryNotRegisteredException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2008 {DiSiD Technologies}   {Create a base Locator implementation}
27
 */
28
package org.cresques;
29

  
30
import org.gvsig.tools.exception.BaseRuntimeException;
31

  
32
/**
33
 * Exception for errors related to the initialization of a Library.
34
 * 
35
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
36
 */
37
public class CRSFactoryNotRegisteredException extends BaseRuntimeException {
38

  
39
	private static final long serialVersionUID = 7354573543115812224L;
40

  
41
	private static final String KEY = "_CRSFactoryNotRegisteredException";
42

  
43
    private static final String MESSAGE = "An instance of ICRSFactory has not " +
44
    		"been registered in the CRSFactory";
45

  
46
    public CRSFactoryNotRegisteredException() {
47
        super(MESSAGE, KEY, serialVersionUID);
48
    }
49
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/DataTypes.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.cresques;
25

  
26
/**
27
 * @author gvSIG Team
28
 * @version $Id$
29
 * 
30
 */
31
public interface DataTypes extends org.gvsig.tools.dataTypes.DataTypes {
32

  
33
    /*
34
	 * 
35
	 */
36
    public static final int CRS = OBJECT + 1;
37
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/coerce/CoerceToString.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.cresques.coerce;
25

  
26
import org.cresques.cts.IProjection;
27
import org.gvsig.tools.dataTypes.CoercionException;
28
import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
29

  
30
/**
31
 * Convert a Projection to String.
32
 * 
33
 * Support convert:
34
 * - Projection to String (do nothing)
35
 * 
36
 * @author gvSIG Team
37
 * @version $Id$
38
 * 
39
 */
40
public class CoerceToString implements Coercion {
41

  
42
	Coercion previous = null;
43
	
44
	public CoerceToString() {
45
		// Do nothing
46
	}
47
	
48
	public CoerceToString(Coercion previous) {
49
		this.previous = previous;
50
	}
51
	
52
	
53
	public Object coerce(Object value) throws CoercionException {
54
		try {
55
			if( value == null || value instanceof String ) {
56
				return value;
57
			}
58
			if( value instanceof IProjection ) {
59
				return ((IProjection)value).getFullCode();
60
			}
61
			if( previous != null ) {
62
				return previous.coerce(value);
63
			}
64
		} catch (Exception e) {
65
			throw new CoercionException(e);
66
		}
67
		throw new CoercionException();
68
	}
69

  
70
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/coerce/CoerceToCRS.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.cresques.coerce;
24

  
25
import org.cresques.cts.IProjection;
26
import org.gvsig.fmap.crs.CRSFactory;
27
import org.gvsig.tools.dataTypes.CoercionException;
28
import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
29

  
30
/**
31
 * Convert a string value of projection code to IProjection
32
 *
33
 * @author gvSIG Team
34
 * @version $Id$
35
 *
36
 */
37
public class CoerceToCRS implements Coercion {
38

  
39
    public Object coerce(Object value) throws CoercionException {
40
        if (value == null) {
41
            return null;
42
        }
43
        try {
44
            if (value instanceof IProjection) {
45
                return value;
46
            }
47
            Object proj = CRSFactory.getCRS(value.toString());
48
            if (proj == null) {
49
                throw new CoercionException("Can't convert value '" + getValueAsString(value) + "' to IProjection. Probably not a valid format for a projection.");
50
            }
51
            return proj;
52
        } catch (Exception e) {
53
            throw new CoercionException("Can't convert value '" + getValueAsString(value) + "' to IProjection. Probably not a valid format for a projection.", e);
54
        }
55

  
56
    }
57

  
58
    private String getValueAsString(Object value) {
59
        try {
60
            return value.toString();
61
        } catch (Exception e) {
62
            return "(unknow)";
63
        }
64
    }
65

  
66
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/ProjectionLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* gvSIG. Geographic Information System of the Valencian Government
25
*
26
* Copyright (C) 2007-2008 Infrastructures and Transports Department
27
* of the Valencian Government (CIT)
28
*
29
* This program is free software; you can redistribute it and/or
30
* modify it under the terms of the GNU General Public License
31
* as published by the Free Software Foundation; either version 2
32
* of the License, or (at your option) any later version.
33
*
34
* This program is distributed in the hope that it will be useful,
35
* but WITHOUT ANY WARRANTY; without even the implied warranty of
36
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
* GNU General Public License for more details.
38
*
39
* You should have received a copy of the GNU General Public License
40
* along with this program; if not, write to the Free Software
41
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
42
* MA  02110-1301, USA.
43
*
44
*/
45
package org.cresques;
46

  
47
import org.cresques.coerce.CoerceToCRS;
48
import org.cresques.coerce.CoerceToString;
49
import org.cresques.cts.IProjection;
50
import org.gvsig.fmap.crs.CRSFactory;
51
import org.gvsig.fmap.crs.persistence.CoordTransPersistenceFactory;
52
import org.gvsig.fmap.crs.persistence.ProjectionPersistenceFactory;
53
import org.gvsig.tools.ToolsLibrary;
54
import org.gvsig.tools.ToolsLocator;
55
import org.gvsig.tools.dataTypes.DataTypesManager;
56
import org.gvsig.tools.library.AbstractLibrary;
57
import org.gvsig.tools.library.LibraryException;
58
import org.slf4j.Logger;
59
import org.slf4j.LoggerFactory;
60

  
61
public class ProjectionLibrary extends AbstractLibrary {
62

  
63
	private static final Logger logger = LoggerFactory.getLogger(ProjectionLibrary.class);
64
	
65
    public void doRegistration() {
66
        registerAsAPI(ProjectionLibrary.class);
67
        require(ToolsLibrary.class);
68
    }
69

  
70
	protected void doInitialize() throws LibraryException {
71
	}
72

  
73
	protected void doPostInitialize() throws LibraryException {
74
		if (CRSFactory.getCRSFactory()==null) {
75
			logger.warn("has not registered an implementation of " + this.getClass().getName()+".");
76
		}
77

  
78
		DataTypesManager dataTypesManager = ToolsLocator.getDataTypesManager();
79
        dataTypesManager.addtype(DataTypes.CRS, "CRS", "CRS",
80
            IProjection.class, new CoerceToCRS());
81
        dataTypesManager.setCoercion(DataTypes.STRING, new CoerceToString(
82
            dataTypesManager.getCoercion(DataTypes.STRING)));
83

  
84
		// Register the PersistenceFactory to be able to persist 
85
		// IProjection objects
86
		ToolsLocator.getPersistenceManager().registerFactory(
87
				new ProjectionPersistenceFactory());
88
		ToolsLocator.getPersistenceManager().registerFactory(
89
            new CoordTransPersistenceFactory());
90
	}
91

  
92
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/Messages.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.cresques;
26

  
27
import org.gvsig.tools.ToolsLocator;
28
import org.gvsig.tools.i18n.I18nManager;
29

  
30
/**
31
* Bridge class to provide internationalization services to the library.
32
* It uses the gvsig-i18n library as a backend, and includes its
33
* necessary initialization.
34
* 
35
*/
36
public class Messages {
37
	private static I18nManager manager = null;
38
	/**
39
	 * Loads the translations in the dictionary. It initializes the backend
40
	 * gvsig-i18n library
41
	 *
42
	 */
43
	private static void init() {
44
		manager = ToolsLocator.getI18nManager(); 
45
		manager.addResourceFamily("org.cresques.resources.i18n.text", Messages.class.getClassLoader(), Messages.class.getClass().getName());
46
	}
47
	
48
	/**
49
	 * Gets the translation associated with the provided translation key.
50
	 * 
51
	 * @param key The translation key which identifies the target text
52
	 * @return The translation associated with the provided translation key.
53
	 */
54
	public static String getText(String key) {
55
		if (manager == null ) {
56
			init();
57
		}
58
		return manager.getTranslation(key);
59
	}
60

  
61
}
62

  
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/px/Extent.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.cresques.px;
25

  
26
import java.awt.geom.Point2D;
27
import java.awt.geom.Rectangle2D;
28
import java.text.DecimalFormat;
29

  
30
/**
31
 *	Clase que getiona el extent de una imagen
32
 *	
33
 *  @author Luis W.Sevilla (sevilla_lui@gva.es)
34
 */
35
public class Extent {
36
    Point2D min = null;
37
    Point2D max = null;
38

  
39
    /**
40
     * Constructor sin par?metros
41
     */
42
    public Extent() {
43
        min = new Point2D.Double(999999999.0, 999999999.0);
44
        max = new Point2D.Double(-999999999.0, -999999999.0);
45
    }
46

  
47
    /**
48
     * Constructor 
49
     * @param pt1	punto que representa la esquina superior izquierda
50
     * @param pt2	punto que representa la esquina inferior derecha
51
     */
52
    public Extent(Point2D pt1, Point2D pt2) {
53
        newExtent(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY());
54
    }
55

  
56
    /**
57
     * Contructor
58
     * @param x1 punto que representa la coordenada X de la esquina superior izquierda
59
     * @param y1 punto que representa la coordenada Y de la esquina superior izquierda
60
     * @param x2 punto que representa la coordenada X de la esquina inferior derecha
61
     * @param y2 punto que representa la coordenada Y de la esquina inferior derecha
62
     */
63
    public Extent(double x1, double y1, double x2, double y2) {
64
        newExtent(x1, y1, x2, y2);
65
    }
66

  
67
    /**
68
     * Constructor
69
     * @param r	Rectangulo 2D
70
     */
71
    public Extent(Rectangle2D r) {
72
        newExtent(r.getX(), r.getY(), r.getX() + r.getWidth(),
73
                  r.getY() + r.getHeight());
74
    }
75

  
76
    /**
77
     * Constructor de copia
78
     * @param ext	Objeto Extent
79
     */
80
    public Extent(Extent ext) {
81
        newExtent(ext.minX(), ext.minY(), ext.maxX(), ext.maxY());
82
    }
83

  
84
    /**
85
     * Crea un objeto extent identico y lo retorna
86
     * @return Objeto extent
87
     */
88
    public Object clone() {
89
        Extent e = (Extent) clone();
90
        e.min = (Point2D) min.clone();
91
        e.max = (Point2D) max.clone();
92

  
93
        return e;
94
    }
95

  
96
    private void newExtent(double x1, double y1, double x2, double y2) {
97
        min = new Point2D.Double(Math.min(x1, x2), Math.min(y1, y2));
98
        max = new Point2D.Double(Math.max(x1, x2), Math.max(y1, y2));
99
    }
100

  
101
    /**
102
     * Obtiene la coordenada X m?nima
103
     * @return valor de la coordenada X m?nima
104
     */
105
    public double minX() {
106
        return min.getX();
107
    }
108

  
109
    /**
110
     * Obtiene la coordenada Y m?nima
111
     * @return valor de la coordenada X m?nima
112
     */
113
    public double minY() {
114
        return min.getY();
115
    }
116

  
117
    /**
118
     * Obtiene la coordenada X m?xima
119
     * @return valor de la coordenada X m?xima
120
     */
121
    public double maxX() {
122
        return max.getX();
123
    }
124

  
125
    /**
126
     * Obtiene la coordenada Y m?xima
127
     * @return valor de la coordenada Y m?xima
128
     */
129
    public double maxY() {
130
        return max.getY();
131
    }
132
    
133
    /**
134
     * Obtiene el punto m?nimo
135
     * @return m?nimo
136
     */
137
    public Point2D getMin() {
138
        return min;
139
    }
140

  
141
    /**
142
     * Obtiene el punto m?ximo
143
     * @return m?ximo
144
     */
145
    public Point2D getMax() {
146
        return max;
147
    }
148

  
149
    public boolean isAt(Point2D pt) {
150
        if (pt.getX() < minX()) {
151
            return false;
152
        }
153

  
154
        if (pt.getX() > maxX()) {
155
            return false;
156
        }
157

  
158
        if (pt.getY() < minY()) {
159
            return false;
160
        }
161

  
162
        if (pt.getY() > maxY()) {
163
            return false;
164
        }
165

  
166
        return true;
167
    }
168

  
169
    public double width() {
170
        return Math.abs(maxX() - minX());
171
    }
172

  
173
    public double height() {
174
        return Math.abs(maxY() - minY());
175
    }
176

  
177
    /**
178
     * Verifica un punto, y modifica el extent si no est? incluido
179
     */
180
    public void add(Point2D pt) {
181
        if (pt == null) {
182
            return;
183
        }
184

  
185
        min.setLocation(Math.min(pt.getX(), minX()), Math.min(pt.getY(), minY()));
186
        max.setLocation(Math.max(pt.getX(), maxX()), Math.max(pt.getY(), maxY()));
187
    }
188

  
189
    public void add(Extent ext) {
190
        if (ext == null) {
191
            return;
192
        }
193

  
194
        min.setLocation(Math.min(ext.minX(), minX()),
195
                        Math.min(ext.minY(), minY()));
196
        max.setLocation(Math.max(ext.maxX(), maxX()),
197
                        Math.max(ext.maxY(), maxY()));
198
    }
199

  
200
    /**
201
     * Obtiene la escala
202
     * @param width	Ancho
203
     * @param height	Alto
204
     * @return
205
     */
206
    public double[] getScale(int width, int height) {
207
        return getScale((double) width, (double) height);
208
    }
209

  
210
    public double[] getScale(double width, double height) {
211
        double[] scale = new double[2];
212
        scale[0] = ((float) width) / width();
213
        scale[1] = ((float) height) / height();
214

  
215
        return scale;
216
    }
217

  
218
    public Rectangle2D toRectangle2D() {
219
        return new Rectangle2D.Double(minX(), minY(), width(), height());
220
    }
221

  
222
    public String toString() {
223
        DecimalFormat format = new DecimalFormat("####.000");
224

  
225
        return "Extent: (" + format.format(minX()) + "," +
226
               format.format(minY()) + "), (" + format.format(maxX()) + "," +
227
               format.format(maxY()) + ")";
228
    }
229

  
230
    public interface Has {
231
        public Extent getExtent();
232
    }
233
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/px/.cvsignore
1
*.dfPackage
2
*.wmf
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/px/package.html
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<html>
27
	<body>Pixel: Clases para dibujar.
28
</body>
29
</html>
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/cts/GeoCalc.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.cresques.cts;
25

  
26
import java.awt.geom.Point2D;
27

  
28

  
29
/**
30
 * Operaciones relacionadas con las proyecciones y sistemas
31
 * de coordenadas.
32
 *
33
 * cmartinez: Esta clase no deber?a formar parte de una API, pero
34
 * se deja hasta que se aborde el refactoring de libProjection.
35
 *
36
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
37
 */
38
public class GeoCalc {
39
    IProjection proj;
40

  
41
    /**
42
     *
43
     * @param proj
44
     */
45
    public GeoCalc(IProjection proj) {
46
        this.proj = proj;
47
    }
48

  
49
    /* (non-Javadoc)
50
	 * @see org.cresques.impl.cts.GeoCalc#distanceGeo(java.awt.geom.Point2D, java.awt.geom.Point2D)
51
	 */
52
    public double distanceGeo(Point2D pt1, Point2D pt2) {
53
    	
54
        double R2 = Math.pow(proj.getCoordinateReferenceSystem().getDefinition().getDatum().getEllipsoid().getSemiMajorAxis(), 2);
55
        double dLat = Math.toRadians(pt2.getY() - pt1.getY());
56
        double dLong = Math.toRadians(pt2.getX() - pt1.getX());
57

  
58
        double alfa = Math.toRadians(pt1.getY());
59
        double alfa2 = Math.toRadians(pt2.getY());
60

  
61
        if (Math.abs(alfa2) < Math.abs(alfa)) {
62
            alfa = alfa2;
63
        }
64

  
65
        double ds2 = (R2 * dLat * dLat) +
66
                     (R2 * Math.cos(alfa) * Math.cos(alfa) * dLong * dLong);
67

  
68
        return Math.sqrt(ds2);
69
    }
70

  
71
    /* (non-Javadoc)
72
	 * @see org.cresques.impl.cts.GeoCalc#distanceEli(java.awt.geom.Point2D, java.awt.geom.Point2D)
73
	 */
74
    public double distanceEli(Point2D pt1, Point2D pt2) {
75
        double lat1 = Math.toRadians(pt1.getY());
76
        double lon1 = -Math.toRadians(pt1.getX());
77
        double lat2 = Math.toRadians(pt2.getY());
78
        double lon2 = -Math.toRadians(pt2.getX());
79

  
80
        double F = (lat1 + lat2) / 2D;
81
        double G = (lat1 - lat2) / 2D;
82
        double L = (lon1 - lon2) / 2D;
83

  
84
        double sing = Math.sin(G);
85
        double cosl = Math.cos(L);
86
        double cosf = Math.cos(F);
87
        double sinl = Math.sin(L);
88
        double sinf = Math.sin(F);
89
        double cosg = Math.cos(G);
90

  
91
        double flat = 1D / proj.getDatum().getEIFlattening();
92

  
93
        double S = (sing * sing * cosl * cosl) + (cosf * cosf * sinl * sinl);
94
        double C = (cosg * cosg * cosl * cosl) + (sinf * sinf * sinl * sinl);
95
        double W = Math.atan2(Math.sqrt(S), Math.sqrt(C));
96
        double R = Math.sqrt((S * C)) / W;
97
        double H1 = ((3D * R) - 1D) / (2D * C);
98
        double H2 = ((3D * R) + 1D) / (2D * S);
99
        double D = 2D * W * proj.getDatum().getESemiMajorAxis();
100

  
101
        return (D * ((1D + (flat * H1 * sinf * sinf * cosg * cosg)) -
102
               (flat * H2 * cosf * cosf * sing * sing)));
103
    }
104

  
105
    /**
106
     * Algrothims from Geocentric Datum of Australia Technical Manual
107
     *
108
     * http://www.anzlic.org.au/icsm/gdatum/chapter4.html
109
     *
110
     * This page last updated 11 May 1999
111
     *
112
     * Computations on the Ellipsoid
113
     *
114
     * There are a number of formulae that are available
115
     * to calculate accurate geodetic positions,
116
     * azimuths and distances on the ellipsoid.
117
     *
118
     * Vincenty's formulae (Vincenty, 1975) may be used
119
     * for lines ranging from a few cm to nearly 20,000 km,
120
     * with millimetre accuracy.
121
     * The formulae have been extensively tested
122
     * for the Australian region, by comparison with results
123
     * from other formulae (Rainsford, 1955 & Sodano, 1965).
124
     *
125
     * * Inverse problem: azimuth and distance from known
126
     *                 latitudes and longitudes
127
     * * Direct problem: Latitude and longitude from known
128
     *                 position, azimuth and distance.
129
     * * Sample data
130
     * * Excel spreadsheet
131
     *
132
     * Vincenty's Inverse formulae
133
     * Given: latitude and longitude of two points
134
     *                 (phi1, lembda1 and phi2, lembda2),
135
     * Calculate: the ellipsoidal distance (s) and
136
     * forward and reverse azimuths between the points (alpha12, alpha21).
137
     */
138
    /* (non-Javadoc)
139
	 * @see org.cresques.impl.cts.GeoCalc#distanceVincenty(java.awt.geom.Point2D, java.awt.geom.Point2D)
140
	 */
141
    public double distanceVincenty(Point2D pt1, Point2D pt2) {
142
        return distanceAzimutVincenty(pt1, pt2).dist;
143
    }
144

  
145
    /**
146
     * Returns the distance between two geographic points on the ellipsoid
147
     *        and the forward and reverse azimuths between these points.
148
     *       lats, longs and azimuths are in decimal degrees, distance in metres
149
     *        Returns ( s, alpha12,  alpha21 ) as a tuple
150
     * @param pt1
151
     * @param pt2
152
     * @return
153
     */
154
    protected GeoData distanceAzimutVincenty(Point2D pt1, Point2D pt2) {
155
        GeoData gd = new GeoData(0, 0);
156
        double f = 1D / proj.getDatum().getEIFlattening();
157
        double a = proj.getDatum().getESemiMajorAxis();
158
        double phi1 = pt1.getY();
159
        double lembda1 = pt1.getX();
160
        double phi2 = pt2.getY();
161
        double lembda2 = pt2.getX();
162

  
163
        if ((Math.abs(phi2 - phi1) < 1e-8) &&
164
                (Math.abs(lembda2 - lembda1) < 1e-8)) {
165
            return gd;
166
        }
167

  
168
        double piD4 = Math.atan(1.0);
169
        double two_pi = piD4 * 8.0;
170

  
171
        phi1 = (phi1 * piD4) / 45.0;
172
        lembda1 = (lembda1 * piD4) / 45.0; // unfortunately lambda is a key word!
173
        phi2 = (phi2 * piD4) / 45.0;
174
        lembda2 = (lembda2 * piD4) / 45.0;
175

  
176
        double b = a * (1.0 - f);
177

  
178
        double TanU1 = (1 - f) * Math.tan(phi1);
179
        double TanU2 = (1 - f) * Math.tan(phi2);
180

  
181
        double U1 = Math.atan(TanU1);
182
        double U2 = Math.atan(TanU2);
183

  
184
        double lembda = lembda2 - lembda1;
185
        double last_lembda = -4000000.0; // an impossibe value
186
        double omega = lembda;
187

  
188
        // Iterate the following equations,
189
        //  until there is no significant change in lembda
190
        double Sin_sigma = 0;
191

  
192
        // Iterate the following equations,
193
        //  until there is no significant change in lembda
194
        double Cos_sigma = 0;
195
        double Cos2sigma_m = 0;
196
        double alpha = 0;
197
        double sigma = 0;
198
        double sqr_sin_sigma = 0;
199

  
200
        while ((last_lembda < -3000000.0) ||
201
                   ((lembda != 0) &&
202
                   (Math.abs((last_lembda - lembda) / lembda) > 1.0e-9))) {
203
            sqr_sin_sigma = Math.pow(Math.cos(U2) * Math.sin(lembda), 2) +
204
                            Math.pow(((Math.cos(U1) * Math.sin(U2)) -
205
                                     (Math.sin(U1) * Math.cos(U2) * Math.cos(lembda))),
206
                                     2);
207

  
208
            Sin_sigma = Math.sqrt(sqr_sin_sigma);
209

  
210
            Cos_sigma = (Math.sin(U1) * Math.sin(U2)) +
211
                        (Math.cos(U1) * Math.cos(U2) * Math.cos(lembda));
212

  
213
            sigma = Math.atan2(Sin_sigma, Cos_sigma);
214

  
215
            double Sin_alpha = (Math.cos(U1) * Math.cos(U2) * Math.sin(lembda)) / Math.sin(sigma);
216
            alpha = Math.asin(Sin_alpha);
217

  
218
            Cos2sigma_m = Math.cos(sigma) -
219
                          ((2 * Math.sin(U1) * Math.sin(U2)) / Math.pow(Math.cos(alpha),
220
                                                                        2));
221

  
222
            double C = (f / 16) * Math.pow(Math.cos(alpha), 2) * (4 +
223
                       (f * (4 - (3 * Math.pow(Math.cos(alpha), 2)))));
224

  
225
            last_lembda = lembda;
226

  
227
            lembda = omega +
228
                     ((1 - C) * f * Math.sin(alpha) * (sigma +
229
                     (C * Math.sin(sigma) * (Cos2sigma_m +
230
                     (C * Math.cos(sigma) * (-1 +
231
                     (2 * Math.pow(Cos2sigma_m, 2))))))));
232
        }
233

  
234
        double u2 = (Math.pow(Math.cos(alpha), 2) * ((a * a) - (b * b))) / (b * b);
235

  
236
        double A = 1 +
237
                   ((u2 / 16384) * (4096 +
238
                   (u2 * (-768 + (u2 * (320 - (175 * u2)))))));
239

  
240
        double B = (u2 / 1024) * (256 +
241
                   (u2 * (-128 + (u2 * (74 - (47 * u2))))));
242

  
243
        double delta_sigma = B * Sin_sigma * (Cos2sigma_m +
244
                             ((B / 4) * ((Cos_sigma * (-1 +
245
                             (2 * Math.pow(Cos2sigma_m, 2)))) -
246
                             ((B / 6) * Cos2sigma_m * (-3 +
247
                             (4 * sqr_sin_sigma)) * (-3 +
248
                             (4 * Math.pow(Cos2sigma_m, 2)))))));
249

  
250
        double s = b * A * (sigma - delta_sigma);
251

  
252
        double alpha12 = Math.atan2((Math.cos(U2) * Math.sin(lembda)),
253
                                    ((Math.cos(U1) * Math.sin(U2)) -
254
                                    (Math.sin(U1) * Math.cos(U2) * Math.cos(lembda))));
255

  
256
        double alpha21 = Math.atan2((Math.cos(U1) * Math.sin(lembda)),
257
                                    ((-Math.sin(U1) * Math.cos(U2)) +
258
                                    (Math.cos(U1) * Math.sin(U2) * Math.cos(lembda))));
259

  
260
        if (alpha12 < 0.0) {
261
            alpha12 = alpha12 + two_pi;
262
        }
263

  
264
        if (alpha12 > two_pi) {
265
            alpha12 = alpha12 - two_pi;
266
        }
267

  
268
        alpha21 = alpha21 + (two_pi / 2.0);
269

  
270
        if (alpha21 < 0.0) {
271
            alpha21 = alpha21 + two_pi;
272
        }
273

  
274
        if (alpha21 > two_pi) {
275
            alpha21 = alpha21 - two_pi;
276
        }
277

  
278
        alpha12 = (alpha12 * 45.0) / piD4;
279
        alpha21 = (alpha21 * 45.0) / piD4;
280

  
281
        return new GeoData(0, 0, s, alpha12, alpha21);
282
    }
283

  
284
    /**
285
     * Vincenty's Direct formulae
286
     * Given: latitude and longitude of a point (phi1, lembda1) and
287
     * the geodetic azimuth (alpha12)
288
     * and ellipsoidal distance in metres (s) to a second point,
289
     *
290
     * Calculate: the latitude and longitude of the second point (phi2, lembda2)
291
     * and the reverse azimuth (alpha21).
292
     */
293
	/**
294
	 * Returns the lat and long of projected point and reverse azimuth
295
	 *        given a reference point and a distance and azimuth to project.
296
	 *  lats, longs and azimuths are passed in decimal degrees.
297
	 * Returns ( phi2,  lambda2,  alpha21 ) as a tuple
298
	 * @param pt
299
	 * @param azimut
300
	 * @param dist
301
	 * @return
302
	 */
303
    protected GeoData getPointVincenty(Point2D pt, double azimut, double dist) {
304
        GeoData ret = new GeoData(0, 0);
305
        double f = 1D / proj.getDatum().getEIFlattening();
306
        double a = proj.getDatum().getESemiMajorAxis();
307
        double phi1 = pt.getY();
308
        double lembda1 = pt.getX();
309
        double alpha12 = azimut;
310
        double s = dist;
311

  
312
        double piD4 = Math.atan(1.0);
313
        double two_pi = piD4 * 8.0;
314

  
315
        phi1 = (phi1 * piD4) / 45.0;
316
        lembda1 = (lembda1 * piD4) / 45.0;
317
        alpha12 = (alpha12 * piD4) / 45.0;
318

  
319
        if (alpha12 < 0.0) {
320
            alpha12 = alpha12 + two_pi;
321
        }
322

  
323
        if (alpha12 > two_pi) {
324
            alpha12 = alpha12 - two_pi;
325
        }
326

  
327
        double b = a * (1.0 - f);
328

  
329
        double TanU1 = (1 - f) * Math.tan(phi1);
330
        double U1 = Math.atan(TanU1);
331
        double sigma1 = Math.atan2(TanU1, Math.cos(alpha12));
332
        double Sinalpha = Math.cos(U1) * Math.sin(alpha12);
333
        double cosalpha_sq = 1.0 - (Sinalpha * Sinalpha);
334

  
335
        double u2 = (cosalpha_sq * ((a * a) - (b * b))) / (b * b);
336
        double A = 1.0 +
337
                   ((u2 / 16384) * (4096 +
338
                   (u2 * (-768 + (u2 * (320 - (175 * u2)))))));
339
        double B = (u2 / 1024) * (256 +
340
                   (u2 * (-128 + (u2 * (74 - (47 * u2))))));
341

  
342
        // Starting with the approximation
343
        double sigma = (s / (b * A));
344

  
345
        double last_sigma = (2.0 * sigma) + 2.0; // something impossible
346

  
347
        // Iterate the following three equations
348
        //  until there is no significant change in sigma
349
        // two_sigma_m , delta_sigma
350
        double two_sigma_m = 0;
351

  
352
        while (Math.abs((last_sigma - sigma) / sigma) > 1.0e-9) {
353
            two_sigma_m = (2 * sigma1) + sigma;
354

  
355
            double delta_sigma = B * Math.sin(sigma) * (Math.cos(two_sigma_m) +
356
                                 ((B / 4) * (Math.cos(sigma) * ((-1 +
357
                                 (2 * Math.pow(Math.cos(two_sigma_m), 2))) -
358
                                 ((B / 6) * Math.cos(two_sigma_m) * (-3 +
359
                                 (4 * Math.pow(Math.sin(sigma), 2))) * (-3 +
360
                                 (4 * Math.pow(Math.cos(two_sigma_m), 2))))))));
361

  
362
            last_sigma = sigma;
363
            sigma = (s / (b * A)) + delta_sigma;
364
        }
365

  
366
        double phi2 = Math.atan2(((Math.sin(U1) * Math.cos(sigma)) +
367
                                 (Math.cos(U1) * Math.sin(sigma) * Math.cos(alpha12))),
368
                                 ((1 - f) * Math.sqrt(Math.pow(Sinalpha, 2) +
369
                                                      Math.pow((Math.sin(U1) * Math.sin(sigma)) -
370
                                                               (Math.cos(U1) * Math.cos(sigma) * Math.cos(alpha12)),
371
                                                               2))));
372

  
373
        double lembda = Math.atan2((Math.sin(sigma) * Math.sin(alpha12)),
374
                                   ((Math.cos(U1) * Math.cos(sigma)) -
375
                                   (Math.sin(U1) * Math.sin(sigma) * Math.cos(alpha12))));
376

  
377
        double C = (f / 16) * cosalpha_sq * (4 + (f * (4 - (3 * cosalpha_sq))));
378

  
379
        double omega = lembda -
380
                       ((1 - C) * f * Sinalpha * (sigma +
381
                       (C * Math.sin(sigma) * (Math.cos(two_sigma_m) +
382
                       (C * Math.cos(sigma) * (-1 +
383
                       (2 * Math.pow(Math.cos(two_sigma_m), 2))))))));
384

  
385
        double lembda2 = lembda1 + omega;
386

  
387
        double alpha21 = Math.atan2(Sinalpha,
388
                                    ((-Math.sin(U1) * Math.sin(sigma)) +
389
                                    (Math.cos(U1) * Math.cos(sigma) * Math.cos(alpha12))));
390

  
391
        alpha21 = alpha21 + (two_pi / 2.0);
392

  
393
        if (alpha21 < 0.0) {
394
            alpha21 = alpha21 + two_pi;
395
        }
396

  
397
        if (alpha21 > two_pi) {
398
            alpha21 = alpha21 - two_pi;
399
        }
400

  
401
        phi2 = (phi2 * 45.0) / piD4;
402
        lembda2 = (lembda2 * 45.0) / piD4;
403
        alpha21 = (alpha21 * 45.0) / piD4;
404

  
405
        ret.pt = new Point2D.Double(lembda2, phi2);
406
        ret.azimut = alpha21;
407

  
408
        return ret;
409
    }
410

  
411
    /* (non-Javadoc)
412
	 * @see org.cresques.impl.cts.GeoCalc#surfaceSphere(java.awt.geom.Point2D, java.awt.geom.Point2D, java.awt.geom.Point2D)
413
	 */
414
    public double surfaceSphere(Point2D pt1, Point2D pt2, Point2D pt3) {
415
        double sup = -1;
416
        double A = distanceGeo(pt1, pt2);
417
        double B = distanceGeo(pt2, pt3);
418
        double C = distanceGeo(pt3, pt1);
419
        sup = (((A + B + C) - Math.toRadians(180D)) * Math.PI * proj.getDatum()
420
                                                                    .getESemiMajorAxis()) / Math.toRadians(180D);
421

  
422
        return sup;
423
    }
424

  
425
    /*
426
     * F?rmulas de Vincenty's.
427
     * (pasadas de http://wegener.mechanik.tu-darmstadt.de/GMT-Help/Archiv/att-8710/Geodetic_py
428
     * http://www.icsm.gov.au/icsm/gda/gdatm/index.html
429
     */
430
    protected class GeoData {
431
        Point2D pt;
432
        double azimut;
433
        double revAzimut;
434
        double dist;
435

  
436
        public GeoData(double x, double y) {
437
            pt = new Point2D.Double(x, y);
438
            azimut = revAzimut = dist = 0;
439
        }
440

  
441
        public GeoData(double x, double y, double dist, double azi, double rAzi) {
442
            pt = new Point2D.Double(x, y);
443
            azimut = azi;
444
            revAzimut = rAzi;
445
            this.dist = dist;
446
        }
447
    }
448
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/cts/package.html
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<html>
27
	<body>Clases relacionadas con el manejo de proyecciones.
28
</body>
29
</html>
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/cts/CoordTransRuntimeException.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.cresques.cts;
24

  
25
/**
26
 * @author fdiaz
27
 *
28
 */
29
public class CoordTransRuntimeException extends RuntimeException {
30

  
31
    /**
32
     *
33
     */
34
    private static final long serialVersionUID = 1348981767734366776L;
35
    IProjection source;
36
    IProjection target;
37
    double x;
38
    double y;
39

  
40
    /**
41
     *
42
     */
43
    public CoordTransRuntimeException(IProjection source, IProjection target, double x, double y, Throwable cause) {
44
        super("Error reprojecting point (" + x + "," + y + ") from " + source.getAbrev() + " to " + target.getAbrev()
45
            + ".", cause);
46
        this.source = source;
47
        this.target = target;
48
        this.x = x;
49
        this.y = y;
50
    }
51

  
52
    /**
53
    *
54
    */
55
    public CoordTransRuntimeException(IProjection source, IProjection target, double x, double y) {
56
        this(source, target, x, y, null);
57
    }
58

  
59
    /**
60
     * @return the source
61
     */
62
    public IProjection getSource() {
63
        return source;
64
    }
65

  
66
    /**
67
     * @return the target
68
     */
69
    public IProjection getTarget() {
70
        return target;
71
    }
72

  
73
    /**
74
     * @return the x
75
     */
76
    public double getX() {
77
        return x;
78
    }
79

  
80
    /**
81
     * @return the y
82
     */
83
    public double getY() {
84
        return y;
85
    }
86

  
87
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/cts/IDatum.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
1 24
package org.cresques.cts;
2 25

  
26

  
3 27
/**
4 28
 * @author "Luis W. Sevilla" (sevilla_lui@gva.es)
5
 * @deprecated Use {@link org.gvsig.proj.catalogue.datum.Datum} instead
6
 * @see org.gvsig.proj.catalogue.CRSDefinition
7
 */ 
29
 * @deprecated Use {@link org.gvsig.proj.catalog.CRSDefinition#getDatum}
30
 */
8 31
@Deprecated
9 32
public interface IDatum {
10 33
    /**
11 34
     * Semieje Mayor del elipsoide.
12 35
     * @return
13 36
     */
14
	@Deprecated
15 37
    public double getESemiMajorAxis();
16 38

  
17 39
    /**
18 40
     * Aplanamiento del elipsoide.
19 41
     * @return
20 42
     */
21
	@Deprecated
22 43
    public double getEIFlattening();
23 44
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/cts/IProjection.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
1 24
package org.cresques.cts;
2 25

  
3 26
import java.awt.geom.Point2D;
......
2 25

  
26
import org.gvsig.proj.CoordinateReferenceSystem;
3 27
import org.gvsig.tools.lang.Cloneable;
......
20 44
     * @param format
21 45
     * @return
22 46
     */
23
	@Deprecated
24 47
    public String export(String format);
25 48

  
26
//    @Deprecated
27
//    public Point2D createPoint(double x, double y);
49
    public IDatum getDatum();
28 50

  
29
    @Deprecated
51
    // TODO Quitar si no son necesarias.
30 52
    public String getAbrev();
31 53

  
32 54
    /**
......
35 57
     *
36 58
     * @return getAbrev() o getAbrev()+parametros
37 59
     */
38
    @Deprecated
39 60
    public String getFullCode();
40 61

  
41
    @Deprecated
62
    /**
63
     * Crea un ICoordTrans para transformar coordenadas
64
     * desde el IProjection actual al dest.
65
     * @param dest
66
     * @return
67
     */
68

  
69
    public ICoordTrans getCT(IProjection dest);
70

  
71
    public Point2D toGeo(Point2D pt);
72

  
42 73
    public boolean isProjected();
43
    
44
    @Deprecated
45
    public IDatum getDatum();
46
    
74

  
47 75
    /**
48 76
     * First two parameters must be in meters.
49 77
     * This should be changed (map units should be used) and then
......
55 83
     * @param dpi dots per inch
56 84
     * @return Scale denominator ( the "X" in "1 : X" )
57 85
     */
58
    //public double getScale(double minX, double maxX, double width, double dpi);
59

  
60
    //public Rectangle2D getExtent(Rectangle2D extent,double scale,double wImage,double hImage,double mapUnits,double distanceUnits,double dpi);
86
    public double getScale(double minX, double maxX, double width, double dpi);
61 87
    
62
//    public void drawGrid(Graphics2D g, ViewPortData vp);
63
//
64
//    public void setGridColor(Color c);
65
//
66
//    public Color getGridColor();
67

  
68 88
    /**
69
     * Crea un ICoordTrans para transformar coordenadas
70
     * desde el IProjection actual al dest.
71
     * @param dest
89
     * Gets an instance of a CoordinateReferenceSystem equivalent to this
90
     * IProjection object. {@link CoordinateReferenceSystem} is the interface
91
     * used to represent CRSs in the new API.
92
     *  
72 93
     * @return
73 94
     */
95
    public CoordinateReferenceSystem getCoordinateReferenceSystem();
74 96

  
75
//    public ICoordTrans getCT(IProjection dest);
76
//
77
//    public Point2D toGeo(Point2D pt);
78
//
79
//    public Point2D fromGeo(Point2D gPt, Point2D mPt);
97
    //public Rectangle2D getExtent(Rectangle2D extent,double scale,double wImage,double hImage,double mapUnits,double distanceUnits,double dpi);
80 98
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/cts/UTM.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.cresques.cts;
25

  
26
public interface UTM extends IProjection {
27

  
28
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/cresques/cts/ICoordTrans.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.cresques.cts;
25

  
26
import java.awt.geom.Point2D;
27
import java.awt.geom.Rectangle2D;
28

  
29

  
30
/**
31
 * @author "Luis W. Sevilla" (sevilla_lui@gva.es)
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff