Class GlobeCountryLines3D

java.lang.Object
edu.cnu.mdi.mdi3D.item3D.Item3D
edu.cnu.mdi.mdi3D.item3D.GlobeCountryLines3D

public class GlobeCountryLines3D extends Item3D
Draws country outlines on a sphere as 3D polyline strips.

Input polygons are provided as rings of Point2D.Double values where:

  • x is longitude in radians (typically wrapped to [-pi, pi))
  • y is latitude in radians ([-pi/2, pi/2])
This is the format produced by edu.cnu.mdi.mapping.GeoJsonCountryLoader.

Dateline seam handling

GeoJSON rings that cross the dateline can contain adjacent points whose longitudes differ by nearly 2*pi. If rendered as a continuous strip on the sphere, those segments would "cut across" the globe.

For demo purposes, this item takes a simple, robust approach: it splits the polyline whenever a segment exhibits |dLon| > pi. This avoids globe-spanning chords at the cost of a small seam gap at the dateline.

Rendering details

By default, vertices are placed slightly above the sphere surface (getRadialLift()) to reduce z-fighting with the sphere mesh.
  • Field Details

    • DEFAULT_DATELINE_SPLIT_THRESHOLD

      public static final double DEFAULT_DATELINE_SPLIT_THRESHOLD
      Threshold for splitting segments across the dateline seam.
      See Also:
  • Constructor Details

    • GlobeCountryLines3D

      public GlobeCountryLines3D(Panel3D panel3D, List<edu.cnu.mdi.mapping.loader.GeoJsonCountryLoader.CountryFeature> features, float radius)
      Construct a country outline renderer.
      Parameters:
      panel3D - the owning 3D panel
      features - country features loaded from GeoJSON
      radius - sphere radius in scene units
  • Method Details

    • rebuild

      public final void rebuild(List<edu.cnu.mdi.mapping.loader.GeoJsonCountryLoader.CountryFeature> features)
      Rebuild the internal polyline strips from the provided features.
      Parameters:
      features - country features
    • setLineColor

      public void setLineColor(Color c)
      Set the outline color.
      Overrides:
      setLineColor in class Item3D
      Parameters:
      c - the new color (non-null)
    • getLineColor

      public Color getLineColor()
      Get the current outline color.
      Overrides:
      getLineColor in class Item3D
      Returns:
      line color
    • setLineWidth

      public void setLineWidth(float w)
      Set the polyline width (OpenGL line width).
      Overrides:
      setLineWidth in class Item3D
      Parameters:
      w - width in pixels (values <= 0 are clamped to 1)
    • getLineWidth

      public float getLineWidth()
      Get the current line width.
      Overrides:
      getLineWidth in class Item3D
      Returns:
      line width in pixels
    • setRadialLift

      public void setRadialLift(float lift)
      Set a small radial lift applied to all vertices to reduce z-fighting with the sphere.
      Parameters:
      lift - radial lift in scene units (negative values treated as 0)
    • getRadialLift

      public float getRadialLift()
      Get the radial lift.
      Returns:
      radial lift in scene units
    • setDatelineSplitThreshold

      public void setDatelineSplitThreshold(double threshold)
      Set the longitude discontinuity threshold (radians) used to split rings at the dateline.
      Parameters:
      threshold - radians; values <= 0 revert to DEFAULT_DATELINE_SPLIT_THRESHOLD
    • getDatelineSplitThreshold

      public double getDatelineSplitThreshold()
      Get the current dateline split threshold.
      Returns:
      threshold in radians
    • draw

      public void draw(com.jogamp.opengl.GLAutoDrawable drawable)
      Description copied from class: Item3D
      The custom drawing method
      Specified by:
      draw in class Item3D
      Parameters:
      drawable - the OpenGL drawable