-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathC5Ren.ts
More file actions
178 lines (163 loc) · 7.28 KB
/
Copy pathC5Ren.ts
File metadata and controls
178 lines (163 loc) · 7.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import { ErrorLogger } from "./src/main/ts/armyc2/c5isr/renderer/utilities/ErrorLogger";
import { GENCLookup } from "./src/main/ts/armyc2/c5isr/renderer/utilities/GENCLookup";
import { C2DLookup } from "./src/main/ts/armyc2/c5isr/renderer/utilities/C2DLookup";
import { MSLookup } from "./src/main/ts/armyc2/c5isr/renderer/utilities/MSLookup";
import { SVGLookup } from "./src/main/ts/armyc2/c5isr/renderer/utilities/SVGLookup";
export { Point } from "./src/main/ts/armyc2/c5isr/graphics2d/Point";
export { Point2D } from "./src/main/ts/armyc2/c5isr/graphics2d/Point2D";
export { Rectangle2D } from "./src/main/ts/armyc2/c5isr/graphics2d/Rectangle2D";
export { Font } from "./src/main/ts/armyc2/c5isr/graphics2d/Font";
export { Color } from "./src/main/ts/armyc2/c5isr/renderer/utilities/Color";
export { AffiliationColors } from "./src/main/ts/armyc2/c5isr/renderer/utilities/AffiliationColors";
export { DistanceUnit } from "./src/main/ts/armyc2/c5isr/renderer/utilities/DistanceUnit";
export { LogLevel } from "./src/main/ts/armyc2/c5isr/renderer/utilities/LogLevel";
export { ErrorLogger } from "./src/main/ts/armyc2/c5isr/renderer/utilities/ErrorLogger";
export { MilStdAttributes } from "./src/main/ts/armyc2/c5isr/renderer/utilities/MilStdAttributes";
export { Modifiers } from "./src/main/ts/armyc2/c5isr/renderer/utilities/Modifiers";
export { DrawRules } from "./src/main/ts/armyc2/c5isr/renderer/utilities/DrawRules";
export { MODrawRules } from "./src/main/ts/armyc2/c5isr/renderer/utilities/MODrawRules";
export { GENCLookup } from "./src/main/ts/armyc2/c5isr/renderer/utilities/GENCLookup";
export { C2DLookup } from "./src/main/ts/armyc2/c5isr/renderer/utilities/C2DLookup";
export { MSLookup } from "./src/main/ts/armyc2/c5isr/renderer/utilities/MSLookup";
export { MSInfo } from "./src/main/ts/armyc2/c5isr/renderer/utilities/MSInfo";
export { SectorModUtils } from "./src/main/ts/armyc2/c5isr/renderer/utilities/SectorModUtils";
export { SVGInfo } from "./src/main/ts/armyc2/c5isr/renderer/utilities/SVGInfo";
export { SVGLookup } from "./src/main/ts/armyc2/c5isr/renderer/utilities/SVGLookup";
export { SVGSymbolInfo } from "./src/main/ts/armyc2/c5isr/renderer/utilities/SVGSymbolInfo";
export { SymbolUtilities } from "./src/main/ts/armyc2/c5isr/renderer/utilities/SymbolUtilities";
export { RendererSettings } from "./src/main/ts/armyc2/c5isr/renderer/utilities/RendererSettings";
export { SymbolID } from "./src/main/ts/armyc2/c5isr/renderer/utilities/SymbolID";
export { ShapeInfo } from "./src/main/ts/armyc2/c5isr/renderer/utilities/ShapeInfo";
export { MilStdSymbol } from "./src/main/ts/armyc2/c5isr/renderer/utilities/MilStdSymbol";
export { BasicShapes } from "./src/main/ts/armyc2/c5isr/JavaLineArray/BasicShapes";
export { Basic3DShapes } from "./src/main/ts/armyc2/c5isr/web/render/utilities/Basic3DShapes";
export type { IPointConversion } from "./src/main/ts/armyc2/c5isr/renderer/utilities/IPointConversion";
export { PointConverter3D } from "./src/main/ts/armyc2/c5isr/renderer/utilities/PointConverter3D";
export { clsRenderer } from "./src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer";
export { RendererUtilities } from "./src/main/ts/armyc2/c5isr/renderer/utilities/RendererUtilities";
export { MilStdIconRenderer } from "./src/main/ts/armyc2/c5isr/renderer/MilStdIconRenderer";
export { WebRenderer } from "./src/main/ts/armyc2/c5isr/web/render/WebRenderer";
/**
* Module for rendering 2525D/E symbology
*/
let initialized: boolean = false;
let initializing: boolean = false;
/**
* Loads files needed by the renderer and initializes its data.
* Required call before any rendering.
* Must wait for the returned promise to resolve before any rendering.
* @param location where renderer and asset files are location. So if location is "127.0.0.1:8080/dist/C5Ren.js"
* pass in "/dist/". This is needed when all the files aren't in the same location. When the renderer gets imported, it thinks it's
* in the location of the file that imported it, not where it actually exists and then it can't find the asset files. If location is not
* set, the renderer assumes the json asset files are in the same location as where the C5Ren script is being run.
* Additionally, if your build process hashes the manifest.json file, you should include the new name like "/dist/manifest.[hash].json"
* @deprecated
*/
export async function initialize(location?: string): Promise<any> {
initializing = true;
/*
try
{
if(!initialized)
{
let promises:Array<Promise<any>> = new Array<Promise<any>>()
let manifestName:string = 'manifest.json';
let manifestIndex:number = -1;
//Load data from specific path
let path:string = "";
if(location)
{
if(location.startsWith('/')==false)
location = '/' + location;
manifestIndex = location.indexOf("manifest");
if(location.endsWith("json") && manifestIndex >= 0)
{
manifestName = location.substring(manifestIndex);
location = location.substring(0,manifestIndex);
}
if(location.endsWith('/')==true)
location = location.substring(0,location.length-1);
path = location;
}
//load data from path provided in manifest file/////////////////////
// Fetch Webpack manifest to get the hashed filename
const manifestResponse = await fetch(location + "/" + manifestName);
const manifest = await manifestResponse.json();
// Get the hashed JSON file URL
const gencUrl = path + manifest['data/genc.json'];
const msdUrl = path + manifest['data/msd.json'];
const mseUrl = path + manifest['data/mse.json'];
const svgdUrl = path + manifest['data/svgd.json'];
const svgeUrl = path + manifest['data/svge.json'];
promises.push(GENCLookup.setData(gencUrl));
promises.push(MSLookup.setData([msdUrl,mseUrl]));
promises.push(SVGLookup.setData([svgdUrl,svgeUrl]));
await Promise.all(promises).then(values => {GENCLookup.getInstance();MSLookup.getInstance();SVGLookup.getInstance()}).catch(error => {throw error;});
initialized=true;
}
}
catch(e)
{
throw e;
}
finally
{
initializing = false;
}//*/
initializing = false;
initialized = true;
}
/**
*
* @param location
* @deprecated
*/
export async function init(location?: string) {
/*initializing = true;
try
{
if(!initialized)
{
GENCLookup.setDataObject();//(genc);
MSLookup.setDataObject();//(msd,mse);
SVGLookup.setDataObject();//(svgd,svge);
if(GENCLookup.getInstance() && MSLookup.getInstance() && SVGLookup.getInstance())
initialized=true;
}
}
catch(e)
{
throw e;
}
finally
{
initializing = false;
}//*/
initialized = true;
}
/**
* Returns true if renderer files are loaded and initialized.
* @returns boolean
*/
export function isReady(): boolean {
try {
if (
GENCLookup.getInstance() &&
C2DLookup.getInstance() &&
MSLookup.getInstance() &&
SVGLookup.getInstance()
)
return (
GENCLookup.getInstance().isReady() &&
C2DLookup.getInstance().isReady() &&
MSLookup.getInstance().isReady() &&
SVGLookup.getInstance().isReady()
);
else return false;
} catch (e) {
if (e instanceof Error) {
ErrorLogger.LogException("C5Ren", "isReady()", e);
}
return false;
}
}