Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import gov.nasa.worldwind.shape.Placemark;
import gov.nasa.worldwind.shape.PlacemarkAttributes;
import gov.nasa.worldwind.shape.SurfaceImage;
import mil.emp3.api.Circle;
import mil.emp3.api.Ellipse;
import mil.emp3.api.Path;
import mil.emp3.api.Polygon;
import mil.emp3.api.Text;
Expand Down Expand Up @@ -55,6 +57,8 @@ public class EMPtoWWFeatureConverter {
// to apply an additional factor to account for the display density.
private static final double STIPPLE_FACTOR_DISPLAY_DENSITY_MODIFIER = DISPLAY_PIXEL_DENSITY / 96.0;

private static final int ELLIPSE_MAXIMUM_INTERVAL = 256;

private final MapInstance mapInstance;

public EMPtoWWFeatureConverter(MapInstance instance) {
Expand Down Expand Up @@ -304,6 +308,55 @@ public gov.nasa.worldwind.shape.Label createWWLabel(Text feature, boolean isSele
return wwLabel;
}


public gov.nasa.worldwind.shape.Ellipse createWWCircle(final Circle circle, final boolean isSelected) {
IGeoStrokeStyle selectedStrokeStyle = null;
gov.nasa.worldwind.shape.ShapeAttributes shapeAttribute = new gov.nasa.worldwind.shape.ShapeAttributes();
if(isSelected) {
selectedStrokeStyle = getMapInstance().getEmpResources().getSelectedStrokeStyle(getMapInstance());
}
// TODO - Code Review: Are we supporting altitude, please advise.
final Position center = new Position(circle.getFeatureBoundingBox().centerLatitude(),
circle.getFeatureBoundingBox().centerLongitude(),
0.0);

final gov.nasa.worldwind.shape.Ellipse wwEllipse = new gov.nasa.worldwind.shape.Ellipse(center,
circle.getRadius(),
circle.getRadius(),
shapeAttribute);
setWWCircleAttributes(circle, wwEllipse, selectedStrokeStyle);

wwEllipse.setPickDelegate(circle);
wwEllipse.setFollowTerrain(true);
wwEllipse.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
wwEllipse.setMaximumIntervals(ELLIPSE_MAXIMUM_INTERVAL);
return wwEllipse;
}

public gov.nasa.worldwind.shape.Ellipse createWWEllipse(final Ellipse ellipse, final boolean isSelected) {
IGeoStrokeStyle selectedStrokeStyle = null;
gov.nasa.worldwind.shape.ShapeAttributes shapeAttribute = new gov.nasa.worldwind.shape.ShapeAttributes();
if(isSelected) {
selectedStrokeStyle = getMapInstance().getEmpResources().getSelectedStrokeStyle(getMapInstance());
}
// TODO - Code Review: Are we supporting altitude, please advise.
final Position center = new Position(ellipse.getFeatureBoundingBox().centerLatitude(),
ellipse.getFeatureBoundingBox().centerLongitude(),
0.0);
final gov.nasa.worldwind.shape.Ellipse wwEllipse = new gov.nasa.worldwind.shape.Ellipse(center,
ellipse.getSemiMajor(),
ellipse.getSemiMinor(),
shapeAttribute);
setWWEllipseAttributes(ellipse, wwEllipse, selectedStrokeStyle);

wwEllipse.setPickDelegate(ellipse);
wwEllipse.setFollowTerrain(true);
wwEllipse.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
wwEllipse.setMaximumIntervals(ELLIPSE_MAXIMUM_INTERVAL);

return wwEllipse;
}

/**
* This method must be override by the subclass to create a buffer renderable for the feature.
* @param buffer The buffer distance in meters.
Expand Down Expand Up @@ -524,6 +577,166 @@ private void setWWPolygonAttributes(mil.emp3.api.Polygon feature, gov.nasa.world
break;
}
}
// TODO - These set attributes methods are too similar. Collapse and condense into helper methods.
private void setWWEllipseAttributes(mil.emp3.api.Ellipse feature, gov.nasa.worldwind.shape.Ellipse wwEllipse, IGeoStrokeStyle strokeStyle) {
gov.nasa.worldwind.shape.ShapeAttributes shapeAttribute = wwEllipse.getAttributes();

if (shapeAttribute == null) {
shapeAttribute = new gov.nasa.worldwind.shape.ShapeAttributes();
}

if (feature.getExtrude()) {
shapeAttribute.setDrawVerticals(true);
} else {
shapeAttribute.setDrawVerticals(false);
}

if ((strokeStyle == null) && (feature.getStrokeStyle() != null)) {
strokeStyle = feature.getStrokeStyle();
}

if (strokeStyle != null) {
shapeAttribute.setDrawOutline(true);
shapeAttribute.setOutlineColor(Conversion.convertColor(strokeStyle.getStrokeColor()));
shapeAttribute.setOutlineWidth((float) strokeStyle.getStrokeWidth());

if (strokeStyle.getStipplingPattern() != 0) {
ImageSource imageSource = ImageSource.fromLineStipple((int) ((double) strokeStyle.getStipplingFactor() * STIPPLE_FACTOR_DISPLAY_DENSITY_MODIFIER),
strokeStyle.getStipplingPattern());
shapeAttribute.setOutlineImageSource(imageSource);
}
} else {
shapeAttribute.setDrawOutline(false);
}


if (feature.getFillStyle() != null) {
IGeoFillStyle fillStyle = feature.getFillStyle();

shapeAttribute.setDrawInterior(true);

switch (fillStyle.getFillPattern()) {
case crossHatched:
shapeAttribute.setInteriorImageSource(mapInstance.getCrossHatchImage());
break;
case hatched:
shapeAttribute.setInteriorImageSource(mapInstance.getHatchImage());
break;
case solid:
// nothing additional to fill
break;
default:
}
shapeAttribute.setInteriorColor(Conversion.convertColor(fillStyle.getFillColor()));
} else {
shapeAttribute.setDrawInterior(false);
}

Conversion.convertAndSetIGeoAltitudeMode(wwEllipse, feature.getAltitudeMode());

if (feature.getAltitudeMode() == IGeoAltitudeMode.AltitudeMode.ABSOLUTE){
wwEllipse.setFollowTerrain(false);
} else {
wwEllipse.setFollowTerrain(true);
}
wwEllipse.setPickDelegate(feature);
wwEllipse.setAttributes(shapeAttribute);
wwEllipse.setHighlighted(false);
wwEllipse.setMaximumIntervals(256);


switch (feature.getPathType()) {
case GREAT_CIRCLE:
wwEllipse.setPathType(WorldWind.GREAT_CIRCLE);
break;
case LINEAR:
wwEllipse.setPathType(WorldWind.LINEAR);
break;
case RHUMB_LINE:
wwEllipse.setPathType(WorldWind.RHUMB_LINE);
break;
}
}

private void setWWCircleAttributes(mil.emp3.api.Circle feature, gov.nasa.worldwind.shape.Ellipse wwEllipse, IGeoStrokeStyle strokeStyle) {
gov.nasa.worldwind.shape.ShapeAttributes shapeAttribute = wwEllipse.getAttributes();

if (shapeAttribute == null) {
shapeAttribute = new gov.nasa.worldwind.shape.ShapeAttributes();
}

if (feature.getExtrude()) {
shapeAttribute.setDrawVerticals(true);
} else {
shapeAttribute.setDrawVerticals(false);
}

if ((strokeStyle == null) && (feature.getStrokeStyle() != null)) {
strokeStyle = feature.getStrokeStyle();
}

if (strokeStyle != null) {
shapeAttribute.setDrawOutline(true);
shapeAttribute.setOutlineColor(Conversion.convertColor(strokeStyle.getStrokeColor()));
shapeAttribute.setOutlineWidth((float) strokeStyle.getStrokeWidth());

if (strokeStyle.getStipplingPattern() != 0) {
ImageSource imageSource = ImageSource.fromLineStipple((int) ((double) strokeStyle.getStipplingFactor() * STIPPLE_FACTOR_DISPLAY_DENSITY_MODIFIER),
strokeStyle.getStipplingPattern());
shapeAttribute.setOutlineImageSource(imageSource);
}
} else {
shapeAttribute.setDrawOutline(false);
}


if (feature.getFillStyle() != null) {
IGeoFillStyle fillStyle = feature.getFillStyle();

shapeAttribute.setDrawInterior(true);

switch (fillStyle.getFillPattern()) {
case crossHatched:
shapeAttribute.setInteriorImageSource(mapInstance.getCrossHatchImage());
break;
case hatched:
shapeAttribute.setInteriorImageSource(mapInstance.getHatchImage());
break;
case solid:
// nothing additional to fill
break;
default:
}
shapeAttribute.setInteriorColor(Conversion.convertColor(fillStyle.getFillColor()));
} else {
shapeAttribute.setDrawInterior(false);
}

Conversion.convertAndSetIGeoAltitudeMode(wwEllipse, feature.getAltitudeMode());

if (feature.getAltitudeMode() == IGeoAltitudeMode.AltitudeMode.ABSOLUTE){
wwEllipse.setFollowTerrain(false);
} else {
wwEllipse.setFollowTerrain(true);
}
wwEllipse.setPickDelegate(feature);
wwEllipse.setAttributes(shapeAttribute);
wwEllipse.setHighlighted(false);
wwEllipse.setMaximumIntervals(256);


switch (feature.getPathType()) {
case GREAT_CIRCLE:
wwEllipse.setPathType(WorldWind.GREAT_CIRCLE);
break;
case LINEAR:
wwEllipse.setPathType(WorldWind.LINEAR);
break;
case RHUMB_LINE:
wwEllipse.setPathType(WorldWind.RHUMB_LINE);
break;
}
}

/**
* Takes path type value of {@link gov.nasa.worldwind.shape.Path} and converts it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import gov.nasa.worldwind.render.RenderContext;
import gov.nasa.worldwind.render.Renderable;
import mil.emp3.api.Circle;
import mil.emp3.api.Ellipse;
import mil.emp3.api.Path;
import mil.emp3.api.Polygon;
import mil.emp3.api.Text;
Expand Down Expand Up @@ -172,7 +174,14 @@ protected void generateRenderables() {
if (this.getFeature() instanceof mil.emp3.api.Point) {
// Create a WW placemark.
tempRenderable = this.createPlacemark((mil.emp3.api.Point) this.getFeature(), isSelected());
} else if (this.getFeature() instanceof Path) {
}
else if (this.getFeature() instanceof Circle) {
tempRenderable = this.createWWCircle((Circle) this.getFeature(), isSelected());
}
else if (this.getFeature() instanceof Ellipse) {
tempRenderable = this.createWWEllipse((Ellipse) this.getFeature(), isSelected());
}
else if (this.getFeature() instanceof Path) {
// Create a WW path object.
tempRenderable = this.createWWPath((Path) this.getFeature(), isSelected());
} else if (this.getFeature() instanceof Polygon) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import gov.nasa.worldwind.render.RenderContext;
import gov.nasa.worldwind.render.Renderable;
import mil.emp3.api.Circle;
import mil.emp3.api.Ellipse;
import mil.emp3.api.Path;
import mil.emp3.api.Polygon;
import mil.emp3.api.Text;
Expand Down Expand Up @@ -121,7 +123,22 @@ private void renderFeature(IGeoBounds bounds) {
tempRenderable.setPickDelegate(this.getFeature());
this.pathRenderableList.add(tempRenderable);
}
} else if (feature instanceof Polygon) {
}
else if (feature instanceof Circle) {
tempRenderable = this.createWWCircle((Circle) feature, false);
if (tempRenderable != null) {
tempRenderable.setPickDelegate(this.getFeature());
this.addRenderable(tempRenderable);
}
}
else if (feature instanceof Ellipse) {
tempRenderable = this.createWWEllipse((Ellipse) feature, false);
if (tempRenderable != null) {
tempRenderable.setPickDelegate(this.getFeature());
this.addRenderable(tempRenderable);
}
}
else if (feature instanceof Polygon) {
// Create a WW polygon object.
tempRenderable = this.createWWPolygon((Polygon) feature, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import armyc2.c2sd.renderer.utilities.ModifiersTG;
import armyc2.c2sd.renderer.utilities.RendererSettings;
import armyc2.c2sd.renderer.utilities.ShapeInfo;
import mil.emp3.api.Circle;
import mil.emp3.api.Ellipse;
import mil.emp3.api.MilStdSymbol;
import mil.emp3.api.Path;
import mil.emp3.api.Polygon;
Expand Down Expand Up @@ -625,7 +627,6 @@ public List<IFeature> getFeatureRenderableShapes(IMapInstance mapInstance, IFeat
String altitudeModeStr = MilStdUtilities.geoAltitudeModeToString(feature.getAltitudeMode());
SparseArray<String> modifiers = new SparseArray<>();
SparseArray<String> attributes;

if (feature instanceof mil.emp3.api.Circle) {
mil.emp3.api.Circle circleFeature = (mil.emp3.api.Circle) feature;
symbolCode = "PBS_CIRCLE-----";
Expand Down Expand Up @@ -779,10 +780,18 @@ private void renderBasicShapeParser(List<IFeature> featureList,
List<List<IGeoPosition>> listOfPosList = this.convertListOfPointListsToListOfPositionLists(shapeInfo.getPolylines());

for (List<IGeoPosition> posList : listOfPosList) {
IFeature feature = new Path(posList);
feature.setStrokeStyle(currentStrokeStyle);
feature.setAltitudeMode(renderFeature.getAltitudeMode());
featureList.add(feature);
if(renderFeature instanceof Circle) {
featureList.add(renderFeature);
}
else if (renderFeature instanceof Ellipse) {
featureList.add(renderFeature);
}
else {
IFeature feature = new Path(posList);
feature.setStrokeStyle(currentStrokeStyle);
feature.setAltitudeMode(renderFeature.getAltitudeMode());
featureList.add(feature);
}
}
break;
}
Expand Down