Revision 25285
tags/JCRS_V02_BN11/libJCRS/.cvsignore | ||
---|---|---|
1 |
bin |
|
0 | 2 |
tags/JCRS_V02_BN11/libJCRS/.settings/org.eclipse.core.resources.prefs | ||
---|---|---|
1 |
#Tue Jul 25 14:11:17 CEST 2006 |
|
2 |
eclipse.preferences.version=1 |
|
3 |
encoding/<project>=ISO-8859-1 |
|
0 | 4 |
tags/JCRS_V02_BN11/libJCRS/build.xml | ||
---|---|---|
1 |
<project name="libJCRS" default="generate-without-source" basedir="."> |
|
2 |
<description> |
|
3 |
Instala el plugin de JCrs en Andami. |
|
4 |
</description> |
|
5 |
<!-- set global properties for this build --> |
|
6 |
<property name="src" location="src"/> |
|
7 |
<property name="build" location="bin"/> |
|
8 |
<property name="lib" location="lib" /> |
|
9 |
<property name="dist" location="dist"/> |
|
10 |
<property name="plugin" value="jcrs"/> |
|
11 |
<property name="geotools" value="jcrs-geotools"/> |
|
12 |
<property name="andami" location="../_fwAndami"/> |
|
13 |
<property name="andamiLibs" location="${andami}/lib"/> |
|
14 |
<property name="extension-dir" location="${andami}/gvSIG/extensiones"/> |
|
15 |
<property name="targetDir" location="../libFMap/lib" /> |
|
16 |
<property name="installDir" location="${extension-dir}/com.iver.cit.gvsig/lib" /> |
|
17 |
<property name="JavaSourceVersion" value="1.5"/> |
|
18 |
<property name="JavaTargetVersion" value="1.5"/> |
|
19 |
<property name="debug" value="on"/> |
|
20 |
<property name="debuglevel" value="line, vars"/> |
|
21 |
<property name="encoding" value="ISO_8859_1"/> |
|
22 |
|
|
23 |
|
|
24 |
<target name="init"> |
|
25 |
<!-- Create the time stamp --> |
|
26 |
<tstamp/> |
|
27 |
<echo> |
|
28 |
Compiling ${ant.project.name}...</echo> |
|
29 |
<!-- Create the build directory structure used by compile --> |
|
30 |
<mkdir dir="${build}"/> |
|
31 |
<mkdir dir="${dist}"/> |
|
32 |
|
|
33 |
</target> |
|
34 |
|
|
35 |
<target name="compile" |
|
36 |
description="compile the source" > |
|
37 |
<!-- Compile the Java code from ${src} to ${bin} --> |
|
38 |
<javac srcdir="${src}" |
|
39 |
destdir="${build}" |
|
40 |
source="${JavaSourceVersion}" |
|
41 |
target="${JavaTargetVersion}" |
|
42 |
debug="${debug}" |
|
43 |
debuglevel="${debuglevel}" |
|
44 |
encoding="${encoding}" |
|
45 |
classpath="${andamiLibs}/beans.jar:${andamiLibs}/iver-utiles.jar:${lib}/jGridShiftApi.jar:${extension-dir}/com.iver.cit.gvsig/lib/fmap.jar:${extension-dir}/com.iver.cit.gvsig/lib/com.iver.cit.gvsig.jar:../libFMap/lib/cms.jar:../libFMap/lib/gdbms-0.8-SNAPSHOT.jar:${andami}/andami.jar"/> |
|
46 |
<copy todir="${build}"> |
|
47 |
<fileset |
|
48 |
dir="${src}" |
|
49 |
excludes="**/*.java"/> |
|
50 |
</copy> |
|
51 |
|
|
52 |
</target> |
|
53 |
|
|
54 |
<target name="generate-without-source" description="generate the distribution without the source file" > |
|
55 |
<!-- Create the distribution directory --> |
|
56 |
<mkdir dir="${dist}"/> |
|
57 |
|
|
58 |
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --> |
|
59 |
<jar jarfile="${dist}/${plugin}.jar" basedir="${build}" includes="org/gvsig/ es/idr/"/> |
|
60 |
<jar jarfile="${dist}/${geotools}.jar" basedir="${build}" includes="org/geotools/ META-INF/"/> |
|
61 |
|
|
62 |
<!-- copy file="${dist}/${plugin}.jar" todir="lib/"/> --> |
|
63 |
<copy file="${dist}/${plugin}.jar" todir="${targetDir}"/> |
|
64 |
<copy file="${dist}/${geotools}.jar" todir="${targetDir}"/> |
|
65 |
<copy todir="${targetDir}"> |
|
66 |
<fileset dir="./lib" includes="*.jar" /> |
|
67 |
</copy> |
|
68 |
<!-- <copy file="${dist}/${plugin}.jar" todir="../extJCRS/lib/"/> --> |
|
69 |
</target> |
|
70 |
|
|
71 |
<target name="batch-build" |
|
72 |
description="compile the sources, create the jar file" |
|
73 |
depends="init,compile,generate-without-source,install-to-andami"> |
|
74 |
</target> |
|
75 |
|
|
76 |
<target name="install-to-andami"> |
|
77 |
<copy todir="${installDir}"> |
|
78 |
<fileset dir="./lib" includes="*.jar" /> |
|
79 |
</copy> |
|
80 |
<copy file="${dist}/${plugin}.jar" todir="${installDir}"/> |
|
81 |
<copy file="${dist}/${geotools}.jar" todir="${installDir}"/> |
|
82 |
</target> |
|
83 |
|
|
84 |
<target name="clean" |
|
85 |
description="cleans the build directories"> |
|
86 |
<delete dir="${build}"/> |
|
87 |
<delete dir="${dist}"/> |
|
88 |
</target> |
|
89 |
</project> |
|
90 |
|
|
91 |
|
|
0 | 92 |
tags/JCRS_V02_BN11/libJCRS/.cdtproject | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<?eclipse-cdt version="2.0"?> |
|
3 |
|
|
4 |
<cdtproject/> |
|
0 | 5 |
tags/JCRS_V02_BN11/libJCRS/.classpath | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="src" path="src"/> |
|
4 |
<classpathentry kind="src" path="src-test"/> |
|
5 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
6 |
<classpathentry kind="lib" path="/libFMap/lib/geoapi-2.0.jar"/> |
|
7 |
<classpathentry kind="lib" path="/libFMap/lib/hsqldb.jar"/> |
|
8 |
<classpathentry kind="lib" path="/libFMap/lib/gt2-main.jar"/> |
|
9 |
<classpathentry kind="lib" path="/libFMap/lib/vecmath-1.3.jar"/> |
|
10 |
<classpathentry kind="lib" path="lib/db_iau2000.jar"/> |
|
11 |
<classpathentry kind="lib" path="lib/db_usr.jar"/> |
|
12 |
<classpathentry kind="lib" path="lib/db_esri.jar"/> |
|
13 |
<classpathentry combineaccessrules="false" kind="src" path="/_fwAndami"/> |
|
14 |
<classpathentry kind="lib" path="lib/db_epsg.jar"/> |
|
15 |
<classpathentry kind="lib" path="/libFMap/lib/units-0.01.jar"/> |
|
16 |
<classpathentry kind="lib" path="/libFMap/lib/cms.jar" sourcepath="/jCMS"/> |
|
17 |
<classpathentry kind="output" path="bin"/> |
|
18 |
</classpath> |
|
0 | 19 |
tags/JCRS_V02_BN11/libJCRS/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>crsgdal</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> |
|
15 |
<triggers>full,incremental,</triggers> |
|
16 |
<arguments> |
|
17 |
<dictionary> |
|
18 |
<key>LaunchConfigHandle</key> |
|
19 |
<value><project>/.externalToolBuilders/crsgdal build.xml [Builder].launch</value> |
|
20 |
</dictionary> |
|
21 |
</arguments> |
|
22 |
</buildCommand> |
|
23 |
</buildSpec> |
|
24 |
<natures> |
|
25 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
26 |
</natures> |
|
27 |
</projectDescription> |
|
0 | 28 |
tags/JCRS_V02_BN11/libJCRS/src-test/es/idr/projection/test/TestGeotools21.java | ||
---|---|---|
1 |
package es.idr.projection.test; |
|
2 |
|
|
3 |
import org.gvsig.crs.CrsException; |
|
4 |
import org.gvsig.crs.CrsFactory; |
|
5 |
import org.gvsig.crs.ICrs; |
|
6 |
import org.gvsig.crs.Proj4; |
|
7 |
import org.opengis.referencing.FactoryException; |
|
8 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
9 |
|
|
10 |
public class TestGeotools21 { |
|
11 |
|
|
12 |
|
|
13 |
/** |
|
14 |
* @param args |
|
15 |
*/ |
|
16 |
public static void main(String[] args) { |
|
17 |
try { |
|
18 |
String strEpsgCode; |
|
19 |
// Notas: |
|
20 |
// - transverse mercator south orientated no esta soportada por Proj4 |
|
21 |
// - Buscar ejemplo de la CylindricalEqualArea |
|
22 |
// - Buscar ejemplo de la AzimuthalEquidistant |
|
23 |
// - Buscar ejemplo de la Gnomonic |
|
24 |
// - Buscar ejemplo de la Bonne |
|
25 |
// - Buscar ejemplo de la Equirectangular |
|
26 |
// - Buscar ejemplo de la EquidistantConic |
|
27 |
// - Buscar ejemplo de la MillerCylindrical |
|
28 |
// - Buscar ejemplo de la Mollweide |
|
29 |
// - Buscar ejemplo de la EckertIV |
|
30 |
// - Buscar ejemplo de la EckertVI |
|
31 |
// - Buscar ejemplo de la Robinson |
|
32 |
// - Buscar ejemplo de la VanDerGrinten |
|
33 |
// - Buscar ejemplo de la Sinusoidal |
|
34 |
// - Buscar ejemplo de la GallStereographic |
|
35 |
// - Buscar ejemplo de la Goode |
|
36 |
|
|
37 |
//strEpsgCode="EPSG:2065"; // Krovak |
|
38 |
//strEpsgCode="EPSG:2052"; // tm south orientated No en mi Proj4 |
|
39 |
//strEpsgCode="EPSG:2084"; // tm south orientated |
|
40 |
//strEpsgCode="EPSG:32662"; // Plate Carree -> Funciona, problema elipsoide |
|
41 |
// Tomara como radio el semieje mayor del elipsoide |
|
42 |
//strEpsgCode="EPSG:27200"; // NewZealandMapGrid -> Mirar lo de +datum |
|
43 |
// He tenido que incluir un mecanismo para valores concretos de parametros |
|
44 |
strEpsgCode="EPSG:32761"; // CassiniSoldner -> Falla +to_meter=.. |
|
45 |
//strEpsgCode="EPSG:2099"; |
|
46 |
//strEpsgCode="EPSG:2200"; // en lugar de stere pone sterea,igual 2171 |
|
47 |
// 2036 - falla, 32661 |
|
48 |
//strEpsgCode="EPSG:2163"; // Laea esferica, funciona |
|
49 |
//strEpsgCode="EPSG:3035"; // ETRS-LAEA, funciona |
|
50 |
//strEpsgCode="EPSG:29100"; // Polyconic, falla en geotools |
|
51 |
//strEpsgCode="EPSG:2964"; // Albers-conic-equal-area |
|
52 |
// deberÃa fallar por cambio de unidad |
|
53 |
//strEpsgCode="EPSG:24571"; // Oblicua de mercator, rf mas decimales |
|
54 |
// quitar segundo alpha |
|
55 |
//strEpsgCode="EPSG:29700"; // Oblicua de mercator, rf mas decimales |
|
56 |
//strEpsgCode="EPSG:21780"; //somer, sin alpha |
|
57 |
ICrs crs=null; |
|
58 |
//CoordinateReferenceSystem source; |
|
59 |
//source = CRS.decode(strEpsgCode); |
|
60 |
crs = new CrsFactory().getCRS(strEpsgCode); |
|
61 |
|
|
62 |
System.out.println(crs.getWKT()); |
|
63 |
System.out.println(crs.getProj4String()); //proj4.exportToProj4(crs)); |
|
64 |
|
|
65 |
|
|
66 |
} catch (CrsException e) { |
|
67 |
// TODO Auto-generated catch block |
|
68 |
e.printStackTrace(); |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
} |
|
0 | 73 |
tags/JCRS_V02_BN11/libJCRS/src-test/es/idr/test/ValidateEpsgCRSs.java | ||
---|---|---|
1 |
package es.idr.test; |
|
2 |
|
|
3 |
import java.sql.Connection; |
|
4 |
import java.sql.PreparedStatement; |
|
5 |
import java.sql.ResultSet; |
|
6 |
import java.sql.SQLException; |
|
7 |
import java.util.ArrayList; |
|
8 |
|
|
9 |
import javax.units.Unit; |
|
10 |
|
|
11 |
import org.geotools.referencing.CRS; |
|
12 |
import org.geotools.referencing.crs.DefaultGeographicCRS; |
|
13 |
import org.geotools.referencing.crs.DefaultProjectedCRS; |
|
14 |
import org.geotools.referencing.datum.DefaultGeodeticDatum; |
|
15 |
import org.gvsig.crs.Crs; |
|
16 |
import org.gvsig.crs.CrsException; |
|
17 |
import org.geotools.referencing.factory.epsg.HSQLDataSource; |
|
18 |
import org.opengis.referencing.FactoryException; |
|
19 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
20 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
21 |
import org.opengis.referencing.crs.GeographicCRS; |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
public class ValidateEpsgCRSs { |
|
26 |
|
|
27 |
public ValidateEpsgCRSs() { |
|
28 |
|
|
29 |
} |
|
30 |
|
|
31 |
/** |
|
32 |
* @param args |
|
33 |
*/ |
|
34 |
public static void main(String[] args) { |
|
35 |
HSQLDataSource ds = new HSQLDataSource(); |
|
36 |
Connection conn; |
|
37 |
try { |
|
38 |
conn = ds.getConnection(); |
|
39 |
|
|
40 |
final PreparedStatement stmt; |
|
41 |
stmt = conn.prepareStatement("SELECT COORD_REF_SYS_CODE" |
|
42 |
+ " FROM epsg_coordinatereferencesystem"); |
|
43 |
ResultSet result; |
|
44 |
|
|
45 |
result = stmt.executeQuery(); |
|
46 |
|
|
47 |
ArrayList res = new ArrayList(); |
|
48 |
ArrayList units = new ArrayList(); |
|
49 |
ArrayList validos = new ArrayList(); |
|
50 |
while (result.next()) { |
|
51 |
int cod = result.getInt("COORD_REF_SYS_CODE"); |
|
52 |
|
|
53 |
String strEpsgCode="EPSG:"+cod; |
|
54 |
CoordinateReferenceSystem source; |
|
55 |
|
|
56 |
try { |
|
57 |
source = CRS.decode(strEpsgCode); |
|
58 |
validos.add(String.valueOf(cod)); |
|
59 |
if (source instanceof DefaultProjectedCRS) { |
|
60 |
String str; |
|
61 |
boolean esta = false; |
|
62 |
DefaultProjectedCRS sour = (DefaultProjectedCRS) source; |
|
63 |
|
|
64 |
Unit u = ((DefaultGeodeticDatum) sour.getDatum()).getPrimeMeridian().getAngularUnit(); |
|
65 |
units.add(u.toString()); |
|
66 |
|
|
67 |
/*for (int j = 0; j< units.size(); j++) { |
|
68 |
if (units.get(j).equals(u.toString())){ |
|
69 |
esta = true; |
|
70 |
break; |
|
71 |
} |
|
72 |
} |
|
73 |
if (!esta){ |
|
74 |
units.add(u.toString()); |
|
75 |
esta = false; |
|
76 |
}*/ |
|
77 |
for (int i=0; i< sour.getConversionFromBase().getParameterValues().values().size();i++) { |
|
78 |
str = sour.getConversionFromBase().getParameterValues().values().get(i).toString(); |
|
79 |
u = sour.getConversionFromBase().getParameterValues().parameter(str.split("=")[0]).getUnit(); |
|
80 |
units.add(u.toString()); |
|
81 |
|
|
82 |
} |
|
83 |
} |
|
84 |
if (source instanceof DefaultGeographicCRS) { |
|
85 |
DefaultGeographicCRS sour = (DefaultGeographicCRS) source; |
|
86 |
boolean esta = false; |
|
87 |
Unit u = ((DefaultGeodeticDatum) sour.getDatum()).getPrimeMeridian().getAngularUnit(); |
|
88 |
units.add(u.toString()); |
|
89 |
|
|
90 |
} |
|
91 |
} catch (NoSuchAuthorityCodeException e) { |
|
92 |
res.add(String.valueOf(cod)+" --> "+e); |
|
93 |
// TODO Auto-generated catch block |
|
94 |
//e.printStackTrace(); |
|
95 |
} catch (FactoryException e) { |
|
96 |
res.add(String.valueOf(cod)+" --> "+e); |
|
97 |
// TODO Auto-generated catch block |
|
98 |
//e.printStackTrace(); |
|
99 |
} |
|
100 |
} |
|
101 |
for (int i = 0; i< res.size(); i++) { |
|
102 |
System.out.println(res.get(i)); |
|
103 |
} |
|
104 |
for (int i = 0; i< units.size(); i++) { |
|
105 |
System.out.println(units.get(i)); |
|
106 |
} |
|
107 |
System.out.println("Numero CRSs validos: " + validos.size()); |
|
108 |
System.out.println("Numero CRSs fallidos: " + res.size()); |
|
109 |
System.out.println("Numero medidas: " + units.size()); |
|
110 |
} catch (SQLException e1) { |
|
111 |
// TODO Auto-generated catch block |
|
112 |
e1.printStackTrace(); |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
} |
|
117 |
|
|
118 |
|
|
119 |
/*CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); |
|
120 |
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:23032"); |
|
121 |
|
|
122 |
MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS); |
|
123 |
System.out.println("Dimensiones: "+transform.getSourceDimensions()); |
|
124 |
double points[] = {2.5,3.0}; |
|
125 |
System.out.println("Puntos fuente: "+ points[0]+" "+points[1]); |
|
126 |
transform.transform(points, 0, points, 0, 1); |
|
127 |
System.out.println("Puntos destino: "+ points[0]+" "+points[1]); |
|
128 |
|
|
129 |
int epsgCount = 0; |
|
130 |
System.out.println("CRSs Disponibles en EPSG: \n"); |
|
131 |
Set codes = CRS.getSupportedCodes("EPSG"); |
|
132 |
for (Iterator iter = codes.iterator(); iter.hasNext();) { |
|
133 |
String code = (String) iter.next(); |
|
134 |
System.out.println("EPSG:"+code); |
|
135 |
epsgCount++; |
|
136 |
} |
|
137 |
System.out.println("N�mero de CRSs en EPSG: "+epsgCount); |
|
138 |
try { |
|
139 |
System.out.println("Descripci�n de EPSG:23030: \n"+CRS.getAuthorityFactory(false).getDescriptionText("EPSG:23030")); |
|
140 |
} catch (FactoryRegistryException e) { |
|
141 |
// TODO Auto-generated catch block |
|
142 |
e.printStackTrace(); |
|
143 |
} catch (FactoryException e) { |
|
144 |
// TODO Auto-generated catch block |
|
145 |
e.printStackTrace(); |
|
146 |
} |
|
147 |
|
|
148 |
} catch (NoSuchAuthorityCodeException e) { |
|
149 |
// TODO Auto-generated catch block |
|
150 |
e.printStackTrace(); |
|
151 |
} catch (FactoryException e) { |
|
152 |
// TODO Auto-generated catch block |
|
153 |
e.printStackTrace(); |
|
154 |
}*/ |
|
155 |
|
|
0 | 156 |
tags/JCRS_V02_BN11/libJCRS/src-test/es/idr/test/InsertUserDataCrs.java | ||
---|---|---|
1 |
package es.idr.test; |
|
2 |
|
|
3 |
import java.sql.SQLException; |
|
4 |
|
|
5 |
import es.idr.teledeteccion.connection.EpsgConnection; |
|
6 |
|
|
7 |
|
|
8 |
public class InsertUserDataCrs { |
|
9 |
|
|
10 |
/** |
|
11 |
* @param args |
|
12 |
*/ |
|
13 |
public static void main(String[] args) { |
|
14 |
// TODO Auto-generated method stub |
|
15 |
EpsgConnection conn = new EpsgConnection(); |
|
16 |
conn.setConnectionUsr(); |
|
17 |
|
|
18 |
String sentence = "INSERT INTO USR VALUES(2000,'PROJCS[\"Anguilla_1957_British_West_Indies_Grid\",GEOGCS[\"GCS_Anguilla_1957\",DATUM[\"D_Anguilla_1957\",SPHEROID[\"Clarke_1880_RGS\",6378249.145,293.465]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",400000.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-62.0],PARAMETER[\"Scale_Factor\",0.9995],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]','Anguilla_1957_British_West_Indies_Grid','GCS_Anguilla_1957','D_Anguilla_1957')"; |
|
19 |
|
|
20 |
try { |
|
21 |
conn.update(sentence); |
|
22 |
conn.shutdown(); |
|
23 |
} catch (SQLException e) { |
|
24 |
// TODO Auto-generated catch block |
|
25 |
e.printStackTrace(); |
|
26 |
} |
|
27 |
} |
|
28 |
|
|
29 |
} |
|
0 | 30 |
tags/JCRS_V02_BN11/libJCRS/src-test/es/idr/test/TestWKTandProj4Epsg.java | ||
---|---|---|
1 |
package es.idr.test; |
|
2 |
|
|
3 |
import java.io.BufferedWriter; |
|
4 |
import java.io.FileWriter; |
|
5 |
import java.io.IOException; |
|
6 |
import java.sql.Connection; |
|
7 |
import java.sql.PreparedStatement; |
|
8 |
import java.sql.ResultSet; |
|
9 |
import java.sql.SQLException; |
|
10 |
import java.util.ArrayList; |
|
11 |
|
|
12 |
import javax.units.ConversionException; |
|
13 |
|
|
14 |
import org.geotools.referencing.factory.epsg.HSQLDataSource; |
|
15 |
import org.geotools.referencing.wkt.UnformattableObjectException; |
|
16 |
import org.gvsig.crs.Crs; |
|
17 |
import org.gvsig.crs.CrsException; |
|
18 |
import org.gvsig.crs.CrsFactory; |
|
19 |
import org.gvsig.crs.CrsGT; |
|
20 |
import org.gvsig.crs.ICrs; |
|
21 |
import org.gvsig.crs.Proj4; |
|
22 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
23 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
24 |
|
|
25 |
public class TestWKTandProj4Epsg { |
|
26 |
|
|
27 |
public static void main(String[] args) { |
|
28 |
HSQLDataSource ds = new HSQLDataSource(); |
|
29 |
Connection conn; |
|
30 |
try { |
|
31 |
conn = ds.getConnection(); |
|
32 |
int indice = 0; |
|
33 |
int fallo = 0; |
|
34 |
final PreparedStatement stmt; |
|
35 |
stmt = conn.prepareStatement("SELECT COORD_REF_SYS_CODE, COORD_REF_SYS_NAME" |
|
36 |
+" FROM epsg_coordinatereferencesystem "); |
|
37 |
//+" WHERE COORD_REF_SYS_CODE>29372"); |
|
38 |
ResultSet result; |
|
39 |
|
|
40 |
result = stmt.executeQuery(); |
|
41 |
|
|
42 |
String filename = "salida.txt"; |
|
43 |
|
|
44 |
BufferedWriter bw = new BufferedWriter(new FileWriter(filename)); |
|
45 |
|
|
46 |
while (result.next()) { |
|
47 |
ICrs crs = null; |
|
48 |
int cod = result.getInt("COORD_REF_SYS_CODE"); |
|
49 |
try { |
|
50 |
|
|
51 |
crs = new CrsFactory().getCRS("EPSG:"+cod); |
|
52 |
if (crs instanceof CrsGT) { |
|
53 |
// //continue; |
|
54 |
if (crs.getProj4String() == null){ |
|
55 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
56 |
bw.write("Cadena WKT: "+crs.getWKT()+"\n"); |
|
57 |
bw.write("Cadena Proj4: No cadena proj4 \n"); |
|
58 |
bw.write("Fallo: Fallo generando en cadena proj4 \n"); |
|
59 |
bw.write("\n\n"); |
|
60 |
} |
|
61 |
} |
|
62 |
else { |
|
63 |
if (crs != null) { |
|
64 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
65 |
bw.write("Cadena WKT: "+crs.getWKT()+"\n"); |
|
66 |
bw.write("Cadena Proj4: "+crs.getProj4String()+"\n"); |
|
67 |
bw.write("Fallo: Creado con crs antiguo \n"); |
|
68 |
bw.write("\n\n"); |
|
69 |
} |
|
70 |
else { |
|
71 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
72 |
bw.write("Fallo: Falla tanto geotools como crs antiguo \n"); |
|
73 |
bw.write("\n\n"); |
|
74 |
} |
|
75 |
|
|
76 |
} |
|
77 |
|
|
78 |
|
|
79 |
} catch (CrsException e) { |
|
80 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
81 |
bw.write("Cadena WKT: No cadena wkt \n"); |
|
82 |
bw.write("Cadena Proj4: No cadena proj4\n"); |
|
83 |
bw.write("Fallo: "+e+" \n"); |
|
84 |
bw.write("\n\n"); |
|
85 |
} catch (NumberFormatException e) { |
|
86 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
87 |
bw.write("Cadena WKT: No cadena wkt \n"); |
|
88 |
bw.write("Cadena Proj4: No cadena proj4\n"); |
|
89 |
bw.write("Fallo: "+e+" \n"); |
|
90 |
bw.write("\n\n"); |
|
91 |
} catch (ConversionException e) { |
|
92 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
93 |
bw.write("Cadena WKT: No cadena wkt \n"); |
|
94 |
bw.write("Cadena Proj4: No cadena proj4\n"); |
|
95 |
bw.write("Fallo: "+e+" \n"); |
|
96 |
bw.write("\n\n"); |
|
97 |
}catch (UnformattableObjectException e) { |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
bw.flush(); |
|
102 |
bw.close(); |
|
103 |
|
|
104 |
} catch (SQLException e1) { |
|
105 |
// TODO Auto-generated catch block |
|
106 |
e1.printStackTrace(); |
|
107 |
} catch (IOException e) { |
|
108 |
// TODO Auto-generated catch block |
|
109 |
e.printStackTrace(); |
|
110 |
} |
|
111 |
} |
|
112 |
} |
|
0 | 113 |
tags/JCRS_V02_BN11/libJCRS/src-test/es/idr/test/ValidateEsriCRSs.java | ||
---|---|---|
1 |
package es.idr.test; |
|
2 |
|
|
3 |
import java.sql.Connection; |
|
4 |
import java.sql.PreparedStatement; |
|
5 |
import java.sql.ResultSet; |
|
6 |
import java.sql.SQLException; |
|
7 |
import java.util.ArrayList; |
|
8 |
|
|
9 |
import javax.units.Unit; |
|
10 |
|
|
11 |
import org.geotools.referencing.CRS; |
|
12 |
import org.geotools.referencing.crs.DefaultGeographicCRS; |
|
13 |
import org.geotools.referencing.crs.DefaultProjectedCRS; |
|
14 |
import org.geotools.referencing.datum.DefaultGeodeticDatum; |
|
15 |
import org.geotools.referencing.factory.epsg.HSQLDataSource; |
|
16 |
import org.opengis.referencing.FactoryException; |
|
17 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
18 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
19 |
|
|
20 |
import es.idr.teledeteccion.connection.EpsgConnection; |
|
21 |
import es.idr.teledeteccion.connection.Query; |
|
22 |
|
|
23 |
public class ValidateEsriCRSs { |
|
24 |
|
|
25 |
public ValidateEsriCRSs() { |
|
26 |
|
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* @param args |
|
31 |
*/ |
|
32 |
public static void main(String[] args) { |
|
33 |
//HSQLDataSource ds = new HSQLDataSource(); |
|
34 |
EpsgConnection conn = new EpsgConnection(); |
|
35 |
//Connection conn; |
|
36 |
conn.setConnectionEsri(); |
|
37 |
try { |
|
38 |
//conn = ds.getConnection(); |
|
39 |
|
|
40 |
//final PreparedStatement stmt; |
|
41 |
/*stmt = conn.prepareStatement("SELECT esri_code" |
|
42 |
+ " FROM esri"); |
|
43 |
*/ |
|
44 |
String sentence = "SELECT esri_code,esri_wkt " + |
|
45 |
"FROM ESRI"; |
|
46 |
ResultSet result; |
|
47 |
result = Query.select(sentence,conn.getConnection()); |
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
//result = stmt.executeQuery(); |
|
52 |
|
|
53 |
ArrayList res = new ArrayList(); |
|
54 |
ArrayList units = new ArrayList(); |
|
55 |
ArrayList validos = new ArrayList(); |
|
56 |
while (result.next()) { |
|
57 |
int cod = result.getInt("esri_code"); |
|
58 |
String wkt = result.getString("esri_wkt"); |
|
59 |
//String strEpsgCode="ESRI:"+cod; |
|
60 |
CoordinateReferenceSystem source; |
|
61 |
|
|
62 |
/*try { |
|
63 |
source = CRS.parseWKT(wkt); |
|
64 |
validos.add(String.valueOf(cod)); |
|
65 |
if (source instanceof DefaultProjectedCRS) { |
|
66 |
String str; |
|
67 |
boolean esta = false; |
|
68 |
DefaultProjectedCRS sour = (DefaultProjectedCRS) source; |
|
69 |
|
|
70 |
Unit u = ((DefaultGeodeticDatum) sour.getDatum()).getPrimeMeridian().getAngularUnit(); |
|
71 |
units.add(u.toString()); |
|
72 |
|
|
73 |
for (int j = 0; j< units.size(); j++) { |
|
74 |
if (units.get(j).equals(u.toString())){ |
|
75 |
esta = true; |
|
76 |
break; |
|
77 |
} |
|
78 |
} |
|
79 |
if (!esta){ |
|
80 |
units.add(u.toString()); |
|
81 |
esta = false; |
|
82 |
} |
|
83 |
for (int i=0; i< sour.getConversionFromBase().getParameterValues().values().size();i++) { |
|
84 |
str = sour.getConversionFromBase().getParameterValues().values().get(i).toString(); |
|
85 |
u = sour.getConversionFromBase().getParameterValues().parameter(str.split("=")[0]).getUnit(); |
|
86 |
units.add(u.toString()); |
|
87 |
|
|
88 |
} |
|
89 |
} |
|
90 |
if (source instanceof DefaultGeographicCRS) { |
|
91 |
DefaultGeographicCRS sour = (DefaultGeographicCRS) source; |
|
92 |
boolean esta = false; |
|
93 |
Unit u = ((DefaultGeodeticDatum) sour.getDatum()).getPrimeMeridian().getAngularUnit(); |
|
94 |
units.add(u.toString()); |
|
95 |
|
|
96 |
} |
|
97 |
} catch (NoSuchAuthorityCodeException e) { |
|
98 |
res.add(String.valueOf(cod)+" --> "+e); |
|
99 |
// TODO Auto-generated catch block |
|
100 |
//e.printStackTrace(); |
|
101 |
} catch (FactoryException e) { |
|
102 |
res.add(String.valueOf(cod)+" --> "+e); |
|
103 |
// TODO Auto-generated catch block |
|
104 |
//e.printStackTrace(); |
|
105 |
}*/ |
|
106 |
} |
|
107 |
/*for (int i = 0; i< res.size(); i++) { |
|
108 |
System.out.println(res.get(i)); |
|
109 |
}*/ |
|
110 |
for (int i = 0; i< units.size(); i++) { |
|
111 |
System.out.println(units.get(i)); |
|
112 |
} |
|
113 |
System.out.println("Numero CRSs validos: " + validos.size()); |
|
114 |
System.out.println("Numero medidas: " + units.size()); |
|
115 |
System.out.println("Numero CRSs fallidos: " + res.size()); |
|
116 |
} catch (SQLException e1) { |
|
117 |
// TODO Auto-generated catch block |
|
118 |
e1.printStackTrace(); |
|
119 |
} |
|
120 |
} |
|
121 |
} |
|
0 | 122 |
tags/JCRS_V02_BN11/libJCRS/src-test/es/idr/test/TestGeotools21.java | ||
---|---|---|
1 |
package es.idr.test; |
|
2 |
|
|
3 |
import org.geotools.referencing.CRS; |
|
4 |
import org.opengis.referencing.FactoryException; |
|
5 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
6 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
7 |
|
|
8 |
public class TestGeotools21 { |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @param args |
|
13 |
*/ |
|
14 |
public static void main(String[] args) { |
|
15 |
try { |
|
16 |
String strEpsgCode="EPSG:27572"; |
|
17 |
CoordinateReferenceSystem source; |
|
18 |
source = CRS.decode(strEpsgCode); |
|
19 |
System.out.println(source.toWKT()); |
|
20 |
|
|
21 |
} catch (NoSuchAuthorityCodeException e) { |
|
22 |
// TODO Auto-generated catch block |
|
23 |
e.printStackTrace(); |
|
24 |
} catch (FactoryException e) { |
|
25 |
// TODO Auto-generated catch block |
|
26 |
e.printStackTrace(); |
|
27 |
} |
|
28 |
} |
|
29 |
|
|
30 |
} |
|
0 | 31 |
tags/JCRS_V02_BN11/libJCRS/src-test/es/idr/test/connection/UsrConnection.java | ||
---|---|---|
1 |
package es.idr.test.connection; |
|
2 |
|
|
3 |
import java.sql.Connection; |
|
4 |
import java.sql.DriverManager; |
|
5 |
import java.sql.SQLException; |
|
6 |
import java.sql.Statement; |
|
7 |
|
|
8 |
public class UsrConnection { |
|
9 |
|
|
10 |
Connection connect; |
|
11 |
|
|
12 |
public UsrConnection() { |
|
13 |
try { |
|
14 |
Class.forName("org.hsqldb.jdbcDriver"); |
|
15 |
} catch (ClassNotFoundException e) { |
|
16 |
e.printStackTrace(); |
|
17 |
} |
|
18 |
|
|
19 |
try { |
|
20 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:/home/jlgomez/gvSIGF2/gt2-usr-hsql/src/org/geotools/referencing/factory/usr/usr", "sa", ""); |
|
21 |
} catch (SQLException e1) { |
|
22 |
e1.printStackTrace(); |
|
23 |
} |
|
24 |
} |
|
25 |
|
|
26 |
public Connection getConnection(){ |
|
27 |
return connect; |
|
28 |
} |
|
29 |
|
|
30 |
public void shutdown() throws SQLException { |
|
31 |
|
|
32 |
Statement st = connect.createStatement(); |
|
33 |
|
|
34 |
// db writes out to files and performs clean shuts down |
|
35 |
// otherwise there will be an unclean shutdown |
|
36 |
// when program ends |
|
37 |
st.execute("SHUTDOWN"); |
|
38 |
connect.close(); // if there are no other open connection |
|
39 |
} |
|
40 |
|
|
41 |
public synchronized void update(String expression) throws SQLException { |
|
42 |
|
|
43 |
Statement st = null; |
|
44 |
|
|
45 |
st = connect.createStatement(); // statements |
|
46 |
|
|
47 |
int i = st.executeUpdate(expression); // run the query |
|
48 |
|
|
49 |
if (i == -1) { |
|
50 |
System.out.println("db error : " + expression); |
|
51 |
} |
|
52 |
|
|
53 |
st.close(); |
|
54 |
} |
|
55 |
} |
|
0 | 56 |
tags/JCRS_V02_BN11/libJCRS/src-test/es/idr/test/connection/TestConnection.java | ||
---|---|---|
1 |
package es.idr.test.connection; |
|
2 |
|
|
3 |
|
|
4 |
import java.sql.ResultSet; |
|
5 |
import java.sql.SQLException; |
|
6 |
|
|
7 |
import es.idr.teledeteccion.connection.EpsgConnection; |
|
8 |
import es.idr.teledeteccion.connection.Query; |
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
public class TestConnection { |
|
13 |
|
|
14 |
public TestConnection () { |
|
15 |
testEpsgDataBase(); |
|
16 |
testEsriDataBase(); |
|
17 |
testIau2000DataBase(); |
|
18 |
} |
|
19 |
/** |
|
20 |
* @param args |
|
21 |
*/ |
|
22 |
public static void main(String[] args) { |
|
23 |
// TODO Auto-generated method stub |
|
24 |
TestConnection tc = new TestConnection(); |
|
25 |
|
|
26 |
|
|
27 |
} |
|
28 |
|
|
29 |
private void testEpsgDataBase() { |
|
30 |
EpsgConnection connect = new EpsgConnection(); |
|
31 |
connect.setConnectionEPSG(); |
|
32 |
String sentence = "SELECT coord_ref_sys_name " + |
|
33 |
"FROM epsg_coordinatereferencesystem " + |
|
34 |
"WHERE coord_ref_sys_code = 23030"; |
|
35 |
|
|
36 |
ResultSet result; |
|
37 |
try { |
|
38 |
result = Query.select(sentence,connect.getConnection()); |
|
39 |
result.next(); |
|
40 |
System.out.println(result.getString("coord_ref_sys_name")); |
|
41 |
} catch (SQLException e) { |
|
42 |
// TODO Auto-generated catch block |
|
43 |
e.printStackTrace(); |
|
44 |
} |
|
45 |
} |
|
46 |
|
|
47 |
private void testEsriDataBase (){ |
|
48 |
EpsgConnection connect = new EpsgConnection(); |
|
49 |
connect.setConnectionEsri(); |
|
50 |
String sentence = "SELECT esri_proj " + |
|
51 |
"FROM ESRI " + |
|
52 |
"WHERE esri_code = 23030"; |
|
53 |
|
|
54 |
ResultSet result = null; |
|
55 |
try { |
|
56 |
result = Query.select(sentence,connect.getConnection()); |
|
57 |
result.next(); |
|
58 |
System.out.println(result.getString("esri_proj")); |
|
59 |
} catch (SQLException e) { |
|
60 |
// TODO Auto-generated catch block |
|
61 |
e.printStackTrace(); |
|
62 |
} |
|
63 |
|
|
64 |
} |
|
65 |
|
|
66 |
private void testIau2000DataBase() { |
|
67 |
EpsgConnection connect = new EpsgConnection(); |
|
68 |
connect.setConnectionIAU2000(); |
|
69 |
String sentence = "SELECT iau_geog " + |
|
70 |
"FROM IAU2000 " + |
|
71 |
"WHERE iau_code = 19900"; |
|
72 |
|
|
73 |
ResultSet result = null; |
|
74 |
try { |
|
75 |
result = Query.select(sentence,connect.getConnection()); |
|
76 |
result.next(); |
|
77 |
System.out.println(result.getString("iau_geog")); |
|
78 |
} catch (SQLException e) { |
|
79 |
// TODO Auto-generated catch block |
|
80 |
e.printStackTrace(); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
} |
|
0 | 85 |
tags/JCRS_V02_BN11/libJCRS/src-test/es/idr/crs/crsGT/ProvidersTest.java | ||
---|---|---|
1 |
package es.idr.crs.crsGT; |
|
2 |
|
|
3 |
import java.util.Arrays; |
|
4 |
import java.util.Iterator; |
|
5 |
|
|
6 |
import org.geotools.factory.FactoryRegistry; |
|
7 |
import org.geotools.referencing.operation.MathTransformProvider; |
|
8 |
|
|
9 |
public class ProvidersTest { |
|
10 |
|
|
11 |
|
|
12 |
public static void main(String[] args) { |
|
13 |
final Class[] categories = {org.geotools.referencing.operation.MathTransformProvider.class}; |
|
14 |
FactoryRegistry registry = new FactoryRegistry(Arrays.asList(categories)); |
|
15 |
Iterator providers = registry.getServiceProviders(MathTransformProvider.class); |
|
16 |
Iterator providers2 = null; |
|
17 |
MathTransformProvider provider = null; |
|
18 |
MathTransformProvider provider2 = null; |
|
19 |
while (providers.hasNext()){ |
|
20 |
provider = (MathTransformProvider) providers.next(); |
|
21 |
if(provider.nameMatches("IDR")){ |
|
22 |
providers2 = registry.getServiceProviders(MathTransformProvider.class); |
|
23 |
while (providers2.hasNext()){ |
|
24 |
provider2 = (MathTransformProvider) providers2.next(); |
|
25 |
if(provider2.nameMatches(provider.getName().toString()) && !provider2.nameMatches("IDR")) |
|
26 |
registry.deregisterServiceProvider(provider2, categories[0]); |
|
27 |
} |
|
28 |
} |
|
29 |
} |
|
30 |
providers = registry.getServiceProviders(MathTransformProvider.class); |
|
31 |
while (providers.hasNext()) { |
|
32 |
provider = (MathTransformProvider) providers.next(); |
|
33 |
if (provider.nameMatches("IDR")) |
|
34 |
System.out.println("-IDR-"+provider.toString()); |
|
35 |
else |
|
36 |
System.out.println(provider.toString()); |
|
37 |
} |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
0 | 41 |
tags/JCRS_V02_BN11/libJCRS/src-test/es/idr/crs/crsGT/CrsGTTest.java | ||
---|---|---|
1 |
package es.idr.crs.crsGT; |
|
2 |
|
|
3 |
import org.cresques.cts.IProjection; |
|
4 |
import org.gvsig.crs.CrsException; |
|
5 |
import org.gvsig.crs.CrsGT; |
|
6 |
import org.gvsig.crs.ICrs; |
|
7 |
import org.gvsig.crs.Proj4; |
|
8 |
import org.gvsig.crs.repository.EpsgRepositoryGT; |
|
9 |
import org.gvsig.crs.repository.EsriRepositoryGT; |
|
10 |
import org.gvsig.crs.repository.Iau2000RepositoryGT; |
|
11 |
import org.gvsig.crs.repository.UsrRepositoryGT; |
|
12 |
|
|
13 |
public class CrsGTTest { |
|
14 |
|
|
15 |
public CrsGTTest() { |
|
16 |
epsgTest(); |
|
17 |
esriTest(); |
|
18 |
iau2000Test(); |
|
19 |
usrTest(); |
|
20 |
} |
|
21 |
/** |
|
22 |
* @param args |
|
23 |
*/ |
|
24 |
public static void main(String[] args) { |
|
25 |
CrsGTTest g = new CrsGTTest(); |
|
26 |
} |
|
27 |
|
|
28 |
public void epsgTest() { |
|
29 |
EpsgRepositoryGT repo = new EpsgRepositoryGT(); |
|
30 |
IProjection crs=null; |
|
31 |
crs = repo.getCrs("23030"); |
|
32 |
if (crs!=null){ |
|
33 |
System.out.println(crs.getAbrev()); |
|
34 |
System.out.println(((ICrs)crs).getCode()); |
|
35 |
System.out.println(((ICrs)crs).getWKT()); |
|
36 |
System.out.println(((ICrs)crs).getDatum().getEIFlattening()); |
|
37 |
System.out.println(((ICrs)crs).getDatum().getESemiMajorAxis()); |
|
38 |
System.out.println(((ICrs)crs).isProjected()+"\n\n"); |
|
39 |
|
|
40 |
System.out.println("----------- CrsWkt:--------------"); |
|
41 |
System.out.println(((ICrs)crs).getCrsWkt().getAuthority()[0]+":"+((ICrs)crs).getCrsWkt().getAuthority()[1]); |
|
42 |
System.out.println(((ICrs)crs).getCrsWkt().getName()); |
|
43 |
System.out.println(((ICrs)crs).getCrsWkt().getDatumName()); |
|
44 |
System.out.println(((ICrs)crs).getCrsWkt().getGeogcs()); |
|
45 |
System.out.println(((ICrs)crs).getCrsWkt().getProjcs()); |
|
46 |
System.out.println(((ICrs)crs).getCrsWkt().getProjection()); |
|
47 |
System.out.println(((ICrs)crs).getCrsWkt().getPrimen()[0]+" -- "+ ((ICrs)crs).getCrsWkt().getPrimen()[1]+"\n\n"); |
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
try { |
|
52 |
Proj4 proj4 = new Proj4(); |
|
53 |
System.out.println(proj4.exportToProj4(((CrsGT)crs).getCrsGT())); |
|
54 |
} catch (CrsException e) { |
|
55 |
// TODO Auto-generated catch block |
|
56 |
e.printStackTrace(); |
|
57 |
} |
|
58 |
|
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
public void esriTest() { |
|
63 |
EsriRepositoryGT repo = new EsriRepositoryGT(); |
|
64 |
IProjection crs=null; |
|
65 |
crs = repo.getCrs("23030"); |
|
66 |
if (crs!=null){ |
|
67 |
System.out.println(crs.getAbrev()); |
|
68 |
System.out.println(((ICrs)crs).getCode()); |
|
69 |
System.out.println(((ICrs)crs).getWKT()); |
|
70 |
System.out.println(((ICrs)crs).getDatum().getEIFlattening()); |
|
71 |
System.out.println(((ICrs)crs).getDatum().getESemiMajorAxis()); |
|
72 |
System.out.println(((ICrs)crs).isProjected()+"\n\n"); |
|
73 |
|
|
74 |
System.out.println("----------- CrsWkt:--------------"); |
|
75 |
System.out.println(((ICrs)crs).getCrsWkt().getAuthority()[0]+":"+((ICrs)crs).getCrsWkt().getAuthority()[1]); |
|
76 |
System.out.println(((ICrs)crs).getCrsWkt().getName()); |
|
77 |
System.out.println(((ICrs)crs).getCrsWkt().getDatumName()); |
|
78 |
System.out.println(((ICrs)crs).getCrsWkt().getGeogcs()); |
|
79 |
System.out.println(((ICrs)crs).getCrsWkt().getProjcs()); |
|
80 |
System.out.println(((ICrs)crs).getCrsWkt().getProjection()); |
|
81 |
System.out.println(((ICrs)crs).getCrsWkt().getPrimen()[0]+" -- "+ ((ICrs)crs).getCrsWkt().getPrimen()[1]+"\n\n"); |
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
try { |
|
86 |
Proj4 proj4 = new Proj4(); |
|
87 |
System.out.println(proj4.exportToProj4(((CrsGT)crs).getCrsGT())); |
|
88 |
} catch (CrsException e) { |
|
89 |
// TODO Auto-generated catch block |
|
90 |
e.printStackTrace(); |
|
91 |
} |
|
92 |
|
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
public void iau2000Test() { |
|
97 |
Iau2000RepositoryGT repo = new Iau2000RepositoryGT(); |
|
98 |
IProjection crs=null; |
|
99 |
crs = repo.getCrs("19900"); |
|
100 |
if (crs!=null){ |
|
101 |
System.out.println(crs.getAbrev()); |
|
102 |
System.out.println(((ICrs)crs).getCode()); |
|
103 |
System.out.println(((ICrs)crs).getWKT()); |
|
104 |
System.out.println(((ICrs)crs).getDatum().getEIFlattening()); |
|
105 |
System.out.println(((ICrs)crs).getDatum().getESemiMajorAxis()); |
|
106 |
System.out.println(((ICrs)crs).isProjected()+"\n\n"); |
|
107 |
|
|
108 |
System.out.println("----------- CrsWkt:--------------"); |
|
109 |
System.out.println(((ICrs)crs).getCrsWkt().getAuthority()[0]+":"+((ICrs)crs).getCrsWkt().getAuthority()[1]); |
|
110 |
System.out.println(((ICrs)crs).getCrsWkt().getName()); |
|
111 |
System.out.println(((ICrs)crs).getCrsWkt().getDatumName()); |
|
112 |
System.out.println(((ICrs)crs).getCrsWkt().getGeogcs()); |
|
113 |
System.out.println(((ICrs)crs).getCrsWkt().getProjcs()); |
|
114 |
System.out.println(((ICrs)crs).getCrsWkt().getProjection()); |
|
115 |
System.out.println(((ICrs)crs).getCrsWkt().getPrimen()[0]+" -- "+ ((ICrs)crs).getCrsWkt().getPrimen()[1]+"\n\n"); |
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
try { |
|
120 |
Proj4 proj4 = new Proj4(); |
|
121 |
System.out.println(proj4.exportToProj4(((CrsGT)crs).getCrsGT())); |
|
122 |
} catch (CrsException e) { |
|
123 |
// TODO Auto-generated catch block |
|
124 |
e.printStackTrace(); |
|
125 |
} |
|
126 |
|
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
public void usrTest() { |
|
131 |
UsrRepositoryGT repo = new UsrRepositoryGT(); |
|
132 |
IProjection crs=null; |
|
133 |
crs = repo.getCrs("2000"); |
|
134 |
if (crs!=null){ |
|
135 |
System.out.println(crs.getAbrev()); |
|
136 |
System.out.println(((ICrs)crs).getCode()); |
|
137 |
System.out.println(((ICrs)crs).getWKT()); |
|
138 |
System.out.println(((ICrs)crs).getDatum().getEIFlattening()); |
|
139 |
System.out.println(((ICrs)crs).getDatum().getESemiMajorAxis()); |
|
140 |
System.out.println(((ICrs)crs).isProjected()+"\n\n"); |
|
141 |
|
|
142 |
System.out.println("----------- CrsWkt:--------------"); |
|
143 |
System.out.println(((ICrs)crs).getCrsWkt().getAuthority()[0]+":"+((ICrs)crs).getCrsWkt().getAuthority()[1]); |
|
144 |
System.out.println(((ICrs)crs).getCrsWkt().getName()); |
|
145 |
System.out.println(((ICrs)crs).getCrsWkt().getDatumName()); |
|
146 |
System.out.println(((ICrs)crs).getCrsWkt().getGeogcs()); |
|
147 |
System.out.println(((ICrs)crs).getCrsWkt().getProjcs()); |
|
148 |
System.out.println(((ICrs)crs).getCrsWkt().getProjection()); |
|
149 |
System.out.println(((ICrs)crs).getCrsWkt().getPrimen()[0]+" -- "+ ((ICrs)crs).getCrsWkt().getPrimen()[1]+"\n\n"); |
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
try { |
|
154 |
Proj4 proj4 = new Proj4(); |
|
155 |
System.out.println(proj4.exportToProj4(((CrsGT)crs).getCrsGT())); |
|
156 |
} catch (CrsException e) { |
|
157 |
// TODO Auto-generated catch block |
|
158 |
e.printStackTrace(); |
|
159 |
} |
|
160 |
|
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
} |
|
0 | 165 |
tags/JCRS_V02_BN11/libJCRS/src-test/org/gvsig/crs/jscrollpanel/ScrollPanelTest.java | ||
---|---|---|
1 |
package org.gvsig.crs.jscrollpanel; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
|
|
5 |
import javax.swing.BorderFactory; |
|
6 |
import javax.swing.JFrame; |
|
7 |
import javax.swing.JScrollPane; |
|
8 |
import javax.swing.JTable; |
|
9 |
import javax.swing.table.DefaultTableModel; |
|
10 |
import javax.swing.table.TableColumn; |
|
11 |
|
|
12 |
public class ScrollPanelTest { |
|
13 |
|
|
14 |
JTable jTable = null; |
|
15 |
JScrollPane jScrollPane = null; |
|
16 |
|
|
17 |
public ScrollPanelTest() { |
|
18 |
super(); |
|
19 |
JFrame jFrame = new JFrame(); |
|
20 |
jFrame.getContentPane().add(getJScrollPane()); |
|
21 |
jFrame.setSize(500, 150); |
|
22 |
jFrame.setVisible(true); |
|
23 |
// TODO Auto-generated constructor stub |
|
24 |
} |
|
25 |
|
|
26 |
public JTable getJTable() { |
|
27 |
if (jTable == null) { |
|
28 |
String[] columnNames= {"UNA COLUMNA", "DOS COLUMNAS"}; |
|
29 |
Object[][]data = {}; |
|
30 |
DefaultTableModel dtm = new DefaultTableModel(data, columnNames); |
|
31 |
jTable = new JTable(dtm); |
|
32 |
jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
|
33 |
TableColumn column = null; |
|
34 |
for (int i = 0; i < 2; i++) { |
|
35 |
column = jTable.getColumnModel().getColumn(i); |
|
36 |
if (i == 0) { |
|
37 |
column.setPreferredWidth(600); |
|
38 |
} |
|
39 |
} |
|
40 |
//jTable.setPreferredSize(new Dimension(800, 100)); |
|
41 |
|
|
42 |
} |
|
43 |
|
|
44 |
return jTable; |
|
45 |
|
|
46 |
} |
|
47 |
|
|
48 |
|
|
49 |
private JScrollPane getJScrollPane() { |
|
50 |
if (jScrollPane == null) { |
|
51 |
jScrollPane = new JScrollPane(getJTable(),JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); |
|
52 |
jScrollPane.setPreferredSize(new Dimension(500,150)); |
|
53 |
jScrollPane.setBorder( |
|
54 |
BorderFactory.createCompoundBorder( |
|
55 |
BorderFactory.createCompoundBorder( |
|
56 |
BorderFactory.createTitledBorder("TABLA GEN?RICA DE 2 CAMPOS"), |
|
57 |
BorderFactory.createEmptyBorder(5,5,5,5)), |
|
58 |
jScrollPane.getBorder())); |
|
59 |
jScrollPane.setViewportView(getJTable()); |
|
60 |
} |
|
61 |
return jScrollPane; |
|
62 |
} |
|
63 |
|
|
64 |
|
|
65 |
public static void main(String[] args){ |
|
66 |
ScrollPanelTest al = new ScrollPanelTest(); |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
} |
|
0 | 72 |
tags/JCRS_V02_BN11/libJCRS/src-test/org/gvsig/crs/repository/RepositoryTest.java | ||
---|---|---|
1 |
package org.gvsig.crs.repository; |
|
2 |
|
|
3 |
import org.gvsig.crs.Crs; |
|
4 |
|
|
5 |
|
|
6 |
public class RepositoryTest { |
|
7 |
public static void main(String[] args){ |
|
8 |
EpsgRepository epsgRep= new EpsgRepository(); |
|
9 |
Crs crs = (Crs)epsgRep.getCrs("23030"); |
|
10 |
if (crs != null){ |
|
11 |
String abrev = crs.getAbrev(); |
|
12 |
System.out.println(abrev); |
|
13 |
} |
|
14 |
else |
|
15 |
System.out.println("el c?digo no existe en el repositorio."); |
|
16 |
} |
|
17 |
} |
|
0 | 18 |
tags/JCRS_V02_BN11/libJCRS/src/es/idr/teledeteccion/connection/Query.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha) |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package es.idr.teledeteccion.connection; |
|
42 |
|
|
43 |
import java.io.Serializable; |
|
44 |
import java.sql.Connection; |
|
45 |
import java.sql.ResultSet; |
|
46 |
import java.sql.ResultSetMetaData; |
|
47 |
import java.sql.SQLException; |
|
48 |
import java.sql.Statement; |
|
49 |
|
|
50 |
/** |
|
51 |
* Clase para realizar las consultas a las bases de datos utilizadas |
|
52 |
* |
|
53 |
* @author Jos? Luis G?mez Mart?nez (jolugomar@gmail.com) |
|
54 |
* |
|
55 |
*/ |
|
56 |
public class Query implements Serializable{ |
|
57 |
|
|
58 |
/** |
|
59 |
* |
|
60 |
*/ |
|
61 |
private static final long serialVersionUID = 1L; |
|
62 |
|
|
63 |
/** |
|
64 |
* Acepta la sentencia y la conexi?n a la base de datos actual, |
|
65 |
* realiza una selecci?n y devuelve los datos en un ResultSet |
|
66 |
* @param sentence |
|
67 |
* @param conn |
|
68 |
* @return |
|
69 |
*/ |
|
70 |
public static synchronized ResultSet select(String sentence, Connection conn){ |
|
71 |
Statement st = null; |
|
72 |
ResultSet rs = null; |
|
73 |
|
|
74 |
try { |
|
75 |
st = conn.createStatement(); |
|
76 |
rs = st.executeQuery(sentence); |
|
77 |
st.close(); |
|
78 |
} catch (SQLException e) { |
|
79 |
e.printStackTrace(); |
|
80 |
} |
|
81 |
return rs; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
0 | 85 |
tags/JCRS_V02_BN11/libJCRS/src/es/idr/teledeteccion/connection/EpsgConnection.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
Also available in: Unified diff