esri-gl 0.9.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,118 @@
1
+ import type { Map, ServiceMetadata } from '@/types';
2
+ export interface ServiceOptions {
3
+ url: string;
4
+ proxy?: boolean;
5
+ useCors?: boolean;
6
+ timeout?: number;
7
+ token?: string;
8
+ requestParams?: Record<string, unknown>;
9
+ getAttributionFromService?: boolean;
10
+ }
11
+ export type ServiceCallback<T = unknown> = (error?: Error, response?: T) => void;
12
+ export interface ServiceEvents {
13
+ requeststart: {
14
+ url: string;
15
+ params: Record<string, unknown>;
16
+ method: string;
17
+ };
18
+ requestsuccess: {
19
+ url: string;
20
+ params: Record<string, unknown>;
21
+ response: unknown;
22
+ method: string;
23
+ };
24
+ requesterror: {
25
+ url: string;
26
+ params: Record<string, unknown>;
27
+ message: string;
28
+ code?: number;
29
+ method: string;
30
+ };
31
+ requestend: {
32
+ url: string;
33
+ params: Record<string, unknown>;
34
+ method: string;
35
+ };
36
+ authenticationrequired: {
37
+ authenticate: (token: string) => void;
38
+ };
39
+ }
40
+ /**
41
+ * Base Service class for ArcGIS REST API services
42
+ * Similar to Esri Leaflet's Service class
43
+ */
44
+ export declare class Service {
45
+ protected options: ServiceOptions & {
46
+ proxy: boolean;
47
+ useCors: boolean;
48
+ timeout: number;
49
+ getAttributionFromService: boolean;
50
+ };
51
+ protected _requestQueue: Array<[
52
+ string,
53
+ string,
54
+ Record<string, unknown>,
55
+ (error?: Error, response?: unknown) => void,
56
+ unknown
57
+ ]>;
58
+ protected _authenticating: boolean;
59
+ protected _serviceMetadata: ServiceMetadata | null;
60
+ protected _map?: Map;
61
+ private _eventListeners;
62
+ constructor(options: ServiceOptions);
63
+ /**
64
+ * Make a GET request
65
+ */
66
+ get(path: string, params?: Record<string, unknown>): Promise<unknown>;
67
+ /**
68
+ * Make a POST request
69
+ */
70
+ post(path: string, params?: Record<string, unknown>): Promise<unknown>;
71
+ /**
72
+ * Make a generic request
73
+ */
74
+ request(path: string, params?: Record<string, unknown>): Promise<unknown>;
75
+ /**
76
+ * Make a request with callback support (public for Tasks)
77
+ */
78
+ requestWithCallback<T = unknown>(method: string, path: string, params: Record<string, unknown>, callback?: ServiceCallback<T>): Promise<T> | void;
79
+ /**
80
+ * Get service metadata
81
+ */
82
+ metadata(): Promise<ServiceMetadata>;
83
+ /**
84
+ * Set authentication token
85
+ */
86
+ authenticate(token: string): Service;
87
+ /**
88
+ * Get request timeout
89
+ */
90
+ getTimeout(): number;
91
+ /**
92
+ * Set request timeout
93
+ */
94
+ setTimeout(timeout: number): Service;
95
+ /**
96
+ * Set attribution from service metadata
97
+ */
98
+ setAttributionFromService(): Promise<void>;
99
+ /**
100
+ * Add event listener
101
+ */
102
+ on<K extends keyof ServiceEvents>(event: K, callback: (event: ServiceEvents[K]) => void): Service;
103
+ /**
104
+ * Remove event listener
105
+ */
106
+ off<K extends keyof ServiceEvents>(event: K, callback: (event: ServiceEvents[K]) => void): Service;
107
+ /**
108
+ * Fire an event
109
+ */
110
+ fire<K extends keyof ServiceEvents>(event: K, data: ServiceEvents[K]): Service;
111
+ private _requestWithCallback;
112
+ private _request;
113
+ private _makeRequest;
114
+ private _createServiceCallback;
115
+ private _runQueue;
116
+ }
117
+ export declare function service(options: ServiceOptions): Service;
118
+ export default service;
@@ -0,0 +1,30 @@
1
+ import { Service, ServiceOptions } from './Service';
2
+ import { IdentifyFeatures } from '../Tasks/IdentifyFeatures';
3
+ import { Query } from '../Tasks/Query';
4
+ import { Find } from '../Tasks/Find';
5
+ export interface MapServiceOptions extends ServiceOptions {
6
+ }
7
+ /**
8
+ * MapService - ArcGIS Server Map Service
9
+ * Exactly matches Esri Leaflet's MapService pattern
10
+ */
11
+ export declare class MapService extends Service {
12
+ constructor(options: MapServiceOptions);
13
+ /**
14
+ * Return an IdentifyFeatures task instance
15
+ */
16
+ identify(): IdentifyFeatures;
17
+ /**
18
+ * Return a Query task instance
19
+ */
20
+ query(): Query;
21
+ /**
22
+ * Return a Find task instance
23
+ */
24
+ find(): Find;
25
+ export(params: Record<string, unknown>): Promise<{
26
+ href?: string;
27
+ }>;
28
+ }
29
+ export declare function mapService(options: MapServiceOptions): MapService;
30
+ export default mapService;
@@ -0,0 +1,28 @@
1
+ import type { Map, EsriServiceOptions, RasterSourceOptions, ServiceMetadata } from '@/types';
2
+ interface TiledMapServiceOptions extends EsriServiceOptions {
3
+ fetchOptions?: RequestInit;
4
+ }
5
+ interface RasterSource {
6
+ type: 'raster';
7
+ tiles: string[];
8
+ tileSize?: number;
9
+ attribution?: string;
10
+ bounds?: number[];
11
+ minzoom?: number;
12
+ maxzoom?: number;
13
+ }
14
+ export declare class TiledMapService {
15
+ private _sourceId;
16
+ private _map;
17
+ private _serviceMetadata;
18
+ rasterSrcOptions?: RasterSourceOptions;
19
+ esriServiceOptions: TiledMapServiceOptions;
20
+ constructor(sourceId: string, map: Map, esriServiceOptions: TiledMapServiceOptions, rasterSrcOptions?: RasterSourceOptions);
21
+ get _source(): RasterSource;
22
+ private _createSource;
23
+ setAttributionFromService(): Promise<void>;
24
+ getMetadata(): Promise<ServiceMetadata>;
25
+ update(): void;
26
+ remove(): void;
27
+ }
28
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare class VectorBasemapStyle {
2
+ styleName: string;
3
+ private _apikey;
4
+ constructor(styleName?: string, apikey?: string);
5
+ get styleUrl(): string;
6
+ setStyle(styleName: string): void;
7
+ update(): void;
8
+ remove(): void;
9
+ }
@@ -0,0 +1,41 @@
1
+ import type { Map, VectorTileServiceOptions, VectorSourceOptions, ServiceMetadata } from '@/types';
2
+ interface VectorTileServiceExtendedOptions extends VectorTileServiceOptions {
3
+ useDefaultStyle?: boolean;
4
+ fetchOptions?: RequestInit;
5
+ }
6
+ interface StyleLayoutPaint {
7
+ [key: string]: unknown;
8
+ }
9
+ interface StyleData {
10
+ type: string;
11
+ source?: string;
12
+ 'source-layer': string;
13
+ layout?: StyleLayoutPaint;
14
+ paint?: StyleLayoutPaint;
15
+ }
16
+ export declare class VectorTileService {
17
+ private _sourceId;
18
+ private _map;
19
+ private _defaultEsriOptions;
20
+ private _serviceMetadata;
21
+ private _defaultStyleData;
22
+ vectorSrcOptions?: VectorSourceOptions;
23
+ esriServiceOptions: VectorTileServiceExtendedOptions;
24
+ constructor(sourceId: string, map: Map, esriServiceOptions: VectorTileServiceExtendedOptions, vectorSrcOptions?: VectorSourceOptions);
25
+ get options(): Required<VectorTileServiceExtendedOptions>;
26
+ get _tileUrl(): string;
27
+ get _source(): VectorSourceOptions & {
28
+ type: 'vector';
29
+ tiles: string[];
30
+ };
31
+ private _createSource;
32
+ private _mapToLocalSource;
33
+ get defaultStyle(): StyleData;
34
+ get _styleUrl(): string;
35
+ getStyle(): Promise<StyleData>;
36
+ private _retrieveStyle;
37
+ getMetadata(): Promise<ServiceMetadata>;
38
+ update(): void;
39
+ remove(): void;
40
+ }
41
+ export {};
@@ -0,0 +1,85 @@
1
+ import { Task } from './Task';
2
+ import { Service } from '@/Services/Service';
3
+ export interface FindOptions {
4
+ url: string;
5
+ token?: string;
6
+ searchText?: string;
7
+ contains?: boolean;
8
+ searchFields?: string | string[];
9
+ sr?: string | number;
10
+ layers?: number | number[] | string;
11
+ returnGeometry?: boolean;
12
+ maxAllowableOffset?: number;
13
+ geometryPrecision?: number;
14
+ dynamicLayers?: unknown[];
15
+ returnZ?: boolean;
16
+ returnM?: boolean;
17
+ gdbVersion?: string;
18
+ layerDefs?: string;
19
+ }
20
+ /**
21
+ * Find task for searching text in ArcGIS Map Services
22
+ * Based on Esri Leaflet's Find functionality
23
+ */
24
+ export declare class Find extends Task {
25
+ protected setters: {
26
+ contains: string;
27
+ text: string;
28
+ fields: string;
29
+ spatialReference: string;
30
+ sr: string;
31
+ layers: string;
32
+ returnGeometry: string;
33
+ maxAllowableOffset: string;
34
+ precision: string;
35
+ dynamicLayers: string;
36
+ returnZ: string;
37
+ returnM: string;
38
+ gdbVersion: string;
39
+ token: string;
40
+ };
41
+ protected path: string;
42
+ protected params: Record<string, unknown>;
43
+ constructor(options: string | FindOptions | Service);
44
+ /**
45
+ * Set the text to search for
46
+ */
47
+ text(searchText: string): Find;
48
+ /**
49
+ * Set the fields to search in
50
+ */
51
+ fields(fields: string | string[]): Find;
52
+ /**
53
+ * Set whether the search should contain the text (partial match) or exact match
54
+ */
55
+ contains(contains: boolean): Find;
56
+ /**
57
+ * Set which layers to search in
58
+ */
59
+ layers(layers: number | number[] | string): Find;
60
+ /**
61
+ * Set layer definitions for filtering specific layers
62
+ */
63
+ layerDefs(layerId: number | string, whereClause: string): Find;
64
+ /**
65
+ * Simplify geometries based on map resolution
66
+ */
67
+ simplify(map: {
68
+ getBounds(): {
69
+ getWest(): number;
70
+ getEast(): number;
71
+ };
72
+ getSize(): {
73
+ x: number;
74
+ y: number;
75
+ };
76
+ }, factor: number): Find;
77
+ /**
78
+ * Execute the find operation
79
+ */
80
+ run(): Promise<GeoJSON.FeatureCollection<GeoJSON.Geometry | null>>;
81
+ private _convertToGeoJSON;
82
+ private _convertEsriGeometry;
83
+ }
84
+ export declare function find(options: string | FindOptions): Find;
85
+ export default find;
@@ -0,0 +1,91 @@
1
+ import { Task } from '@/Tasks/Task';
2
+ import { Service } from '@/Services/Service';
3
+ import type { Map } from '@/types';
4
+ export interface IdentifyFeaturesOptions {
5
+ url: string;
6
+ layers?: number[] | number | string;
7
+ layerDefs?: Record<string, string>;
8
+ tolerance?: number;
9
+ returnGeometry?: boolean;
10
+ maxAllowableOffset?: number;
11
+ geometryPrecision?: number;
12
+ dynamicLayers?: unknown[];
13
+ mapExtent?: [number, number, number, number];
14
+ imageDisplay?: [number, number, number];
15
+ sr?: string | number;
16
+ layerTimeOptions?: Record<string, unknown>;
17
+ time?: number[] | Date[];
18
+ fetchOptions?: RequestInit;
19
+ }
20
+ export interface IdentifyResult {
21
+ layerId: number;
22
+ layerName: string;
23
+ value: string;
24
+ displayFieldName: string;
25
+ attributes: Record<string, unknown>;
26
+ geometry?: unknown;
27
+ geometryType?: string;
28
+ }
29
+ export interface IdentifyResponse {
30
+ results: IdentifyResult[];
31
+ }
32
+ export interface GeometryInput {
33
+ x: number;
34
+ y: number;
35
+ spatialReference?: {
36
+ wkid: number;
37
+ latestWkid?: number;
38
+ };
39
+ }
40
+ /**
41
+ * IdentifyFeatures task for performing identify operations against ArcGIS Map Services
42
+ * Similar to Esri Leaflet's identifyFeatures functionality
43
+ */
44
+ export declare class IdentifyFeatures extends Task {
45
+ protected setters: {
46
+ layers: string;
47
+ precision: string;
48
+ tolerance: string;
49
+ returnGeometry: string;
50
+ };
51
+ protected path: string;
52
+ protected params: Record<string, unknown>;
53
+ constructor(options: string | IdentifyFeaturesOptions | Service);
54
+ /**
55
+ * Perform identify operation at a point location
56
+ */
57
+ at(point: {
58
+ lng: number;
59
+ lat: number;
60
+ } | [number, number]): IdentifyFeatures;
61
+ layers(value: number[] | number | string): IdentifyFeatures;
62
+ tolerance(value: number): IdentifyFeatures;
63
+ returnGeometry(value: boolean): IdentifyFeatures;
64
+ precision(value: number): IdentifyFeatures;
65
+ /**
66
+ * Set the map extent and image display for the identify operation
67
+ */
68
+ on(map: Map): IdentifyFeatures;
69
+ /**
70
+ * Set layer definitions for filtering specific layers
71
+ */
72
+ layerDef(layerId: number | string, whereClause: string): IdentifyFeatures;
73
+ /**
74
+ * Simplify geometries based on map resolution
75
+ */
76
+ simplify(map: {
77
+ getBounds(): {
78
+ getWest(): number;
79
+ getEast(): number;
80
+ };
81
+ getSize(): {
82
+ x: number;
83
+ y: number;
84
+ };
85
+ }, factor: number): IdentifyFeatures;
86
+ /**
87
+ * Execute the identify operation
88
+ */
89
+ run(): Promise<GeoJSON.FeatureCollection>;
90
+ private _convertToGeoJSON;
91
+ }
@@ -0,0 +1,107 @@
1
+ import { Task } from '@/Tasks/Task';
2
+ export interface IdentifyImageOptions {
3
+ url: string;
4
+ token?: string;
5
+ geometry?: unknown;
6
+ geometryType?: string;
7
+ sr?: string | number;
8
+ mosaic?: boolean;
9
+ renderingRules?: unknown[];
10
+ pixelSize?: [number, number];
11
+ returnGeometry?: boolean;
12
+ returnCatalogItems?: boolean;
13
+ f?: string;
14
+ }
15
+ export interface PixelValue {
16
+ attributes: Record<string, unknown>;
17
+ geometry?: unknown;
18
+ }
19
+ export interface IdentifyImageResult {
20
+ objectId?: number;
21
+ name?: string;
22
+ value?: string;
23
+ location?: {
24
+ x: number;
25
+ y: number;
26
+ spatialReference?: {
27
+ wkid: number;
28
+ latestWkid?: number;
29
+ };
30
+ };
31
+ attributes?: Record<string, unknown>;
32
+ catalogItems?: unknown[];
33
+ catalogItemVisibilities?: number[];
34
+ }
35
+ /**
36
+ * IdentifyImage task for identifying pixel values in ArcGIS Image Services
37
+ * Based on Esri Leaflet's IdentifyImage functionality
38
+ */
39
+ export declare class IdentifyImage extends Task {
40
+ protected setters: {
41
+ returnCatalogItems: string;
42
+ returnGeometry: string;
43
+ pixelSize: string;
44
+ token: string;
45
+ };
46
+ protected path: string;
47
+ protected params: Record<string, unknown>;
48
+ constructor(options: string | IdentifyImageOptions);
49
+ /**
50
+ * Identify pixel values at a specific point
51
+ */
52
+ at(point: {
53
+ lng: number;
54
+ lat: number;
55
+ } | [number, number]): IdentifyImage;
56
+ /**
57
+ * Set custom geometry for identification
58
+ */
59
+ geometry(geometry: unknown, geometryType?: string): IdentifyImage;
60
+ /**
61
+ * Set pixel size for the identify operation
62
+ */
63
+ pixelSize(size: [number, number] | {
64
+ x: number;
65
+ y: number;
66
+ }): IdentifyImage;
67
+ /**
68
+ * Set whether to return geometry with results
69
+ */
70
+ returnGeometry(returnGeom: boolean): IdentifyImage;
71
+ /**
72
+ * Set whether to return catalog items
73
+ */
74
+ returnCatalogItems(returnItems: boolean): IdentifyImage;
75
+ /**
76
+ * Set mosaic rule for the identify operation
77
+ */
78
+ mosaicRule(rule: unknown): IdentifyImage;
79
+ /**
80
+ * Set rendering rules for the identify operation
81
+ */
82
+ renderingRule(rule: unknown): IdentifyImage;
83
+ /**
84
+ * Execute the identify operation
85
+ */
86
+ run(): Promise<{
87
+ results: IdentifyImageResult[];
88
+ location?: {
89
+ x: number;
90
+ y: number;
91
+ spatialReference?: {
92
+ wkid: number;
93
+ latestWkid?: number;
94
+ };
95
+ };
96
+ }>;
97
+ /**
98
+ * Execute and return pixel values as a simple array
99
+ */
100
+ getPixelValues(): Promise<Array<string | number | null>>;
101
+ /**
102
+ * Execute and return detailed pixel information
103
+ */
104
+ getPixelData(): Promise<IdentifyImageResult[]>;
105
+ }
106
+ export declare function identifyImage(options: string | IdentifyImageOptions): IdentifyImage;
107
+ export default identifyImage;
@@ -0,0 +1,180 @@
1
+ import { Task } from './Task';
2
+ import { Service } from '@/Services/Service';
3
+ export interface QueryOptions {
4
+ url: string;
5
+ token?: string;
6
+ where?: string;
7
+ outFields?: string | string[];
8
+ returnGeometry?: boolean;
9
+ spatialRel?: string;
10
+ geometry?: unknown;
11
+ geometryType?: string;
12
+ inSR?: string | number;
13
+ outSR?: string | number;
14
+ returnDistinctValues?: boolean;
15
+ returnIdsOnly?: boolean;
16
+ returnCountOnly?: boolean;
17
+ returnExtentOnly?: boolean;
18
+ orderByFields?: string;
19
+ groupByFieldsForStatistics?: string;
20
+ outStatistics?: unknown[];
21
+ resultOffset?: number;
22
+ resultRecordCount?: number;
23
+ maxAllowableOffset?: number;
24
+ geometryPrecision?: number;
25
+ time?: number[];
26
+ gdbVersion?: string;
27
+ historicMoment?: number;
28
+ returnTrueCurves?: boolean;
29
+ returnZ?: boolean;
30
+ returnM?: boolean;
31
+ f?: string;
32
+ }
33
+ export interface QueryGeometry {
34
+ x?: number;
35
+ y?: number;
36
+ xmin?: number;
37
+ ymin?: number;
38
+ xmax?: number;
39
+ ymax?: number;
40
+ paths?: number[][][];
41
+ rings?: number[][][];
42
+ points?: number[][];
43
+ spatialReference?: {
44
+ wkid: number;
45
+ latestWkid?: number;
46
+ };
47
+ }
48
+ export interface Bounds {
49
+ _southWest: {
50
+ lat: number;
51
+ lng: number;
52
+ };
53
+ _northEast: {
54
+ lat: number;
55
+ lng: number;
56
+ };
57
+ }
58
+ /**
59
+ * Query task for ArcGIS Feature Services
60
+ * Based on Esri Leaflet's Query functionality
61
+ */
62
+ export declare class Query extends Task {
63
+ protected setters: {
64
+ offset: string;
65
+ limit: string;
66
+ fields: string;
67
+ precision: string;
68
+ featureIds: string;
69
+ returnGeometry: string;
70
+ returnM: string;
71
+ transform: string;
72
+ token: string;
73
+ };
74
+ protected path: string;
75
+ protected params: Record<string, unknown>;
76
+ constructor(options: string | QueryOptions | Service);
77
+ /**
78
+ * Returns a feature if its shape is wholly contained within the search geometry
79
+ */
80
+ within(geometry: QueryGeometry | unknown): Query;
81
+ /**
82
+ * Returns a feature if any spatial relationship is found
83
+ */
84
+ intersects(geometry: QueryGeometry | unknown): Query;
85
+ /**
86
+ * Returns a feature if its shape wholly contains the search geometry
87
+ */
88
+ contains(geometry: QueryGeometry | unknown): Query;
89
+ /**
90
+ * Returns a feature if the intersection of the interiors is not empty and has lower dimension
91
+ */
92
+ crosses(geometry: QueryGeometry | unknown): Query;
93
+ /**
94
+ * Returns a feature if the two shapes share a common boundary
95
+ */
96
+ touches(geometry: QueryGeometry | unknown): Query;
97
+ /**
98
+ * Returns a feature if the intersection results in same dimension but different from both shapes
99
+ */
100
+ overlaps(geometry: QueryGeometry | unknown): Query;
101
+ /**
102
+ * Returns a feature if the envelope of the two shapes intersects
103
+ */
104
+ bboxIntersects(geometry: QueryGeometry | unknown): Query;
105
+ /**
106
+ * Nearby search - only valid for ArcGIS Server 10.3+ or ArcGIS Online
107
+ */
108
+ nearby(latlng: {
109
+ lat: number;
110
+ lng: number;
111
+ }, radius: number): Query;
112
+ /**
113
+ * Set WHERE clause for the query
114
+ */
115
+ where(whereClause: string): Query;
116
+ /**
117
+ * Set time range for temporal queries
118
+ */
119
+ between(start: Date | number, end: Date | number): Query;
120
+ /**
121
+ * Simplify geometries based on map resolution
122
+ */
123
+ simplify(map: {
124
+ getBounds(): Bounds;
125
+ getSize(): {
126
+ x: number;
127
+ y: number;
128
+ };
129
+ }, factor: number): Query;
130
+ /**
131
+ * Set order by fields
132
+ */
133
+ orderBy(fieldName: string, order?: 'ASC' | 'DESC'): Query;
134
+ /**
135
+ * Set specific layer to query (for Map Services)
136
+ */
137
+ layer(layerId: number): Query;
138
+ /**
139
+ * Return only distinct values
140
+ */
141
+ distinct(): Query;
142
+ /**
143
+ * Set pixel size for image services
144
+ */
145
+ pixelSize(point: {
146
+ x: number;
147
+ y: number;
148
+ }): Query;
149
+ /**
150
+ * Execute the query and return features
151
+ */
152
+ run(): Promise<GeoJSON.FeatureCollection>;
153
+ /**
154
+ * Execute the query and return only the count
155
+ */
156
+ count(): Promise<number>;
157
+ /**
158
+ * Execute the query and return only feature IDs
159
+ */
160
+ ids(): Promise<number[]>;
161
+ /**
162
+ * Execute the query and return extent bounds (ArcGIS Server 10.3+)
163
+ */
164
+ bounds(): Promise<{
165
+ _southWest: {
166
+ lat: number;
167
+ lng: number;
168
+ };
169
+ _northEast: {
170
+ lat: number;
171
+ lng: number;
172
+ };
173
+ }>;
174
+ private _setGeometryParams;
175
+ private _setGeometry;
176
+ private _cleanParams;
177
+ private _convertToGeoJSON;
178
+ }
179
+ export declare function query(options: string | QueryOptions): Query;
180
+ export default query;