@orbat-mapper/tactical-map-sheet 0.9.3 → 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",
@@ -2689,14 +2690,9 @@ function compactReference(reference) {
2689
2690
  function assertPrecision(precision) {
2690
2691
  if (!Number.isInteger(precision) || precision < 0 || precision > 5) throw new RangeError("MGRS precision must be an integer from 0 through 5");
2691
2692
  }
2692
- function pointForMgrsFormatting(coordinate, precision) {
2693
- if (coordinate.crs.kind !== "ups") return coordinate;
2694
- const cellSizeMeters = 1e5 / 10 ** precision;
2695
- if (coordinate.northing % cellSizeMeters !== 0) return coordinate;
2696
- return {
2697
- easting: coordinate.easting,
2698
- northing: coordinate.northing + 1e-6
2699
- };
2693
+ const PROJECTION_ROUNDOFF_METERS = 1e-6;
2694
+ function settleProjectionRoundoff(value) {
2695
+ return Math.round(value / PROJECTION_ROUNDOFF_METERS) * PROJECTION_ROUNDOFF_METERS;
2700
2696
  }
2701
2697
  /** Parse a complete MGRS cell and resolve its southwest grid intersection. */
2702
2698
  function parseMgrsReference(reference) {
@@ -2751,14 +2747,16 @@ function mgrsToGeographic(reference) {
2751
2747
  }
2752
2748
  function projectedToMgrs(coordinate, precision = 5) {
2753
2749
  assertPrecision(precision);
2754
- return geographicLibGridProjection.formatMgrs(coordinate.crs, pointForMgrsFormatting(coordinate, precision), precision);
2750
+ return geographicLibGridProjection.formatMgrs(coordinate.crs, coordinate, precision);
2755
2751
  }
2756
2752
  function geographicToMgrs(position, precision = 5) {
2757
2753
  assertPrecision(precision);
2758
2754
  const crs = geographicLibGridProjection.selectStandard(position);
2755
+ const { easting, northing } = geographicLibGridProjection.forward(crs, position);
2759
2756
  return projectedToMgrs({
2760
2757
  crs,
2761
- ...geographicLibGridProjection.forward(crs, position)
2758
+ easting: settleProjectionRoundoff(easting),
2759
+ northing: settleProjectionRoundoff(northing)
2762
2760
  }, precision);
2763
2761
  }
2764
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-CskLLhZ4.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-CskLLhZ4.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.3",
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,7 +26,7 @@
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",