the editable site (validation-lab)
This commit is contained in:
commit
3ac81d5a52
13454 files changed
+2227005
No files matched your search
+65
@@ -0,0 +1,65 @@
|
||||
import { Feature, Point, Polygon, LineString } from "geojson";
|
||||
import { Validation } from "../common";
|
||||
export type JSON = string | number | boolean | null | JSONArray | JSONObject;
|
||||
export interface JSONObject {
|
||||
[member: string]: JSON;
|
||||
}
|
||||
type JSONArray = Array<JSON>;
|
||||
type DefinedProperties = Record<string, JSON>;
|
||||
export type GeoJSONStoreGeometries = Polygon | LineString | Point;
|
||||
export type BBoxPolygon = Feature<Polygon, DefinedProperties>;
|
||||
export type GeoJSONStoreFeatures<G extends GeoJSONStoreGeometries = GeoJSONStoreGeometries> = Feature<G, DefinedProperties>;
|
||||
export type StoreValidation = {
|
||||
id?: FeatureId;
|
||||
} & ReturnType<Validation>;
|
||||
type StoreChangeEvents = "delete" | "create" | "update" | "styling";
|
||||
export type StoreChangeHandler<OnChangeContext> = (ids: FeatureId[], change: StoreChangeEvents, context?: OnChangeContext) => void;
|
||||
export type FeatureId = string | number;
|
||||
export type IdStrategy<Id extends FeatureId> = {
|
||||
isValidId: (id: Id) => boolean;
|
||||
getId: () => Id;
|
||||
};
|
||||
type GeoJSONStoreConfig<Id extends FeatureId> = {
|
||||
idStrategy?: IdStrategy<Id>;
|
||||
tracked?: boolean;
|
||||
};
|
||||
export declare const defaultIdStrategy: {
|
||||
getId: <FeatureId>() => FeatureId;
|
||||
isValidId: (id: FeatureId) => boolean;
|
||||
};
|
||||
export declare class GeoJSONStore<OnChangeContext extends JSONObject | undefined, Id extends FeatureId = FeatureId> {
|
||||
constructor(config?: GeoJSONStoreConfig<Id>);
|
||||
idStrategy: IdStrategy<Id>;
|
||||
private tracked;
|
||||
private spatialIndex;
|
||||
private store;
|
||||
private _onChange;
|
||||
private clone;
|
||||
getId(): FeatureId;
|
||||
has(id: FeatureId): boolean;
|
||||
load(data: GeoJSONStoreFeatures[], featureValidation?: (feature: unknown, tracked?: boolean) => StoreValidation, afterFeatureAdded?: (feature: GeoJSONStoreFeatures) => void, context?: OnChangeContext): StoreValidation[];
|
||||
search(bbox: BBoxPolygon, filter?: (feature: GeoJSONStoreFeatures) => boolean): GeoJSONStoreFeatures<GeoJSONStoreGeometries>[];
|
||||
registerOnChange(onChange: StoreChangeHandler<OnChangeContext | undefined>): void;
|
||||
getGeometryCopy<T extends GeoJSONStoreGeometries>(id: FeatureId): T;
|
||||
getPropertiesCopy(id: FeatureId): DefinedProperties;
|
||||
updateProperty(propertiesToUpdate: {
|
||||
id: FeatureId;
|
||||
property: string;
|
||||
value: JSON | undefined;
|
||||
}[], context?: OnChangeContext): void;
|
||||
updateGeometry(geometriesToUpdate: {
|
||||
id: FeatureId;
|
||||
geometry: GeoJSONStoreGeometries;
|
||||
}[], context?: OnChangeContext): void;
|
||||
create<Id extends FeatureId>(features: {
|
||||
geometry: GeoJSONStoreGeometries;
|
||||
properties?: JSONObject;
|
||||
}[], context?: OnChangeContext): Id[];
|
||||
delete(ids: FeatureId[], context?: OnChangeContext): void;
|
||||
copy(id: FeatureId): GeoJSONStoreFeatures;
|
||||
copyAll(): GeoJSONStoreFeatures[];
|
||||
copyAllWhere(equals: (properties: JSONObject) => boolean): GeoJSONStoreFeatures[];
|
||||
clear(context: OnChangeContext): void;
|
||||
size(): number;
|
||||
}
|
||||
export {};
|
||||
Reference in new issue
Block a user