wael-lib
Version:
Well-Known Text Arithmetic Expression Language
85 lines (77 loc) • 3.06 kB
TypeScript
import * as geojson from 'geojson';
import { Point } from 'geojson';
interface ScopeBindings {
[identifier: string]: any;
}
interface Metadata {
public: boolean;
}
declare class Scope {
private parent?;
readonly level: number;
bindings: ScopeBindings;
availableBindings: ScopeBindings;
private metadata;
constructor(parent?: Scope | undefined, level?: number, defaultBindings?: ScopeBindings);
store(identifier: string, value: any, metadata?: Metadata, searchParentChain?: boolean): void;
resolveScope(identifier: string): Scope | undefined;
resolve(identifier: string): any;
push(extraBindings?: ScopeBindings): Scope;
pop(additionalBindings?: ScopeBindings): Scope | undefined;
import(scopeBindings: ScopeBindings): void;
useImports(selectedIdentifiers?: string[]): ScopeBindings;
useNamedImports(selectedIdentifiers: string[]): ScopeBindings;
}
declare enum OutputFormat {
WKT = "WKT",
GeoJSON = "GeoJSON"
}
interface Options {
outputFormat?: OutputFormat;
outputNonGeoJSON?: boolean;
scope?: Scope;
storeHistoricalEvaluations?: boolean;
}
declare const DEFAULT_OPTIONS: Options;
declare class Wael {
private options;
private evaluationCount;
static IDENTIFIER_LAST: string;
constructor(initialOptions?: Options);
getEvaluationCount(): number;
evaluate(input: string, overrideOptions?: Partial<Options>): any;
static evaluate(input: string, options?: Partial<Options>): any;
private static getOutputString;
}
declare namespace BuiltInFunctions {
const Flatten: (value: any) => any;
const PointCircle: (radius: number, count: number) => geojson.GeometryCollection<geojson.Geometry>;
const PointGrid: (x: number, y: number, spacing?: number) => geojson.GeometryCollection<geojson.Geometry>;
const ToLineString: (value: any) => geojson.LineString;
const ToMultiPoint: (value: any) => geojson.MultiPoint;
const ToPolygon: (value: any) => geojson.Polygon;
const ToGeometryCollection: (value: any) => geojson.GeometryCollection<geojson.Geometry>;
const Rotate: (angleDegrees: number, origin: Point | undefined, geometry: any) => any;
const Round: (precision: number | undefined, val: any) => any;
}
declare namespace Interpreter {
const IMPORT_DEFAULT_IDENTIFIER = "Default";
const IMPORT_USING_ALL = "*";
const STANDARD_LIBRARY: ScopeBindings;
const createGlobalScope: () => Scope;
function evaluateInput(input: string, initialScope?: Scope): any;
}
type GeoJSON = any;
declare enum GeometryType {
Point = "Point",
LineString = "LineString",
Polygon = "Polygon",
MultiPoint = "MultiPoint",
MultiLineString = "MultiLineString",
MultiPolygon = "MultiPolygon",
GeometryCollection = "GeometryCollection"
}
type Unit = null;
declare const UNIT: Unit;
declare const GRAMMAR: string;
export { BuiltInFunctions, DEFAULT_OPTIONS, GRAMMAR, type GeoJSON, GeometryType, Interpreter, type Options, OutputFormat, Scope, type ScopeBindings, UNIT, type Unit, Wael };