36 package gov.sandia.geotess.examples;
42 import gov.
sandia.gmp.util.globals.DataType;
43 import gov.
sandia.gmp.util.globals.InterpolatorType;
44 import gov.
sandia.gmp.util.numerical.vector.VectorGeo;
45 import gov.
sandia.gmp.util.numerical.vector.VectorUnit;
48 import java.util.Date;
81 public static void main(String[] args)
87 "\nMust specify a single command line argument specifying " +
88 "the path to the file geotess_grid_04000.geotess\n");
90 System.out.println(
"Start simple example");
95 GeoTessMetaData metaData =
new GeoTessMetaData();
100 metaData.setDescription(String
101 .format(
"Simple example of a GeoTess model,%n"
102 +
"storing the distance from station ANMO %n"
103 +
"near Albuquerque, New Mexico, USA%n"
104 +
"Lat, lon = 34.9462, -106.4567 degrees.%n"
105 +
"author: Sandy Ballard%n"
106 +
"contact: sballar@sandia.gov%n"));
111 metaData.setLayerNames(
"surface");
122 metaData.setAttributes(
"Distance",
"degrees");
126 metaData.setDataType(DataType.FLOAT);
130 metaData.setModelSoftwareVersion(
"TestSimpleExample 1.0.0");
134 metaData.setModelGenerationDate(
new Date().toString());
140 String gridFile =
new File(args[0]).getCanonicalPath();
145 GeoTessModel model =
new GeoTessModel(gridFile, metaData);
151 double[] anmo = VectorGeo.getVectorDegrees(34.9462, -106.4567);
156 for (
int vtx = 0; vtx < model.getGrid().getNVertices(); ++vtx)
160 double[] vertex = model.getGrid().getVertex(vtx);
163 float distance = (float) VectorUnit.angleDegrees(anmo, vertex);
169 Data data = Data.getDataFloat(distance);
173 model.setProfile(vtx, data);
180 System.out.println(model.toString());
186 GeoTessPosition position = model
187 .getGeoTessPosition(InterpolatorType.LINEAR);
195 position.setTop(layerID, VectorGeo.getVectorDegrees(lat, lon));
198 "Interpolation lat, lon = %7.3f deg, %7.3f deg%n%n",
199 VectorGeo.getLatDegrees(position.getVector()),
200 VectorGeo.getLonDegrees(position.getVector()));
204 double distance = position.getValue(0);
208 System.out.printf(
"Interpolated distance from station ANMO = %1.3f degrees%n%n",
212 double actualDistance = VectorUnit.angle(anmo,
213 position.getVector());
215 System.out.printf(
"Actual distance from station ANMO = %1.3f degrees%n",
216 Math.toDegrees(actualDistance));
218 System.out.println();
221 System.out.printf(
"Interpolated point resides in triangle index = %d%n%n",
222 position.getTriangle());
227 System.out.println(
" Node Lat Lon Coeff");
231 int[] x = position.getVertices();
234 double[] coef = position.getHorizontalCoefficients();
236 for (
int j = 0; j < x.length; ++j)
240 "%6d %10.4f %10.4f %10.6f%n",
242 VectorGeo.getLatDegrees(model.getGrid().getVertex(vtx)),
243 VectorGeo.getLonDegrees(model.getGrid().getVertex(vtx)),
246 System.out.printf(
"%nSimple example completed successfully%n%n");
251 ex.printStackTrace();