1   /* Copyright 2013-2025 CS GROUP
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.orekit.rugged.raster;
18  
19  import org.hipparchus.util.FastMath;
20  import org.orekit.bodies.GeodeticPoint;
21  import org.orekit.utils.Constants;
22  
23  public class VolcanicConeElevationUpdater implements TileUpdater {
24  
25      private GeodeticPoint summit;
26      private double        slope;
27      private double        base;
28      private double        size;
29      private int           n;
30  
31      public VolcanicConeElevationUpdater(GeodeticPoint summit, double slope, double base,
32                                          double size, int n) {
33          this.summit = summit;
34          this.slope  = slope;
35          this.base   = base;
36          this.size   = size;
37          this.n      = n;
38      }
39  
40      public void updateTile(double latitude, double longitude, UpdatableTile tile) {
41          
42          double step         = size / (n - 1);
43          double minLatitude  = size * FastMath.floor(latitude  / size);
44          double minLongitude = size * FastMath.floor(longitude / size);
45          double sinSlope     = FastMath.sin(slope);
46          tile.setGeometry(minLatitude, minLongitude, step, step, n, n);
47          for (int i = 0; i < n; ++i) {
48              double cellLatitude = minLatitude + i * step;
49              for (int j = 0; j < n; ++j) {
50                  double cellLongitude = minLongitude + j * step;
51                  double distance       = Constants.WGS84_EARTH_EQUATORIAL_RADIUS *
52                                          FastMath.hypot(cellLatitude  - summit.getLatitude(),
53                                                         cellLongitude - summit.getLongitude());
54                  double altitude = FastMath.max(summit.getAltitude() - distance * sinSlope,
55                                                 base);
56                  tile.setElevation(i, j, altitude);
57              }
58          }
59      }
60  }