public static MeshCoords createMeshCoords(Sector sector) {
    double aspect = sector.getDeltaLonDegrees() / sector.getDeltaLatDegrees();

    float width = 100.0f;
    float height = (float) (width * aspect);

    return new MeshCoords(0f, 0f, height, width);
  }
 private static AffineTransform createTransform(Sector source, MeshCoords destination) {
   java.awt.geom.AffineTransform transform = new java.awt.geom.AffineTransform();
   transform.translate(destination.left, destination.bottom);
   transform.scale(
       (destination.right - destination.left) / source.getDeltaLonDegrees(),
       (destination.top - destination.bottom) / source.getDeltaLatDegrees());
   transform.translate(-source.getMinLongitude().degrees, -source.getMinLatitude().degrees);
   return transform;
 }
  protected static boolean isSectorVisible(
      DrawContext dc, Sector sector, double minDistanceSquared, double maxDistanceSquared) {

    View view = dc.getView();
    Position eyePos = view.getEyePosition();
    if (eyePos == null) return false;

    Angle lat = clampAngle(eyePos.getLatitude(), sector.getMinLatitude(), sector.getMaxLatitude());
    Angle lon =
        clampAngle(eyePos.getLongitude(), sector.getMinLongitude(), sector.getMaxLongitude());
    Vec4 p = dc.getGlobe().computePointFromPosition(lat, lon, 0d);
    double distSquared = dc.getView().getEyePoint().distanceToSquared3(p);
    //noinspection RedundantIfStatement
    if (minDistanceSquared > distSquared || maxDistanceSquared < distSquared) return false;

    return true;
  }
  private static MeshCoords transformSector(AffineTransform transform, Sector sector) {
    java.awt.geom.Point2D p = new java.awt.geom.Point2D.Double();
    java.awt.geom.Point2D ll = new java.awt.geom.Point2D.Double();
    java.awt.geom.Point2D ur = new java.awt.geom.Point2D.Double();

    p.setLocation(sector.getMinLongitude().degrees, sector.getMinLatitude().degrees);
    transform.transform(p, ll);

    p.setLocation(sector.getMaxLongitude().degrees, sector.getMaxLatitude().degrees);
    transform.transform(p, ur);

    return new MeshCoords(
        (float) ur.getY(), // Top
        (float) ll.getX(), // Left
        (float) ll.getY(), // Bottom
        (float) ur.getX()); // Right
  }
  private static MeshTile[] createTiles(LevelSet levelSet, int levelNumber, MeshCoords coords) {
    Sector sector = levelSet.getSector();
    Level level = levelSet.getLevel(levelNumber);
    Angle dLat = level.getTileDelta().getLatitude();
    Angle dLon = level.getTileDelta().getLongitude();
    Angle latOrigin = levelSet.getTileOrigin().getLatitude();
    Angle lonOrigin = levelSet.getTileOrigin().getLongitude();

    // Determine the row and column offset from the common World Wind global tiling origin.
    int firstRow = Tile.computeRow(dLat, sector.getMinLatitude(), latOrigin);
    int firstCol = Tile.computeColumn(dLon, sector.getMinLongitude(), lonOrigin);
    int lastRow = Tile.computeRow(dLat, sector.getMaxLatitude(), latOrigin);
    int lastCol = Tile.computeColumn(dLon, sector.getMaxLongitude(), lonOrigin);

    int numLatTiles = lastRow - firstRow + 1;
    int numLonTiles = lastCol - firstCol + 1;

    AffineTransform sectorTransform = createTransform(sector, coords);

    MeshTile[] tiles = new MeshTile[numLatTiles * numLonTiles];
    int index = 0;

    Angle p1 = Tile.computeRowLatitude(firstRow, dLat, latOrigin);

    for (int row = firstRow; row <= lastRow; row++) {
      Angle p2 = p1.add(dLat);

      Angle t1 = Tile.computeColumnLongitude(firstCol, dLon, lonOrigin);

      for (int col = firstCol; col <= lastCol; col++) {
        Angle t2 = t1.add(dLon);

        Sector tileSector = new Sector(p1, p2, t1, t2);
        MeshCoords tileCoords = transformSector(sectorTransform, tileSector);
        tiles[index++] = new MeshTile(tileSector, level, row, col, tileCoords);

        t1 = t2;
      }
      p1 = p2;
    }

    return tiles;
  }
    protected boolean isNavSectorVisible(
        DrawContext dc, double minDistanceSquared, double maxDistanceSquared) {
      if (!navSector.intersects(dc.getVisibleSector())) return false;

      View view = dc.getView();
      Position eyePos = view.getEyePosition();
      if (eyePos == null) return false;

      // check for eyePos over globe
      if (Double.isNaN(eyePos.getLatitude().getDegrees())
          || Double.isNaN(eyePos.getLongitude().getDegrees())) return false;

      Angle lat =
          clampAngle(eyePos.getLatitude(), navSector.getMinLatitude(), navSector.getMaxLatitude());
      Angle lon =
          clampAngle(
              eyePos.getLongitude(), navSector.getMinLongitude(), navSector.getMaxLongitude());
      Vec4 p = dc.getGlobe().computePointFromPosition(lat, lon, 0d);
      double distSquared = dc.getView().getEyePoint().distanceToSquared3(p);
      //noinspection RedundantIfStatement
      if (minDistanceSquared > distSquared || maxDistanceSquared < distSquared) return false;

      return true;
    }