svn-gvsig-desktop / trunk / libraries / libJCRS / src / org / gvsig / crs / ogr / Iau2wkt.java @ 8704
History | View | Annotate | Download (3.42 KB)
1 |
package org.gvsig.crs.ogr; |
---|---|
2 |
|
3 |
import org.gvsig.crs.CrsWkt; |
4 |
|
5 |
/**
|
6 |
* Aunque iau2000 posee la cadena wkt, tendremos que volver a generarla con los
|
7 |
* par?metros v?lidos para que no falle con gdal. Lo que haremos ser? recuperar
|
8 |
* todos los campos, buscar la proyecci?n correcta y volver a generar una
|
9 |
* cadena wkt entendible por gdal
|
10 |
* @author Jos? Luis G?mez Mart?nez
|
11 |
*
|
12 |
*/
|
13 |
|
14 |
public class Iau2wkt { |
15 |
|
16 |
String[] projectionsIAU = {"Albers"}; |
17 |
String[] projectionsGDAL = {"Albers_Conic_Equal_Area"}; |
18 |
CrsWkt datos = null;
|
19 |
String cadWKT = ""; |
20 |
String[] param_name = null; |
21 |
String[] param_value = null; |
22 |
|
23 |
public Iau2wkt(String wkt) { |
24 |
datos = new CrsWkt(wkt);
|
25 |
param_name = datos.getParam_name(); |
26 |
param_value = datos.getParam_value(); |
27 |
} |
28 |
|
29 |
/**
|
30 |
* Formacion de la cadena wkt con los nombres correctos de las proyecciones
|
31 |
* de iau2000 para la libreria proj4.
|
32 |
* @return
|
33 |
*/
|
34 |
public String getWkt(){ |
35 |
String proj = getNameProjectionWkt(datos.getProjection());
|
36 |
|
37 |
cadWKT = "PROJCS[\""+ datos.getProjcs()+"\", GEOGCS[\"" + datos.getGeogcs() + "\", DATUM[\""+ datos.getDatumName() + |
38 |
"\", SPHEROID[\""+ datos.getSpheroid()[0] + "\", "+ datos.getSpheroid()[1] + ", "+ datos.getSpheroid()[2] +"]], " + |
39 |
"PRIMEM[\""+ datos.getPrimen()[0] + "\", "+ datos.getPrimen()[1] +"], UNIT[\""+ datos.getUnit()[0] + "\", " + (Math.PI/180) + |
40 |
"]], PROJECTION[\""+ proj + "\"], "; |
41 |
|
42 |
/*
|
43 |
* falta la parte de los par?metros... metodo para nombres...
|
44 |
*/
|
45 |
for (int i= 0; i< param_name.length;i++){ |
46 |
if (proj.equals("Mercator_1SP")){ |
47 |
if (param_name[i].equals("Standard_Parallel_1")) |
48 |
if (param_value[i].startsWith("-")) |
49 |
cadWKT += "PARAMETER[\""+param_name[i]+"\", " + param_value[i].substring(1,param_value[i].length())+ "], "; |
50 |
else
|
51 |
cadWKT += "PARAMETER[\""+param_name[i]+"\", " + param_value[i]+ "], "; |
52 |
else if (param_name[i].equals("Standard_Parallel_2")){} |
53 |
else
|
54 |
cadWKT += "PARAMETER[\""+param_name[i]+"\", " + param_value[i]+ "], "; |
55 |
|
56 |
}else
|
57 |
cadWKT += "PARAMETER[\""+param_name[i]+"\", " + param_value[i]+ "], "; |
58 |
} |
59 |
|
60 |
cadWKT += "UNIT[\""+ datos.getUnit_p()[0] + "\", 1.0], "; |
61 |
cadWKT += "AUTHORITY[\""+ datos.getAuthority()[0] + "\", " + datos.getAuthority()[1] + "]]"; |
62 |
|
63 |
return cadWKT;
|
64 |
} |
65 |
|
66 |
/*
|
67 |
* Metodo auxiliar para el cambio del nombre de la proyeccion.
|
68 |
*/
|
69 |
private String getNameProjectionWkt(String projection) { |
70 |
String proj = null; |
71 |
|
72 |
for (int i = 0; i<projectionsIAU.length; i++){ |
73 |
if (projection.equals(projectionsIAU[i])) {
|
74 |
projection = projectionsGDAL[i]; |
75 |
} |
76 |
} |
77 |
|
78 |
if (projection.equals("Lambert_Conformal_Conic")){ |
79 |
projection = "Lambert_Conformal_Conic_1SP";
|
80 |
String standardParallel1 = ""; |
81 |
String standardParallel2 = ""; |
82 |
for (int i = 0; i < param_name.length; i++) { |
83 |
if (param_name[i].equals("Standard_Parallel_1")) { |
84 |
standardParallel1 = param_value[i]; |
85 |
} |
86 |
if (param_name[i].equals("Standard_Parallel_2")) { |
87 |
standardParallel2 = param_value[i]; |
88 |
projection = "Lambert_Conformal_Conic_2SP";
|
89 |
} |
90 |
} |
91 |
if (standardParallel1.startsWith("-") && standardParallel2.equals(standardParallel1.substring(1, standardParallel1.length()))) |
92 |
projection = "Mercator_1SP";
|
93 |
} |
94 |
|
95 |
if (projection.equals("Mercator")){ |
96 |
projection = "Mercator_1SP";
|
97 |
for (int i = 0; i < param_name.length; i++) { |
98 |
if (param_name[i].equals("Standard_Parallel_2")) { |
99 |
projection = "Mercator_2SP";
|
100 |
} |
101 |
} |
102 |
} |
103 |
proj = projection.replaceAll(" ", "_"); |
104 |
return proj;
|
105 |
} |
106 |
|
107 |
|
108 |
|
109 |
} |