@orbat-mapper/tactical-map-sheet 0.9.2 → 0.9.3

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.
@@ -1091,13 +1091,23 @@ function validateVectorMetadata(vector) {
1091
1091
  requireFinite(vector.octagonAnchor.x, "Vector symbol octagon anchor x");
1092
1092
  requireFinite(vector.octagonAnchor.y, "Vector symbol octagon anchor y");
1093
1093
  }
1094
- function resolveSizePixels(size, groundMetersPerCssPixel) {
1094
+ /**
1095
+ * The Web Mercator metres per CSS pixel at `position`: the resolution a map
1096
+ * adapter reports there, which a `meters` symbol size and a pixel offset's
1097
+ * ground reach are measured in. The sheet's own resolution is true ground
1098
+ * (ADR-0046), so a metre-sized symbol would otherwise print `1 / cos(lat)`
1099
+ * larger than the map shows it.
1100
+ */
1101
+ function symbolMetersPerCssPixel(position, groundMetersPerCssPixel) {
1102
+ return resolveConstructionMetersPerCssPixel([position], groundMetersPerCssPixel) ?? groundMetersPerCssPixel;
1103
+ }
1104
+ function resolveSizePixels(size, metersPerCssPixel) {
1095
1105
  requirePositiveFinite(size.value, "Symbol size");
1096
1106
  if (size.unit === "meters") {
1097
1107
  if (size.minPixels !== void 0) requirePositiveFinite(size.minPixels, "Symbol minimum size");
1098
1108
  if (size.maxPixels !== void 0) requirePositiveFinite(size.maxPixels, "Symbol maximum size");
1099
1109
  }
1100
- return effectivePointSymbolPixelSize({ size }, groundMetersPerCssPixel);
1110
+ return effectivePointSymbolPixelSize({ size }, metersPerCssPixel);
1101
1111
  }
1102
1112
  /** A symbol's drawn opacity, 0–1: a point symbol's style opacities multiplied, or a custom symbol's own. */
1103
1113
  function symbolOpacity(symbol) {
@@ -1112,7 +1122,7 @@ function renderVectorSymbol(symbol, vector, context) {
1112
1122
  const projected = geographicLibGridProjection.forward(context.crs, symbol.position);
1113
1123
  const position = projectedToScenePoint(projected, context);
1114
1124
  const opacity = symbolOpacity(symbol);
1115
- const octagonSizeMm = resolveSizePixels(symbol.size, context.groundMetersPerCssPixel) * MILLIMETRES_PER_CSS_PIXEL;
1125
+ const octagonSizeMm = resolveSizePixels(symbol.size, symbolMetersPerCssPixel(symbol.position, context.groundMetersPerCssPixel)) * MILLIMETRES_PER_CSS_PIXEL;
1116
1126
  return {
1117
1127
  kind: "vector-symbol",
1118
1128
  position,
@@ -1142,7 +1152,7 @@ function renderPointSymbolElements(symbol, vector, context) {
1142
1152
  return [point.xMm / factor, point.yMm / factor];
1143
1153
  },
1144
1154
  getBearing: () => projected.convergenceDegrees * Math.PI / 180,
1145
- getResolution: () => context.groundMetersPerCssPixel
1155
+ getResolution: () => symbolMetersPerCssPixel(symbol.position, context.groundMetersPerCssPixel)
1146
1156
  });
1147
1157
  const sheetLayout = layout && scalePointSymbolLayout(layout, factor);
1148
1158
  const base = renderVectorSymbol(symbol, sheetLayout?.render ?? vector, context);
@@ -1837,7 +1847,7 @@ function renderCollocationElements(collocation, context) {
1837
1847
  return vector;
1838
1848
  };
1839
1849
  const render = buildRender(collocation, capability, context.highlightAppearance, ordinary);
1840
- const layout = layoutCollocation(render, context.groundMetersPerCssPixel);
1850
+ const layout = layoutCollocation(render, render.location ? symbolMetersPerCssPixel(render.location, context.groundMetersPerCssPixel) : context.groundMetersPerCssPixel);
1841
1851
  const location = layout.location;
1842
1852
  if (!location) return { status: "hidden" };
1843
1853
  const locationPoint = context.toScenePoint(location);
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, m as prepareMapSheetNotes, o as mgrsToGeographic, p as toMapSheetCollocation, r as mapSheetRasterPointToGeographic, s as mgrsToProjected, t as createTacticalMapSheet, u as projectedToMgrs } from "./create-tactical-map-sheet-Gu_V4eUT.mjs";
1
+ import { a as geographicToMgrs, c as normalizeMgrsReference, d as snapGeographicToMgrs, f as snapProjectedToMgrs, i as resolveMapSheetRasterPlan, l as parseMgrsReference, m as prepareMapSheetNotes, o as mgrsToGeographic, p as toMapSheetCollocation, r as mapSheetRasterPointToGeographic, s as mgrsToProjected, t as createTacticalMapSheet, u as projectedToMgrs } from "./create-tactical-map-sheet-CskLLhZ4.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 POINTS_PER_MILLIMETRE, g as MILLIMETRES_PER_CSS_PIXEL, h as formatDecimal, n as createTacticalMapSheetDocument, v as openSansCentralBaselineOffset, y as openSansMiddleBaselineOffset } from "./create-tactical-map-sheet-Gu_V4eUT.mjs";
1
+ import { _ as POINTS_PER_MILLIMETRE, g as MILLIMETRES_PER_CSS_PIXEL, h as formatDecimal, n as createTacticalMapSheetDocument, v as openSansCentralBaselineOffset, y as openSansMiddleBaselineOffset } from "./create-tactical-map-sheet-CskLLhZ4.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.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Scale-accurate projected vector tactical map-sheet renderer.",
5
5
  "license": "MIT",
6
6
  "author": "Orbat Mapper",
@@ -31,7 +31,7 @@
31
31
  "opentype.js": "2.0.0",
32
32
  "saxes": "6.0.0",
33
33
  "@orbat-mapper/control-measures": "^0.47.0",
34
- "@orbat-mapper/tactical-draw": "^0.36.1",
34
+ "@orbat-mapper/tactical-draw": "^0.36.2",
35
35
  "@orbat-mapper/tactical-notes": "^0.2.1"
36
36
  },
37
37
  "devDependencies": {