@armyc2.c5isr.renderer/mil-sym-ts-web 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +57 -0
- package/buildNode.bat +2 -0
- package/buildWeb.bat +2 -0
- package/dist/C5Ren.d.ts +6970 -0
- package/dist/C5Ren.js +2 -0
- package/dist/C5Ren.js.map +1 -0
- package/dist/LICENSE +201 -0
- package/dist/README.md +57 -0
- package/dist/armyc2.c5isr.renderer-mil-sym-ts-web-2.2.0.tgz +0 -0
- package/dist/manifest.json +4 -0
- package/dist/package.json +16 -0
- package/index.ts +169 -0
- package/package.bak +50 -0
- package/package.json +40 -0
- package/package.node.json +43 -0
- package/package.pack.json +19 -0
- package/package.packWeb.json +16 -0
- package/package.web.json +40 -0
- package/src/main/ts/android/graphics/Bitmap.ts +7 -0
- package/src/main/ts/android/graphics/Paint.ts +26 -0
- package/src/main/ts/android/graphics/Path.ts +78 -0
- package/src/main/ts/android/graphics/PointF.ts +14 -0
- package/src/main/ts/android/graphics/Rect.ts +18 -0
- package/src/main/ts/android/graphics/RectF.ts +50 -0
- package/src/main/ts/android/graphics/Region.ts +36 -0
- package/src/main/ts/android/graphics/Typeface.ts +11 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/BasicShapes.ts +99 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/CChannelPoints2.ts +34 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/CELineArray.ts +193 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/Channels.ts +2971 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/DISMSupport.ts +4008 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/POINT2.ts +93 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/Shape2.ts +89 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/TacticalLines.ts +515 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/arraysupport.ts +5403 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/countsupport.ts +1084 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/flot.ts +2173 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/lineutility.ts +4934 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/ref.ts +7 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/Modifier2.ts +5601 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/P1.ts +14 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/TGLight.ts +648 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsChannelUtility.ts +647 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsMETOC.ts +2994 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsUtility.ts +2663 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/mdlGeodesic.ts +669 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipPolygon2.ts +971 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipQuad.ts +871 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer.ts +3507 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer2.ts +500 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtility.ts +1089 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityCPOF.ts +2656 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityGE.ts +1419 -0
- package/src/main/ts/armyc2/c5isr/data/genc.json +1407 -0
- package/src/main/ts/armyc2/c5isr/data/msd.json +17311 -0
- package/src/main/ts/armyc2/c5isr/data/mse.json +18500 -0
- package/src/main/ts/armyc2/c5isr/data/svgd.json +31214 -0
- package/src/main/ts/armyc2/c5isr/data/svge.json +30558 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/AffineTransform.ts +10 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Area.ts +437 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/BasicStroke.ts +429 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/BasicTypes.ts +7 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/BufferedImage.ts +35 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Font.ts +111 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/FontMetrics.ts +29 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/FontRenderContext.ts +18 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/GeneralPath.ts +211 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Graphics2D.ts +80 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/IPathIterator.ts +33 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/ImageIO.ts +16 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Line2D.ts +726 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/PathIterator.ts +141 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Point.ts +112 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Point2D.ts +261 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Polygon.ts +391 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle.ts +567 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle2D.ts +445 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Shape.ts +31 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Stroke.ts +18 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/TextLayout.ts +45 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/TexturePaint.ts +25 -0
- package/src/main/ts/armyc2/c5isr/renderer/IIconRenderer.ts +15 -0
- package/src/main/ts/armyc2/c5isr/renderer/IconRenderer.ts +22 -0
- package/src/main/ts/armyc2/c5isr/renderer/MilStdIconRenderer.ts +269 -0
- package/src/main/ts/armyc2/c5isr/renderer/ModifierRenderer.ts +9882 -0
- package/src/main/ts/armyc2/c5isr/renderer/PatternFillRenderer.ts +146 -0
- package/src/main/ts/armyc2/c5isr/renderer/SinglePointSVGRenderer.ts +1265 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/arc.ts +64 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/bcurve.ts +95 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/ellipse.ts +93 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/line.ts +114 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/path.ts +555 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/pathiterator.ts +62 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/point.ts +120 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/rectangle.ts +431 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/roundedrectangle.ts +99 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/types.ts +25 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/utilities.ts +203 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/AffiliationColors.ts +104 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Color.ts +481 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/DistanceUnit.ts +40 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/DrawRules.ts +1323 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/EntityCode.ts +51 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ErrorLogger.ts +736 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/GENCLookup.ts +106 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/GeoPixelConversion3D.ts +84 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/IMultiPointRenderer.ts +87 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/IPointConversion.ts +34 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ImageInfo.ts +324 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUCache.ts +127 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUEntry.ts +18 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LogLevel.ts +111 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MODrawRules.ts +219 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MSInfo.ts +1008 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MSLookup.ts +882 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdAttributes.ts +380 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdSymbol.ts +797 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Modifiers.ts +1699 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversion.ts +178 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversionDummy.ts +45 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConverter3D.ts +126 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RectUtilities.ts +118 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererException.ts +11 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererSettings.ts +1201 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererUtilities.ts +591 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGInfo.ts +29 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGLookup.ts +753 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGSymbolInfo.ts +137 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGTextInfo.ts +438 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEvent.ts +19 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEventListener.ts +10 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsEventListener.ts +5 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Shape2SVG.ts +404 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeInfo.ts +525 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeUtilities.ts +55 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolDimensionInfo.ts +36 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolID.ts +1055 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolUtilities.ts +2085 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/TextInfo.ts +157 -0
- package/src/main/ts/armyc2/c5isr/web/render/GeoPixelConversion.ts +86 -0
- package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandler.ts +3798 -0
- package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandlerSVG.ts +412 -0
- package/src/main/ts/armyc2/c5isr/web/render/PointConverter.ts +124 -0
- package/src/main/ts/armyc2/c5isr/web/render/SymbolModifiers.ts +26 -0
- package/src/main/ts/armyc2/c5isr/web/render/WebRenderer.ts +677 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/JavaRendererUtilities.ts +484 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/LineInfo.ts +62 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/SymbolInfo.ts +46 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/TextInfo.ts +51 -0
- package/src/main/ts/org/gavaghan/geodesy/Angle.ts +31 -0
- package/src/main/ts/org/gavaghan/geodesy/Ellipsoid.ts +71 -0
- package/src/main/ts/org/gavaghan/geodesy/GeodeticCalculator.ts +200 -0
- package/src/main/ts/org/gavaghan/geodesy/GeodeticCurve.ts +55 -0
- package/src/main/ts/org/gavaghan/geodesy/GeodeticMeasurement.ts +68 -0
- package/src/main/ts/org/gavaghan/geodesy/GlobalCoordinates.ts +103 -0
- package/src/main/ts/org/gavaghan/geodesy/GlobalPosition.ts +90 -0
- package/test/ExportSPImages.js +692 -0
- package/test/MPWW.html +556 -0
- package/test/MPWorker.js +318 -0
- package/test/SPWorker.js +233 -0
- package/test/SVGWW.html +363 -0
- package/test/singlePointTester3.html +751 -0
- package/tsconfig.json +54 -0
- package/typedoc.json +30 -0
- package/updateVersion.js +21 -0
- package/webpack.config.js +34 -0
- package/webpackn.config.js +28 -0
- package/webpackr.config.js +47 -0
- package/webpackw.config.js +23 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { Point2D } from "../../graphics2d/Point2D";
|
|
2
|
+
import { Rectangle } from "../../renderer/shapes/rectangle";
|
|
3
|
+
import { ErrorLogger } from "../../renderer/utilities/ErrorLogger";
|
|
4
|
+
import { IPointConversion } from "../../renderer/utilities/IPointConversion";
|
|
5
|
+
import { RendererSettings } from "../../renderer/utilities/RendererSettings";
|
|
6
|
+
import { RendererUtilities } from "../../renderer/utilities/RendererUtilities";
|
|
7
|
+
import { ShapeInfo } from "../../renderer/utilities/ShapeInfo";
|
|
8
|
+
import { MultiPointHandler } from "./MultiPointHandler";
|
|
9
|
+
import { Path } from "../../renderer/shapes/path";
|
|
10
|
+
import { SVGTextInfo } from "../../renderer/utilities/SVGTextInfo";
|
|
11
|
+
import { Color } from "../../renderer/utilities/Color";
|
|
12
|
+
|
|
13
|
+
export class MultiPointHandlerSVG {
|
|
14
|
+
/**
|
|
15
|
+
* Generates an SVG which can be draped on a map.
|
|
16
|
+
* Better with RenderSymbol2D
|
|
17
|
+
*
|
|
18
|
+
* @param {string} id
|
|
19
|
+
* @param {string} name
|
|
20
|
+
* @param {string} description
|
|
21
|
+
* @param {string} symbolID
|
|
22
|
+
* @param {ShapeInfo[]} shapes
|
|
23
|
+
* @param {ShapeInfo[]} modifiers
|
|
24
|
+
* @param {IPointConversion} ipc
|
|
25
|
+
* @param {boolean} normalize
|
|
26
|
+
* @param {string} textColor
|
|
27
|
+
* @param {string} textBackgroundColor
|
|
28
|
+
* @param {boolean} wasClipped
|
|
29
|
+
* @return {string}
|
|
30
|
+
*/
|
|
31
|
+
public static GeoSVGize(id: string, name: string, description: string, symbolID: string, shapes: ShapeInfo[], modifiers: ShapeInfo[], ipc: IPointConversion, normalize: boolean, textColor: string, textBackgroundColor: string, wasClipped: boolean, bbox?: Rectangle): string {
|
|
32
|
+
|
|
33
|
+
let height = 10;
|
|
34
|
+
|
|
35
|
+
let tempBounds: Rectangle = null;
|
|
36
|
+
let paths: string[] = [];
|
|
37
|
+
let pathBounds: Rectangle = null;
|
|
38
|
+
let labels: SVGTextInfo[] = [];
|
|
39
|
+
let labelBounds: Rectangle = null;
|
|
40
|
+
let unionBounds: Rectangle = null;
|
|
41
|
+
let lineWidth: number = null;
|
|
42
|
+
let fillTexture: string = null
|
|
43
|
+
let geoCoordTL: Point2D = null;
|
|
44
|
+
let geoCoordTR: Point2D = null;
|
|
45
|
+
let geoCoordBL: Point2D = null;
|
|
46
|
+
let geoCoordBR: Point2D = null;
|
|
47
|
+
let west: Point2D = null;
|
|
48
|
+
let north: Point2D = null;
|
|
49
|
+
let south: Point2D = null;
|
|
50
|
+
let east: Point2D = null;
|
|
51
|
+
let len = shapes.length;
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const fontInfo = RendererSettings.getInstance().getMPLabelFont();
|
|
55
|
+
height = fontInfo.getSize();
|
|
56
|
+
|
|
57
|
+
for (let i = 0; i < len; i++) {
|
|
58
|
+
let pathInfo = MultiPointHandlerSVG.ShapesToGeoSVG(symbolID, shapes[i], ipc, normalize);
|
|
59
|
+
if (pathInfo.svg && pathInfo.bounds) {
|
|
60
|
+
tempBounds = pathInfo.bounds;
|
|
61
|
+
lineWidth = shapes[i].getStroke().getLineWidth()
|
|
62
|
+
tempBounds.grow(Math.round(lineWidth / 2));//adjust for line width so nothing gets clipped.
|
|
63
|
+
if (pathBounds == null)
|
|
64
|
+
pathBounds = tempBounds.clone();
|
|
65
|
+
else
|
|
66
|
+
pathBounds.union(tempBounds);
|
|
67
|
+
paths.push(pathInfo.svg);
|
|
68
|
+
|
|
69
|
+
if (pathInfo.fillPattern && !fillTexture)
|
|
70
|
+
fillTexture = pathInfo.fillPattern
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let tempModifier: ShapeInfo, len2 = modifiers.length;
|
|
75
|
+
let tiTemp: SVGTextInfo = null;
|
|
76
|
+
for (let j = 0; j < len2; j++) {
|
|
77
|
+
tempModifier = modifiers[j];
|
|
78
|
+
|
|
79
|
+
if (tempModifier.getModifierString()) {
|
|
80
|
+
let tempLocation: Point2D = tempModifier.getModifierPosition();
|
|
81
|
+
|
|
82
|
+
let justify = tempModifier.getTextJustify();
|
|
83
|
+
let strJustify = "start";
|
|
84
|
+
if (justify === ShapeInfo.justify_left)
|
|
85
|
+
strJustify = "start";
|
|
86
|
+
else if (justify === ShapeInfo.justify_center)
|
|
87
|
+
strJustify = "middle";
|
|
88
|
+
else if (justify === ShapeInfo.justify_right)
|
|
89
|
+
strJustify = "end";
|
|
90
|
+
|
|
91
|
+
let degrees = tempModifier.getModifierAngle();
|
|
92
|
+
tiTemp = new SVGTextInfo(tempModifier.getModifierString(), tempLocation, fontInfo, strJustify, degrees);
|
|
93
|
+
|
|
94
|
+
let bounds2D = tiTemp.getTextBounds();
|
|
95
|
+
let bounds = new Rectangle(bounds2D.x, bounds2D.y, bounds2D.width, bounds2D.height)
|
|
96
|
+
|
|
97
|
+
//make sure labels are in the bbox, otherwise they can
|
|
98
|
+
//make the canvas grow out of control.
|
|
99
|
+
//if (tiTemp && bbox.containsRectangle(bounds))
|
|
100
|
+
//if(bbox !== null)
|
|
101
|
+
if (tiTemp) {
|
|
102
|
+
if ((bbox && bbox.intersects(bounds)) || bbox == null) {
|
|
103
|
+
labels.push(tiTemp);
|
|
104
|
+
if (bounds) {
|
|
105
|
+
if (labelBounds)
|
|
106
|
+
labelBounds.union(bounds);
|
|
107
|
+
else
|
|
108
|
+
labelBounds = bounds;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} else if (tempModifier.getModifierImageInfo()) {
|
|
113
|
+
let bounds2D = tempModifier.getModifierImageInfo().getImageBounds()
|
|
114
|
+
let bounds = new Rectangle(0, 0, bounds2D.width, bounds2D.height)
|
|
115
|
+
|
|
116
|
+
let tempLocation: Point2D = tempModifier.getModifierPosition();
|
|
117
|
+
tempLocation.setLocation(tempLocation.x - bounds.getWidth() / 2, tempLocation.y - bounds.getHeight() / 2);
|
|
118
|
+
let x = tempLocation.x
|
|
119
|
+
let y = tempLocation.y
|
|
120
|
+
bounds.setLocation(x, y)
|
|
121
|
+
|
|
122
|
+
let angle = tempModifier.getModifierAngle()
|
|
123
|
+
paths.push('<image transform="translate(' + x + ',' + y + ') rotate(' + angle + ')" href="' + tempModifier.getModifierImage() + '" />')
|
|
124
|
+
if (angle !== 0) {
|
|
125
|
+
bounds2D.x = tempLocation.x
|
|
126
|
+
bounds2D.y = tempLocation.y
|
|
127
|
+
bounds2D = SVGTextInfo.getRotatedRectangleBounds(bounds2D, tempLocation, -angle, "middle")
|
|
128
|
+
bounds = new Rectangle(bounds2D.x, bounds2D.y, bounds2D.width, bounds2D.height)
|
|
129
|
+
}
|
|
130
|
+
if (bounds) {
|
|
131
|
+
if ((bbox && bbox.intersects(bounds)) || bbox == null) {
|
|
132
|
+
if (pathBounds)
|
|
133
|
+
pathBounds.union(bounds);
|
|
134
|
+
else
|
|
135
|
+
pathBounds = bounds;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (pathBounds) {
|
|
141
|
+
unionBounds = pathBounds.clone();
|
|
142
|
+
}
|
|
143
|
+
if (labelBounds) {
|
|
144
|
+
if (unionBounds) {
|
|
145
|
+
unionBounds.union(labelBounds);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
unionBounds = labelBounds;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
//get geo bounds for canvas
|
|
153
|
+
if (unionBounds) {
|
|
154
|
+
let coordTL = new Point2D();
|
|
155
|
+
coordTL.setLocation(unionBounds.getX(), unionBounds.getY());
|
|
156
|
+
let coordBR = new Point2D();
|
|
157
|
+
coordBR.setLocation(unionBounds.getX() + unionBounds.getWidth(), unionBounds.getY() + unionBounds.getHeight());
|
|
158
|
+
|
|
159
|
+
let coordTR = new Point2D();
|
|
160
|
+
coordTR.setLocation(unionBounds.getX() + unionBounds.getWidth(), unionBounds.getY());
|
|
161
|
+
let coordBL = new Point2D();
|
|
162
|
+
coordBL.setLocation(unionBounds.getX(), unionBounds.getY() + unionBounds.getHeight());
|
|
163
|
+
|
|
164
|
+
south = new Point2D(unionBounds.getX() + unionBounds.getWidth() / 2, unionBounds.getY() + unionBounds.getHeight());
|
|
165
|
+
north = new Point2D(unionBounds.getX() + unionBounds.getWidth() / 2, unionBounds.getY());
|
|
166
|
+
east = new Point2D(unionBounds.getX() + unionBounds.getWidth(), unionBounds.getY() + unionBounds.getHeight() / 2);
|
|
167
|
+
west = new Point2D(unionBounds.getX(), unionBounds.getY() + unionBounds.getHeight() / 2);
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
geoCoordTL = ipc.PixelsToGeo(coordTL);
|
|
171
|
+
geoCoordBR = ipc.PixelsToGeo(coordBR);
|
|
172
|
+
geoCoordTR = ipc.PixelsToGeo(coordTR);
|
|
173
|
+
geoCoordBL = ipc.PixelsToGeo(coordBL);
|
|
174
|
+
|
|
175
|
+
north = ipc.PixelsToGeo(north);
|
|
176
|
+
south = ipc.PixelsToGeo(south);
|
|
177
|
+
east = ipc.PixelsToGeo(east);
|
|
178
|
+
west = ipc.PixelsToGeo(west);
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
if (normalize) {
|
|
182
|
+
geoCoordTL = MultiPointHandler.NormalizeCoordToGECoord(geoCoordTL);
|
|
183
|
+
geoCoordBR = MultiPointHandler.NormalizeCoordToGECoord(geoCoordBR);
|
|
184
|
+
geoCoordTR = MultiPointHandler.NormalizeCoordToGECoord(geoCoordTR);
|
|
185
|
+
geoCoordBL = MultiPointHandler.NormalizeCoordToGECoord(geoCoordBL);
|
|
186
|
+
|
|
187
|
+
north = MultiPointHandler.NormalizeCoordToGECoord(north);
|
|
188
|
+
south = MultiPointHandler.NormalizeCoordToGECoord(south);
|
|
189
|
+
east = MultiPointHandler.NormalizeCoordToGECoord(east);
|
|
190
|
+
west = MultiPointHandler.NormalizeCoordToGECoord(west);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else//nothing to draw
|
|
194
|
+
{
|
|
195
|
+
geoCoordTL = new Point2D(0, 0);
|
|
196
|
+
geoCoordBR = new Point2D(0, 0);
|
|
197
|
+
geoCoordTR = new Point2D(0, 0);
|
|
198
|
+
geoCoordBL = new Point2D(0, 0);
|
|
199
|
+
|
|
200
|
+
north = new Point2D(0, 0);
|
|
201
|
+
south = new Point2D(0, 0);
|
|
202
|
+
east = new Point2D(0, 0);
|
|
203
|
+
west = new Point2D(0, 0);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
ErrorLogger.LogException("MultiPointHandler", "GeoSVGize", err);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (paths && len > 0 && unionBounds) {
|
|
211
|
+
//create group with offset translation
|
|
212
|
+
//ctx.translate(bounds.getX() * -1, bounds.getY() * -1);
|
|
213
|
+
let group = '<g transform="translate(' + (unionBounds.getX() * -1) + ',' + (unionBounds.getY() * -1) + ')">';
|
|
214
|
+
|
|
215
|
+
//loop through paths and labels and build SVG.
|
|
216
|
+
for (let i = 0; i < paths.length; i++) {
|
|
217
|
+
group += paths[i];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
let labelStrs = this.renderTextElement(labels, textColor, textBackgroundColor);
|
|
221
|
+
for (let j = 0; j < labelStrs.length; j++) {
|
|
222
|
+
group += labelStrs[j];
|
|
223
|
+
}
|
|
224
|
+
//close
|
|
225
|
+
group += '</g>';
|
|
226
|
+
|
|
227
|
+
//wrap in SVG
|
|
228
|
+
let geoSVG = '<svg width="' + Math.ceil(unionBounds.getWidth()) + 'px" height="' + Math.ceil(unionBounds.getHeight()) + 'px" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" version="1.1">';
|
|
229
|
+
|
|
230
|
+
geoSVG += ("<metadata>\n");
|
|
231
|
+
geoSVG += ("<id>") + id + ("</id>\n");
|
|
232
|
+
geoSVG += ("<name>") + name + ("</name>\n");
|
|
233
|
+
geoSVG += ("<description>") + description + ("</description>\n");
|
|
234
|
+
geoSVG += ("<symbolID>") + symbolID + ("</symbolID>\n");
|
|
235
|
+
geoSVG += ("<geoTL>") + geoCoordTL.getX() + " " + geoCoordTL.getY() + ("</geoTL>\n")
|
|
236
|
+
geoSVG += ("<geoBR>") + geoCoordBR.getX() + " " + geoCoordBR.getY() + ("</geoBR>\n")
|
|
237
|
+
geoSVG += ("<geoTR>") + geoCoordTR.getX() + " " + geoCoordTR.getY() + ("</geoTR>\n")
|
|
238
|
+
geoSVG += ("<geoBL>") + geoCoordBL.getX() + " " + geoCoordBL.getY() + ("</geoBL>\n")
|
|
239
|
+
geoSVG += ("<north>") + north.getY() + ("</north>\n")
|
|
240
|
+
geoSVG += ("<south>") + south.getY() + ("</south>\n")
|
|
241
|
+
geoSVG += ("<east>") + east.getX() + ("</east>\n")
|
|
242
|
+
geoSVG += ("<west>") + west.getX() + ("</west>\n")
|
|
243
|
+
geoSVG += ("<wasClipped>") + wasClipped + ("</wasClipped>\n")
|
|
244
|
+
geoSVG += ("<width>") + unionBounds.getWidth() + ("</width>\n");
|
|
245
|
+
geoSVG += ("<height>") + unionBounds.getHeight() + ("</height>\n");
|
|
246
|
+
geoSVG += ("</metadata>\n");
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
/*//Scale the image, commented out as I decided to alter scale in getReasonableScale rather than adjust after the fact.
|
|
250
|
+
let tempWidth = Math.ceil(unionBounds.getWidth());
|
|
251
|
+
let tempHeight = Math.ceil(unionBounds.getHeight());
|
|
252
|
+
let quality = 1.0;
|
|
253
|
+
let bigger = Math.max(tempWidth, tempHeight);
|
|
254
|
+
let max = 1000;
|
|
255
|
+
if(!converter)
|
|
256
|
+
{
|
|
257
|
+
if(bigger < max)
|
|
258
|
+
{
|
|
259
|
+
if(bigger * 2 < max)
|
|
260
|
+
{
|
|
261
|
+
quality = 2;
|
|
262
|
+
}
|
|
263
|
+
else
|
|
264
|
+
{
|
|
265
|
+
quality = max / bigger;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else
|
|
269
|
+
{
|
|
270
|
+
quality = 1;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
let geoSVG = '<svg viewBox="0 0 ' + tempWidth + ' ' + tempHeight + '"' + ' width="' + (tempWidth * quality) + 'px" height="' + (tempHeight * quality) + 'px" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" version="1.1">';//*/
|
|
274
|
+
if (fillTexture)
|
|
275
|
+
geoSVG += fillTexture;
|
|
276
|
+
geoSVG += group;
|
|
277
|
+
geoSVG += '</svg>';//*/
|
|
278
|
+
|
|
279
|
+
return geoSVG;
|
|
280
|
+
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
//return blank 2x2 SVG
|
|
284
|
+
return '<svg width="2px" height="2px" xmlns="http://www.w3.org/2000/svg" version="1.1"></svg>'
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @param {SVGTextInfo[]} tiArray
|
|
290
|
+
* @param {string} color a hex string "#000000"
|
|
291
|
+
* @param {string} outlineColor a hex string "#000000"
|
|
292
|
+
*/
|
|
293
|
+
static renderTextElement(tiArray: SVGTextInfo[], color: string, outlineColor: string): string[] {
|
|
294
|
+
//ctx.lineCap = "butt";
|
|
295
|
+
//ctx.lineJoin = "miter";
|
|
296
|
+
//ctx.miterLimit = 3;
|
|
297
|
+
/*ctx.lineCap = "round";
|
|
298
|
+
ctx.lineJoin = "round";
|
|
299
|
+
ctx.miterLimit = 3;*/
|
|
300
|
+
let svgElements: string[] = []
|
|
301
|
+
|
|
302
|
+
let size = tiArray.length,
|
|
303
|
+
tempShape: SVGTextInfo = null,
|
|
304
|
+
textColor = "#000000",
|
|
305
|
+
tbm = RendererSettings.getInstance().getTextBackgroundMethod(),
|
|
306
|
+
outlineWidth = RendererSettings.getInstance().getTextOutlineWidth();
|
|
307
|
+
|
|
308
|
+
if (color) {
|
|
309
|
+
textColor = color;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
if (!outlineColor) {
|
|
314
|
+
outlineColor = RendererUtilities.getIdealOutlineColor(new Color(textColor)).toHexString(false);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
if (tbm === RendererSettings.TextBackgroundMethod_OUTLINE) {
|
|
319
|
+
for (let i = 0; i < size; i++) {
|
|
320
|
+
tempShape = tiArray[i];
|
|
321
|
+
svgElements.push(tempShape.toSVGElement(textColor, outlineColor, outlineWidth));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
else if (tbm === RendererSettings.TextBackgroundMethod_OUTLINE_QUICK) {
|
|
325
|
+
//TODO: need to update, this is regular outline approach
|
|
326
|
+
for (let i = 0; i < size; i++) {
|
|
327
|
+
tempShape = tiArray[i];
|
|
328
|
+
svgElements.push(tempShape.toSVGElement(textColor, outlineColor, outlineWidth));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
else if (tbm === RendererSettings.TextBackgroundMethod_COLORFILL) {
|
|
332
|
+
for (let i = 0; i < size; i++) {
|
|
333
|
+
tempShape = tiArray[i];
|
|
334
|
+
svgElements.push(tempShape.getTextOutlineBounds().toSVGElement(null, null, outlineColor));
|
|
335
|
+
svgElements.push(tempShape.toSVGElement(textColor, null));
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
else //if(tbm === RendererSettings.TextBackgroundMethod_NONE)
|
|
339
|
+
{
|
|
340
|
+
for (let j = 0; j < size; j++) {
|
|
341
|
+
tempShape = tiArray[j];
|
|
342
|
+
svgElements.push(tempShape.toSVGElement(textColor, null));
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return svgElements;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* @param {string} symbolID
|
|
351
|
+
* @param {ShapeInfo} shapeInfo
|
|
352
|
+
* @param {IPointConversion} ipc
|
|
353
|
+
* @param {boolean} normalize
|
|
354
|
+
* @returns {object} { svg: string, bounds: Rectangle, fillPattern: string }
|
|
355
|
+
*/
|
|
356
|
+
static ShapesToGeoSVG(symbolID: string, shapeInfo: ShapeInfo, ipc: IPointConversion, normalize: boolean): { svg: string, bounds: Rectangle, fillPattern: string } {
|
|
357
|
+
let path: Path = null;
|
|
358
|
+
let fillColor: string = null;
|
|
359
|
+
let lineColor: string = null;
|
|
360
|
+
let lineWidth: number = null;
|
|
361
|
+
let lineAlpha = 1.0;
|
|
362
|
+
let fillAlpha = 1.0;
|
|
363
|
+
let dashArray: number[] = null;
|
|
364
|
+
let fillPattern: string = null;
|
|
365
|
+
|
|
366
|
+
if (shapeInfo.getLineColor()) {
|
|
367
|
+
let lineColorTemp = shapeInfo.getLineColor();
|
|
368
|
+
lineAlpha = lineColorTemp.getAlpha() / 255;
|
|
369
|
+
lineColor = lineColorTemp.toHexString(false);
|
|
370
|
+
}
|
|
371
|
+
if (shapeInfo.getFillColor()) {
|
|
372
|
+
let fillColorTemp = shapeInfo.getFillColor();
|
|
373
|
+
fillAlpha = fillColorTemp.getAlpha() / 255;
|
|
374
|
+
fillColor = fillColorTemp.toHexString(false);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (shapeInfo.getPatternFillImageInfo()) {
|
|
378
|
+
let bounds = shapeInfo.getPatternFillImageInfo().getImageBounds();
|
|
379
|
+
fillPattern = '<defs><pattern id="fillPattern" patternUnits="userSpaceOnUse" width="' + bounds.width + '" height="' + bounds.height + '"><image href="' + shapeInfo.getPatternFillImage() + '" /></pattern></defs>'
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
let stroke = shapeInfo.getStroke();
|
|
383
|
+
if (stroke !== null) {
|
|
384
|
+
lineWidth = Math.round(stroke.getLineWidth());
|
|
385
|
+
dashArray = stroke.getDashArray();
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
let shapesArray = shapeInfo.getPolylines();
|
|
389
|
+
path = new Path();
|
|
390
|
+
if (dashArray)
|
|
391
|
+
path.setLineDash(dashArray.toString());
|
|
392
|
+
for (let i = 0; i < shapesArray.length; i++) {
|
|
393
|
+
let shape = shapesArray[i];
|
|
394
|
+
|
|
395
|
+
for (let j = 0; j < shape.length; j++) {
|
|
396
|
+
let coord = shape[j];
|
|
397
|
+
if (j === 0) {
|
|
398
|
+
path.moveTo(coord.x, coord.y);
|
|
399
|
+
} else if (dashArray) {
|
|
400
|
+
path.dashedLineTo(coord.x, coord.y, dashArray);
|
|
401
|
+
} else {
|
|
402
|
+
path.lineTo(coord.x, coord.y);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (fillPattern)
|
|
407
|
+
fillColor = "url(#fillPattern)";
|
|
408
|
+
let svgElement = path.toSVGElement(lineColor, lineWidth, fillColor, lineAlpha, fillAlpha,"round");
|
|
409
|
+
let svgInfo = { svg: svgElement, bounds: path.getBounds(), fillPattern: fillPattern };
|
|
410
|
+
return svgInfo;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { type double } from "../../../c5isr/graphics2d/BasicTypes";
|
|
2
|
+
import { Point } from "../../graphics2d/Point";
|
|
3
|
+
import { Point2D } from "../../graphics2d/Point2D";
|
|
4
|
+
import { IPointConversion } from "../../renderer/utilities/IPointConversion";
|
|
5
|
+
import { GeoPixelConversion } from "./GeoPixelConversion";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export class PointConverter implements IPointConversion {
|
|
13
|
+
private _controlLat: double = 0;
|
|
14
|
+
private _controlLong: double = 0;
|
|
15
|
+
private _scale: double = 0;
|
|
16
|
+
private _metersPerPixel: double = 0;
|
|
17
|
+
private _normalize: boolean = true;
|
|
18
|
+
public set_normalize(value: boolean): void {
|
|
19
|
+
this._normalize = value;
|
|
20
|
+
}
|
|
21
|
+
public constructor(controlLong: double, controlLat: double, scale: double);
|
|
22
|
+
/**
|
|
23
|
+
* add constructor to handle when earth is flipped about it's X axis (South is on top)
|
|
24
|
+
* @param left
|
|
25
|
+
* @param right
|
|
26
|
+
* @param top
|
|
27
|
+
* @param bottom
|
|
28
|
+
* @param scale
|
|
29
|
+
*/
|
|
30
|
+
public constructor(left: double, top: double, right: double, bottom: double, scale: double);
|
|
31
|
+
public constructor(...args: unknown[]) {
|
|
32
|
+
switch (args.length) {
|
|
33
|
+
case 3: {
|
|
34
|
+
const [controlLong, controlLat, scale] = args as [double, double, double];
|
|
35
|
+
try {
|
|
36
|
+
this._controlLat = controlLat;
|
|
37
|
+
this._controlLong = controlLong;
|
|
38
|
+
this._scale = scale;
|
|
39
|
+
this._metersPerPixel = GeoPixelConversion.metersPerPixel(scale);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
if (e instanceof Error) {
|
|
42
|
+
throw e;
|
|
43
|
+
} else {
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
case 5: {
|
|
52
|
+
const [left, top, right, bottom, scale] = args as [double, double, double, double, double];
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
this._controlLat = top;
|
|
56
|
+
this._controlLong = left;
|
|
57
|
+
this._scale = scale;
|
|
58
|
+
this._metersPerPixel = GeoPixelConversion.metersPerPixel(scale);
|
|
59
|
+
if (top < bottom) {
|
|
60
|
+
|
|
61
|
+
this._metersPerPixel = -this._metersPerPixel;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
} catch (e) {
|
|
65
|
+
if (e instanceof Error) {
|
|
66
|
+
throw e;
|
|
67
|
+
} else {
|
|
68
|
+
throw e;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
default: {
|
|
76
|
+
throw Error(`Invalid number of arguments`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public PixelsToGeo(pixel: Point): Point;
|
|
82
|
+
public PixelsToGeo(pixel: Point2D): Point2D;
|
|
83
|
+
public PixelsToGeo(...args: unknown[]): Point | Point2D {
|
|
84
|
+
const [pixel] = args as [Point | Point2D];
|
|
85
|
+
try {
|
|
86
|
+
let y: double = GeoPixelConversion.y2lat(pixel.getY(), this._scale, this._controlLat, this._metersPerPixel);
|
|
87
|
+
let x: double = GeoPixelConversion.x2long(pixel.getX(), this._scale, this._controlLong, y, this._metersPerPixel);
|
|
88
|
+
if (pixel instanceof Point)
|
|
89
|
+
return new Point(x, y)
|
|
90
|
+
else
|
|
91
|
+
return new Point2D(x, y)
|
|
92
|
+
} catch (e) {
|
|
93
|
+
if (e instanceof Error) {
|
|
94
|
+
throw e;
|
|
95
|
+
} else {
|
|
96
|
+
throw e;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
public GeoToPixels(coord: Point): Point;
|
|
103
|
+
|
|
104
|
+
public GeoToPixels(coord: Point2D): Point2D;
|
|
105
|
+
public GeoToPixels(...args: unknown[]): Point | Point2D {
|
|
106
|
+
const [coord] = args as [Point | Point2D];
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
let y: double = GeoPixelConversion.lat2y(coord.getY(), this._scale, this._controlLat, this._metersPerPixel);
|
|
110
|
+
let x: double = GeoPixelConversion.long2x(coord.getX(), this._scale, this._controlLong, coord.getY(), this._metersPerPixel, this._normalize);
|
|
111
|
+
if (coord instanceof Point)
|
|
112
|
+
return new Point(x, y)
|
|
113
|
+
else
|
|
114
|
+
return new Point2D(x, y)
|
|
115
|
+
} catch (e) {
|
|
116
|
+
if (e instanceof Error) {
|
|
117
|
+
throw e;
|
|
118
|
+
} else {
|
|
119
|
+
throw e;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
export class SymbolModifiers {
|
|
6
|
+
public A_SYMBOL_ICON: string = "";
|
|
7
|
+
public B_ECHELON: string = "";
|
|
8
|
+
public C_QUANTITY: string = "";
|
|
9
|
+
public H_ADDITIONAL_INFO_1: string = "";
|
|
10
|
+
public H1_ADDITIONAL_INFO_2: string = "";
|
|
11
|
+
public H2_ADDITIONAL_INFO_3: string = "";
|
|
12
|
+
public N_HOSTILE: string = "";
|
|
13
|
+
public Q_DIRECTION_OF_MOVEMENT: string = "";
|
|
14
|
+
public S_OFFSET_INDICATOR: string = "";
|
|
15
|
+
public T_UNIQUE_DESIGNATION_1: string = "";
|
|
16
|
+
public T1_UNIQUE_DESIGNATION_2: string = "";
|
|
17
|
+
public V_EQUIP_TYPE: string = "";
|
|
18
|
+
public W_DTG_1: string = "";
|
|
19
|
+
public W1_DTG_2: string = "";
|
|
20
|
+
public X_ALTITUDE_DEPTH: Array<number> = new Array<number>();
|
|
21
|
+
public Y_LOCATION: string = "";
|
|
22
|
+
public AM_DISTANCE: Array<number> = new Array<number>();
|
|
23
|
+
public AN_AZIMUTH: Array<number> = new Array<number>();
|
|
24
|
+
public FillColor: string = "";
|
|
25
|
+
public LineColor: string = "";
|
|
26
|
+
}
|