1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.rugged.raster;
18
19 import org.hipparchus.util.FastMath;
20 import org.orekit.bodies.GeodeticPoint;
21
22 public class CliffsElevationUpdater implements TileUpdater {
23
24 private GeodeticPoint point1;
25 private GeodeticPoint point2;
26 private double top;
27 private double bottom;
28 private double size;
29 private int n;
30
31 public CliffsElevationUpdater(GeodeticPoint point1, GeodeticPoint point2,
32 double top, double bottom,
33 double size, int n) {
34 this.point1 = point1;
35 this.point2 = point2;
36 this.top = top;
37 this.bottom = bottom;
38 this.size = size;
39 this.n = n;
40 }
41
42 public void updateTile(double latitude, double longitude, UpdatableTile tile) {
43
44 double step = size / (n - 1);
45 double minLatitude = size * FastMath.floor(latitude / size);
46 double minLongitude = size * FastMath.floor(longitude / size);
47 double x2Mx1 = point2.getLongitude() - point1.getLongitude();
48 double y2My1 = point2.getLatitude() - point1.getLatitude();
49 tile.setGeometry(minLatitude, minLongitude, step, step, n, n);
50 for (int i = 0; i < n; ++i) {
51 double cellLatitude = minLatitude + i * step;
52 for (int j = 0; j < n; ++j) {
53 double cellLongitude = minLongitude + j * step;
54 double xMx1 = cellLongitude - point1.getLongitude();
55 double yMy1 = cellLatitude - point1.getLatitude();
56 if (yMy1 * x2Mx1 > xMx1 * y2My1) {
57
58 tile.setElevation(i, j, top);
59 } else {
60
61 tile.setElevation(i, j, bottom);
62 }
63 }
64 }
65 }
66
67 }