@orbat-mapper/tactical-map-sheet 0.3.11 → 0.4.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.
@@ -1,4 +1,5 @@
1
1
  import { ControlMeasure, PatternId, TextAmplifiers } from "@orbat-mapper/control-measures";
2
+ import { PointSymbolOffset, PointSymbolRender } from "@orbat-mapper/tactical-draw";
2
3
 
3
4
  //#region ../../node_modules/.pnpm/@types+geojson@7946.0.16/node_modules/@types/geojson/index.d.ts
4
5
  /**
@@ -277,6 +278,7 @@ interface ControlledVectorSymbol {
277
278
  readonly octagonAnchor: VectorSymbolAnchor;
278
279
  readonly valid?: boolean;
279
280
  readonly validation?: unknown;
281
+ readonly offset?: PointSymbolRender["offset"];
280
282
  }
281
283
  interface MapSheetPointSymbol {
282
284
  readonly id: string;
@@ -285,12 +287,14 @@ interface MapSheetPointSymbol {
285
287
  readonly position: Position;
286
288
  readonly rotation: number;
287
289
  readonly size: MapSheetSymbolSize;
290
+ readonly offset?: PointSymbolOffset;
288
291
  readonly textAmplifiers?: TextAmplifiers;
289
292
  readonly graphicModifiers?: {
290
293
  readonly direction?: number;
291
294
  };
292
295
  readonly style?: {
293
296
  readonly opacity?: number;
297
+ readonly overallOpacity?: number;
294
298
  readonly colors?: {
295
299
  readonly fill?: string;
296
300
  readonly frame?: string;
@@ -360,7 +364,10 @@ interface PointSymbolFallbackWarning extends IdentifiedGraphicWarning {
360
364
  readonly code: "point-symbol-fallback";
361
365
  }
362
366
  type GraphicVisibilityWarning = GraphicClippedWarning | GraphicOutsideFrameWarning | GraphicHiddenWarning;
363
- type GraphicRenderWarning = GraphicVisibilityWarning | PointSymbolFallbackWarning;
367
+ interface PointSymbolOffsetWarning extends IdentifiedGraphicWarning {
368
+ readonly code: "point-symbol-offset-unsupported";
369
+ }
370
+ type GraphicRenderWarning = GraphicVisibilityWarning | PointSymbolFallbackWarning | PointSymbolOffsetWarning;
364
371
  //#endregion
365
372
  //#region src/paper.d.ts
366
373
  type PaperOrientation = "portrait" | "landscape";
@@ -520,4 +527,4 @@ interface TacticalMapSheetResult {
520
527
  }
521
528
  declare function createTacticalMapSheet(request: TacticalMapSheetRequest): TacticalMapSheetResult;
522
529
  //#endregion
523
- export { SceneRectangle as $, PaperSizeName as A, ControlledVectorSymbol as B, ResolvedMapSheetRasterTileMetadata as C, ResolvedRegistrationMark as D, MapSheetRegistrationRequest as E, GraphicOutsideFrameWarning as F, VectorSymbolAnchor as G, MapSheetPointSymbol as H, GraphicRenderWarning as I, MgrsGridOptions as J, MapSheetMarginaliaOptions as K, MapSheetPortrayalDefaults as L, AuthoredMapSheetGraphic as M, GraphicClippedWarning as N, PAPER_SIZES as O, GraphicHiddenWarning as P, MapSheetPatternIdentity as Q, PointSymbolFallbackWarning as R, ResolvedMapSheetRasterLayerMetadata as S, AuthoredRegistrationMark as T, MapSheetPointSymbolCapability as U, MapSheetCustomSymbol as V, MapSheetSymbolSize as W, MgrsPrecision as X, ResolvedMgrsGridMetadata as Y, MgrsSnapInterval as Z, MapSheetRasterLayer as _, ResolvedMapSheetMetadata as a, Position as at, RasterDpiAnisotropyWarning as b, TacticalMapSheetResources as c, UpsProjection as d, GeographicPosition as et, UtmProjection as f, MapSheetRasterBasemap as g, MapSheetRasterAttribution as h, MapSheetPageInput as i, Polygon as it, resolvePaperSize as j, PaperOrientation as k, TacticalMapSheetResult as l, LowRasterDpiWarning as m, CrossZoneFootprintWarning as n, UpsCrs as nt, ScaleDeviationWarning as o, createTacticalMapSheet as p, MapSheetMetadata as q, MapSheetFontIdentity as r, UtmCrs as rt, TacticalMapSheetRequest as s, CrossProjectionFootprintWarning as t, GridCrs as tt, TacticalMapSheetWarning as u, MapSheetRasterTile as v, PrinterCalibrationRequest as w, ResolvedMapSheetRasterBasemapMetadata as x, MapSheetRasterWarning as y, TacticalMapSheetLayer as z };
530
+ export { MapSheetPatternIdentity as $, PaperSizeName as A, TacticalMapSheetLayer as B, ResolvedMapSheetRasterTileMetadata as C, ResolvedRegistrationMark as D, MapSheetRegistrationRequest as E, GraphicOutsideFrameWarning as F, MapSheetSymbolSize as G, MapSheetCustomSymbol as H, GraphicRenderWarning as I, MapSheetMetadata as J, VectorSymbolAnchor as K, MapSheetPortrayalDefaults as L, AuthoredMapSheetGraphic as M, GraphicClippedWarning as N, PAPER_SIZES as O, GraphicHiddenWarning as P, MgrsSnapInterval as Q, PointSymbolFallbackWarning as R, ResolvedMapSheetRasterLayerMetadata as S, AuthoredRegistrationMark as T, MapSheetPointSymbol as U, ControlledVectorSymbol as V, MapSheetPointSymbolCapability as W, ResolvedMgrsGridMetadata as X, MgrsGridOptions as Y, MgrsPrecision as Z, MapSheetRasterLayer as _, ResolvedMapSheetMetadata as a, Polygon as at, RasterDpiAnisotropyWarning as b, TacticalMapSheetResources as c, UpsProjection as d, SceneRectangle as et, UtmProjection as f, MapSheetRasterBasemap as g, MapSheetRasterAttribution as h, MapSheetPageInput as i, UtmCrs as it, resolvePaperSize as j, PaperOrientation as k, TacticalMapSheetResult as l, LowRasterDpiWarning as m, CrossZoneFootprintWarning as n, GridCrs as nt, ScaleDeviationWarning as o, Position as ot, createTacticalMapSheet as p, MapSheetMarginaliaOptions as q, MapSheetFontIdentity as r, UpsCrs as rt, TacticalMapSheetRequest as s, CrossProjectionFootprintWarning as t, GeographicPosition as tt, TacticalMapSheetWarning as u, MapSheetRasterTile as v, PrinterCalibrationRequest as w, ResolvedMapSheetRasterBasemapMetadata as x, MapSheetRasterWarning as y, PointSymbolOffsetWarning as z };
@@ -1,7 +1,8 @@
1
1
  import GeographicLibMgrs from "geographiclib-mgrs";
2
2
  import PolarStereographic from "geographiclib-mgrs/src/polar-stereographic.mjs";
3
3
  import opentype from "opentype.js";
4
- import { DEFAULT_LABEL_HEIGHT_CSS_PIXELS, DEFAULT_LABEL_SIZE_CLAMP_CSS_PIXELS, DEFAULT_LINE_CAP, DEFAULT_LINE_JOIN, DEFAULT_PORTRAYAL, DEFAULT_STROKE_DASH_CSS_PIXELS, DEFAULT_STROKE_WIDTH_CSS_PIXELS, getFillPatternDefinition, renderControlMeasure } from "@orbat-mapper/control-measures";
4
+ import { DEFAULT_LABEL_HEIGHT_CSS_PIXELS, DEFAULT_LABEL_SIZE_CLAMP_CSS_PIXELS, DEFAULT_LINE_CAP, DEFAULT_LINE_JOIN, DEFAULT_PORTRAYAL, DEFAULT_STROKE_DASH_CSS_PIXELS, DEFAULT_STROKE_WIDTH_CSS_PIXELS, getFillPatternDefinition, renderControlMeasure, resolveSymbolColor } from "@orbat-mapper/control-measures";
5
+ import { effectivePointSymbolPixelSize, resolvePointSymbolOffset, scalePointSymbolLayout } from "@orbat-mapper/tactical-draw";
5
6
  import { SaxesParser } from "saxes";
6
7
  //#region src/projection/geographic-lib.ts
7
8
  const backend = GeographicLibMgrs.UTMUPS;
@@ -219,6 +220,11 @@ function openSansIdentities(styles) {
219
220
  const requested = new Set(styles);
220
221
  return OPEN_SANS_IDENTITIES.filter((identity) => requested.has(identity.style));
221
222
  }
223
+ /** SVG middle aligns the alphabetic baseline by half the font's x-height. */
224
+ function openSansMiddleBaselineOffset(sizeCssPixels) {
225
+ const font = getFont("Regular");
226
+ return font.charToGlyph("x").getBoundingBox().y2 * sizeCssPixels / font.unitsPerEm / 2;
227
+ }
222
228
  //#endregion
223
229
  //#region src/units.ts
224
230
  /** Unit conversions shared by the scene builders and serializers. */
@@ -1077,17 +1083,11 @@ function validateVectorMetadata(vector) {
1077
1083
  }
1078
1084
  function resolveSizePixels(size, groundMetersPerCssPixel) {
1079
1085
  requirePositiveFinite(size.value, "Symbol size");
1080
- let pixels = size.unit === "meters" ? size.value / groundMetersPerCssPixel : size.value;
1081
- if (size.unit === "pixels") return pixels;
1082
- if (size.minPixels !== void 0) {
1083
- requirePositiveFinite(size.minPixels, "Symbol minimum size");
1084
- pixels = Math.max(pixels, size.minPixels);
1085
- }
1086
- if (size.maxPixels !== void 0) {
1087
- requirePositiveFinite(size.maxPixels, "Symbol maximum size");
1088
- pixels = Math.min(pixels, size.maxPixels);
1086
+ if (size.unit === "meters") {
1087
+ if (size.minPixels !== void 0) requirePositiveFinite(size.minPixels, "Symbol minimum size");
1088
+ if (size.maxPixels !== void 0) requirePositiveFinite(size.maxPixels, "Symbol maximum size");
1089
1089
  }
1090
- return pixels;
1090
+ return effectivePointSymbolPixelSize({ size }, groundMetersPerCssPixel);
1091
1091
  }
1092
1092
  function renderVectorSymbol(symbol, vector, context) {
1093
1093
  validateVectorMetadata(vector);
@@ -1095,7 +1095,7 @@ function renderVectorSymbol(symbol, vector, context) {
1095
1095
  requireFinite(symbol.rotation, "Symbol rotation");
1096
1096
  const projected = geographicLibGridProjection.forward(context.crs, symbol.position);
1097
1097
  const position = projectedToScenePoint(projected, context);
1098
- const opacity = symbol.kind === "point-symbol" ? symbol.style?.opacity ?? 1 : symbol.opacity ?? 1;
1098
+ const opacity = symbol.kind === "point-symbol" ? (symbol.style?.opacity ?? 1) * (symbol.style?.overallOpacity ?? 1) : symbol.opacity ?? 1;
1099
1099
  if (!Number.isFinite(opacity) || opacity < 0 || opacity > 1) throw new RangeError("Symbol opacity must be between 0 and 1");
1100
1100
  const octagonSizeMm = resolveSizePixels(symbol.size, context.groundMetersPerCssPixel) * MILLIMETRES_PER_CSS_PIXEL;
1101
1101
  return {
@@ -1114,6 +1114,56 @@ function renderVectorSymbol(symbol, vector, context) {
1114
1114
  usesFont: imported.usesFont
1115
1115
  };
1116
1116
  }
1117
+ /** Resolve the same layout as the map, using CSS pixels as a physical sheet unit. */
1118
+ function renderPointSymbolElements(symbol, vector, context) {
1119
+ const factor = MILLIMETRES_PER_CSS_PIXEL;
1120
+ const projected = geographicLibGridProjection.forward(context.crs, symbol.position);
1121
+ const layout = resolvePointSymbolOffset(symbol, {
1122
+ ...vector,
1123
+ valid: vector.valid ?? true
1124
+ }, {
1125
+ getPixelFromCoordinate(position) {
1126
+ const point = projectedToScenePoint(geographicLibGridProjection.forward(context.crs, position), context);
1127
+ return [point.xMm / factor, point.yMm / factor];
1128
+ },
1129
+ getBearing: () => projected.convergenceDegrees * Math.PI / 180,
1130
+ getResolution: () => context.groundMetersPerCssPixel
1131
+ });
1132
+ const sheetLayout = layout && scalePointSymbolLayout(layout, factor);
1133
+ const base = renderVectorSymbol(symbol, sheetLayout?.render ?? vector, context);
1134
+ const body = sheetLayout ? {
1135
+ ...base,
1136
+ position: {
1137
+ xMm: sheetLayout.imageAnchor[0],
1138
+ yMm: sheetLayout.imageAnchor[1]
1139
+ },
1140
+ scaleMmPerUnit: sheetLayout.scale,
1141
+ rotationDegrees: sheetLayout.rotation * 180 / Math.PI,
1142
+ opacity: sheetLayout.bodyOpacity
1143
+ } : base;
1144
+ const elements = [];
1145
+ if (sheetLayout && sheetLayout.path.length > 1) {
1146
+ const style = resolveSymbolColor(sheetLayout.connectorStyle, false);
1147
+ elements.push({
1148
+ kind: "path",
1149
+ points: sheetLayout.path.map(([x, y]) => ({
1150
+ xMm: x,
1151
+ yMm: y
1152
+ })),
1153
+ strokeColor: style.strokeColor,
1154
+ strokeWidthMm: sheetLayout.connectorStyle.strokeWidth,
1155
+ strokeDashMm: sheetLayout.connectorStyle.strokeDash,
1156
+ lineCap: "round",
1157
+ lineJoin: "round",
1158
+ attributes: { "data-connector": symbol.id }
1159
+ });
1160
+ }
1161
+ elements.push(body);
1162
+ return {
1163
+ elements,
1164
+ status: layout?.status ?? "unsupported-presentation"
1165
+ };
1166
+ }
1117
1167
  //#endregion
1118
1168
  //#region src/render-layers.ts
1119
1169
  function geographicBounds(positions, longitudeReference) {
@@ -1589,19 +1639,27 @@ function renderGraphic(layerId, authored, portrayal, context) {
1589
1639
  }] };
1590
1640
  if (graphic.kind === "point-symbol" && !context.pointSymbols) throw new Error(`Cannot render Graphic "${graphic.id}": a point-symbol capability is required`);
1591
1641
  const vector = graphic.kind === "point-symbol" ? context.pointSymbols.render(graphic) : graphic.vector;
1592
- const element = renderVectorSymbol(graphic, vector, context);
1642
+ const result = graphic.kind === "point-symbol" ? renderPointSymbolElements(graphic, vector, context) : {
1643
+ elements: [renderVectorSymbol(graphic, vector, context)],
1644
+ status: "ok"
1645
+ };
1593
1646
  const warnings = [];
1647
+ if (result.status !== "ok") warnings.push({
1648
+ code: "point-symbol-offset-unsupported",
1649
+ layerId,
1650
+ graphicId: graphic.id
1651
+ });
1594
1652
  if (graphic.kind === "point-symbol" && vector.valid === false) warnings.push({
1595
1653
  code: "point-symbol-fallback",
1596
1654
  layerId,
1597
1655
  graphicId: graphic.id
1598
1656
  });
1599
- const visibility = visibilityWarning(layerId, graphic.id, [element], context.frame);
1657
+ const visibility = visibilityWarning(layerId, graphic.id, result.elements, context.frame);
1600
1658
  if (visibility) warnings.push(visibility);
1601
1659
  return {
1602
1660
  graphic: {
1603
1661
  id: graphic.id,
1604
- elements: [element]
1662
+ elements: result.elements
1605
1663
  },
1606
1664
  warnings
1607
1665
  };
@@ -2560,4 +2618,4 @@ function createTacticalMapSheet(request) {
2560
2618
  return createTacticalMapSheetDocument(request).result;
2561
2619
  }
2562
2620
  //#endregion
2563
- export { geographicToMgrs as a, normalizeMgrsReference as c, snapGeographicToMgrs as d, snapProjectedToMgrs as f, openSansCentralBaselineOffset as g, POINTS_PER_MILLIMETRE as h, resolveMapSheetRasterPlan as i, parseMgrsReference as l, MILLIMETRES_PER_CSS_PIXEL as m, createTacticalMapSheetDocument as n, mgrsToGeographic as o, formatDecimal as p, mapSheetRasterPointToGeographic as r, mgrsToProjected as s, createTacticalMapSheet as t, projectedToMgrs as u };
2621
+ export { openSansMiddleBaselineOffset as _, geographicToMgrs as a, normalizeMgrsReference as c, snapGeographicToMgrs as d, snapProjectedToMgrs as f, openSansCentralBaselineOffset as g, POINTS_PER_MILLIMETRE as h, resolveMapSheetRasterPlan as i, parseMgrsReference as l, MILLIMETRES_PER_CSS_PIXEL as m, createTacticalMapSheetDocument as n, mgrsToGeographic as o, formatDecimal as p, mapSheetRasterPointToGeographic as r, mgrsToProjected as s, createTacticalMapSheet as t, projectedToMgrs as u };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as SceneRectangle, A as PaperSizeName, B as ControlledVectorSymbol, C as ResolvedMapSheetRasterTileMetadata, D as ResolvedRegistrationMark, E as MapSheetRegistrationRequest, F as GraphicOutsideFrameWarning, G as VectorSymbolAnchor, H as MapSheetPointSymbol, I as GraphicRenderWarning, J as MgrsGridOptions, K as MapSheetMarginaliaOptions, L as MapSheetPortrayalDefaults, M as AuthoredMapSheetGraphic, N as GraphicClippedWarning, O as PAPER_SIZES, P as GraphicHiddenWarning, Q as MapSheetPatternIdentity, R as PointSymbolFallbackWarning, S as ResolvedMapSheetRasterLayerMetadata, T as AuthoredRegistrationMark, U as MapSheetPointSymbolCapability, V as MapSheetCustomSymbol, W as MapSheetSymbolSize, X as MgrsPrecision, Y as ResolvedMgrsGridMetadata, Z as MgrsSnapInterval, _ as MapSheetRasterLayer, a as ResolvedMapSheetMetadata, at as Position, b as RasterDpiAnisotropyWarning, c as TacticalMapSheetResources, d as UpsProjection, et as GeographicPosition, f as UtmProjection, g as MapSheetRasterBasemap, h as MapSheetRasterAttribution, i as MapSheetPageInput, j as resolvePaperSize, k as PaperOrientation, l as TacticalMapSheetResult, m as LowRasterDpiWarning, n as CrossZoneFootprintWarning, nt as UpsCrs, o as ScaleDeviationWarning, p as createTacticalMapSheet, q as MapSheetMetadata, r as MapSheetFontIdentity, rt as UtmCrs, s as TacticalMapSheetRequest, t as CrossProjectionFootprintWarning, tt as GridCrs, u as TacticalMapSheetWarning, v as MapSheetRasterTile, w as PrinterCalibrationRequest, x as ResolvedMapSheetRasterBasemapMetadata, y as MapSheetRasterWarning, z as TacticalMapSheetLayer } from "./create-tactical-map-sheet-Cydh9ghW.mjs";
1
+ import { $ as MapSheetPatternIdentity, A as PaperSizeName, B as TacticalMapSheetLayer, C as ResolvedMapSheetRasterTileMetadata, D as ResolvedRegistrationMark, E as MapSheetRegistrationRequest, F as GraphicOutsideFrameWarning, G as MapSheetSymbolSize, H as MapSheetCustomSymbol, I as GraphicRenderWarning, J as MapSheetMetadata, K as VectorSymbolAnchor, L as MapSheetPortrayalDefaults, M as AuthoredMapSheetGraphic, N as GraphicClippedWarning, O as PAPER_SIZES, P as GraphicHiddenWarning, Q as MgrsSnapInterval, R as PointSymbolFallbackWarning, S as ResolvedMapSheetRasterLayerMetadata, T as AuthoredRegistrationMark, U as MapSheetPointSymbol, V as ControlledVectorSymbol, W as MapSheetPointSymbolCapability, X as ResolvedMgrsGridMetadata, Y as MgrsGridOptions, Z as MgrsPrecision, _ as MapSheetRasterLayer, a as ResolvedMapSheetMetadata, b as RasterDpiAnisotropyWarning, c as TacticalMapSheetResources, d as UpsProjection, et as SceneRectangle, f as UtmProjection, g as MapSheetRasterBasemap, h as MapSheetRasterAttribution, i as MapSheetPageInput, it as UtmCrs, j as resolvePaperSize, k as PaperOrientation, l as TacticalMapSheetResult, m as LowRasterDpiWarning, n as CrossZoneFootprintWarning, nt as GridCrs, o as ScaleDeviationWarning, ot as Position, p as createTacticalMapSheet, q as MapSheetMarginaliaOptions, r as MapSheetFontIdentity, rt as UpsCrs, s as TacticalMapSheetRequest, t as CrossProjectionFootprintWarning, tt as GeographicPosition, u as TacticalMapSheetWarning, v as MapSheetRasterTile, w as PrinterCalibrationRequest, x as ResolvedMapSheetRasterBasemapMetadata, y as MapSheetRasterWarning, z as PointSymbolOffsetWarning } from "./create-tactical-map-sheet-ByCfDv0u.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 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 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 };
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-D2G1PW2H.mjs";
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-DCUo2mKe.mjs";
2
2
  //#region src/paper.ts
3
3
  const A0 = Object.freeze({
4
4
  widthMm: 841,
package/dist/pdf.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ResolvedMapSheetMetadata, c as TacticalMapSheetResources, it as Polygon, l as TacticalMapSheetResult, s as TacticalMapSheetRequest, u as TacticalMapSheetWarning } from "./create-tactical-map-sheet-Cydh9ghW.mjs";
1
+ import { a as ResolvedMapSheetMetadata, at as Polygon, c as TacticalMapSheetResources, l as TacticalMapSheetResult, s as TacticalMapSheetRequest, u as TacticalMapSheetWarning } from "./create-tactical-map-sheet-ByCfDv0u.mjs";
2
2
 
3
3
  //#region src/pdf.d.ts
4
4
  interface TacticalMapSheetPdfResult {
package/dist/pdf.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { g as openSansCentralBaselineOffset, h as POINTS_PER_MILLIMETRE, m as MILLIMETRES_PER_CSS_PIXEL, n as createTacticalMapSheetDocument, p as formatDecimal } from "./create-tactical-map-sheet-D2G1PW2H.mjs";
1
+ import { _ as openSansMiddleBaselineOffset, g as openSansCentralBaselineOffset, h as POINTS_PER_MILLIMETRE, m as MILLIMETRES_PER_CSS_PIXEL, n as createTacticalMapSheetDocument, p as formatDecimal } from "./create-tactical-map-sheet-DCUo2mKe.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");
@@ -62,7 +62,8 @@ const DEFAULT_VECTOR_PAINT = {
62
62
  fillOpacity: 1,
63
63
  strokeOpacity: 1,
64
64
  fontSize: 16,
65
- textAnchor: "start"
65
+ textAnchor: "start",
66
+ dominantBaseline: "auto"
66
67
  };
67
68
  const FIXED_CREATION_DATE = "D:20000101000000+00'00'";
68
69
  const FIXED_FILE_ID = "00000000000000000000000000000001";
@@ -127,6 +128,7 @@ function inheritedPaint(parent, node) {
127
128
  fillOpacity: numberAttribute(attributes, "fill-opacity", parent.fillOpacity),
128
129
  strokeOpacity: numberAttribute(attributes, "stroke-opacity", parent.strokeOpacity),
129
130
  fontSize: numberAttribute(attributes, "font-size", parent.fontSize),
131
+ dominantBaseline: stringAttribute(attributes, "dominant-baseline") ?? parent.dominantBaseline,
130
132
  textAnchor: stringAttribute(attributes, "text-anchor") ?? parent.textAnchor
131
133
  };
132
134
  }
@@ -402,7 +404,8 @@ function renderVectorNode(pdf, node, parentPaint, context, ignoreNodeOpacity = f
402
404
  }
403
405
  if (node.kind === "text") {
404
406
  const x = numberAttribute(node.attributes, "x");
405
- const y = numberAttribute(node.attributes, "y");
407
+ const baselineOffset = paint.dominantBaseline === "middle" ? openSansMiddleBaselineOffset(paint.fontSize) : paint.dominantBaseline === "central" ? openSansCentralBaselineOffset("Regular", paint.fontSize) : 0;
408
+ const y = numberAttribute(node.attributes, "y") + baselineOffset;
406
409
  pdf.setFont("Open Sans", "normal", 400);
407
410
  pdf.setFontSize(paint.fontSize * POINTS_PER_MILLIMETRE);
408
411
  const renderedWidth = pdf.getTextWidth(node.text);
@@ -422,7 +425,8 @@ function renderVectorNode(pdf, node, parentPaint, context, ignoreNodeOpacity = f
422
425
  else if (node.kind === "ellipse") pdf.ellipse(numberAttribute(node.attributes, "cx"), numberAttribute(node.attributes, "cy"), numberAttribute(node.attributes, "rx"), numberAttribute(node.attributes, "ry"), null);
423
426
  else if (node.kind === "rect") {
424
427
  const x = numberAttribute(node.attributes, "x");
425
- const y = numberAttribute(node.attributes, "y");
428
+ const baselineOffset = paint.dominantBaseline === "middle" ? openSansMiddleBaselineOffset(paint.fontSize) : paint.dominantBaseline === "central" ? openSansCentralBaselineOffset("Regular", paint.fontSize) : 0;
429
+ const y = numberAttribute(node.attributes, "y") + baselineOffset;
426
430
  const width = numberAttribute(node.attributes, "width");
427
431
  const height = numberAttribute(node.attributes, "height");
428
432
  const rawRadiusX = numberAttribute(node.attributes, "rx", numberAttribute(node.attributes, "ry"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbat-mapper/tactical-map-sheet",
3
- "version": "0.3.11",
3
+ "version": "0.4.0",
4
4
  "description": "Scale-accurate projected vector tactical map-sheet renderer.",
5
5
  "license": "MIT",
6
6
  "author": "Orbat Mapper",
@@ -30,7 +30,8 @@
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.22.0"
33
+ "@orbat-mapper/control-measures": "^0.24.0",
34
+ "@orbat-mapper/tactical-draw": "^0.8.0"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@napi-rs/canvas": "1.0.7",
@@ -44,7 +45,7 @@
44
45
  "typescript": "~5.9.3",
45
46
  "vite": "^8.0.16",
46
47
  "vitest": "^4.1.8",
47
- "@orbat-mapper/point-symbols": "0.1.21"
48
+ "@orbat-mapper/point-symbols": "0.2.0"
48
49
  },
49
50
  "inlinedDependencies": {
50
51
  "@types/geojson": "7946.0.16"