-
Notifications
You must be signed in to change notification settings - Fork 12
Home
MIL SYMBOLOGY JAVASCRIPT RENDERER
DEVELOPER’S GUIDE
Revision History
Initial Document 12/16/2014
object
Documentation work in progress
The Android version of the Mil-Std Symbology Renderer supports rendering of single & multi point symbology. Single points as BufferedImage. Multipoints as kml or a collection of points an other information that will allow the user to render.
Targeting Android API 15.
The “RendererSettings” object will let you set some default rendering values. It is accessible at "armyc2.c2sd.renderer.utilities.RendererSettings”.
RendererSettings.getInstance().setSymbologyStandard(RendererSettings.Symbology_2525C);
//Next lines are mandatory. These tell the renderer where the cache folder is located which is needed to process the embedded xml files.
MilStdIconRenderer mir = MilStdIconRenderer.getInstance();
String cacheDir = getApplicationContext().getCacheDir().getAbsoluteFile().getAbsolutePath();
mir.init(cacheDir);
Singlepoint rendering is provided by the MilStdIconRenderer object
You would typically render a single point via the code snippet below:
var ii = armyc2.c2sd.renderer.MilStdIconRenderer.Render("SUGDUSAT----***",modifiers,attributes);
“modifiers” is an SparseArray which can contain Mil-Std modifiers. The modifiers can be set like this:
SparseArray<String> modifiers = new SparseArray<String>();
modifiers.put(ModifierUnits.C_QUANTITY,"10");
modifiers.put(mu.H_ADDITIONAL_INFO_1,"H");
modifiers.put(mu.H1_ADDITIONAL_INFO_2,"H1)";
//or like this for Single Point Tactical Graphics:
modifiers.put(ModifiersTG.H2_ADDITIONAL_INFO_3,"H2")
//or like this for Multi Point Tactical Graphics:
//(comma delimited for modifiers with multiple values)
modifiers.put(ModifiersTG.AM_DISTANCE,"1000,2000,3000");
ModifiersUnits.java and ModifiersTG.java contain all the modifier key constants for units and tactical graphics.
Attributes will override any defaults set in RendererSettings.
SparseArray<String> attributes = new SparseArray<String>();
attributes.put(MilStdAttributes.PixelSize,"60");
attributes.put(MilStdAttributes.KeepUnitRatio,"true");
attributes.put(MilStdAttributes.SymbologyStandard, String.valueOf(RendererSettings.Symbology_2525Bch2_USAS_13_14));
MilStdAttributes.java contains all the modifier key constants for the attributes that can be applied to rendering.
PixelSize = Default size 35. This is the size of the core symbol (not including modifiers) which will fit within a 35x35 pixel space.
LineColor and FillColor, if you want to override the default affiliation colors, do something like: “#FF0000”. You can add transparency by using an alpha value: "#80FF0000".
KeepUnitRatio If true (defaults true), the symbols will have proper proportions in relation to each other (see table VIII in the MilStd 2525C). Hostile airspace, with a size of 35, will end up being 25.667 wide by 30.333 high, hostile unit will be 33.6x33.6 ((35/1.5)*1.44). If false, image will fill the pixel space as much as it can without distorting the shape.
SymbologyStandard Takes RendererSettings.Symbology_2525Bch2_USAS_13_14 or RendererSettings.Symbology_2525C for a value. This parameter determines which rendering standard to use.
ICON=true, will result in a symbol that is stripped of display & text modifiers so that you get just the core symbol. This is useful for use as tree-node icons. If you had all the detail, the symbols would be so small it would be hard for the user to determine what symbol they're looking at.
Looking back at the call to render, you’ll see you get an object back. This object contains the image along with some information about the image.
ImageInfo ii = armyc2.c2sd.renderer.MilStdIconRenderer.RenderIcon("SUGDUSAT----***",modifiers,attributes);
What is returned is the [“ImageInfo” object] (https://github.com/missioncommand/mil-sym-android/blob/master/Renderer/src/main/java/armyc2/c2sd/renderer/utilities/ImageInfo.java). It has the following functions available.
“getImage()” returns a Bitmap (android.graphics.Bitmap).
“getCenterPoint()” returns a point object that represents where the image should be centered if rendered on a coordinate based map. android.graphics.Point
“getSymbolBounds()” returns a rectangle object that represents to area in the image that the core symbol (not including any modifiers) exists. android.graphics.Rect
“getImageBounds()” returns a rectangle object that represents the size of the entire image. android.graphics.Rect
“getSquareImageInfo()” returns an ImageInfo object where space is added as necessary to make the image a square so that it will fit nicely in a tree node or for any other situation where consistent image size is important. So if you draw a friendly ground unit and the resultant image is 16x10, this function will return a version that is 16x16.
Multipoint rendering is provided by the SECWebRenderer object
KML & MilStd Symbol rendering example:
//SECTOR RANGE FAN EXAMPLE/////////////////////////////////
String id = "id";
String name = "name";
String description = "description";
String symbolCode = "GFGPGLF---****X";
String controlPoints = "8.40185525443334,38.95854638813517 15.124217101733166,36.694658205882995 18.49694847529253,40.113591379080155 8.725267851897936,42.44678226078903 8.217048055882143,40.76041657400935";
String altitudeMode = "absolute";
double scale = 5869879.2;
String bbox = "5.76417051405295,34.86552015439102,20.291017309471272,45.188646318100695";
SparseArray<String> modifiers = new SparseArray<String>();
SparseArray<String> attributes = new SparseArray<String>();
attributes.put(MilStdAttributes.LineColor, "ffff0000");
int symStd = 0;
MilStdSymbol flot = SECWebRenderer.RenderMultiPointAsMilStdSymbol(id, name, description, symbolCode, controlPoints, altitudeMode, scale, bbox, modifiers, attributes, symStd);
//[MilStdSymbol]() is an object that contains the information necessary to render.
//Info needed for rendering/////////////////
//ArrayList<ShapeInfo> sShapes = flot.getSymbolShapes();
//ArrayList<ShapeInfo> mShapes = flot.getModifierShapes();
//message.append("Symbol Shape Count: " + String.valueOf(sShapes.size()));
//message.append(" Modifier Shape Count: " + String.valueOf(mShapes.size()));
//line info
//sShapes.get(0).getPolylines();//Arraylist<Point2D>
//sShapes.get(0).getLineColor();
//sShapes.get(0).getFillColor();
//((BasicStroke)sShapes.get(0).getStroke()).getLineWidth();
//((BasicStroke)sShapes.get(0).getStroke()).getDashArray();
//Renderer must be set to use dash array for dashed lines.
//Otherwise, the renderer will break the lines into multiple pieces to create the dashed line effect.
//sShapes.get(0).getShader()//returns a BitmapShader that should be used to tile fill the shape.
//sShapes.get(0).getTexturePaint()//contains a BufferedImage. Use this, if present, to fill the shape assuming you can't use the BitmapShader in your implementation.
////typically used for weather graphics.
//Modifier info
//RendererSettings.getMPModifierFont();//returns a Paint object
//flot.getLineColor (typically you want the modifier text to match the line color of the symbol)
//mShapes.get(0).getModifierString();
//mShapes.get(0).getModifierStringPosition();
//mShapes.get(0).getModifierStringAngle();
////////////////////////////////////////////
//you can also get the symbol as kml
String kml = SECWebRenderer.RenderSymbol(id, name, description, symbolCode, controlPoints, altitudeMode, scale, bbox, modifiers, attributes, 0, symStd);
id = a unique identifier used to identify the symbol by Google map. The id will be the folder name that contains the graphic.
name = a string used to display to the user as the name of the graphic being created.
description = a brief description about the graphic being made and what it represents.
controlPoints = the vertices of the graphics that make up the graphic. They are passed in the format of a string, using decimal degrees separating lat and lon by a comma, separating coordinates by a space. The following format shall be used "x1,y1 [xn,yn]...".
altitudeMode = indicates whether the symbol should interpret altitudes as above sea level or above ground level. Options are "clampToGround", "relativeToGround" (from surface of earth), "absolute" (sea level), "relativeToSeaFloor" (from the bottom of major bodies of water).
scale = a number corresponding to how many meters one meter of our map represents. A value "50000" would mean 1:50K which means for every meter of our map it represents 50000 meters of real world distance.
pixelWidth & pixelHeight = represents the width & height in pixels of the visible map area of a 2D map.
bbox = the viewable area of the map. Passed in the format of a string "lowerLeftX,lowerLeftY,upperRightX,upperRightY." example: "-50.4,23.6,-42.2,24.2"
SpareSrray - use like:
modifiers.put(ModifiersTG.T_UNIQUE_DESIGNATION_1,"T");
Or
modifiers.put(ModifiersTG.AM_DISTANCE,"1000,2000,3000");
SpareSrray - use like:
modifiers.put(MilStdAttributes.LineWidth,"3");
Or
modifiers.put(MilStdAttributes.LineColor,"#00FF00");
format = an enumeration: 0 for KML, 1 for JSON, 2 for GeoJSON.
symStd = a Mil-Std symbology enumeration: 0 for 2525Bch2, 1 for 2525C.
armyc2.c2sd.renderer.utilities.SymbolUtilities is an object with various utility functions used to process symbolIDs. The two a user is most likely to use are below. Please look at the class for other functions that may be of use.
“getBasicSymbolID(symbolID)” will be used often with the other objects in the renderer. It will take a symbolID like “SFGPUCI----K***” and remove the status and affiliation and blank out any modifiers in the last 5 characters of the code. Object like SymbolDefTable & UnitDefTable use the basic symbol ID for lookups.
“hasModifier(symbolID, modifier)” will tell you if the modifier is valid for a specific symbolID.
symbolID – a 15 character symbol code.
modifier – Can be one of the constants from the ModifiersUnits or ModifiersTG object.
Returns true or false.
Use like:
Var SymbolUtilities = armyc2.c2sd.renderer.utilities.SymbolUtilities;
var result = SymbolUtilities.hasModifier(symbolID, ModifiersUnits.B_ECHELON);
“isMultiPoint(symbolID, symStd)” will tell you if the modifier is valid for a specific symbolID.
symbolID – a 15 character symbol code.
symStd – a Mil-Std symbology enumeration: 0 for 2525Bch2, 1 for 2525C. Will use renderer default if not provided.
Returns true or false.
The SymbolDefTable object will provide information about the tactical graphics that can be drawn. (Appendix B in the MilStd 2525)
armyc2.c2sd.renderer.utilities.SymbolDefTable.getSymbolDef(symbolID, symStd)
This function takes the following parameters:
symbolID – a basic 15 character symbol ID code stripped of affiliation, status & modifiers.
symStd – 0 or 1 depending if you want a definition based on 2525B or 2525C.
Returns true if a symbol definition exists for the passed basic symbolID and symbology standard.
armyc2.c2sd.renderer.utilities.SymbolDefTable.getSymbolDef(symbolID, symStd)
This function takes the following parameters: symbolID – a basic 15 character symbol ID code stripped of affiliation, status & modifiers. symStd – 0 or 1 depending if you want a definition based on 2525B or 2525C.
This function will return an object with the following properties:
symbolID – a basic 15 character symbol ID code stripped of affiliation, status & modifiers.
minPoints – the minimum # of points the symbol can have.
maxPoints – the max # of points the symbol can have. Assume any value over 100 means infinite.
modifiers – a string like “T.T1.W.” which shows which modifiers the symbol can have.
drawCategory – an integer representing the type of symbol that is being drawn. These constants can be found in the SymbolDef.java. Based on these constants, you’ll know what symbols have required modifiers. For instance, DRAW_CATEGORY_TWO_POINT_RECT_PARAMETERED_AUTOSHAPE: 20, is a symbol that requires one AM value. These requirements are described in SymbolDefjava as well.