Skip to content

Commit

Permalink
Small tweaks to @seasketch/geostats-types before publish
Browse files Browse the repository at this point in the history
  • Loading branch information
underbluewaters committed Nov 27, 2024
1 parent e43f7bb commit f52c563
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions packages/geostats-types/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.ts
22 changes: 11 additions & 11 deletions packages/geostats-types/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -74,8 +74,8 @@ export interface NumericGeostatsAttribute extends BaseGeostatsAttribute {
stdev: number;
};
}
export type GeostatsAttribute = BaseGeostatsAttribute | NumericGeostatsAttribute;
export type LegacyGeostatsAttribute = Omit<BaseGeostatsAttribute, "values" | "countDistinct"> & {
export declare type GeostatsAttribute = BaseGeostatsAttribute | NumericGeostatsAttribute;
export declare type LegacyGeostatsAttribute = Omit<BaseGeostatsAttribute, "values" | "countDistinct"> & {
values: (string | number | boolean | null)[];
quantiles?: number[];
};
Expand All @@ -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
*/
Expand Down Expand Up @@ -124,7 +124,7 @@ export interface GeostatsLayer {
bounds?: number[];
metadata?: GeostatsMetadata;
}
export type LegacyGeostatsLayer = Omit<GeostatsLayer, "attributes" | "bounds"> & {
export declare type LegacyGeostatsLayer = Omit<GeostatsLayer, "attributes" | "bounds"> & {
attributes: LegacyGeostatsAttribute[];
};
export declare function isLegacyGeostatsLayer(layer: LegacyGeostatsLayer | GeostatsLayer): layer is LegacyGeostatsLayer;
Expand All @@ -134,21 +134,21 @@ 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[];
};
/**
* A color table entry is a tuple of [value, color]. The value references the
* 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;
Expand Down
14 changes: 7 additions & 7 deletions packages/geostats-types/lib/index.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -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;
2 changes: 1 addition & 1 deletion packages/geostats-types/package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"homepage": "https://github.com/seasketch/next#readme",
"license": "BSD-3-Clause",
Expand Down

0 comments on commit f52c563

Please sign in to comment.