Package edu.cnu.mdi.mdi3D.item3D
Class GlobeCountryLines3D
java.lang.Object
edu.cnu.mdi.mdi3D.item3D.Item3D
edu.cnu.mdi.mdi3D.item3D.GlobeCountryLines3D
Draws country outlines on a sphere as 3D polyline strips.
Input polygons are provided as rings of Point2D.Double values where:
xis longitude in radians (typically wrapped to[-pi, pi))yis latitude in radians ([-pi/2, pi/2])
edu.cnu.mdi.mapping.GeoJsonCountryLoader.
Dateline seam handling
GeoJSON rings that cross the dateline can contain adjacent points whose longitudes differ by nearly2*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 Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThreshold for splitting segments across the dateline seam.Fields inherited from class edu.cnu.mdi.mdi3D.item3D.Item3D
_panel3D, FILLALPHA, FILLCOLOR, FONT, LINE_WIDTH, LINEALPHA, LINECOLOR, TEXT_COLOR -
Constructor Summary
ConstructorsConstructorDescriptionGlobeCountryLines3D(Panel3D panel3D, List<edu.cnu.mdi.mapping.loader.GeoJsonCountryLoader.CountryFeature> features, float radius) Construct a country outline renderer. -
Method Summary
Modifier and TypeMethodDescriptionvoiddraw(com.jogamp.opengl.GLAutoDrawable drawable) The custom drawing methoddoubleGet the current dateline split threshold.Get the current outline color.floatGet the current line width.floatGet the radial lift.final voidRebuild the internal polyline strips from the provided features.voidsetDatelineSplitThreshold(double threshold) Set the longitude discontinuity threshold (radians) used to split rings at the dateline.voidSet the outline color.voidsetLineWidth(float w) Set the polyline width (OpenGL line width).voidsetRadialLift(float lift) Set a small radial lift applied to all vertices to reduce z-fighting with the sphere.Methods inherited from class edu.cnu.mdi.mdi3D.item3D.Item3D
addChild, defaultProperties, dispose, disposeItem, drawItem, get, getChildren, getColor, getFillAlpha, getFillColor, getFloat, getFont, getFont, getInt, getLineAlpha, getPanel3D, getParent, getSortPoint, getString, getTextColor, isVisible, put, removeChild, setAlphaOfColor, setFillAlpha, setFillColor, setFont, setLineAlpha, setTextColor, setVisible
-
Field Details
-
DEFAULT_DATELINE_SPLIT_THRESHOLD
public static final double DEFAULT_DATELINE_SPLIT_THRESHOLDThreshold 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 panelfeatures- country features loaded from GeoJSONradius- 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
Set the outline color.- Overrides:
setLineColorin classItem3D- Parameters:
c- the new color (non-null)
-
getLineColor
Get the current outline color.- Overrides:
getLineColorin classItem3D- Returns:
- line color
-
setLineWidth
public void setLineWidth(float w) Set the polyline width (OpenGL line width).- Overrides:
setLineWidthin classItem3D- Parameters:
w- width in pixels (values <= 0 are clamped to 1)
-
getLineWidth
public float getLineWidth()Get the current line width.- Overrides:
getLineWidthin classItem3D- 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 toDEFAULT_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:Item3DThe custom drawing method
-