Revision 493 org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/Crs.java
Crs.java | ||
---|---|---|
45 | 45 |
import java.awt.geom.Point2D; |
46 | 46 |
import java.awt.geom.Rectangle2D; |
47 | 47 |
import java.text.MessageFormat; |
48 |
import java.util.Vector; |
|
49 | 48 |
|
50 | 49 |
import org.apache.commons.lang3.StringUtils; |
51 | 50 |
import org.cresques.cts.ICRSFactory; |
... | ... | |
82 | 81 |
private CrsProj crsProj; |
83 | 82 |
private CrsProj crsBase = null; |
84 | 83 |
private CrsWkt crsWkt; |
85 |
private int epsg_code = 23030; |
|
84 |
private int epsg_code = 0; //23030;
|
|
86 | 85 |
String sourceTrParams = null; |
87 | 86 |
String targetTrParams = null; |
88 | 87 |
String wkt = null; |
... | ... | |
105 | 104 |
*/ |
106 | 105 |
private void initFromSpatialReference(SpatialReference spatialReference) { |
107 | 106 |
this.spatialReference = spatialReference; |
108 |
String authorityCode = spatialReference.GetAuthorityCode(null); |
|
109 |
String authorityName = spatialReference.GetAuthorityName(null); |
|
110 |
spatialReference.Fixup(); |
|
107 |
String authorityCode = this.spatialReference.GetAuthorityCode(null);
|
|
108 |
String authorityName = this.spatialReference.GetAuthorityName(null);
|
|
109 |
this.spatialReference.Fixup();
|
|
111 | 110 |
if(authorityCode==null || authorityName==null){ |
112 | 111 |
try { |
113 |
spatialReference.AutoIdentifyEPSG(); |
|
114 |
authorityCode = spatialReference.GetAuthorityCode(null); |
|
115 |
authorityName = spatialReference.GetAuthorityName(null); |
|
112 |
this.spatialReference.AutoIdentifyEPSG();
|
|
113 |
authorityCode = this.spatialReference.GetAuthorityCode(null);
|
|
114 |
authorityName = this.spatialReference.GetAuthorityName(null);
|
|
116 | 115 |
} catch (Exception e) { |
117 |
logger.error("Can't autoidentifyEPSG.", e);
|
|
116 |
logger.warn("Can't autoidentifyEPSG.", e);
|
|
118 | 117 |
} |
119 | 118 |
} |
120 | 119 |
if(!StringUtils.isEmpty(authorityCode) && !StringUtils.isEmpty(authorityName)){ |
... | ... | |
123 | 122 |
} |
124 | 123 |
abrev = name; |
125 | 124 |
|
126 |
datum = new CRSDatum(spatialReference.GetSemiMajor(), spatialReference.GetInvFlattening()); |
|
127 |
proj4String = spatialReference.ExportToProj4(); |
|
128 |
crsWkt = new CrsWkt(spatialReference); |
|
129 |
setWKT(spatialReference.ExportToWkt()); |
|
125 |
datum = new CRSDatum(this.spatialReference.GetSemiMajor(), this.spatialReference.GetInvFlattening()); |
|
126 |
try { |
|
127 |
proj4String = this.spatialReference.ExportToProj4(); |
|
128 |
} catch (Exception e) { |
|
129 |
logger.warn("Can't get proj4 string from "+name, e); |
|
130 |
} |
|
131 |
crsWkt = new CrsWkt(this.spatialReference); |
|
132 |
setWKT(this.spatialReference.ExportToWkt()); |
|
130 | 133 |
} |
131 | 134 |
|
132 | 135 |
/** |
... | ... | |
145 | 148 |
} else if (aut == 4) { |
146 | 149 |
strEpsgCode = "USR:" + epsgCode; |
147 | 150 |
} else |
148 |
System.out.println("Error, autorithy err?neo");
|
|
151 |
logger.warn("Error, invalid authority");
|
|
149 | 152 |
crsWkt = new CrsWkt(strEpsgCode); |
150 | 153 |
setWKT(crsWkt.getWkt()); |
151 | 154 |
} |
... | ... | |
817 | 820 |
if (format.equalsIgnoreCase(ICRSFactory.FORMAT_PROJ4)) { |
818 | 821 |
return spatialReference.ExportToProj4(); |
819 | 822 |
} else if (format.equalsIgnoreCase(ICRSFactory.FORMAT_WKT_ESRI)) { |
820 |
if (spatialReference.MorphToESRI() == 0) { |
|
821 |
return spatialReference.ExportToWkt(); |
|
822 |
} |
|
823 |
return null; |
|
823 |
SpatialReference srESRI = spatialReference.Clone(); |
|
824 |
//FIXME: Viendo que tenemos problemas para identificar la authority a partir de los WKT de ESRI |
|
825 |
// se ha decidido exportar siempre el WKT estandar. Si en alg?n momento se encuentra la manera |
|
826 |
// de hacerlo correctamente, bastar? con descomentarizar las l?neas siguientes. |
|
827 |
// if (srESRI.MorphToESRI() == 0) { |
|
828 |
return srESRI.ExportToWkt(); |
|
829 |
// } |
|
830 |
// return null; |
|
824 | 831 |
} else if (format.equalsIgnoreCase(ICRSFactory.FORMAT_WKT)) { |
825 | 832 |
return spatialReference.ExportToWkt(); |
826 | 833 |
} else { |
... | ... | |
838 | 845 |
} |
839 | 846 |
return null; |
840 | 847 |
} else if (format.equalsIgnoreCase(ICRSFactory.FORMAT_WKT_ESRI)) { |
841 |
if (spatialReference.MorphToESRI() == 0) { |
|
842 |
String esri = spatialReference.ExportToWkt(); |
|
843 |
Vector<String> vector = new Vector<String>(); |
|
844 |
vector.add(esri); |
|
845 |
auxSpatialReference.ImportFromESRI(vector); |
|
846 |
auxSpatialReference.MorphFromESRI(); |
|
847 |
if (auxSpatialReference.GetAuthorityName(null) != null) { |
|
848 |
return esri; |
|
849 |
} |
|
850 |
return null; |
|
851 |
} |
|
852 |
return null; |
|
848 |
return spatialReference.ExportToWkt(); |
|
849 |
//FIXME: Viendo que tenemos problemas para identificar la authority a partir de los WKT de ESRI |
|
850 |
// se ha decidido exportar siempre el WKT estandar. Si en alg?n momento se encuentra la manera |
|
851 |
// de hacerlo correctamente, bastar? con descomentarizar las l?neas siguientes y eliminar la anterior. |
|
852 |
// if (spatialReference.MorphToESRI() == 0) { |
|
853 |
// String esri = spatialReference.ExportToWkt(); |
|
854 |
// Vector<String> vector = new Vector<String>(); |
|
855 |
// vector.add(esri); |
|
856 |
// auxSpatialReference.ImportFromESRI(vector); |
|
857 |
// auxSpatialReference.MorphFromESRI(); |
|
858 |
// if (auxSpatialReference.GetAuthorityName(null) != null) { |
|
859 |
// return esri; |
|
860 |
// } |
|
861 |
// return null; |
|
862 |
// } |
|
863 |
// return null; |
|
853 | 864 |
} else if (format.equalsIgnoreCase(ICRSFactory.FORMAT_WKT)) { |
854 | 865 |
String wkt = spatialReference.ExportToWkt(); |
855 | 866 |
auxSpatialReference.ImportFromWkt(wkt); |
Also available in: Unified diff