@orbat-mapper/tactical-map-sheet 0.6.9 → 0.8.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/README.md +20 -1
- package/dist/{create-tactical-map-sheet-DLJy2TJk.mjs → create-tactical-map-sheet-DVr96Nie.mjs} +1312 -1170
- package/dist/{create-tactical-map-sheet-CEQT11I-.d.mts → create-tactical-map-sheet-aMfOzCpu.d.mts} +236 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/pdf.d.mts +3 -2
- package/dist/pdf.mjs +30 -3
- package/package.json +5 -4
package/dist/{create-tactical-map-sheet-CEQT11I-.d.mts → create-tactical-map-sheet-aMfOzCpu.d.mts}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ControlMeasure, HighlightAppearance, PatternId, TextAmplifiers } from "@orbat-mapper/control-measures";
|
|
2
2
|
import { PointSymbolOffset, PointSymbolRender } from "@orbat-mapper/tactical-draw";
|
|
3
|
+
import { NoteCapability, NoteModel } from "@orbat-mapper/tactical-notes";
|
|
3
4
|
|
|
4
5
|
//#region ../../node_modules/.pnpm/@types+geojson@7946.0.16/node_modules/@types/geojson/index.d.ts
|
|
5
6
|
/**
|
|
@@ -205,6 +206,52 @@ interface ScenePoint {
|
|
|
205
206
|
readonly xMm: number;
|
|
206
207
|
readonly yMm: number;
|
|
207
208
|
}
|
|
209
|
+
interface ScenePath {
|
|
210
|
+
readonly kind: "path";
|
|
211
|
+
readonly points: readonly ScenePoint[];
|
|
212
|
+
readonly closed?: boolean;
|
|
213
|
+
readonly strokeColor: string;
|
|
214
|
+
/** `0` means the path is not stroked at all (fill only), never a hairline. */
|
|
215
|
+
readonly strokeWidthMm: number;
|
|
216
|
+
readonly strokeDashMm: readonly number[];
|
|
217
|
+
readonly lineCap: "butt" | "round" | "square";
|
|
218
|
+
readonly lineJoin: "bevel" | "round" | "miter";
|
|
219
|
+
/** Stroke opacity multiplied with any alpha in `strokeColor`; omitted means `1`. */
|
|
220
|
+
readonly strokeOpacity?: number;
|
|
221
|
+
readonly fillColor?: string;
|
|
222
|
+
readonly fillPatternId?: string;
|
|
223
|
+
readonly attributes?: Readonly<Record<string, string | number>>;
|
|
224
|
+
}
|
|
225
|
+
type ScenePatternPathOperation = {
|
|
226
|
+
readonly type: "move" | "line";
|
|
227
|
+
readonly to: ScenePoint;
|
|
228
|
+
} | {
|
|
229
|
+
readonly type: "cubic";
|
|
230
|
+
readonly control1: ScenePoint;
|
|
231
|
+
readonly control2: ScenePoint;
|
|
232
|
+
readonly to: ScenePoint;
|
|
233
|
+
} | {
|
|
234
|
+
readonly type: "close";
|
|
235
|
+
};
|
|
236
|
+
interface ScenePatternPaint {
|
|
237
|
+
readonly fillColor?: string;
|
|
238
|
+
readonly stroke?: {
|
|
239
|
+
readonly color: string;
|
|
240
|
+
readonly widthMm: number;
|
|
241
|
+
readonly lineCap: "butt" | "round";
|
|
242
|
+
readonly dashMm: readonly number[];
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
type ScenePatternCommand = {
|
|
246
|
+
readonly type: "path";
|
|
247
|
+
readonly operations: readonly ScenePatternPathOperation[];
|
|
248
|
+
readonly paint: ScenePatternPaint;
|
|
249
|
+
} | {
|
|
250
|
+
readonly type: "circle";
|
|
251
|
+
readonly center: ScenePoint;
|
|
252
|
+
readonly radiusMm: number;
|
|
253
|
+
readonly paint: ScenePatternPaint;
|
|
254
|
+
};
|
|
208
255
|
interface MapSheetPatternIdentity {
|
|
209
256
|
readonly id: string;
|
|
210
257
|
readonly pattern: PatternId;
|
|
@@ -214,6 +261,127 @@ interface MapSheetPatternIdentity {
|
|
|
214
261
|
readonly phaseXMm: number;
|
|
215
262
|
readonly phaseYMm: number;
|
|
216
263
|
}
|
|
264
|
+
interface ScenePatternResource {
|
|
265
|
+
readonly identity: MapSheetPatternIdentity;
|
|
266
|
+
readonly commands: readonly ScenePatternCommand[];
|
|
267
|
+
}
|
|
268
|
+
interface SceneText {
|
|
269
|
+
readonly kind: "text";
|
|
270
|
+
readonly position: ScenePoint;
|
|
271
|
+
readonly text: string;
|
|
272
|
+
readonly rotationDegrees: number;
|
|
273
|
+
readonly fontSizeMm: number;
|
|
274
|
+
readonly widthMm: number;
|
|
275
|
+
readonly heightMm: number;
|
|
276
|
+
readonly lineHeightMm: number;
|
|
277
|
+
readonly anchor: "start" | "middle" | "end";
|
|
278
|
+
readonly justify: "left" | "center" | "right";
|
|
279
|
+
readonly color: string;
|
|
280
|
+
readonly background: boolean;
|
|
281
|
+
readonly haloColor?: string;
|
|
282
|
+
readonly haloWidthMm?: number;
|
|
283
|
+
readonly fontStyle?: "normal" | "italic";
|
|
284
|
+
readonly fontWeight?: 300 | 400;
|
|
285
|
+
readonly attributes?: Readonly<Record<string, string | number>>;
|
|
286
|
+
}
|
|
287
|
+
interface SceneVectorSymbol {
|
|
288
|
+
readonly kind: "vector-symbol";
|
|
289
|
+
readonly position: ScenePoint;
|
|
290
|
+
readonly viewBox: readonly [number, number, number, number];
|
|
291
|
+
readonly nodes: readonly SceneVectorNode[];
|
|
292
|
+
readonly resourceId: string;
|
|
293
|
+
readonly width: number;
|
|
294
|
+
readonly height: number;
|
|
295
|
+
readonly anchor: {
|
|
296
|
+
readonly x: number;
|
|
297
|
+
readonly y: number;
|
|
298
|
+
};
|
|
299
|
+
readonly octagonAnchor: {
|
|
300
|
+
readonly x: number;
|
|
301
|
+
readonly y: number;
|
|
302
|
+
};
|
|
303
|
+
readonly scaleMmPerUnit: number;
|
|
304
|
+
readonly rotationDegrees: number;
|
|
305
|
+
readonly opacity: number;
|
|
306
|
+
readonly usesFont: boolean;
|
|
307
|
+
/**
|
|
308
|
+
* Clips PDF output to the viewBox. SVG output always clips, as a nested
|
|
309
|
+
* `<svg>` does. Set where content past the viewBox must not reach the page.
|
|
310
|
+
*/
|
|
311
|
+
readonly clipToViewBox?: boolean;
|
|
312
|
+
}
|
|
313
|
+
interface SceneRasterImage {
|
|
314
|
+
/**
|
|
315
|
+
* Deflates the image inside a PDF. For flat artwork such as a Note, which shrinks
|
|
316
|
+
* greatly. Off by default, because it costs time and memory on large basemap imagery.
|
|
317
|
+
*/
|
|
318
|
+
readonly compressInPdf?: boolean;
|
|
319
|
+
readonly kind: "raster-image";
|
|
320
|
+
readonly mediaType: "image/png" | "image/jpeg";
|
|
321
|
+
readonly data: Uint8Array;
|
|
322
|
+
readonly frame: SceneRectangle;
|
|
323
|
+
readonly opacity: number;
|
|
324
|
+
readonly resourceId: string;
|
|
325
|
+
/**
|
|
326
|
+
* Clockwise rotation (page y points down) about the centre of `frame`, in
|
|
327
|
+
* degrees. `frame` is the unrotated rectangle. Omitted or 0 draws it axis-aligned.
|
|
328
|
+
*/
|
|
329
|
+
readonly rotationDegrees?: number;
|
|
330
|
+
}
|
|
331
|
+
type SceneVectorAttributeValue = string | number | readonly number[];
|
|
332
|
+
interface SceneVectorPathOperation {
|
|
333
|
+
readonly command: "M" | "L" | "H" | "V" | "C" | "S" | "Q" | "T" | "A" | "Z";
|
|
334
|
+
readonly relative: boolean;
|
|
335
|
+
readonly values: readonly number[];
|
|
336
|
+
}
|
|
337
|
+
interface SceneVectorTransform {
|
|
338
|
+
readonly type: "translate" | "scale" | "rotate" | "matrix";
|
|
339
|
+
readonly values: readonly number[];
|
|
340
|
+
}
|
|
341
|
+
interface SceneVectorNodeBase {
|
|
342
|
+
readonly attributes: Readonly<Record<string, SceneVectorAttributeValue>>;
|
|
343
|
+
}
|
|
344
|
+
type SceneVectorNode = (SceneVectorNodeBase & {
|
|
345
|
+
readonly kind: "group";
|
|
346
|
+
readonly transforms: readonly SceneVectorTransform[];
|
|
347
|
+
readonly children: readonly SceneVectorNode[];
|
|
348
|
+
}) | (SceneVectorNodeBase & {
|
|
349
|
+
readonly kind: "path";
|
|
350
|
+
readonly operations: readonly SceneVectorPathOperation[];
|
|
351
|
+
}) | (SceneVectorNodeBase & {
|
|
352
|
+
readonly kind: "circle" | "ellipse" | "rect" | "line";
|
|
353
|
+
}) | (SceneVectorNodeBase & {
|
|
354
|
+
readonly kind: "polyline" | "polygon";
|
|
355
|
+
readonly points: readonly number[];
|
|
356
|
+
}) | (SceneVectorNodeBase & {
|
|
357
|
+
readonly kind: "text";
|
|
358
|
+
readonly text: string;
|
|
359
|
+
});
|
|
360
|
+
type SceneElement = ScenePath | SceneText | SceneVectorSymbol | SceneRasterImage;
|
|
361
|
+
interface SceneGraphic {
|
|
362
|
+
readonly id: string;
|
|
363
|
+
readonly elements: readonly SceneElement[];
|
|
364
|
+
}
|
|
365
|
+
interface SceneLayer {
|
|
366
|
+
readonly id: string;
|
|
367
|
+
readonly graphics: readonly SceneGraphic[];
|
|
368
|
+
readonly attributes?: Readonly<Record<string, string | number>>;
|
|
369
|
+
}
|
|
370
|
+
interface SceneFontResource {
|
|
371
|
+
readonly family: "Open Sans";
|
|
372
|
+
readonly style: "Regular" | "Italic" | "Light";
|
|
373
|
+
readonly mediaType: "font/ttf";
|
|
374
|
+
readonly base64: string;
|
|
375
|
+
}
|
|
376
|
+
interface MillimetreScene {
|
|
377
|
+
readonly page: PhysicalPageSize;
|
|
378
|
+
readonly mapFrame: SceneRectangle;
|
|
379
|
+
readonly backgroundColor?: string;
|
|
380
|
+
readonly layers: readonly SceneLayer[];
|
|
381
|
+
readonly marginalia?: readonly SceneLayer[];
|
|
382
|
+
readonly fonts: readonly SceneFontResource[];
|
|
383
|
+
readonly patterns: readonly ScenePatternResource[];
|
|
384
|
+
}
|
|
217
385
|
//#endregion
|
|
218
386
|
//#region src/mgrs-domain.d.ts
|
|
219
387
|
declare const MGRS_SNAP_INTERVALS: readonly [100, 1000, 10000, 100000];
|
|
@@ -325,6 +493,70 @@ interface MapSheetPointSymbolCapability {
|
|
|
325
493
|
render(symbol: MapSheetPointSymbol): ControlledVectorSymbol;
|
|
326
494
|
}
|
|
327
495
|
//#endregion
|
|
496
|
+
//#region src/note.d.ts
|
|
497
|
+
/**
|
|
498
|
+
* A Note on the map sheet (ADR-0066, ADR-0070). The fields are the subset of
|
|
499
|
+
* tactical-draw's persisted `note` graphic that printing needs, so a `note`
|
|
500
|
+
* Graphic can be passed as is.
|
|
501
|
+
*/
|
|
502
|
+
interface MapSheetNote extends NoteModel {
|
|
503
|
+
readonly id: string;
|
|
504
|
+
readonly kind: "note";
|
|
505
|
+
readonly schemaVersion?: 1;
|
|
506
|
+
/** Centre of the box. */
|
|
507
|
+
readonly position: Position;
|
|
508
|
+
/** Radians clockwise from north. */
|
|
509
|
+
readonly rotation: number;
|
|
510
|
+
/** Ground size of one em, in Web Mercator metres like every map-side metre size. */
|
|
511
|
+
readonly emSize: {
|
|
512
|
+
readonly value: number;
|
|
513
|
+
readonly unit: "meters";
|
|
514
|
+
};
|
|
515
|
+
readonly style?: {
|
|
516
|
+
readonly opacity?: number;
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
/** A Note rasterised for print: a base64 PNG data URL and its layout's exact height. */
|
|
520
|
+
interface MapSheetNoteRaster {
|
|
521
|
+
readonly url: string;
|
|
522
|
+
readonly heightEm: number;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* What the map sheet needs to print Notes: a raster for each Note, by graphic id.
|
|
526
|
+
* The sheet renders synchronously and never rasterises (ADR-0049, ADR-0067), so the
|
|
527
|
+
* host prepares them first: see {@link prepareMapSheetNotes}.
|
|
528
|
+
*/
|
|
529
|
+
interface MapSheetNoteCapability {
|
|
530
|
+
readonly rasters: {
|
|
531
|
+
resolve(noteId: string): MapSheetNoteRaster | undefined;
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
interface PrepareMapSheetNotesOptions {
|
|
535
|
+
/**
|
|
536
|
+
* The map's note capability. Notes print from its fonts and images, so their
|
|
537
|
+
* line breaks match the map.
|
|
538
|
+
*/
|
|
539
|
+
readonly notes: Pick<NoteCapability, "renderCanvas">;
|
|
540
|
+
/** Raster pixels per printed inch. Defaults to 300. */
|
|
541
|
+
readonly dpi?: number;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Rasterises every Note in `request.layers` at print density, in a browser, and
|
|
545
|
+
* returns the capability to pass as `notes`.
|
|
546
|
+
*
|
|
547
|
+
* @throws if a Note's image can't be resolved: a sheet must not silently lose a picture.
|
|
548
|
+
*/
|
|
549
|
+
declare function prepareMapSheetNotes(request: {
|
|
550
|
+
readonly scaleDenominator: number;
|
|
551
|
+
readonly layers?: readonly {
|
|
552
|
+
readonly graphics: readonly {
|
|
553
|
+
readonly graphic: {
|
|
554
|
+
readonly kind: string;
|
|
555
|
+
};
|
|
556
|
+
}[];
|
|
557
|
+
}[];
|
|
558
|
+
}, options: PrepareMapSheetNotesOptions): Promise<MapSheetNoteCapability>;
|
|
559
|
+
//#endregion
|
|
328
560
|
//#region src/render-layers.d.ts
|
|
329
561
|
interface MapSheetPortrayalDefaults {
|
|
330
562
|
readonly symbolColor?: string;
|
|
@@ -343,7 +575,7 @@ interface MapSheetPortrayalDefaults {
|
|
|
343
575
|
*/
|
|
344
576
|
readonly highlightAppearance?: HighlightAppearance;
|
|
345
577
|
}
|
|
346
|
-
type MapSheetAuthoredGraphic = ControlMeasure | MapSheetPointSymbol | MapSheetCustomSymbol;
|
|
578
|
+
type MapSheetAuthoredGraphic = ControlMeasure | MapSheetPointSymbol | MapSheetCustomSymbol | MapSheetNote;
|
|
347
579
|
interface AuthoredMapSheetGraphic {
|
|
348
580
|
readonly graphic: MapSheetAuthoredGraphic;
|
|
349
581
|
}
|
|
@@ -471,6 +703,8 @@ interface TacticalMapSheetRequest {
|
|
|
471
703
|
readonly grid?: MgrsGridOptions | false;
|
|
472
704
|
readonly layers?: readonly TacticalMapSheetLayer[];
|
|
473
705
|
readonly pointSymbols?: MapSheetPointSymbolCapability;
|
|
706
|
+
/** Required when a layer holds a Note: its prepared rasters (ADR-0067). */
|
|
707
|
+
readonly notes?: MapSheetNoteCapability;
|
|
474
708
|
readonly marginalia?: MapSheetMarginaliaOptions | false;
|
|
475
709
|
readonly metadata?: MapSheetMetadata;
|
|
476
710
|
readonly registration?: MapSheetRegistrationRequest;
|
|
@@ -532,4 +766,4 @@ interface TacticalMapSheetResult {
|
|
|
532
766
|
}
|
|
533
767
|
declare function createTacticalMapSheet(request: TacticalMapSheetRequest): TacticalMapSheetResult;
|
|
534
768
|
//#endregion
|
|
535
|
-
export {
|
|
769
|
+
export { MapSheetMarginaliaOptions as $, PaperSizeName as A, PointSymbolOffsetWarning as B, ResolvedMapSheetRasterTileMetadata as C, ResolvedRegistrationMark as D, MapSheetRegistrationRequest as E, GraphicOutsideFrameWarning as F, PrepareMapSheetNotesOptions as G, MapSheetNote as H, GraphicRenderWarning as I, MapSheetCustomSymbol as J, prepareMapSheetNotes as K, MapSheetAuthoredGraphic as L, AuthoredMapSheetGraphic as M, GraphicClippedWarning as N, PAPER_SIZES as O, GraphicHiddenWarning as P, VectorSymbolAnchor as Q, MapSheetPortrayalDefaults as R, ResolvedMapSheetRasterLayerMetadata as S, AuthoredRegistrationMark as T, MapSheetNoteCapability as U, TacticalMapSheetLayer as V, MapSheetNoteRaster as W, MapSheetPointSymbolCapability as X, MapSheetPointSymbol as Y, MapSheetSymbolSize as Z, MapSheetRasterLayer as _, ResolvedMapSheetMetadata as a, MapSheetPatternIdentity as at, RasterDpiAnisotropyWarning as b, TacticalMapSheetResources as c, GeographicPosition as ct, UpsProjection as d, UtmCrs as dt, MapSheetMetadata as et, UtmProjection as f, Polygon as ft, MapSheetRasterBasemap as g, MapSheetRasterAttribution as h, MapSheetPageInput as i, MgrsSnapInterval as it, resolvePaperSize as j, PaperOrientation as k, TacticalMapSheetResult as l, GridCrs as lt, LowRasterDpiWarning as m, CrossZoneFootprintWarning as n, ResolvedMgrsGridMetadata as nt, ScaleDeviationWarning as o, MillimetreScene as ot, createTacticalMapSheet as p, Position as pt, ControlledVectorSymbol as q, MapSheetFontIdentity as r, MgrsPrecision as rt, TacticalMapSheetRequest as s, SceneRectangle as st, CrossProjectionFootprintWarning as t, MgrsGridOptions as tt, TacticalMapSheetWarning as u, UpsCrs as ut, MapSheetRasterTile as v, PrinterCalibrationRequest as w, ResolvedMapSheetRasterBasemapMetadata as x, MapSheetRasterWarning as y, PointSymbolFallbackWarning as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as MapSheetMarginaliaOptions, A as PaperSizeName, B as PointSymbolOffsetWarning, C as ResolvedMapSheetRasterTileMetadata, D as ResolvedRegistrationMark, E as MapSheetRegistrationRequest, F as GraphicOutsideFrameWarning, G as PrepareMapSheetNotesOptions, H as MapSheetNote, I as GraphicRenderWarning, J as MapSheetCustomSymbol, K as prepareMapSheetNotes, L as MapSheetAuthoredGraphic, M as AuthoredMapSheetGraphic, N as GraphicClippedWarning, O as PAPER_SIZES, P as GraphicHiddenWarning, Q as VectorSymbolAnchor, R as MapSheetPortrayalDefaults, S as ResolvedMapSheetRasterLayerMetadata, T as AuthoredRegistrationMark, U as MapSheetNoteCapability, V as TacticalMapSheetLayer, W as MapSheetNoteRaster, X as MapSheetPointSymbolCapability, Y as MapSheetPointSymbol, Z as MapSheetSymbolSize, _ as MapSheetRasterLayer, a as ResolvedMapSheetMetadata, at as MapSheetPatternIdentity, b as RasterDpiAnisotropyWarning, c as TacticalMapSheetResources, ct as GeographicPosition, d as UpsProjection, dt as UtmCrs, et as MapSheetMetadata, f as UtmProjection, g as MapSheetRasterBasemap, h as MapSheetRasterAttribution, i as MapSheetPageInput, it as MgrsSnapInterval, j as resolvePaperSize, k as PaperOrientation, l as TacticalMapSheetResult, lt as GridCrs, m as LowRasterDpiWarning, n as CrossZoneFootprintWarning, nt as ResolvedMgrsGridMetadata, o as ScaleDeviationWarning, p as createTacticalMapSheet, pt as Position, q as ControlledVectorSymbol, r as MapSheetFontIdentity, rt as MgrsPrecision, s as TacticalMapSheetRequest, st as SceneRectangle, t as CrossProjectionFootprintWarning, tt as MgrsGridOptions, u as TacticalMapSheetWarning, ut as UpsCrs, v as MapSheetRasterTile, w as PrinterCalibrationRequest, x as ResolvedMapSheetRasterBasemapMetadata, y as MapSheetRasterWarning, z as PointSymbolFallbackWarning } from "./create-tactical-map-sheet-aMfOzCpu.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/mgrs.d.ts
|
|
4
4
|
interface ProjectedGridCoordinate {
|
|
@@ -42,4 +42,4 @@ type RasterPlanRequest = Pick<TacticalMapSheetRequest, "page" | "mapFrame" | "ce
|
|
|
42
42
|
declare function resolveMapSheetRasterPlan(request: RasterPlanRequest): MapSheetRasterPlan;
|
|
43
43
|
declare function mapSheetRasterPointToGeographic(plan: MapSheetRasterPlan, normalizedX: number, normalizedY: number): Position;
|
|
44
44
|
//#endregion
|
|
45
|
-
export { type AuthoredMapSheetGraphic, type AuthoredRegistrationMark, type ControlledVectorSymbol, type CrossProjectionFootprintWarning, type CrossZoneFootprintWarning, type GraphicClippedWarning, type GraphicHiddenWarning, type GraphicOutsideFrameWarning, type GraphicRenderWarning, type GridCrs, type LowRasterDpiWarning, type MapSheetCustomSymbol, type MapSheetFontIdentity, type MapSheetMarginaliaOptions, type MapSheetMetadata, type MapSheetPageInput, type MapSheetPatternIdentity, type MapSheetPointSymbol, type MapSheetPointSymbolCapability, type MapSheetPortrayalDefaults, type MapSheetProjectedBounds, type MapSheetRasterAttribution, type MapSheetRasterBasemap, type MapSheetRasterLayer, type MapSheetRasterPlan, type MapSheetRasterTile, type MapSheetRasterWarning, type MapSheetRegistrationRequest, type MapSheetSymbolSize, type MgrsGridOptions, type MgrsPrecision, type MgrsSnapInterval, PAPER_SIZES, type PaperOrientation, type PaperSizeName, type PointSymbolFallbackWarning, type PointSymbolOffsetWarning, type PrinterCalibrationRequest, type ProjectedGridCoordinate, type RasterDpiAnisotropyWarning, type ResolvedMapSheetMetadata, type ResolvedMapSheetRasterBasemapMetadata, type ResolvedMapSheetRasterLayerMetadata, type ResolvedMapSheetRasterTileMetadata, type ResolvedMgrsGridMetadata, type ResolvedMgrsReference, type ResolvedRegistrationMark, type ScaleDeviationWarning, type TacticalMapSheetLayer, type TacticalMapSheetRequest, type TacticalMapSheetResources, type TacticalMapSheetResult, type TacticalMapSheetWarning, type UpsCrs, type UpsProjection, type UtmCrs, type UtmProjection, type VectorSymbolAnchor, createTacticalMapSheet, geographicToMgrs, mapSheetRasterPointToGeographic, mgrsToGeographic, mgrsToProjected, normalizeMgrsReference, parseMgrsReference, projectedToMgrs, resolveMapSheetRasterPlan, resolvePaperSize, snapGeographicToMgrs, snapProjectedToMgrs };
|
|
45
|
+
export { type AuthoredMapSheetGraphic, type AuthoredRegistrationMark, type ControlledVectorSymbol, type CrossProjectionFootprintWarning, type CrossZoneFootprintWarning, type GraphicClippedWarning, type GraphicHiddenWarning, type GraphicOutsideFrameWarning, type GraphicRenderWarning, type GridCrs, type LowRasterDpiWarning, type MapSheetAuthoredGraphic, type MapSheetCustomSymbol, type MapSheetFontIdentity, type MapSheetMarginaliaOptions, type MapSheetMetadata, type MapSheetNote, type MapSheetNoteCapability, type MapSheetNoteRaster, type MapSheetPageInput, type MapSheetPatternIdentity, type MapSheetPointSymbol, type MapSheetPointSymbolCapability, type MapSheetPortrayalDefaults, type MapSheetProjectedBounds, type MapSheetRasterAttribution, type MapSheetRasterBasemap, type MapSheetRasterLayer, type MapSheetRasterPlan, type MapSheetRasterTile, type MapSheetRasterWarning, type MapSheetRegistrationRequest, type MapSheetSymbolSize, type MgrsGridOptions, type MgrsPrecision, type MgrsSnapInterval, PAPER_SIZES, type PaperOrientation, type PaperSizeName, type PointSymbolFallbackWarning, type PointSymbolOffsetWarning, type PrepareMapSheetNotesOptions, type PrinterCalibrationRequest, type ProjectedGridCoordinate, type RasterDpiAnisotropyWarning, type ResolvedMapSheetMetadata, type ResolvedMapSheetRasterBasemapMetadata, type ResolvedMapSheetRasterLayerMetadata, type ResolvedMapSheetRasterTileMetadata, type ResolvedMgrsGridMetadata, type ResolvedMgrsReference, type ResolvedRegistrationMark, type ScaleDeviationWarning, type TacticalMapSheetLayer, type TacticalMapSheetRequest, type TacticalMapSheetResources, type TacticalMapSheetResult, type TacticalMapSheetWarning, type UpsCrs, type UpsProjection, type UtmCrs, type UtmProjection, type VectorSymbolAnchor, createTacticalMapSheet, geographicToMgrs, mapSheetRasterPointToGeographic, mgrsToGeographic, mgrsToProjected, normalizeMgrsReference, parseMgrsReference, prepareMapSheetNotes, projectedToMgrs, resolveMapSheetRasterPlan, resolvePaperSize, snapGeographicToMgrs, snapProjectedToMgrs };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as geographicToMgrs, c as normalizeMgrsReference, d as snapGeographicToMgrs, f as snapProjectedToMgrs, i as resolveMapSheetRasterPlan, l as parseMgrsReference, o as mgrsToGeographic, r as mapSheetRasterPointToGeographic, s as mgrsToProjected, t as createTacticalMapSheet, u as projectedToMgrs } from "./create-tactical-map-sheet-
|
|
1
|
+
import { a as geographicToMgrs, c as normalizeMgrsReference, d as snapGeographicToMgrs, f as snapProjectedToMgrs, i as resolveMapSheetRasterPlan, l as parseMgrsReference, o as mgrsToGeographic, p as prepareMapSheetNotes, r as mapSheetRasterPointToGeographic, s as mgrsToProjected, t as createTacticalMapSheet, u as projectedToMgrs } from "./create-tactical-map-sheet-DVr96Nie.mjs";
|
|
2
2
|
//#region src/paper.ts
|
|
3
3
|
const A0 = Object.freeze({
|
|
4
4
|
widthMm: 841,
|
|
@@ -80,4 +80,4 @@ function resolvePaperSize(name, orientation = "portrait") {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
83
|
-
export { PAPER_SIZES, createTacticalMapSheet, geographicToMgrs, mapSheetRasterPointToGeographic, mgrsToGeographic, mgrsToProjected, normalizeMgrsReference, parseMgrsReference, projectedToMgrs, resolveMapSheetRasterPlan, resolvePaperSize, snapGeographicToMgrs, snapProjectedToMgrs };
|
|
83
|
+
export { PAPER_SIZES, createTacticalMapSheet, geographicToMgrs, mapSheetRasterPointToGeographic, mgrsToGeographic, mgrsToProjected, normalizeMgrsReference, parseMgrsReference, prepareMapSheetNotes, projectedToMgrs, resolveMapSheetRasterPlan, resolvePaperSize, snapGeographicToMgrs, snapProjectedToMgrs };
|
package/dist/pdf.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ResolvedMapSheetMetadata,
|
|
1
|
+
import { a as ResolvedMapSheetMetadata, c as TacticalMapSheetResources, ft as Polygon, l as TacticalMapSheetResult, ot as MillimetreScene, s as TacticalMapSheetRequest, u as TacticalMapSheetWarning } from "./create-tactical-map-sheet-aMfOzCpu.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/pdf.d.ts
|
|
4
4
|
interface TacticalMapSheetPdfResult {
|
|
@@ -9,6 +9,7 @@ interface TacticalMapSheetPdfResult {
|
|
|
9
9
|
readonly resources: TacticalMapSheetResources;
|
|
10
10
|
readonly registrationMarks?: TacticalMapSheetResult["registrationMarks"];
|
|
11
11
|
}
|
|
12
|
+
declare function serializePdf(inputScene: MillimetreScene): Uint8Array;
|
|
12
13
|
declare function renderMapSheetPdf(request: TacticalMapSheetRequest): TacticalMapSheetPdfResult;
|
|
13
14
|
//#endregion
|
|
14
|
-
export { TacticalMapSheetPdfResult, renderMapSheetPdf };
|
|
15
|
+
export { TacticalMapSheetPdfResult, renderMapSheetPdf, serializePdf };
|
package/dist/pdf.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as openSansCentralBaselineOffset, g as POINTS_PER_MILLIMETRE, h as MILLIMETRES_PER_CSS_PIXEL, m as formatDecimal, n as createTacticalMapSheetDocument, v as openSansMiddleBaselineOffset } from "./create-tactical-map-sheet-DVr96Nie.mjs";
|
|
2
2
|
import { jsPDF } from "jspdf";
|
|
3
3
|
//#region src/pdf-transparency.ts
|
|
4
4
|
const FORM_DICTIONARY_MARKER = new TextEncoder().encode("/Subtype /Form\n/BBox");
|
|
@@ -515,11 +515,33 @@ function renderText(pdf, text) {
|
|
|
515
515
|
}
|
|
516
516
|
pdf.restoreGraphicsState();
|
|
517
517
|
}
|
|
518
|
+
/**
|
|
519
|
+
* jsPDF rotates an image about its bottom-left corner, clockwise on the
|
|
520
|
+
* advanced API's y-down page. Returns the unrotated top-left that puts the
|
|
521
|
+
* rotated image's centre on the frame centre.
|
|
522
|
+
*/
|
|
523
|
+
function rasterImageOrigin(element) {
|
|
524
|
+
const { xMm, yMm, widthMm, heightMm } = element.frame;
|
|
525
|
+
if (!element.rotationDegrees) return {
|
|
526
|
+
xMm,
|
|
527
|
+
yMm
|
|
528
|
+
};
|
|
529
|
+
const angle = element.rotationDegrees * Math.PI / 180;
|
|
530
|
+
const cos = Math.cos(angle);
|
|
531
|
+
const sin = Math.sin(angle);
|
|
532
|
+
const halfWidth = widthMm / 2;
|
|
533
|
+
const halfHeight = heightMm / 2;
|
|
534
|
+
return {
|
|
535
|
+
xMm: xMm + halfWidth + (-halfWidth * cos - halfHeight * sin),
|
|
536
|
+
yMm: yMm + halfHeight + (-halfWidth * sin + halfHeight * cos) - heightMm
|
|
537
|
+
};
|
|
538
|
+
}
|
|
518
539
|
function renderElement(pdf, element, formIds) {
|
|
519
540
|
if (element.kind === "raster-image") {
|
|
520
541
|
pdf.saveGraphicsState();
|
|
521
542
|
if (element.opacity !== 1) pdf.setGState(pdf.GState({ opacity: element.opacity }));
|
|
522
|
-
|
|
543
|
+
const { xMm, yMm } = rasterImageOrigin(element);
|
|
544
|
+
pdf.addImage(element.data, element.mediaType === "image/png" ? "PNG" : "JPEG", xMm, yMm, element.frame.widthMm, element.frame.heightMm, element.resourceId, element.compressInPdf ? "FAST" : "NONE", element.rotationDegrees || 0);
|
|
523
545
|
pdf.restoreGraphicsState();
|
|
524
546
|
return;
|
|
525
547
|
}
|
|
@@ -536,6 +558,11 @@ function renderElement(pdf, element, formIds) {
|
|
|
536
558
|
const offsetX = (element.width - viewWidth * viewportScale) / 2 - viewX * viewportScale;
|
|
537
559
|
const offsetY = (element.height - viewHeight * viewportScale) / 2 - viewY * viewportScale;
|
|
538
560
|
pdf.setCurrentTransformationMatrix(pdf.Matrix(viewportScale, 0, 0, viewportScale, offsetX, offsetY));
|
|
561
|
+
if (element.clipToViewBox) {
|
|
562
|
+
pdf.rect(viewX, viewY, viewWidth, viewHeight, null);
|
|
563
|
+
pdf.clip();
|
|
564
|
+
pdf.discardPath();
|
|
565
|
+
}
|
|
539
566
|
const paint = {
|
|
540
567
|
...DEFAULT_VECTOR_PAINT,
|
|
541
568
|
fill: "#000000"
|
|
@@ -700,4 +727,4 @@ function renderMapSheetPdf(request) {
|
|
|
700
727
|
};
|
|
701
728
|
}
|
|
702
729
|
//#endregion
|
|
703
|
-
export { renderMapSheetPdf };
|
|
730
|
+
export { renderMapSheetPdf, serializePdf };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-map-sheet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Scale-accurate projected vector tactical map-sheet renderer.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Orbat Mapper",
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"jspdf": "4.2.1",
|
|
31
31
|
"opentype.js": "2.0.0",
|
|
32
32
|
"saxes": "6.0.0",
|
|
33
|
-
"@orbat-mapper/control-measures": "^0.
|
|
34
|
-
"@orbat-mapper/tactical-draw": "^0.
|
|
33
|
+
"@orbat-mapper/control-measures": "^0.45.0",
|
|
34
|
+
"@orbat-mapper/tactical-draw": "^0.31.0",
|
|
35
|
+
"@orbat-mapper/tactical-notes": "^0.1.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@napi-rs/canvas": "1.0.7",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"typescript": "~5.9.3",
|
|
46
47
|
"vite": "^8.0.16",
|
|
47
48
|
"vitest": "^4.1.8",
|
|
48
|
-
"@orbat-mapper/point-symbols": "0.2.
|
|
49
|
+
"@orbat-mapper/point-symbols": "0.2.29"
|
|
49
50
|
},
|
|
50
51
|
"inlinedDependencies": {
|
|
51
52
|
"@types/geojson": "7946.0.16"
|