Skip to content

Commit

Permalink
Merge pull request #656 from maneetgoyal/symbol-enums
Browse files Browse the repository at this point in the history
Replace string union types with const enums
  • Loading branch information
dbouwman authored Feb 27, 2020
2 parents 8a2daac + 55551bc commit f3f856b
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 70 deletions.
28 changes: 26 additions & 2 deletions packages/arcgis-rest-types/src/statisticDefinition.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
* Apache-2.0 */

/**
* Enum of all different statistics operations
*/
export const enum StatisticType {
Count = "count",
Sum = "sum",
Minimum = "min",
Maximum = "max",
Average = "avg",
StandardDeviation = "stddev",
Variance = "var",
ContinuousPercentile = "percentile_cont",
DiscretePercentile = "percentile_disc"
}

/**
* Enum of sorting orders
*/
export const enum SortingOrder {
Ascending = "asc",
Descending = "desc"
}

export interface IStatisticDefinition {
/**
* Statistical operation to perform (count, sum, min, max, avg, stddev, var, percentile_cont, percentile_disc).
Expand All @@ -14,13 +37,14 @@ export interface IStatisticDefinition {
| "stddev"
| "var"
| "percentile_cont"
| "percentile_disc";
| "percentile_disc"
| StatisticType;
/**
* Parameter to be used along with statisticType. Currently, only applicable for percentile_cont (continuous percentile) and percentile_disc (discrete percentile).
*/
statisticParameter?: {
value: number;
orderBy?: "asc" | "desc";
orderBy?: "asc" | "desc" | SortingOrder;
};
/**
* Field on which to perform the statistical operation.
Expand Down
185 changes: 133 additions & 52 deletions packages/arcgis-rest-types/src/symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,43 @@
*/
export type Color = [number, number, number, number];

/**
*
*/
export const enum FontStyle {
Italic = "italic",
Normal = "normal",
Oblique = "oblique"
}

/**
*
*/
export const enum FontWeight {
Bold = "bold",
Bolder = "bolder",
Lighter = "lighter",
Normal = "normal"
}

/**
*
*/
export const enum FontDecoration {
LineThrough = "line-through",
Underline = "underline",
None = "none"
}

/**
*
*/
export interface IFont {
family?: string; // "<fontFamily>";
size?: number; // <fontSize>;
style?: "italic" | "normal" | "oblique";
weight?: "bold" | "bolder" | "lighter" | "normal";
decoration?: "line-through" | "underline" | "none";
style?: "italic" | "normal" | "oblique" | FontStyle;
weight?: "bold" | "bolder" | "lighter" | "normal" | FontWeight;
decoration?: "line-through" | "underline" | "none" | FontDecoration;
}

/**
Expand All @@ -34,16 +62,27 @@ export interface IPictureSourced {
/**
*
*/
export interface ISymbol {
type: SymbolType;
style?: string;
export const enum SymbolType {
SLS = "esriSLS",
SMS = "esriSMS",
SFS = "esriSFS",
PMS = "esriPMS",
PFS = "esriPFS",
TS = "esriTS"
}

/**
*
*/
export interface ISymbol {
type: SymbolType;
type:
| "esriSLS"
| "esriSMS"
| "esriSFS"
| "esriPMS"
| "esriPFS"
| "esriTS"
| SymbolType;
style?: string;
}

Expand All @@ -60,7 +99,7 @@ export interface IMarkerSymbol extends ISymbol {
*
*/
export interface IPictureFillSymbol extends ISymbol, IPictureSourced {
type: "esriPFS";
type: "esriPFS" | SymbolType.PFS;
outline?: ISimpleLineSymbol; // if outline has been specified
xscale?: number;
yscale?: number;
Expand All @@ -70,61 +109,62 @@ export interface IPictureFillSymbol extends ISymbol, IPictureSourced {
*
*/
export interface IPictureMarkerSymbol extends IMarkerSymbol, IPictureSourced {
type: "esriPMS";
type: "esriPMS" | SymbolType.PMS;
}

/**
*
*/
export type SimpleMarkerSymbolStyle =
| "esriSMSCircle"
| "esriSMSCross"
| "esriSMSDiamond"
| "esriSMSSquare"
| "esriSMSX"
| "esriSMSTriangle";

/**
*
*/
export type SimpleLineSymbolStyle =
| "esriSLSDash"
| "esriSLSDashDot"
| "esriSLSDashDotDot"
| "esriSLSDot"
| "esriSLSNull"
| "esriSLSSolid";
export const enum SimpleMarkerSymbolStyle {
Circle = "esriSMSCircle",
Cross = "esriSMSCross",
Diamond = "esriSMSDiamond",
Square = "esriSMSSquare",
X = "esriSMSX",
Triangle = "esriSMSTriangle"
}

/**
*
*/
export type SimpleFillSymbolStyle =
| "esriSFSBackwardDiagonal"
| "esriSFSCross"
| "esriSFSDiagonalCross"
| "esriSFSForwardDiagonal"
| "esriSFSHorizontal"
| "esriSFSNull"
| "esriSFSSolid"
| "esriSFSVertical";
export const enum SimpleLineSymbolStyle {
Dash = "esriSLSDash",
DashDot = "esriSLSDashDot",
DashDotDot = "esriSLSDashDotDot",
Dot = "esriSLSDot",
Null = "esriSLSNull",
Solid = "esriSLSSolid"
}

/**
*
*/
export type SymbolType =
| "esriSLS"
| "esriSMS"
| "esriSFS"
| "esriPMS"
| "esriPFS"
| "esriTS";
export const enum SimpleFillSymbolStyle {
BackwardDiagonal = "esriSFSBackwardDiagonal",
Cross = "esriSFSCross",
DiagonalCross = "esriSFSDiagonalCross",
ForwardDiagonal = "esriSFSForwardDiagonal",
Horizontal = "esriSFSHorizontal",
Null = "esriSFSNull",
Solid = "esriSFSSolid",
Vertical = "esriSFSVertical"
}

/**
*
*/
export interface ISimpleFillSymbol extends ISymbol {
type: "esriSFS";
style?: SimpleFillSymbolStyle;
type: "esriSFS" | SymbolType.SFS;
style?:
| "esriSFSBackwardDiagonal"
| "esriSFSCross"
| "esriSFSDiagonalCross"
| "esriSFSForwardDiagonal"
| "esriSFSHorizontal"
| "esriSFSNull"
| "esriSFSSolid"
| "esriSFSVertical"
| SimpleFillSymbolStyle;
color?: Color;
outline?: ISimpleLineSymbol; // if outline has been specified
}
Expand All @@ -133,8 +173,15 @@ export interface ISimpleFillSymbol extends ISymbol {
*
*/
export interface ISimpleLineSymbol extends ISymbol {
type: "esriSLS";
style?: SimpleLineSymbolStyle;
type: "esriSLS" | SymbolType.SLS;
style?:
| "esriSLSDash"
| "esriSLSDashDot"
| "esriSLSDashDotDot"
| "esriSLSDot"
| "esriSLSNull"
| "esriSLSSolid"
| SimpleLineSymbolStyle;
color?: Color;
width?: number;
}
Expand All @@ -143,26 +190,60 @@ export interface ISimpleLineSymbol extends ISymbol {
*
*/
export interface ISimpleMarkerSymbol extends IMarkerSymbol {
type: "esriSMS";
style?: SimpleMarkerSymbolStyle;
type: "esriSMS" | SymbolType.SMS;
style?:
| "esriSMSCircle"
| "esriSMSCross"
| "esriSMSDiamond"
| "esriSMSSquare"
| "esriSMSX"
| "esriSMSTriangle"
| SimpleMarkerSymbolStyle;
color?: Color;
size?: number;
outline?: ISimpleLineSymbol;
}

/**
*
*/
export const enum VerticalAlignment {
Baseline = "baseline",
Top = "top",
Middle = "middle",
Bottom = "bottom"
}

export const enum HorizontalAlignment {
Left = "left",
Right = "right",
Center = "center",
Justify = "justify"
}

/**
*
*/
export interface ITextSymbol extends IMarkerSymbol {
type: "esriTS";
type: "esriTS" | SymbolType.TS;
color?: Color;
backgroundColor?: Color;
borderLineSize?: number; // <size>;
borderLineColor?: Color;
haloSize?: number; // <size>;
haloColor?: Color;
verticalAlignment?: "baseline" | "top" | "middle" | "bottom";
horizontalAlignment?: "left" | "right" | "center" | "justify";
verticalAlignment?:
| "baseline"
| "top"
| "middle"
| "bottom"
| VerticalAlignment;
horizontalAlignment?:
| "left"
| "right"
| "center"
| "justify"
| HorizontalAlignment;
rightToLeft?: boolean;
kerning?: boolean;
font?: IFont;
Expand Down
Loading

0 comments on commit f3f856b

Please sign in to comment.