Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
fix(ts): Wrong enum export
Browse files Browse the repository at this point in the history
  • Loading branch information
ibesora committed Mar 30, 2022
1 parent e1c1f35 commit c9ff858
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 28 deletions.
2 changes: 1 addition & 1 deletion dist/dd-symbolizers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Point from "@mapbox/point-geometry";
import { Feature } from "./tilecache";
import { Justify, LabelSymbolizer, TextSymbolizer } from "./symbolizer";
import { Label, Layout } from "./labeler";
export declare enum TextPlacements {
export declare const enum TextPlacements {
N = 1,
NE = 2,
E = 3,
Expand Down
41 changes: 15 additions & 26 deletions dist/dd-symbolizers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@ import Point from "@mapbox/point-geometry";
import { GeomType } from "./tilecache";
// @ts-ignore
import { Justify, TextSymbolizer } from "./symbolizer";
export var TextPlacements;
(function (TextPlacements) {
TextPlacements[TextPlacements["N"] = 1] = "N";
TextPlacements[TextPlacements["NE"] = 2] = "NE";
TextPlacements[TextPlacements["E"] = 3] = "E";
TextPlacements[TextPlacements["SE"] = 4] = "SE";
TextPlacements[TextPlacements["S"] = 5] = "S";
TextPlacements[TextPlacements["SW"] = 6] = "SW";
TextPlacements[TextPlacements["W"] = 7] = "W";
TextPlacements[TextPlacements["NW"] = 8] = "NW";
})(TextPlacements || (TextPlacements = {}));
export class DataDrivenOffsetSymbolizer {
constructor(symbolizer, options) {
this.getBbox = (anchor, bbOrigin, firstLabelBbox) => {
Expand All @@ -28,14 +17,14 @@ export class DataDrivenOffsetSymbolizer {
this.offsetX = options.offsetX || 0;
this.offsetY = options.offsetY || 0;
this.placements = options.placements || [
TextPlacements.NE,
TextPlacements.SW,
TextPlacements.NW,
TextPlacements.SE,
TextPlacements.N,
TextPlacements.S,
TextPlacements.E,
TextPlacements.W,
2 /* NE */,
6 /* SW */,
8 /* NW */,
4 /* SE */,
1 /* N */,
5 /* S */,
3 /* E */,
7 /* W */,
];
this.attrs =
options.attrs ||
Expand Down Expand Up @@ -97,30 +86,30 @@ export class DataDrivenOffsetSymbolizer {
computeXAxisOffset(offsetX, fb, placement) {
const labelWidth = fb.maxX;
const labelHalfWidth = labelWidth / 2;
if ([TextPlacements.N, TextPlacements.S].includes(placement))
if ([1 /* N */, 5 /* S */].includes(placement))
return offsetX - labelHalfWidth;
if ([TextPlacements.NW, TextPlacements.W, TextPlacements.SW].includes(placement))
if ([8 /* NW */, 7 /* W */, 6 /* SW */].includes(placement))
return -offsetX - labelWidth;
return offsetX;
}
computeYAxisOffset(offsetY, fb, placement) {
const labelHalfHeight = Math.abs(fb.minY);
const labelBottom = fb.maxY;
const labelCenterHeight = (fb.minY + fb.maxY) / 2;
if ([TextPlacements.E, TextPlacements.W].includes(placement))
if ([3 /* E */, 7 /* W */].includes(placement))
return offsetY - labelCenterHeight;
if ([TextPlacements.NW, TextPlacements.NE, TextPlacements.N].includes(placement))
if ([8 /* NW */, 2 /* NE */, 1 /* N */].includes(placement))
return -offsetY - labelBottom;
if ([TextPlacements.SW, TextPlacements.SE, TextPlacements.S].includes(placement))
if ([6 /* SW */, 4 /* SE */, 5 /* S */].includes(placement))
return offsetY + labelHalfHeight;
return offsetY;
}
computeJustify(fixedJustify, placement) {
if (fixedJustify)
return fixedJustify;
if ([TextPlacements.N, TextPlacements.S].includes(placement))
if ([1 /* N */, 5 /* S */].includes(placement))
return Justify.Center;
if ([TextPlacements.NE, TextPlacements.E, TextPlacements.SE].includes(placement))
if ([2 /* NE */, 3 /* E */, 4 /* SE */].includes(placement))
return Justify.Left;
return Justify.Right;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dd-symbolizers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Justify, LabelSymbolizer, TextSymbolizer } from "./symbolizer";
import { NumberAttr } from "./attribute";
import { Label, Layout } from "./labeler";

export enum TextPlacements {
export const enum TextPlacements {
N = 1,
NE = 2,
E = 3,
Expand Down

0 comments on commit c9ff858

Please sign in to comment.