Revision 8405
trunk/libraries/libJCRS/src/org/gvsig/crs/Crs.java | ||
---|---|---|
9 | 9 |
import org.cresques.cts.IDatum; |
10 | 10 |
import org.cresques.cts.IProjection; |
11 | 11 |
import org.cresques.geo.ViewPortData; |
12 |
import org.gvsig.crs.epsg.CrsEpsg; |
|
13 |
import org.gvsig.crs.epsg.CrsEpsgException; |
|
14 |
import org.gvsig.crs.epsg.OperationCrs; |
|
15 |
import org.gvsig.crs.epsg.OperationCrsException; |
|
16 | 12 |
import org.gvsig.crs.ogr.CrsOgr; |
17 | 13 |
import org.gvsig.crs.ogr.CrsOgrException; |
18 | 14 |
import org.gvsig.crs.ogr.OGRException; |
19 | 15 |
import org.gvsig.crs.ogr.OGRSpatialReference; |
20 | 16 |
import org.gvsig.crs.ogr.crsgdalException; |
17 |
import org.gvsig.crs.proj.CrsProj; |
|
18 |
import org.gvsig.crs.proj.CrsProjException; |
|
19 |
import org.gvsig.crs.proj.OperationCrs; |
|
20 |
import org.gvsig.crs.proj.OperationCrsException; |
|
21 | 21 |
|
22 | 22 |
public class Crs implements ICrs { |
23 | 23 |
private static final Color basicGridColor = new Color(64, 64, 64, 128); |
... | ... | |
26 | 26 |
//private String transOrigin = ""; |
27 | 27 |
private String abrev; |
28 | 28 |
private String name = ""; |
29 |
private CrsEpsg crsProj4;
|
|
30 |
private CrsEpsg crsBase = null;
|
|
29 |
private CrsProj crsProj4;
|
|
30 |
private CrsProj crsBase = null;
|
|
31 | 31 |
private CrsWkt crsWkt; |
32 | 32 |
private int epsg_code = 23030; |
33 | 33 |
boolean targetNad = false; |
... | ... | |
53 | 53 |
Integer.parseInt(code)); |
54 | 54 |
//Guardamos la cadena Proj4 devuelva por la OGRSpatialReference |
55 | 55 |
proj4 = CrsOgr.exportToProj4(oSRSSource); |
56 |
crsProj4 = new CrsEpsg(proj4);
|
|
56 |
crsProj4 = new CrsProj(proj4);
|
|
57 | 57 |
setName(fullCode); |
58 | 58 |
setAbrev(fullCode); |
59 | 59 |
|
... | ... | |
80 | 80 |
OGRSpatialReference oSRSSource = new OGRSpatialReference(); |
81 | 81 |
CrsOgr.importFromWkt(oSRSSource,code2); |
82 | 82 |
proj4 =CrsOgr.exportToProj4(oSRSSource); |
83 |
crsProj4 = new CrsEpsg(proj4);
|
|
83 |
crsProj4 = new CrsProj(proj4);
|
|
84 | 84 |
setName(fullCode); |
85 | 85 |
setAbrev(crsWkt.getName()); |
86 | 86 |
} catch (OGRException e) { |
... | ... | |
100 | 100 |
//crs base (en el caso de ser projectado): |
101 | 101 |
if(this.isProjected()){ |
102 | 102 |
String proj4Base = "+proj=latlong +a=" + crsWkt.getSpheroid()[1] + " +rf=" + crsWkt.getSpheroid()[2] ; |
103 |
crsBase = new CrsEpsg(proj4Base);
|
|
103 |
crsBase = new CrsProj(proj4Base);
|
|
104 | 104 |
} |
105 | 105 |
} |
106 | 106 |
} |
... | ... | |
123 | 123 |
Integer.parseInt(code)); |
124 | 124 |
//Guardamos la cadena Proj4 devuelva por la OGRSpatialReference |
125 | 125 |
proj4 = CrsOgr.exportToProj4(oSRSSource); |
126 |
crsProj4 = new CrsEpsg(proj4);
|
|
126 |
crsProj4 = new CrsProj(proj4);
|
|
127 | 127 |
setName(fullCode); |
128 | 128 |
setAbrev(fullCode); |
129 | 129 |
|
... | ... | |
150 | 150 |
OGRSpatialReference oSRSSource = new OGRSpatialReference(); |
151 | 151 |
CrsOgr.importFromWkt(oSRSSource,code2); |
152 | 152 |
proj4 = CrsOgr.exportToProj4(oSRSSource); |
153 |
crsProj4 = new CrsEpsg(proj4);
|
|
153 |
crsProj4 = new CrsProj(proj4);
|
|
154 | 154 |
setName(fullCode); |
155 | 155 |
setAbrev(crsWkt.getName()); |
156 | 156 |
} catch (OGRException e) { |
... | ... | |
170 | 170 |
// Crs base (en el caso de ser projectado): |
171 | 171 |
if(this.isProjected()){ |
172 | 172 |
String proj4Base = "+proj=latlong +a=" + crsWkt.getSpheroid()[1] + " +rf=" + crsWkt.getSpheroid()[2] ; |
173 |
crsBase = new CrsEpsg(proj4Base);
|
|
173 |
crsBase = new CrsProj(proj4Base);
|
|
174 | 174 |
} |
175 | 175 |
} |
176 | 176 |
} |
... | ... | |
193 | 193 |
Integer.parseInt(code)); |
194 | 194 |
//Guardamos la cadena Proj4 devuelva por la OGRSpatialReference |
195 | 195 |
proj4 = CrsOgr.exportToProj4(oSRSSource); |
196 |
crsProj4 = new CrsEpsg(proj4);
|
|
196 |
crsProj4 = new CrsProj(proj4);
|
|
197 | 197 |
setName(fullCode); |
198 | 198 |
setAbrev(fullCode); |
199 | 199 |
|
... | ... | |
220 | 220 |
OGRSpatialReference oSRSSource = new OGRSpatialReference(); |
221 | 221 |
CrsOgr.importFromWkt(oSRSSource,code2); |
222 | 222 |
proj4 =CrsOgr.exportToProj4(oSRSSource)+params+" "; |
223 |
crsProj4 = new CrsEpsg(proj4);
|
|
223 |
crsProj4 = new CrsProj(proj4);
|
|
224 | 224 |
setName(fullCode); |
225 | 225 |
setAbrev(crsWkt.getName()); |
226 | 226 |
} catch (OGRException e) { |
... | ... | |
240 | 240 |
// Crs base (en el caso de ser projectado): |
241 | 241 |
if(this.isProjected()){ |
242 | 242 |
String proj4Base = "+proj=latlong +a=" + crsWkt.getSpheroid()[1] + " +rf=" + crsWkt.getSpheroid()[2] ; |
243 |
crsBase = new CrsEpsg(proj4Base);
|
|
243 |
crsBase = new CrsProj(proj4Base);
|
|
244 | 244 |
} |
245 | 245 |
} |
246 | 246 |
} |
... | ... | |
309 | 309 |
else return new COperation(this, target); |
310 | 310 |
} |
311 | 311 |
|
312 |
protected CrsEpsg getCrsEpsg() {
|
|
312 |
protected CrsProj getCrsEpsg() {
|
|
313 | 313 |
return crsProj4; |
314 | 314 |
} |
315 | 315 |
|
... | ... | |
356 | 356 |
} catch (OperationCrsException e) { |
357 | 357 |
// TODO Auto-generated catch block |
358 | 358 |
e.printStackTrace(); |
359 |
} catch (CrsEpsgException e) {
|
|
359 |
} catch (CrsProjException e) {
|
|
360 | 360 |
// TODO Auto-generated catch block |
361 | 361 |
e.printStackTrace(); |
362 | 362 |
} |
trunk/libraries/libJCRS/src/org/gvsig/crs/proj/OperationCrsException.java | ||
---|---|---|
1 |
package org.gvsig.crs.proj; |
|
2 |
|
|
3 |
public class OperationCrsException extends Exception { |
|
4 |
/** |
|
5 |
* |
|
6 |
*/ |
|
7 |
private static final long serialVersionUID = 1L; |
|
8 |
private String _strSrcCrs,_strDestCrs; |
|
9 |
|
|
10 |
public OperationCrsException(CrsProj srcCrs, CrsProj destCrs) { |
|
11 |
_strSrcCrs=srcCrs.getStr(); |
|
12 |
_strDestCrs=destCrs.getStr(); |
|
13 |
} |
|
14 |
|
|
15 |
public String getStrError() { |
|
16 |
return ("Error en operacion del CRS "+_strSrcCrs+" al CRS "+_strDestCrs); |
|
17 |
} |
|
18 |
} |
|
0 | 19 |
trunk/libraries/libJCRS/src/org/gvsig/crs/proj/OperationCrs.java | ||
---|---|---|
1 |
package org.gvsig.crs.proj; |
|
2 |
|
|
3 |
|
|
4 |
public class OperationCrs extends JNIBaseOperation |
|
5 |
{ |
|
6 |
public static void operate(double[] firstCoord, |
|
7 |
double[] secondCoord, |
|
8 |
double[] thirdCoord, |
|
9 |
CrsProj srcCrs, |
|
10 |
CrsProj destCrs) |
|
11 |
throws OperationCrsException, |
|
12 |
CrsProjException { |
|
13 |
|
|
14 |
int error=operation(firstCoord,secondCoord,thirdCoord, |
|
15 |
srcCrs.getPtr(),destCrs.getPtr()); |
|
16 |
if(error!=1) throw new OperationCrsException(srcCrs,destCrs); |
|
17 |
} |
|
18 |
|
|
19 |
public static void operateSimple(double firstCoord, |
|
20 |
double secondCoord, |
|
21 |
double thirdCoord, |
|
22 |
CrsProj srcCrs, |
|
23 |
CrsProj destCrs) throws OperationCrsException, |
|
24 |
CrsProjException { |
|
25 |
|
|
26 |
int error = operationSimple(firstCoord, secondCoord, thirdCoord, |
|
27 |
srcCrs.getPtr(),destCrs.getPtr()); |
|
28 |
if(error!=1) throw new OperationCrsException(srcCrs,destCrs); |
|
29 |
} |
|
30 |
|
|
31 |
public static void operateArraySimple(double[] Coord, |
|
32 |
CrsProj srcCrs, |
|
33 |
CrsProj destCrs)throws OperationCrsException, |
|
34 |
CrsProjException { |
|
35 |
|
|
36 |
int error = operationArraySimple(Coord,srcCrs.getPtr(),destCrs.getPtr()); |
|
37 |
|
|
38 |
if(error!=1) throw new OperationCrsException(srcCrs,destCrs); |
|
39 |
|
|
40 |
} |
|
41 |
public static int compareDatums(CrsProj crs1, CrsProj crs2){ |
|
42 |
int compare = 0; |
|
43 |
try { |
|
44 |
compare = compareDatums(crs1.getPtr(),crs2.getPtr()); |
|
45 |
} catch (CrsProjException e) { |
|
46 |
// TODO Auto-generated catch block |
|
47 |
e.printStackTrace(); |
|
48 |
} |
|
49 |
return compare; |
|
50 |
} |
|
51 |
} |
|
0 | 52 |
trunk/libraries/libJCRS/src/org/gvsig/crs/proj/JNIBaseOperation.java | ||
---|---|---|
1 |
package org.gvsig.crs.proj; |
|
2 |
|
|
3 |
public class JNIBaseOperation |
|
4 |
{ |
|
5 |
protected static native int operation(double[] firstCoord, |
|
6 |
double[] secondCoord, |
|
7 |
double[] values, |
|
8 |
long srcCodeString, |
|
9 |
long destCodeString); |
|
10 |
|
|
11 |
protected static native int operationSimple(double firstcoord, |
|
12 |
double secondcoord, |
|
13 |
double values, |
|
14 |
long srcCodeString, |
|
15 |
long destCodeString); |
|
16 |
|
|
17 |
protected static native int operationArraySimple(double[] Coord, |
|
18 |
long srcCodeString, |
|
19 |
long destCodeString); |
|
20 |
protected static native int compareDatums(long datum1, long datum2); |
|
21 |
static |
|
22 |
{ |
|
23 |
System.loadLibrary("crsjniproj"); |
|
24 |
} |
|
25 |
} |
|
0 | 26 |
trunk/libraries/libJCRS/src/org/gvsig/crs/proj/CrsProjException.java | ||
---|---|---|
1 |
package org.gvsig.crs.proj; |
|
2 |
|
|
3 |
public class CrsProjException extends Exception { |
|
4 |
/** |
|
5 |
* |
|
6 |
*/ |
|
7 |
|
|
8 |
private static final long serialVersionUID = 1L; |
|
9 |
|
|
10 |
public CrsProjException(String message) |
|
11 |
{ |
|
12 |
super(message); |
|
13 |
} |
|
14 |
} |
|
0 | 15 |
trunk/libraries/libJCRS/src/org/gvsig/crs/proj/CrsProj.java | ||
---|---|---|
1 |
package org.gvsig.crs.proj; |
|
2 |
|
|
3 |
import com.iver.andami.messages.NotificationManager; |
|
4 |
|
|
5 |
|
|
6 |
public class CrsProj extends JNIBaseCrs { |
|
7 |
/** |
|
8 |
* |
|
9 |
* |
|
10 |
* @param strCrs Cadena proj4. |
|
11 |
*/ |
|
12 |
public CrsProj(String strCrs) { |
|
13 |
try { |
|
14 |
createCrs(strCrs); |
|
15 |
} catch(CrsProjException e) { |
|
16 |
NotificationManager.addError(e); |
|
17 |
} |
|
18 |
|
|
19 |
} |
|
20 |
|
|
21 |
protected void finalize() { |
|
22 |
deleteCrs(); |
|
23 |
} |
|
24 |
} |
|
0 | 25 |
trunk/libraries/libJCRS/src/org/gvsig/crs/proj/JNIBaseCrs.java | ||
---|---|---|
1 |
package org.gvsig.crs.proj; |
|
2 |
|
|
3 |
|
|
4 |
public class JNIBaseCrs |
|
5 |
{ |
|
6 |
protected long cPtr; |
|
7 |
protected int latLong; |
|
8 |
protected String _strCrs; |
|
9 |
protected native long loadCrs(String crs); |
|
10 |
protected native void freeCrs(long crs); |
|
11 |
protected native int isLatlong(long crs); |
|
12 |
protected native int compareDatums(long datum1, long datum2); |
|
13 |
protected native int getErrno(); |
|
14 |
protected native String strErrno(int errno); |
|
15 |
|
|
16 |
static { |
|
17 |
System.loadLibrary("crsjniproj"); |
|
18 |
} |
|
19 |
|
|
20 |
protected void createCrs(String strCrs) throws CrsProjException { |
|
21 |
cPtr=loadCrs(strCrs); |
|
22 |
|
|
23 |
int errNo = getErrNo(); |
|
24 |
if (errNo<0) throw new CrsProjException("Error creating CRS: "+strErrNo(errNo)); |
|
25 |
_strCrs=strCrs; |
|
26 |
} |
|
27 |
|
|
28 |
protected void deleteCrs() { |
|
29 |
if(cPtr>0) freeCrs(cPtr); |
|
30 |
} |
|
31 |
|
|
32 |
public boolean isLatlong() { |
|
33 |
latLong = isLatlong(cPtr); |
|
34 |
if(latLong == 0) |
|
35 |
return false; |
|
36 |
return true; |
|
37 |
} |
|
38 |
|
|
39 |
protected long getPtr() throws CrsProjException { |
|
40 |
if (cPtr>0) return cPtr; |
|
41 |
else throw new CrsProjException(_strCrs); |
|
42 |
} |
|
43 |
|
|
44 |
public String getStr() { |
|
45 |
return _strCrs; |
|
46 |
} |
|
47 |
|
|
48 |
public void changeStrCrs(String code) { |
|
49 |
_strCrs += code; |
|
50 |
} |
|
51 |
|
|
52 |
protected int getErrNo(){ |
|
53 |
return getErrno(); |
|
54 |
} |
|
55 |
|
|
56 |
protected String strErrNo(int errno){ |
|
57 |
return strErrno(errno); |
|
58 |
} |
|
59 |
} |
|
0 | 60 |
trunk/libraries/libJCRS/src/org/gvsig/crs/COperation.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import org.cresques.cts.ICoordTrans; |
7 | 7 |
import org.cresques.cts.IProjection; |
8 |
import org.gvsig.crs.epsg.CrsEpsgException;
|
|
9 |
import org.gvsig.crs.epsg.OperationCrs;
|
|
10 |
import org.gvsig.crs.epsg.OperationCrsException;
|
|
8 |
import org.gvsig.crs.proj.CrsProjException;
|
|
9 |
import org.gvsig.crs.proj.OperationCrs;
|
|
10 |
import org.gvsig.crs.proj.OperationCrsException;
|
|
11 | 11 |
|
12 | 12 |
public class COperation implements ICOperation { |
13 | 13 |
private Crs sourceCrs; |
... | ... | |
34 | 34 |
sourceCrs.getCrsEpsg(), targetCrs.getCrsEpsg()); |
35 | 35 |
} catch (OperationCrsException e) { |
36 | 36 |
throw new CrsException(e); |
37 |
} catch (CrsEpsgException e) {
|
|
37 |
} catch (CrsProjException e) {
|
|
38 | 38 |
throw new CrsException(e); |
39 | 39 |
} |
40 | 40 |
// System.out.println("x="+x[0]+"y="+y[0]); |
... | ... | |
53 | 53 |
sourceCrs.getCrsEpsg(), targetCrs.getCrsEpsg()); |
54 | 54 |
} catch (OperationCrsException e) { |
55 | 55 |
throw new CrsException(e); |
56 |
} catch (CrsEpsgException e) {
|
|
56 |
} catch (CrsProjException e) {
|
|
57 | 57 |
throw new CrsException(e); |
58 | 58 |
} |
59 | 59 |
|
trunk/libraries/libJCRS/src/org/gvsig/crs/ogr/JNIBase.java | ||
---|---|---|
26 | 26 |
} |
27 | 27 |
|
28 | 28 |
static { |
29 |
System.loadLibrary("jgdal060");
|
|
29 |
System.loadLibrary("jgdal"); |
|
30 | 30 |
} |
31 | 31 |
|
32 | 32 |
} |
trunk/libraries/libJCRS/src/org/gvsig/crs/epsg/OperationCrsException.java | ||
---|---|---|
1 |
package org.gvsig.crs.epsg; |
|
2 |
|
|
3 |
public class OperationCrsException extends Exception { |
|
4 |
/** |
|
5 |
* |
|
6 |
*/ |
|
7 |
private static final long serialVersionUID = 1L; |
|
8 |
private String _strSrcCrs,_strDestCrs; |
|
9 |
|
|
10 |
public OperationCrsException(CrsEpsg srcCrs, CrsEpsg destCrs) { |
|
11 |
_strSrcCrs=srcCrs.getStr(); |
|
12 |
_strDestCrs=destCrs.getStr(); |
|
13 |
} |
|
14 |
|
|
15 |
public String getStrError() { |
|
16 |
return ("Error en operacion del CRS "+_strSrcCrs+" al CRS "+_strDestCrs); |
|
17 |
} |
|
18 |
} |
trunk/libraries/libJCRS/src/org/gvsig/crs/epsg/OperationCrs.java | ||
---|---|---|
1 |
package org.gvsig.crs.epsg; |
|
2 |
|
|
3 |
|
|
4 |
public class OperationCrs extends JNIBaseOperation |
|
5 |
{ |
|
6 |
public static void operate(double[] firstCoord, |
|
7 |
double[] secondCoord, |
|
8 |
double[] thirdCoord, |
|
9 |
CrsEpsg srcCrs, |
|
10 |
CrsEpsg destCrs) |
|
11 |
throws OperationCrsException, |
|
12 |
CrsEpsgException { |
|
13 |
|
|
14 |
int error=operation(firstCoord,secondCoord,thirdCoord, |
|
15 |
srcCrs.getPtr(),destCrs.getPtr()); |
|
16 |
if(error!=1) throw new OperationCrsException(srcCrs,destCrs); |
|
17 |
} |
|
18 |
|
|
19 |
public static void operateSimple(double firstCoord, |
|
20 |
double secondCoord, |
|
21 |
double thirdCoord, |
|
22 |
CrsEpsg srcCrs, |
|
23 |
CrsEpsg destCrs) throws OperationCrsException, |
|
24 |
CrsEpsgException { |
|
25 |
|
|
26 |
int error = operationSimple(firstCoord, secondCoord, thirdCoord, |
|
27 |
srcCrs.getPtr(),destCrs.getPtr()); |
|
28 |
if(error!=1) throw new OperationCrsException(srcCrs,destCrs); |
|
29 |
} |
|
30 |
|
|
31 |
public static void operateArraySimple(double[] Coord, |
|
32 |
CrsEpsg srcCrs, |
|
33 |
CrsEpsg destCrs)throws OperationCrsException, |
|
34 |
CrsEpsgException { |
|
35 |
|
|
36 |
int error = operationArraySimple(Coord,srcCrs.getPtr(),destCrs.getPtr()); |
|
37 |
|
|
38 |
if(error!=1) throw new OperationCrsException(srcCrs,destCrs); |
|
39 |
|
|
40 |
} |
|
41 |
public static int compareDatums(CrsEpsg crs1, CrsEpsg crs2){ |
|
42 |
int compare = 0; |
|
43 |
try { |
|
44 |
compare = compareDatums(crs1.getPtr(),crs2.getPtr()); |
|
45 |
} catch (CrsEpsgException e) { |
|
46 |
// TODO Auto-generated catch block |
|
47 |
e.printStackTrace(); |
|
48 |
} |
|
49 |
return compare; |
|
50 |
} |
|
51 |
} |
trunk/libraries/libJCRS/src/org/gvsig/crs/epsg/JNIBaseOperation.java | ||
---|---|---|
1 |
package org.gvsig.crs.epsg; |
|
2 |
|
|
3 |
public class JNIBaseOperation |
|
4 |
{ |
|
5 |
protected static native int operation(double[] firstCoord, |
|
6 |
double[] secondCoord, |
|
7 |
double[] values, |
|
8 |
long srcCodeString, |
|
9 |
long destCodeString); |
|
10 |
|
|
11 |
protected static native int operationSimple(double firstcoord, |
|
12 |
double secondcoord, |
|
13 |
double values, |
|
14 |
long srcCodeString, |
|
15 |
long destCodeString); |
|
16 |
|
|
17 |
protected static native int operationArraySimple(double[] Coord, |
|
18 |
long srcCodeString, |
|
19 |
long destCodeString); |
|
20 |
protected static native int compareDatums(long datum1, long datum2); |
|
21 |
static |
|
22 |
{ |
|
23 |
System.loadLibrary("crsjniproj"); |
|
24 |
} |
|
25 |
} |
trunk/libraries/libJCRS/src/org/gvsig/crs/epsg/JNIBaseCrs.java | ||
---|---|---|
10 | 10 |
protected native void freeCrs(long crs); |
11 | 11 |
protected native int isLatlong(long crs); |
12 | 12 |
protected native int compareDatums(long datum1, long datum2); |
13 |
protected native int getErrno(); |
|
14 |
protected native String strErrno(int errno); |
|
13 | 15 |
|
14 | 16 |
static { |
15 | 17 |
System.loadLibrary("crsjniproj"); |
... | ... | |
17 | 19 |
|
18 | 20 |
protected void createCrs(String strCrs) throws CrsEpsgException { |
19 | 21 |
cPtr=loadCrs(strCrs); |
20 |
if(cPtr<=0) throw new CrsEpsgException(strCrs); |
|
22 |
|
|
23 |
int errNo = getErrNo(); |
|
24 |
if (errNo<0) throw new CrsEpsgException("Error creating CRS: "+strErrNo(errNo)); |
|
21 | 25 |
_strCrs=strCrs; |
22 | 26 |
} |
23 | 27 |
|
... | ... | |
44 | 48 |
public void changeStrCrs(String code) { |
45 | 49 |
_strCrs += code; |
46 | 50 |
} |
51 |
|
|
52 |
protected int getErrNo(){ |
|
53 |
return getErrno(); |
|
54 |
} |
|
55 |
|
|
56 |
protected String strErrNo(int errno){ |
|
57 |
return strErrno(errno); |
|
58 |
} |
|
47 | 59 |
} |
trunk/libraries/libJCRS/src/org/gvsig/crs/epsg/CrsEpsgException.java | ||
---|---|---|
4 | 4 |
/** |
5 | 5 |
* |
6 | 6 |
*/ |
7 |
|
|
7 | 8 |
private static final long serialVersionUID = 1L; |
8 | 9 |
|
9 |
public CrsEpsgException(String strCrs)
|
|
10 |
public CrsEpsgException(String message)
|
|
10 | 11 |
{ |
11 |
_strCrs=strCrs; |
|
12 |
} |
|
13 |
public String getStrError() |
|
14 |
{ |
|
15 |
return ("Imposible crear CRS "+_strCrs); |
|
16 |
} |
|
17 |
private String _strCrs; |
|
12 |
super(message); |
|
13 |
} |
|
18 | 14 |
} |
trunk/libraries/libJCRS/src/org/gvsig/crs/epsg/CrsEpsg.java | ||
---|---|---|
1 | 1 |
package org.gvsig.crs.epsg; |
2 | 2 |
|
3 |
import com.iver.andami.messages.NotificationManager; |
|
3 | 4 |
|
5 |
|
|
4 | 6 |
public class CrsEpsg extends JNIBaseCrs { |
5 | 7 |
/** |
6 | 8 |
* |
... | ... | |
10 | 12 |
public CrsEpsg(String strCrs) { |
11 | 13 |
try { |
12 | 14 |
createCrs(strCrs); |
13 |
} catch(CrsEpsgException exp) {
|
|
14 |
System.out.println(exp.getStrError());
|
|
15 |
} catch(CrsEpsgException e) { |
|
16 |
NotificationManager.addError(e);
|
|
15 | 17 |
} |
18 |
|
|
16 | 19 |
} |
17 | 20 |
|
18 | 21 |
protected void finalize() { |
trunk/libraries/libJCRS/src/org/gvsig/crs/Test.java | ||
---|---|---|
6 | 6 |
import java.io.IOException; |
7 | 7 |
import java.io.InputStreamReader; |
8 | 8 |
|
9 |
import org.gvsig.crs.epsg.CrsEpsg; |
|
10 |
import org.gvsig.crs.epsg.CrsEpsgException; |
|
11 |
import org.gvsig.crs.epsg.OperationCrs; |
|
12 |
import org.gvsig.crs.epsg.OperationCrsException; |
|
13 | 9 |
import org.gvsig.crs.ogr.CrsOgr; |
14 | 10 |
import org.gvsig.crs.ogr.CrsOgrException; |
15 | 11 |
import org.gvsig.crs.ogr.OGRException; |
16 | 12 |
import org.gvsig.crs.ogr.OGRSpatialReference; |
17 | 13 |
import org.gvsig.crs.ogr.crsgdalException; |
14 |
import org.gvsig.crs.proj.CrsProj; |
|
15 |
import org.gvsig.crs.proj.CrsProjException; |
|
16 |
import org.gvsig.crs.proj.OperationCrs; |
|
17 |
import org.gvsig.crs.proj.OperationCrsException; |
|
18 | 18 |
|
19 | 19 |
|
20 | 20 |
|
... | ... | |
27 | 27 |
private static double[] z = new double[1]; |
28 | 28 |
private static double[] coord = new double [15]; // Para la proyeccion PCI |
29 | 29 |
|
30 |
public static void main(String[] args) throws OGRException, CrsOgrException, crsgdalException, OperationCrsException, CrsEpsgException, IOException {
|
|
30 |
public static void main(String[] args) throws OGRException, CrsOgrException, crsgdalException, OperationCrsException, CrsProjException, IOException {
|
|
31 | 31 |
opera(args); |
32 | 32 |
//pruebaWKT(); |
33 | 33 |
} |
34 | 34 |
|
35 |
public static void opera(String[] args) throws OGRException, CrsOgrException, crsgdalException, OperationCrsException, CrsEpsgException, IOException {
|
|
35 |
public static void opera(String[] args) throws OGRException, CrsOgrException, crsgdalException, OperationCrsException, CrsProjException, IOException {
|
|
36 | 36 |
|
37 | 37 |
//System.out.print((new File(".").getCanonicalPath())); |
38 | 38 |
OGRSpatialReference oSRSSource = new OGRSpatialReference(); |
... | ... | |
121 | 121 |
oSRSTarget.finalice(); |
122 | 122 |
} |
123 | 123 |
} |
124 |
public static void reiniciar(String strCrsSource, String strCrsTarget) throws OperationCrsException, CrsEpsgException
|
|
124 |
public static void reiniciar(String strCrsSource, String strCrsTarget) throws OperationCrsException, CrsProjException
|
|
125 | 125 |
{ |
126 | 126 |
// x[0] = -(3.0+24.0/60.0+30.12345/3600.0); |
127 | 127 |
// y[0] = (40.0+24.0/60.0+30.12345/3600.0); |
... | ... | |
132 | 132 |
double ygood = 4473032.98; |
133 | 133 |
// double xgood = -(3.0+24.0/60.0+34.804968/3600.0);//*Math.PI/180.0; |
134 | 134 |
// double ygood = (40.0+24.0/60.0+25.867951/3600.0);//*Math.PI/180; |
135 |
CrsEpsg srcCrs = new CrsEpsg(strCrsSource);
|
|
136 |
CrsEpsg destCrs = new CrsEpsg(strCrsTarget);
|
|
135 |
CrsProj srcCrs = new CrsProj(strCrsSource);
|
|
136 |
CrsProj destCrs = new CrsProj(strCrsTarget);
|
|
137 | 137 |
System.out.println("Coordenadas Iniciales: "+"x = " + x[0] + " y = " + y[0] + " z = " + z[0]); |
138 | 138 |
OperationCrs.operate(x, y, z, srcCrs, destCrs); |
139 | 139 |
double difx=(xgood-x[0]); |
... | ... | |
144 | 144 |
System.out.println(destCrs.isLatlong()); |
145 | 145 |
} |
146 | 146 |
|
147 |
public static void reiniciarSimple(String strCrsSource, String strCrsTarget) throws OperationCrsException, CrsEpsgException{
|
|
147 |
public static void reiniciarSimple(String strCrsSource, String strCrsTarget) throws OperationCrsException, CrsProjException{
|
|
148 | 148 |
|
149 | 149 |
double []pt = {465348.7823, 4473240.8768, 0.0}; |
150 |
CrsEpsg srcCrs = new CrsEpsg(strCrsSource);
|
|
151 |
CrsEpsg destCrs = new CrsEpsg(strCrsTarget);
|
|
150 |
CrsProj srcCrs = new CrsProj(strCrsSource);
|
|
151 |
CrsProj destCrs = new CrsProj(strCrsTarget);
|
|
152 | 152 |
System.out.print("Coordenadas transformadas: "); |
153 | 153 |
OperationCrs.operateSimple(pt[0],pt[1], pt[2], srcCrs, destCrs); |
154 | 154 |
} |
155 | 155 |
|
156 |
public static void reiniciarArraySimple(String strCrsSource, String strCrsTarget) throws OperationCrsException, CrsEpsgException{
|
|
156 |
public static void reiniciarArraySimple(String strCrsSource, String strCrsTarget) throws OperationCrsException, CrsProjException{
|
|
157 | 157 |
|
158 | 158 |
double []pt = {465348.7823, 4473240.8768, 0.0}; |
159 |
CrsEpsg srcCrs = new CrsEpsg(strCrsSource);
|
|
160 |
CrsEpsg destCrs = new CrsEpsg(strCrsTarget);
|
|
159 |
CrsProj srcCrs = new CrsProj(strCrsSource);
|
|
160 |
CrsProj destCrs = new CrsProj(strCrsTarget);
|
|
161 | 161 |
OperationCrs.operateArraySimple(pt, srcCrs, destCrs); |
162 | 162 |
System.out.println("Coordenadas transformadas: "+"x = " + pt[0] + " y = " + pt[1] + " z = " + pt[2]); |
163 | 163 |
|
Also available in: Unified diff