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

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.
@@ -7,7 +7,8 @@ import { SaxesParser } from "saxes";
7
7
  //#region src/projection/geographic-lib.ts
8
8
  const backend = GeographicLibMgrs.UTMUPS;
9
9
  const mgrsBackend$1 = GeographicLibMgrs.MGRS;
10
- const FORCE_UTM_ZONE_SELECTION = -2;
10
+ const STANDARD_ZONE_SELECTION = backend.STANDARD;
11
+ const FORCE_UTM_ZONE_SELECTION = backend.UTM;
11
12
  const UPS_FALSE_ORIGIN_METERS = 2e6;
12
13
  const polarBackend = PolarStereographic.UPS();
13
14
  var GridProjectionRangeError = class extends RangeError {};
@@ -52,7 +53,7 @@ function assertFiniteProjection(result) {
52
53
  const geographicLibGridProjection = {
53
54
  selectStandard(position) {
54
55
  const [longitude, latitude] = readPosition(position);
55
- const result = backend.forward(latitude, longitude, false, false);
56
+ const result = backend.forward(latitude, longitude, STANDARD_ZONE_SELECTION, false);
56
57
  assertFiniteProjection(result);
57
58
  return result.zone === 0 ? {
58
59
  kind: "ups",
@@ -1091,13 +1092,23 @@ function validateVectorMetadata(vector) {
1091
1092
  requireFinite(vector.octagonAnchor.x, "Vector symbol octagon anchor x");
1092
1093
  requireFinite(vector.octagonAnchor.y, "Vector symbol octagon anchor y");
1093
1094
  }
1094
- function resolveSizePixels(size, groundMetersPerCssPixel) {
1095
+ /**
1096
+ * The Web Mercator metres per CSS pixel at `position`: the resolution a map
1097
+ * adapter reports there, which a `meters` symbol size and a pixel offset's
1098
+ * ground reach are measured in. The sheet's own resolution is true ground
1099
+ * (ADR-0046), so a metre-sized symbol would otherwise print `1 / cos(lat)`
1100
+ * larger than the map shows it.
1101
+ */
1102
+ function symbolMetersPerCssPixel(position, groundMetersPerCssPixel) {
1103
+ return resolveConstructionMetersPerCssPixel([position], groundMetersPerCssPixel) ?? groundMetersPerCssPixel;
1104
+ }
1105
+ function resolveSizePixels(size, metersPerCssPixel) {
1095
1106
  requirePositiveFinite(size.value, "Symbol size");
1096
1107
  if (size.unit === "meters") {
1097
1108
  if (size.minPixels !== void 0) requirePositiveFinite(size.minPixels, "Symbol minimum size");
1098
1109
  if (size.maxPixels !== void 0) requirePositiveFinite(size.maxPixels, "Symbol maximum size");
1099
1110
  }
1100
- return effectivePointSymbolPixelSize({ size }, groundMetersPerCssPixel);
1111
+ return effectivePointSymbolPixelSize({ size }, metersPerCssPixel);
1101
1112
  }
1102
1113
  /** A symbol's drawn opacity, 0–1: a point symbol's style opacities multiplied, or a custom symbol's own. */
1103
1114
  function symbolOpacity(symbol) {
@@ -1112,7 +1123,7 @@ function renderVectorSymbol(symbol, vector, context) {
1112
1123
  const projected = geographicLibGridProjection.forward(context.crs, symbol.position);
1113
1124
  const position = projectedToScenePoint(projected, context);
1114
1125
  const opacity = symbolOpacity(symbol);
1115
- const octagonSizeMm = resolveSizePixels(symbol.size, context.groundMetersPerCssPixel) * MILLIMETRES_PER_CSS_PIXEL;
1126
+ const octagonSizeMm = resolveSizePixels(symbol.size, symbolMetersPerCssPixel(symbol.position, context.groundMetersPerCssPixel)) * MILLIMETRES_PER_CSS_PIXEL;
1116
1127
  return {
1117
1128
  kind: "vector-symbol",
1118
1129
  position,
@@ -1142,7 +1153,7 @@ function renderPointSymbolElements(symbol, vector, context) {
1142
1153
  return [point.xMm / factor, point.yMm / factor];
1143
1154
  },
1144
1155
  getBearing: () => projected.convergenceDegrees * Math.PI / 180,
1145
- getResolution: () => context.groundMetersPerCssPixel
1156
+ getResolution: () => symbolMetersPerCssPixel(symbol.position, context.groundMetersPerCssPixel)
1146
1157
  });
1147
1158
  const sheetLayout = layout && scalePointSymbolLayout(layout, factor);
1148
1159
  const base = renderVectorSymbol(symbol, sheetLayout?.render ?? vector, context);
@@ -1837,7 +1848,7 @@ function renderCollocationElements(collocation, context) {
1837
1848
  return vector;
1838
1849
  };
1839
1850
  const render = buildRender(collocation, capability, context.highlightAppearance, ordinary);
1840
- const layout = layoutCollocation(render, context.groundMetersPerCssPixel);
1851
+ const layout = layoutCollocation(render, render.location ? symbolMetersPerCssPixel(render.location, context.groundMetersPerCssPixel) : context.groundMetersPerCssPixel);
1841
1852
  const location = layout.location;
1842
1853
  if (!location) return { status: "hidden" };
1843
1854
  const locationPoint = context.toScenePoint(location);
@@ -2679,14 +2690,9 @@ function compactReference(reference) {
2679
2690
  function assertPrecision(precision) {
2680
2691
  if (!Number.isInteger(precision) || precision < 0 || precision > 5) throw new RangeError("MGRS precision must be an integer from 0 through 5");
2681
2692
  }
2682
- function pointForMgrsFormatting(coordinate, precision) {
2683
- if (coordinate.crs.kind !== "ups") return coordinate;
2684
- const cellSizeMeters = 1e5 / 10 ** precision;
2685
- if (coordinate.northing % cellSizeMeters !== 0) return coordinate;
2686
- return {
2687
- easting: coordinate.easting,
2688
- northing: coordinate.northing + 1e-6
2689
- };
2693
+ const PROJECTION_ROUNDOFF_METERS = 1e-6;
2694
+ function settleProjectionRoundoff(value) {
2695
+ return Math.round(value / PROJECTION_ROUNDOFF_METERS) * PROJECTION_ROUNDOFF_METERS;
2690
2696
  }
2691
2697
  /** Parse a complete MGRS cell and resolve its southwest grid intersection. */
2692
2698
  function parseMgrsReference(reference) {
@@ -2741,14 +2747,16 @@ function mgrsToGeographic(reference) {
2741
2747
  }
2742
2748
  function projectedToMgrs(coordinate, precision = 5) {
2743
2749
  assertPrecision(precision);
2744
- return geographicLibGridProjection.formatMgrs(coordinate.crs, pointForMgrsFormatting(coordinate, precision), precision);
2750
+ return geographicLibGridProjection.formatMgrs(coordinate.crs, coordinate, precision);
2745
2751
  }
2746
2752
  function geographicToMgrs(position, precision = 5) {
2747
2753
  assertPrecision(precision);
2748
2754
  const crs = geographicLibGridProjection.selectStandard(position);
2755
+ const { easting, northing } = geographicLibGridProjection.forward(crs, position);
2749
2756
  return projectedToMgrs({
2750
2757
  crs,
2751
- ...geographicLibGridProjection.forward(crs, position)
2758
+ easting: settleProjectionRoundoff(easting),
2759
+ northing: settleProjectionRoundoff(northing)
2752
2760
  }, precision);
2753
2761
  }
2754
2762
  function snapUpOnHalf(value, interval) {
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-DFP-2Ifu.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-DFP-2Ifu.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.4",
4
4
  "description": "Scale-accurate projected vector tactical map-sheet renderer.",
5
5
  "license": "MIT",
6
6
  "author": "Orbat Mapper",
@@ -26,12 +26,12 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "geographiclib-mgrs": "^1.0.5",
29
+ "geographiclib-mgrs": "^1.0.7",
30
30
  "jspdf": "4.2.1",
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": {