Skip to content
spyhunter99 edited this page Jan 19, 2018 · 23 revisions

MIL SYMBOLOGY JAVASCRIPT RENDERER

DEVELOPER’S GUIDE

Revision History
Initial Document 12/16/2014
object

Documentation work in progress

1 OVERVIEW

1.1 FEATURES

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.

1.2 System Requirements

Targeting Android API 15.

2 RENDERING

2.1 CONFIGURING THE RENDERER FOR YOUR NEEDS

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);

2.2 SINGLEPOINT ICON SYMBOLOGY

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);  

3.2.1 SETTING MODIFIERS

“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.

3.2.2 SETTING ATTRIBUTES

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.

3.2.2.1 SIZE

PixelSize = Default size 35. This is the size of the core symbol (not including modifiers) which will fit within a 35x35 pixel space.

3.2.2.2 LINECOLOR / FILLCOLOR

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".

3.2.2.3 KEEPUNITRATIO

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.

3.2.2.4 SYMBOLOGY STANDARD

SymbologyStandard Takes RendererSettings.Symbology_2525Bch2_USAS_13_14 or RendererSettings.Symbology_2525C for a value. This parameter determines which rendering standard to use.

3.2.2.5 ICON

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.

3.2.3 GETTING YOUR IMAGE (IMAGEINFO)

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.

3.2.3.1 GETIMAGE()

“getImage()” returns a Bitmap (android.graphics.Bitmap).

3.2.3.2 GETCENTERPOINT()

“getCenterPoint()” returns a point object that represents where the image should be centered if rendered on a coordinate based map. android.graphics.Point

3.2.3.3 GETSYMBOLBOUNDS()

“getSymbolBounds()” returns a rectangle object that represents to area in the image that the core symbol (not including any modifiers) exists. android.graphics.Rect

3.2.3.4 GETIMAGEBOUNDS()

“getImageBounds()” returns a rectangle object that represents the size of the entire image. android.graphics.Rect

3.2.3.6 GETSQUAREImageInfo()

“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.

3.3 MULTIPOINT SYMBOLOGY

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);  

3.3.1 REQUIRED PARAMETERS FOR MULTIPOINT SYMBOLOGY

3.3.1.1 ID (FOR 3D & 2D)

id = a unique identifier used to identify the symbol by Google map. The id will be the folder name that contains the graphic.

3.3.1.2 NAME (FOR 3D & 2D)

name = a string used to display to the user as the name of the graphic being created.

3.3.1.3 DESCRIPTION (FOR 3D & 2D)

description = a brief description about the graphic being made and what it represents.

3.3.1.4 CONTROL POINTS (FOR 3D & 2D)

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]...".

3.3.1.5 ALTITUDE MODE (FOR 3D)

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).

3.3.1.6 SCALE (FOR 3D)

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.

3.3.1.7 PIXELWIDTH & PIXELHEIGHT (FOR 2D)

pixelWidth & pixelHeight = represents the width & height in pixels of the visible map area of a 2D map.

3.3.1.8 BOUNDING BOX (FOR 3D & 2D)

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"

3.3.1.9 MODIFIERS (FOR 3D & 2D)

SpareSrray - use like:
modifiers.put(ModifiersTG.T_UNIQUE_DESIGNATION_1,"T"); Or modifiers.put(ModifiersTG.AM_DISTANCE,"1000,2000,3000");

3.3.1.10 ATTRIBUTES (FOR 3D & 2D)

SpareSrray - use like:
modifiers.put(MilStdAttributes.LineWidth,"3"); Or modifiers.put(MilStdAttributes.LineColor,"#00FF00");

3.3.1.11 FORMAT (FOR 3D & 2D)

format = an enumeration: 0 for KML, 1 for JSON, 2 for GeoJSON.

3.3.1.12 SYMBOLOGY STANDARD (FOR 3D & 2D)

symStd = a Mil-Std symbology enumeration: 0 for 2525Bch2, 1 for 2525C.

4 SYMBOLUTILITIES

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.

4.1 GETBASICSYMBOLID

“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.

4.2 HASMODIFIER

“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);

4.3 ISMULTIPOINT

“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.

5 THE SYMBOL DEFINITION TABLE

The SymbolDefTable object will provide information about the tactical graphics that can be drawn. (Appendix B in the MilStd 2525)

5.1 HASSYMBOLDEF

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.

5.2 GETSYMBOLDEF

armyc2.c2sd.renderer.utilities.SymbolDefTable.getSymbolDef(symbolID, symStd)

5.2.1 PARAMETERS

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.

5.2.2 RETURN OBJECT

This function will return an object with the following properties:

5.2.2.1 SYMBOLID

symbolID – a basic 15 character symbol ID code stripped of affiliation, status & modifiers.

5.2.2.2 MINPOINTS

minPoints – the minimum # of points the symbol can have.

5.2.2.3 MAXPOINTS

maxPoints – the max # of points the symbol can have. Assume any value over 100 means infinite.

5.2.2.4 MODIFIERS

modifiers – a string like “T.T1.W.” which shows which modifiers the symbol can have.

5.2.2.5 DRAWCATEGORY

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.