diff --git a/packages/geostats-types/.npmignore b/packages/geostats-types/.npmignore new file mode 100644 index 00000000..7e98e25e --- /dev/null +++ b/packages/geostats-types/.npmignore @@ -0,0 +1 @@ +**/*.ts \ No newline at end of file diff --git a/packages/geostats-types/lib/index.d.ts b/packages/geostats-types/lib/index.d.ts index 47cd31a5..ddf7b3f3 100644 --- a/packages/geostats-types/lib/index.d.ts +++ b/packages/geostats-types/lib/index.d.ts @@ -2,18 +2,18 @@ import { GeoJsonGeometryTypes } from "geojson"; /** * Attribute type as translated to a javacsript type */ -export type GeostatsAttributeType = "string" | "number" | "boolean" | "null" | "mixed" | "object" | "array"; +export declare type GeostatsAttributeType = "string" | "number" | "boolean" | "null" | "mixed" | "object" | "array"; /** * A bucket is a tuple of [break, count]. Each bucket has a count of the number * of features between the break and the next break. The last bucket will have * a null count. */ -export type Bucket = [number, number | null]; +export declare type Bucket = [number, number | null]; /** * A set of buckets for a given number of breaks. This way cartography * interfaces can give the user an option to choose the number of breaks */ -export type Buckets = { +export declare type Buckets = { [numBreaks: number]: Bucket[]; }; export interface BaseGeostatsAttribute { @@ -74,8 +74,8 @@ export interface NumericGeostatsAttribute extends BaseGeostatsAttribute { stdev: number; }; } -export type GeostatsAttribute = BaseGeostatsAttribute | NumericGeostatsAttribute; -export type LegacyGeostatsAttribute = Omit & { +export declare type GeostatsAttribute = BaseGeostatsAttribute | NumericGeostatsAttribute; +export declare type LegacyGeostatsAttribute = Omit & { values: (string | number | boolean | null)[]; quantiles?: number[]; }; @@ -84,7 +84,7 @@ export declare enum MetadataType { ISO19139 = "ISO19139", FGDC = "FGDC" } -export type GeostatsMetadata = { +export declare type GeostatsMetadata = { /** * metadata for the layer summarized as a prosemirror document */ @@ -124,7 +124,7 @@ export interface GeostatsLayer { bounds?: number[]; metadata?: GeostatsMetadata; } -export type LegacyGeostatsLayer = Omit & { +export declare type LegacyGeostatsLayer = Omit & { attributes: LegacyGeostatsAttribute[]; }; export declare function isLegacyGeostatsLayer(layer: LegacyGeostatsLayer | GeostatsLayer): layer is LegacyGeostatsLayer; @@ -134,12 +134,12 @@ export declare function isLegacyGeostatsAttribute(attr: LegacyGeostatsAttribute * number of features between the break and the next break. The last bucket will * have a null fraction. */ -export type RasterBucket = [number, number | null]; +export declare type RasterBucket = [number, number | null]; /** * A set of buckets for a given number of breaks. This way cartography * interfaces can give the user an option to choose the number of breaks */ -export type RasterBuckets = { +export declare type RasterBuckets = { [numBreaks: number]: RasterBucket[]; }; /** @@ -147,8 +147,8 @@ export type RasterBuckets = { * raster value and the color is a CSS color string. Raster values should match * those in the stats.categories array. */ -export type ColorTableEntry = [number, string]; -export type RasterBandInfo = { +export declare type ColorTableEntry = [number, string]; +export declare type RasterBandInfo = { name: string; colorInterpretation: "Red" | "Green" | "Blue" | "Alpha" | "Gray" | string | null; base: number; diff --git a/packages/geostats-types/lib/index.js b/packages/geostats-types/lib/index.js index 84451ad9..e24f3af6 100644 --- a/packages/geostats-types/lib/index.js +++ b/packages/geostats-types/lib/index.js @@ -1,14 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.SuggestedRasterPresentation = void 0; -exports.isNumericGeostatsAttribute = isNumericGeostatsAttribute; -exports.isLegacyGeostatsLayer = isLegacyGeostatsLayer; -exports.isLegacyGeostatsAttribute = isLegacyGeostatsAttribute; -exports.isRasterInfo = isRasterInfo; -exports.isGeostatsLayer = isGeostatsLayer; +exports.isGeostatsLayer = exports.isRasterInfo = exports.SuggestedRasterPresentation = exports.isLegacyGeostatsAttribute = exports.isLegacyGeostatsLayer = exports.isNumericGeostatsAttribute = void 0; function isNumericGeostatsAttribute(attr) { return attr.type === "number"; } +exports.isNumericGeostatsAttribute = isNumericGeostatsAttribute; function isLegacyGeostatsLayer(layer) { if ("attributesCount" in layer && layer.attributesCount) { return layer.attributes[0].countDistinct === undefined; @@ -17,9 +13,11 @@ function isLegacyGeostatsLayer(layer) { return !("bounds" in layer); } } +exports.isLegacyGeostatsLayer = isLegacyGeostatsLayer; function isLegacyGeostatsAttribute(attr) { return Array.isArray(attr.values); } +exports.isLegacyGeostatsAttribute = isLegacyGeostatsAttribute; /** * SuggestedRasterPresentation is a hint to the client on how to present the * raster data. This can be used to determine the default visualization type for @@ -35,10 +33,12 @@ var SuggestedRasterPresentation; SuggestedRasterPresentation[SuggestedRasterPresentation["categorical"] = 0] = "categorical"; SuggestedRasterPresentation[SuggestedRasterPresentation["continuous"] = 1] = "continuous"; SuggestedRasterPresentation[SuggestedRasterPresentation["rgb"] = 2] = "rgb"; -})(SuggestedRasterPresentation || (exports.SuggestedRasterPresentation = SuggestedRasterPresentation = {})); +})(SuggestedRasterPresentation = exports.SuggestedRasterPresentation || (exports.SuggestedRasterPresentation = {})); function isRasterInfo(info) { return info.bands !== undefined; } +exports.isRasterInfo = isRasterInfo; function isGeostatsLayer(data) { return (!Array.isArray(data) && data.attributes !== undefined); } +exports.isGeostatsLayer = isGeostatsLayer; diff --git a/packages/geostats-types/package.json b/packages/geostats-types/package.json index 8f84ac1a..df8c40c4 100644 --- a/packages/geostats-types/package.json +++ b/packages/geostats-types/package.json @@ -1,7 +1,7 @@ { "name": "@seasketch/geostats-types", "version": "1.0.0", - "description": "Types for metadata describing vector and raster data, useful for cartography and data handling", + "description": "Types for metadata describing vector and raster data, useful for cartography and data handling in SeaSketch", "author": "Chad Burt ", "homepage": "https://github.com/seasketch/next#readme", "license": "BSD-3-Clause",