Skip to content

The OSINT investigator's workbench. One case, one folder, every tool. Local-first: your media and your investigations never leave your machine.

JavaScript
3.3 KB
Raw Blame
/**
 * The two marks the map can put on a point, as plain SVG.
 *
 * A capture is a document: whatever the analyst saw on screen is what the PNG
 * has to show, so these strings are the same ones the server draws into a
 * capture. Kept out of the tool because a marker is a picture with a claim in it
 * — the pin's tip is the location, the crosshair's centre is — and an anchor
 * that disagrees with the drawing puts the mark somewhere the point is not.
 */

/** Size and anchor per style, in CSS pixels. The anchor is the point itself. */
export const MARKER_GEOMETRY = {
  // The tip at the bottom of the teardrop is what points at the location.
  pin: { size: [30, 42], anchor: [15, 42] },
  // Centred: the gap between the four arms is the point.
  crosshair: { size: [46, 46], anchor: [23, 23] },
};

const PIN = `<svg width="30" height="42" viewBox="0 0 30 42">
          <path d="M15 41 C15 41 27 24 27 14 A12 12 0 1 0 3 14 C3 24 15 41 15 41 Z"
            fill="#e5484d" stroke="#3c0c0e" stroke-width="1.5"/>
          <circle cx="15" cy="14" r="4.5" fill="#fff" stroke="#3c0c0e" stroke-width="1"/>
        </svg>`;

// Drawn twice: a heavy dark pass under a light one, so the arms stay legible on
// bright sand and on dark water without a halo box around them.
const CROSSHAIR = `<svg width="46" height="46" viewBox="0 0 46 46">
        <g stroke="#000" stroke-width="4" opacity="0.55">
          <line x1="1" y1="23" x2="16" y2="23"/><line x1="30" y1="23" x2="45" y2="23"/>
          <line x1="23" y1="1" x2="23" y2="16"/><line x1="23" y1="30" x2="23" y2="45"/>
        </g>
        <g stroke="#fff" stroke-width="2">
          <line x1="1" y1="23" x2="16" y2="23"/><line x1="30" y1="23" x2="45" y2="23"/>
          <line x1="23" y1="1" x2="23" y2="16"/><line x1="23" y1="30" x2="23" y2="45"/>
          <circle cx="23" cy="23" r="2.5" fill="none"/>
        </g>
      </svg>`;

/** The marker SVG for a style. Anything but `pin` draws the crosshair. */
export function markerSvg(style) {
  return style === 'pin' ? PIN : CROSSHAIR;
}

/** Size and anchor for a style, matching what `markerSvg` returns. */
export function markerGeometry(style) {
  return style === 'pin' ? MARKER_GEOMETRY.pin : MARKER_GEOMETRY.crosshair;
}

/**
 * The teardrop the map draws on a saved point, in every overlay that draws one.
 *
 * It is a 24 px box with one sharp corner, turned 45° so that corner hangs
 * straight down — and the corner is the claim, the same way the pin's tip is.
 * A rotation moves it half a diagonal below the middle of the box, so that is
 * where the anchor goes; anchored on the middle, as it used to be, every mark
 * sat 17 px above what it pointed at, which is ten metres at zoom 18 and five
 * at zoom 19.
 *
 * `extension/mapdraw.js` draws the same shape on other people's maps and
 * repeats these numbers, because a classic script cannot import this one.
 */
const TEARDROP_BOX = 24;
const TEARDROP_TIP = (TEARDROP_BOX / 2) * Math.SQRT2;

export const TEARDROP = {
  size: [TEARDROP_BOX, TEARDROP_BOX],
  anchor: [TEARDROP_BOX / 2, TEARDROP_BOX / 2 + TEARDROP_TIP],
};

/** How far a mark's card hangs off the point, now that the body is all above
 *  it: the whole diagonal, or the card opens over the mark it belongs to. */
export const TEARDROP_CARD_OFFSET = Math.round(2 * TEARDROP_TIP);