@orbat-mapper/tactical-map-sheet 0.6.8 → 0.7.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,7 +1,7 @@
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_BAND, DEFAULT_LINE_CAP, DEFAULT_LINE_JOIN, DEFAULT_PORTRAYAL, DEFAULT_STROKE_DASH_CSS_PIXELS, DEFAULT_STROKE_WIDTH_CSS_PIXELS, getFillPatternDefinition, renderControlMeasure, resolveConstructionMetersPerCssPixel, resolveSymbolColor } from "@orbat-mapper/control-measures";
4
+ import { DEFAULT_LABEL_HEIGHT_CSS_PIXELS, DEFAULT_LABEL_SIZE_BAND, DEFAULT_LINE_CAP, DEFAULT_LINE_JOIN, DEFAULT_PORTRAYAL, DEFAULT_STROKE_DASH_CSS_PIXELS, DEFAULT_STROKE_WIDTH_CSS_PIXELS, getFillPatternDefinition, labelTextOffsetEms, renderControlMeasure, resolveConstructionMetersPerCssPixel, resolveSymbolColor } from "@orbat-mapper/control-measures";
5
5
  import { effectivePointSymbolPixelSize, highlightBandsInPaintOrder, resolvePointSymbolOffset, resolveTextAppearance, scalePointSymbolLayout } from "@orbat-mapper/tactical-draw";
6
6
  import { SaxesParser } from "saxes";
7
7
  //#region src/projection/geographic-lib.ts
@@ -1478,6 +1478,21 @@ function resolveTextSizeCssPixels(properties, portrayal, constructionMetersPerCs
1478
1478
  ...band
1479
1479
  }, constructionMetersPerCssPixel, { pinBelowMinimum: true })?.sizePixels;
1480
1480
  }
1481
+ /**
1482
+ * The scene point at `(x, y)` mm in a frame at `origin` rotated
1483
+ * `rotationDegrees` clockwise (scene y grows downward). Text, its screen-space
1484
+ * offset (`labelTextOffsetEms`, ADR-0068) and vector symbols all use it, so
1485
+ * they share one rotation convention.
1486
+ */
1487
+ function pointInRotatedFrame(origin, rotationDegrees, x, y) {
1488
+ const radians = rotationDegrees * Math.PI / 180;
1489
+ const cos = Math.cos(radians);
1490
+ const sin = Math.sin(radians);
1491
+ return {
1492
+ xMm: origin.xMm + x * cos - y * sin,
1493
+ yMm: origin.yMm + x * sin + y * cos
1494
+ };
1495
+ }
1481
1496
  function textFromFeature(feature, portrayal, context, constructionMetersPerCssPixel) {
1482
1497
  if (feature.geometry.type !== "Point" || feature.properties.text === void 0) return;
1483
1498
  const fontSizeCssPixels = resolveTextSizeCssPixels(feature.properties, portrayal, constructionMetersPerCssPixel);
@@ -1491,11 +1506,14 @@ function textFromFeature(feature, portrayal, context, constructionMetersPerCssPi
1491
1506
  sizeCssPixels: fontSizeCssPixels
1492
1507
  });
1493
1508
  const fontSizeMm = fontSizeCssPixels * MILLIMETRES_PER_CSS_PIXEL;
1509
+ const rotationDegrees = (Math.PI - (feature.properties.rotation ?? Math.PI)) * 180 / Math.PI;
1510
+ const anchor = toScenePoint(feature.geometry.coordinates, context);
1511
+ const offsetEms = labelTextOffsetEms(feature.properties);
1494
1512
  return {
1495
1513
  kind: "text",
1496
- position: toScenePoint(feature.geometry.coordinates, context),
1514
+ position: offsetEms ? pointInRotatedFrame(anchor, rotationDegrees, offsetEms[0] * fontSizeMm, offsetEms[1] * fontSizeMm) : anchor,
1497
1515
  text,
1498
- rotationDegrees: (Math.PI - (feature.properties.rotation ?? Math.PI)) * 180 / Math.PI,
1516
+ rotationDegrees,
1499
1517
  fontSizeMm,
1500
1518
  widthMm: measured.widthCssPixels * MILLIMETRES_PER_CSS_PIXEL,
1501
1519
  heightMm: measured.heightCssPixels * MILLIMETRES_PER_CSS_PIXEL,
@@ -1574,18 +1592,12 @@ function textCorners(text) {
1574
1592
  const top = -text.heightMm / 2 - haloExpansion;
1575
1593
  const width = text.widthMm + 2 * haloExpansion;
1576
1594
  const height = text.heightMm + 2 * haloExpansion;
1577
- const radians = text.rotationDegrees * Math.PI / 180;
1578
- const cos = Math.cos(radians);
1579
- const sin = Math.sin(radians);
1580
1595
  return [
1581
1596
  [left, top],
1582
1597
  [left + width, top],
1583
1598
  [left + width, top + height],
1584
1599
  [left, top + height]
1585
- ].map(([x, y]) => ({
1586
- xMm: text.position.xMm + x * cos - y * sin,
1587
- yMm: text.position.yMm + x * sin + y * cos
1588
- }));
1600
+ ].map(([x, y]) => pointInRotatedFrame(text.position, text.rotationDegrees, x, y));
1589
1601
  }
1590
1602
  function rectangleCorners(frame) {
1591
1603
  const right = frame.xMm + frame.widthMm;
@@ -1632,22 +1644,12 @@ function visibilityOfElement(element, frame) {
1632
1644
  };
1633
1645
  }
1634
1646
  function vectorSymbolCorners(element) {
1635
- const radians = element.rotationDegrees * Math.PI / 180;
1636
- const cos = Math.cos(radians);
1637
- const sin = Math.sin(radians);
1638
1647
  return [
1639
1648
  [0, 0],
1640
1649
  [element.width, 0],
1641
1650
  [element.width, element.height],
1642
1651
  [0, element.height]
1643
- ].map(([x, y]) => {
1644
- const localX = (x - element.anchor.x) * element.scaleMmPerUnit;
1645
- const localY = (y - element.anchor.y) * element.scaleMmPerUnit;
1646
- return {
1647
- xMm: element.position.xMm + localX * cos - localY * sin,
1648
- yMm: element.position.yMm + localX * sin + localY * cos
1649
- };
1650
- });
1652
+ ].map(([x, y]) => pointInRotatedFrame(element.position, element.rotationDegrees, (x - element.anchor.x) * element.scaleMmPerUnit, (y - element.anchor.y) * element.scaleMmPerUnit));
1651
1653
  }
1652
1654
  function visibilityWarning(layerId, graphicId, elements, frame) {
1653
1655
  const visibility = elements.map((element) => visibilityOfElement(element, frame));
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-DLJy2TJk.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-DqixXba-.mjs";
2
2
  //#region src/paper.ts
3
3
  const A0 = Object.freeze({
4
4
  widthMm: 841,
package/dist/pdf.mjs CHANGED
@@ -1,4 +1,4 @@
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-DLJy2TJk.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-DqixXba-.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");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbat-mapper/tactical-map-sheet",
3
- "version": "0.6.8",
3
+ "version": "0.7.0",
4
4
  "description": "Scale-accurate projected vector tactical map-sheet renderer.",
5
5
  "license": "MIT",
6
6
  "author": "Orbat Mapper",
@@ -30,8 +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.43.0",
34
- "@orbat-mapper/tactical-draw": "^0.28.0"
33
+ "@orbat-mapper/control-measures": "^0.45.0",
34
+ "@orbat-mapper/tactical-draw": "^0.30.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@napi-rs/canvas": "1.0.7",
@@ -45,7 +45,7 @@
45
45
  "typescript": "~5.9.3",
46
46
  "vite": "^8.0.16",
47
47
  "vitest": "^4.1.8",
48
- "@orbat-mapper/point-symbols": "0.2.26"
48
+ "@orbat-mapper/point-symbols": "0.2.28"
49
49
  },
50
50
  "inlinedDependencies": {
51
51
  "@types/geojson": "7946.0.16"