@loaders.gl/wms 4.3.0-alpha.1 → 4.3.0-alpha.3

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.
Files changed (70) hide show
  1. package/dist/csw-capabilities-loader.js +1 -1
  2. package/dist/csw-domain-loader.js +1 -1
  3. package/dist/csw-records-loader.js +1 -1
  4. package/dist/gml-loader.js +1 -1
  5. package/dist/index.cjs +125 -300
  6. package/dist/index.cjs.map +4 -4
  7. package/dist/index.d.ts +7 -13
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +8 -10
  10. package/dist/lib/deprecated/create-image-source.d.ts +21 -0
  11. package/dist/lib/deprecated/create-image-source.d.ts.map +1 -0
  12. package/dist/lib/deprecated/create-image-source.js +44 -0
  13. package/dist/lib/parsers/wfs/parse-wfs-capabilities.d.ts.map +1 -0
  14. package/dist/{wip/lib → lib/parsers}/wfs/parse-wfs-capabilities.js +5 -2
  15. package/dist/lib/parsers/wfs/parse-wfs.d.ts.map +1 -0
  16. package/dist/services/arcgis/arcgis-feature-server.d.ts +67 -0
  17. package/dist/services/arcgis/arcgis-feature-server.d.ts.map +1 -0
  18. package/dist/services/arcgis/arcgis-feature-server.js +446 -0
  19. package/dist/services/arcgis/{arcgis-image-service.d.ts → arcgis-image-server.d.ts} +25 -10
  20. package/dist/services/arcgis/arcgis-image-server.d.ts.map +1 -0
  21. package/dist/services/arcgis/{arcgis-image-service.js → arcgis-image-server.js} +28 -11
  22. package/dist/services/ogc/csw-service.d.ts +13 -13
  23. package/dist/services/ogc/csw-service.d.ts.map +1 -1
  24. package/dist/services/ogc/wfs-service.d.ts +279 -0
  25. package/dist/services/ogc/wfs-service.d.ts.map +1 -0
  26. package/dist/services/ogc/wfs-service.js +388 -0
  27. package/dist/services/ogc/wms-service.d.ts +42 -21
  28. package/dist/services/ogc/wms-service.d.ts.map +1 -1
  29. package/dist/services/ogc/wms-service.js +29 -14
  30. package/dist/{wip/wfs-capabilities-loader.d.ts → wfs-capabilities-loader.d.ts} +2 -1
  31. package/dist/wfs-capabilities-loader.d.ts.map +1 -0
  32. package/dist/{wip/wfs-capabilities-loader.js → wfs-capabilities-loader.js} +3 -2
  33. package/dist/wip/wcs-capabilities-loader.js +1 -1
  34. package/dist/wip/wmts-capabilities-loader.js +1 -1
  35. package/dist/wms-capabilities-loader.js +1 -1
  36. package/dist/wms-error-loader.js +1 -1
  37. package/package.json +6 -6
  38. package/src/index.ts +12 -24
  39. package/src/lib/{services/create-image-service.ts → deprecated/create-image-service.ts.disabled} +4 -4
  40. package/src/lib/deprecated/create-image-source.ts +70 -0
  41. package/src/{wip/lib → lib/parsers}/wfs/parse-wfs-capabilities.ts +8 -5
  42. package/src/services/arcgis/arcgis-feature-server.ts +506 -0
  43. package/src/services/arcgis/{arcgis-image-service.ts → arcgis-image-server.ts} +41 -18
  44. package/src/services/ogc/csw-service.ts +17 -15
  45. package/src/services/ogc/wfs-service.ts +624 -0
  46. package/src/services/ogc/wms-service.ts +54 -30
  47. package/src/{wip/wfs-capabilities-loader.ts → wfs-capabilities-loader.ts} +3 -2
  48. package/dist/lib/services/create-image-service.d.ts +0 -14
  49. package/dist/lib/services/create-image-service.d.ts.map +0 -1
  50. package/dist/lib/services/create-image-service.js +0 -39
  51. package/dist/lib/services/image-service.d.ts +0 -28
  52. package/dist/lib/services/image-service.d.ts.map +0 -1
  53. package/dist/lib/services/image-service.js +0 -45
  54. package/dist/services/arcgis/arcgis-image-service.d.ts.map +0 -1
  55. package/dist/services/create-image-source.d.ts +0 -18
  56. package/dist/services/create-image-source.d.ts.map +0 -1
  57. package/dist/services/create-image-source.js +0 -17
  58. package/dist/wip/lib/wfs/parse-wfs-capabilities.d.ts.map +0 -1
  59. package/dist/wip/lib/wfs/parse-wfs.d.ts.map +0 -1
  60. package/dist/wip/services/arcgis-feature-service.d.ts +0 -56
  61. package/dist/wip/services/arcgis-feature-service.d.ts.map +0 -1
  62. package/dist/wip/services/arcgis-feature-service.js +0 -27
  63. package/dist/wip/wfs-capabilities-loader.d.ts.map +0 -1
  64. package/src/services/create-image-source.ts +0 -33
  65. package/src/wip/services/arcgis-feature-service.ts +0 -89
  66. /package/dist/{wip/lib → lib/parsers}/wfs/parse-wfs-capabilities.d.ts +0 -0
  67. /package/dist/{wip/lib → lib/parsers}/wfs/parse-wfs.d.ts +0 -0
  68. /package/dist/{wip/lib → lib/parsers}/wfs/parse-wfs.js +0 -0
  69. /package/src/lib/{services/image-service.ts → deprecated/template-image-service.ts.disabled} +0 -0
  70. /package/src/{wip/lib → lib/parsers}/wfs/parse-wfs.ts +0 -0
package/dist/index.js CHANGED
@@ -9,17 +9,15 @@ export { WMSErrorLoader } from "./wms-error-loader.js";
9
9
  export { WMSCapabilitiesLoader } from "./wms-capabilities-loader.js";
10
10
  export { WMSFeatureInfoLoader as _WMSFeatureInfoLoader } from "./wip/wms-feature-info-loader.js";
11
11
  export { WMSLayerDescriptionLoader as _WMSLayerDescriptionLoader } from "./wip/wms-layer-description-loader.js";
12
- export { WFSCapabilitiesLoader as _WFSCapabilitiesLoader } from "./wip/wfs-capabilities-loader.js";
12
+ export { WFSCapabilitiesLoader as _WFSCapabilitiesLoader } from "./wfs-capabilities-loader.js";
13
13
  export { GMLLoader as _GMLLoader } from "./gml-loader.js";
14
14
  // EXPERIMENTAL: DATA SOURCES
15
- // TODO - restore once deck.gl has been udpated
16
- export { ImageSource } from '@loaders.gl/loader-utils';
17
- export { createImageService } from "./lib/services/create-image-service.js";
18
- export { createImageSource } from "./services/create-image-source.js";
19
- export { ImageService } from "./lib/services/image-service.js";
20
15
  // OGC Services
21
- export { CSWService } from "./services/ogc/csw-service.js";
22
- export { WMSSource, WMSService } from "./services/ogc/wms-service.js";
23
- // ArcGIS Services
16
+ // export {CSWSource} from './services/ogc/csw-service';
17
+ export { WMSSource, WMSImageSource } from "./services/ogc/wms-service.js";
18
+ // ArcGIS SourceLoaders
24
19
  export { getArcGISServices as _getArcGISServices } from "./services/arcgis/arcgis-server.js";
25
- export { ArcGISImageService as _ArcGISImageService } from "./services/arcgis/arcgis-image-service.js";
20
+ export { ArcGISImageServerSource as _ArcGISImageServerSource } from "./services/arcgis/arcgis-image-server.js";
21
+ // DEPRECATED: TODO - remove once deck.gl has been udpated
22
+ export { ImageSource } from '@loaders.gl/loader-utils';
23
+ export { createImageSource } from "./lib/deprecated/create-image-source.js";
@@ -0,0 +1,21 @@
1
+ import type { Source, ImageSource, ImageSourceProps } from '@loaders.gl/loader-utils';
2
+ import type { WMSImageSourceProps } from "../../services/ogc/wms-service.js";
3
+ export type ImageSourceType = 'wms' | 'arcgis-image-server' | 'template';
4
+ /**
5
+ * * @deprecated Use createDataSource from @loaders.gl/core
6
+ */
7
+ type CreateImageSourceProps = ImageSourceProps & WMSImageSourceProps & {
8
+ type?: ImageSourceType | 'auto';
9
+ };
10
+ /**
11
+ * Creates an image source
12
+ * If type is not supplied, will try to automatically detect the the
13
+ * @param url URL to the image source
14
+ * @param type type of source. if not known, set to 'auto'
15
+ * @returns an ImageSource instance
16
+ *
17
+ * @deprecated Use createDataSource from @loaders.gl/core
18
+ */
19
+ export declare function createImageSource(url: string, props: CreateImageSourceProps, sources?: Source<import("@loaders.gl/loader-utils").DataSource<import("@loaders.gl/loader-utils").DataSourceProps>, any>[]): ImageSource;
20
+ export {};
21
+ //# sourceMappingURL=create-image-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-image-source.d.ts","sourceRoot":"","sources":["../../../src/lib/deprecated/create-image-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AACpF,OAAO,KAAK,EAAC,mBAAmB,EAAC,0CAAuC;AAIxE,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,qBAAqB,GAAG,UAAU,CAAC;AAIzE;;GAEG;AACH,KAAK,sBAAsB,GAAG,gBAAgB,GAC5C,mBAAmB,GAAG;IACpB,IAAI,CAAC,EAAE,eAAe,GAAG,MAAM,CAAC;CACjC,CAAC;AAEJ;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,sBAAsB,EAC7B,OAAO,mHAAU,GAChB,WAAW,CASb"}
@@ -0,0 +1,44 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { WMSSource } from "../../services/ogc/wms-service.js";
5
+ import { ArcGISImageServerSource } from "../../services/arcgis/arcgis-image-server.js";
6
+ const SOURCES = [WMSSource, ArcGISImageServerSource];
7
+ /**
8
+ * Creates an image source
9
+ * If type is not supplied, will try to automatically detect the the
10
+ * @param url URL to the image source
11
+ * @param type type of source. if not known, set to 'auto'
12
+ * @returns an ImageSource instance
13
+ *
14
+ * @deprecated Use createDataSource from @loaders.gl/core
15
+ */
16
+ export function createImageSource(url, props, sources = SOURCES) {
17
+ const { type = 'auto' } = props;
18
+ const source = type === 'auto' ? guessSourceType(url, sources) : getSourceOfType(type, sources);
19
+ if (!source) {
20
+ throw new Error('Not a valid image source type');
21
+ }
22
+ return source.createDataSource(url, props);
23
+ }
24
+ /** Guess service type from URL */
25
+ function getSourceOfType(type, sources) {
26
+ // if (type === 'template') {
27
+ // return ImageSource;
28
+ // }
29
+ for (const source of sources) {
30
+ if (source.type === type) {
31
+ return source;
32
+ }
33
+ }
34
+ return null;
35
+ }
36
+ /** Guess source type from URL */
37
+ function guessSourceType(url, sources) {
38
+ for (const source of sources) {
39
+ if (source.testURL && source.testURL(url)) {
40
+ return source;
41
+ }
42
+ }
43
+ return null;
44
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-wfs-capabilities.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/wfs/parse-wfs-capabilities.ts"],"names":[],"mappings":"AAIA,gHAAgH;AAChH,MAAM,MAAM,eAAe,GAAG;IAC5B,qBAAqB,EAAE;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,kBAAkB,EAAE,MAAM,CAAC;QAC3B,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IAEF,eAAe,EAAE;QACf,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE;YACd,cAAc,EAAE,MAAM,CAAC;YACvB,YAAY,EAAE,MAAM,CAAC;YACrB,WAAW,EAAE;gBACX,OAAO,EAAE;oBACP,kBAAkB,EAAE,MAAM,CAAC;oBAC3B,IAAI,EAAE,MAAM,CAAC;oBACb,OAAO,EAAE,MAAM,CAAC;oBAChB,aAAa,EAAE,MAAM,CAAC;oBACtB,qBAAqB,EAAE,MAAM,CAAC;oBAC9B,UAAU,EAAE,MAAM,CAAC;iBACpB,CAAC;gBACF,KAAK,EAAE;oBACL,KAAK,EAAE,MAAM,CAAC;iBACf,CAAC;aACH,CAAC;SACH,CAAC;KACH,CAAC;IAEF,kBAAkB,EAAE;QAClB,eAAe,EAAE,GAAG,CAAC;QACrB,cAAc,EAAE,GAAG,CAAC;QACpB,OAAO,EAAE,GAAG,CAAC;KACd,CAAC;IAEF,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE,MAAM,CAAC;YACnB,KAAK,EAAE,MAAM,CAAC;YACd,OAAO,EAAE,MAAM,EAAE,CAAC;YAClB,MAAM,EAAE;gBACN,UAAU,EAAE,MAAM,CAAC;gBACnB,SAAS,EAAE,MAAM,CAAC;gBAClB,KAAK,EAAE,MAAM,CAAC;gBACd,QAAQ,CAAC,EAAE,MAAM,CAAC;aACnB,EAAE,CAAC;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,MAAM,CAAC;gBACb,KAAK,EAAE,MAAM,CAAC;gBACd,MAAM,EAAE,MAAM,CAAC;gBACf,GAAG,EAAE,MAAM,CAAC;aACb,CAAC;YACF,kBAAkB,EAAE;gBAClB,aAAa,EAAE,MAAM,CAAC;aACvB,EAAE,CAAC;YACJ,cAAc,EAAE;gBACd,UAAU,EAAE,MAAM,CAAC;gBACnB,SAAS,EAAE;oBACT,UAAU,EAAE,MAAM,CAAC;oBACnB,YAAY,EAAE,MAAM,CAAC;oBACrB,WAAW,EAAE,MAAM,CAAC;oBACpB,gBAAgB,EAAE,MAAM,CAAC;oBACzB,SAAS,EAAE,MAAM,CAAC;oBAClB,UAAU,EAAE,MAAM,CAAC;oBACnB,aAAa,EAAE;wBACb,GAAG,EAAE,MAAM,CAAC;wBACZ,GAAG,EAAE,MAAM,CAAC;qBACb,CAAC;iBACH,EAAE,CAAC;aACL,CAAC;SACH,EAAE,CAAC;KACL,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,KAAA,GAAG,eAAe,CAY3E"}
@@ -5,11 +5,14 @@ import { XMLLoader } from '@loaders.gl/xml';
5
5
  * @note Error handlings is fairly weak
6
6
  */
7
7
  export function parseWFSCapabilities(text, options) {
8
- const parsedXML = XMLLoader.parseTextSync?.(text, { ...options, xml: {
8
+ const parsedXML = XMLLoader.parseTextSync?.(text, {
9
+ ...options,
10
+ xml: {
9
11
  ...options?.xml,
10
12
  removeNSPrefix: true,
11
13
  uncapitalizeKeys: true
12
- } });
14
+ }
15
+ });
13
16
  const xmlCapabilities = parsedXML.Capabilities || parsedXML;
14
17
  return xmlCapabilities;
15
18
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-wfs.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/wfs/parse-wfs.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC;AAEjC;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,KAAA,GAAG,eAAe,CAM3E"}
@@ -0,0 +1,67 @@
1
+ import { Schema, GeoJSONTable } from '@loaders.gl/schema';
2
+ import type { VectorSourceProps, VectorSourceMetadata, GetFeaturesParameters, LoaderWithParser } from '@loaders.gl/loader-utils';
3
+ import { VectorSource } from '@loaders.gl/loader-utils';
4
+ export type ArcGISImageServiceQueryOptions = {
5
+ returnGeometry: boolean;
6
+ where: '1%3D1';
7
+ outSR: 4326;
8
+ outFields: string | '*';
9
+ inSR: 4326;
10
+ geometry: `${-90}%2C+${30}%2C+${-70}%2C+${50}`;
11
+ geometryType: 'esriGeometryEnvelope';
12
+ spatialRel: 'esriSpatialRelIntersects';
13
+ geometryPrecision: number;
14
+ resultType: 'tile';
15
+ f?: 'geojson';
16
+ };
17
+ /**
18
+ * @ndeprecated This is a WIP, not fully implemented
19
+ * @see https://developers.arcgis.com/rest/services-reference/enterprise/feature-service.htm
20
+ */
21
+ export declare const ArcGISFeatureServerSource: {
22
+ readonly name: "ArcGISFeatureServer";
23
+ readonly id: "arcgis-feature-server";
24
+ readonly module: "wms";
25
+ readonly version: "0.0.0";
26
+ readonly extensions: [];
27
+ readonly mimeTypes: [];
28
+ readonly options: {
29
+ readonly url: never;
30
+ readonly 'arcgis-feature-server': {
31
+ /** Tabular loaders, normally the GeoJSONLoader */
32
+ readonly loaders: [];
33
+ };
34
+ };
35
+ readonly type: "arcgis-feature-server";
36
+ readonly fromUrl: true;
37
+ readonly fromBlob: false;
38
+ readonly testURL: (url: string) => boolean;
39
+ readonly createDataSource: (url: string | Blob, props: ArcGISVectorSourceProps) => ArcGISVectorSource;
40
+ };
41
+ export type ArcGISVectorSourceProps = VectorSourceProps & {
42
+ url: string;
43
+ 'arcgis-feature-server'?: {
44
+ loaders: LoaderWithParser[];
45
+ };
46
+ };
47
+ /**
48
+ * ArcGIS ImageServer
49
+ * Note - exports a big API, that could be exposed here if there is a use case
50
+ * @see https://developers.arcgis.com/rest/services-reference/enterprise/feature-service.htm
51
+ */
52
+ export declare class ArcGISVectorSource extends VectorSource<ArcGISVectorSourceProps> {
53
+ data: string;
54
+ protected formatSpecificMetadata: Promise<any>;
55
+ constructor(props: ArcGISVectorSourceProps);
56
+ /** TODO - not yet clear if we can find schema information in the FeatureServer metadata or if we need to request a feature */
57
+ getSchema(): Promise<Schema>;
58
+ getMetadata(options: {
59
+ formatSpecificMetadata: any;
60
+ }): Promise<VectorSourceMetadata>;
61
+ getFeatures(parameters: GetFeaturesParameters): Promise<GeoJSONTable>;
62
+ protected _getFormatSpecificMetadata(): Promise<any>;
63
+ }
64
+ /** Sample metadata
65
+ * @see https://developers.arcgis.com/rest/services-reference/enterprise/feature-service.htm
66
+ */
67
+ //# sourceMappingURL=arcgis-feature-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arcgis-feature-server.d.ts","sourceRoot":"","sources":["../../../src/services/arcgis/arcgis-feature-server.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAS,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAW9D,MAAM,MAAM,8BAA8B,GAAG;IAC3C,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,IAAI,CAAC;IACZ,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC;IAC/C,YAAY,EAAE,sBAAsB,CAAC;IACrC,UAAU,EAAE,0BAA0B,CAAC;IACvC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,CAAC,EAAE,SAAS,CAAC;CACf,CAAC;AAuEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;YAUhC,kDAAkD;;;;;;;4BASvC,MAAM,KAAG,OAAO;2DACA,uBAAuB,KAAG,kBAAkB;CAEL,CAAC;AAEzE,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,uBAAuB,CAAC,EAAE;QACxB,OAAO,EAAE,gBAAgB,EAAE,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,YAAY,CAAC,uBAAuB,CAAC;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,sBAAsB,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;gBAEnC,KAAK,EAAE,uBAAuB;IAM1C,8HAA8H;IACxH,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAK5B,WAAW,CAAC,OAAO,EAAE;QAAC,sBAAsB,MAAA;KAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAa7E,WAAW,CAAC,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC;cAY3D,0BAA0B;CAM3C;AA2ID;;GAEG"}
@@ -0,0 +1,446 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { VectorSource } from '@loaders.gl/loader-utils';
5
+ const TEST_SERVICE = 'https://services2.arcgis.com/CcI36Pduqd0OR4W9/ArcGIS/rest/services/Bicycle_Routes_Public/FeatureServer/0';
6
+ const TEST_QUERY =
7
+ // eslint-disable-next-line no-template-curly-in-string
8
+ 'query?returnGeometry=true&where=1%3D1&outSR=4326&outFields=*&inSR=4326&geometry=${-90}%2C+${30}%2C+${-70}%2C+${50}&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&geometryPrecision=6&resultType=tile&f=geojson';
9
+ // const DEFAULT_QUERY_OPTIONS: Required<ArcGISImageServiceQueryOptions> = {
10
+ // returnGeometry:true,
11
+ // where: '1%3D1',
12
+ // outSR: 4326,
13
+ // outFields: '*',
14
+ // inSR: 4326,
15
+ // geometry: `${-90}%2C+${30}%2C+${-70}%2C+${50}`,
16
+ // geometryType: 'esriGeometryEnvelope',
17
+ // spatialRel: 'esriSpatialRelIntersects',
18
+ // geometryPrecision: 6,
19
+ // resultType: 'tile',
20
+ // f: 'geojson'
21
+ // };
22
+ // export type ArcGISFeatureServiceProps = ArcGISImageServiceQueryOptions & {
23
+ // url: string;
24
+ // loadOptions?: LoaderOptions;
25
+ // fetch?: typeof fetch | FetchLike;
26
+ // };
27
+ // export class ArcGISFeatureService {
28
+ // url: string;
29
+ // loadOptions: LoaderOptions;
30
+ // fetch: typeof fetch | FetchLike;
31
+ // constructor(props: ArcGISFeatureServiceProps) {
32
+ // this.url = props.url;
33
+ // this.loadOptions = props.loadOptions || {};
34
+ // this.fetch = props.fetch || fetch;
35
+ // }
36
+ // // URL creators
37
+ // metadataURL(options: {parameters?: Record<string, unknown>}): string {
38
+ // return this.getUrl({...options});
39
+ // }
40
+ // /**
41
+ // * Form a URL to an ESRI FeatureServer
42
+ // // https://services2.arcgis.com/CcI36Pduqd0OR4W9/ArcGIS/rest/services/Bicycle_Routes_Public/FeatureServer/0/query?
43
+ // // returnGeometry=true&where=1%3D1&outSR=4326&outFields=*&inSR=4326&geometry=${-90}%2C+${30}%2C+${-70}%2C+${50}&
44
+ // // geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&geometryPrecision=6&resultType=tile&f=geojson`
45
+ // */
46
+ // exportImageURL(options: {
47
+ // boundingBox: [number, number, number, number];
48
+ // boundingBoxSR?: string;
49
+ // width: number;
50
+ // height: number;
51
+ // imageSR?: string;
52
+ // time?: never;
53
+ // f?: 'geojson';
54
+ // resultType?: 'tile';
55
+ // noData?: never;
56
+ // noDataInterpretation?: 'esriNoDataMatchAny';
57
+ // interpolation?: '+RSP_NearestNeighbor';
58
+ // compression?: never
59
+ // compressionQuality?: never;
60
+ // bandIds?: never;
61
+ // mosaicRule?: never;
62
+ // renderingRule?: never;
63
+ // f?: 'image';
64
+ // }): string {
65
+ // const {boundingBox} = options;
66
+ // // const bbox = `bbox=${boundingBox[0]},${boundingBox[1]},${boundingBox[2]},${boundingBox[3]}`;
67
+ // // const size = `size=${width},${height}`
68
+ // return this.getUrl({path: 'exportImage', });
69
+ // }
70
+ // }
71
+ /**
72
+ * @ndeprecated This is a WIP, not fully implemented
73
+ * @see https://developers.arcgis.com/rest/services-reference/enterprise/feature-service.htm
74
+ */
75
+ export const ArcGISFeatureServerSource = {
76
+ name: 'ArcGISFeatureServer',
77
+ id: 'arcgis-feature-server',
78
+ module: 'wms',
79
+ version: '0.0.0',
80
+ extensions: [],
81
+ mimeTypes: [],
82
+ options: {
83
+ url: undefined,
84
+ 'arcgis-feature-server': {
85
+ /** Tabular loaders, normally the GeoJSONLoader */
86
+ loaders: []
87
+ }
88
+ },
89
+ type: 'arcgis-feature-server',
90
+ fromUrl: true,
91
+ fromBlob: false,
92
+ testURL: (url) => url.toLowerCase().includes('FeatureServer'),
93
+ createDataSource: (url, props) => new ArcGISVectorSource(props)
94
+ };
95
+ /**
96
+ * ArcGIS ImageServer
97
+ * Note - exports a big API, that could be exposed here if there is a use case
98
+ * @see https://developers.arcgis.com/rest/services-reference/enterprise/feature-service.htm
99
+ */
100
+ export class ArcGISVectorSource extends VectorSource {
101
+ data;
102
+ formatSpecificMetadata;
103
+ constructor(props) {
104
+ super(props);
105
+ this.data = props.url;
106
+ this.formatSpecificMetadata = this._getFormatSpecificMetadata();
107
+ }
108
+ /** TODO - not yet clear if we can find schema information in the FeatureServer metadata or if we need to request a feature */
109
+ async getSchema() {
110
+ await this.getMetadata({ formatSpecificMetadata: true });
111
+ return { metadata: {}, fields: [] };
112
+ }
113
+ async getMetadata(options) {
114
+ // Wait for raw metadata to load
115
+ const formatSpecificMetadata = await this.formatSpecificMetadata;
116
+ const metadata = parseArcGISFeatureServerMetadata(formatSpecificMetadata);
117
+ // Only add the big blob of source metadata if explicitly requested
118
+ if (options.formatSpecificMetadata) {
119
+ metadata.formatSpecificMetadata = formatSpecificMetadata;
120
+ }
121
+ return metadata;
122
+ }
123
+ async getFeatures(parameters) {
124
+ const url = `${TEST_SERVICE}/${TEST_QUERY}`;
125
+ const response = await this.fetch(url);
126
+ const arrayBuffer = await response.arrayBuffer();
127
+ // TODO - hack - done to avoid pulling in selectLoader from core
128
+ const loader = this.props['arcgis-feature-server']?.loaders?.[0];
129
+ const table = loader?.parse(arrayBuffer);
130
+ return table;
131
+ }
132
+ // ImageServer endpoints
133
+ async _getFormatSpecificMetadata() {
134
+ // PJSON is formatted by a bit slower than JSON
135
+ const url = `${TEST_SERVICE}/f=pjson`;
136
+ const response = await this.fetch(url);
137
+ return await response.json();
138
+ }
139
+ }
140
+ /*
141
+ getArcGISOptions({
142
+ boundingBox: [min: [x: number, y: number], max: [x: number, y: number]]
143
+ }) {
144
+ return {
145
+ returnGeometry: true,
146
+ where: '1=1',
147
+ outFields: '*',
148
+ inSR: 432,
149
+ geometry: '${-90}%2C+${30}%2C+${-70}%2C+${50}',
150
+ geometryType: 'esriGeometryEnvelope',
151
+ spatialRel: 'esriSpatialRelIntersects',
152
+ geometryPrecision: 6,
153
+ resultType: 'tile',
154
+ f: 'geojson'
155
+ };
156
+ }
157
+ */
158
+ /**
159
+ * Form a URL to an ESRI ImageServer
160
+ // https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer/exportImage?bbox=${bounds[0]},${bounds[1]},${bounds[2]},${bounds[3]}&bboxSR=4326&size=${width},${height}&imageSR=102100&time=&format=jpgpng&pixelType=U8&noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_NearestNeighbor&compression=&compressionQuality=&bandIds=&mosaicRule=&renderingRule=&f=image`,
161
+ *
162
+ exportImage(options: {
163
+ boundingBox: [number, number, number, number];
164
+ boundingBoxSR?: string;
165
+ width: number;
166
+ height: number;
167
+ imageSR?: string;
168
+ time?: never;
169
+ format?: 'jpgpng';
170
+ pixelType?: 'U8';
171
+ noData?: never;
172
+ noDataInterpretation?: 'esriNoDataMatchAny';
173
+ interpolation?: '+RSP_NearestNeighbor';
174
+ compression?: never;
175
+ compressionQuality?: never;
176
+ bandIds?: never;
177
+ mosaicRule?: never;
178
+ renderingRule?: never;
179
+ f?: 'image';
180
+ }): Promise<ImageType> {
181
+ // See WMSService.getMap()
182
+ throw new Error('not implemented');
183
+ }
184
+
185
+ // URL creators
186
+
187
+ metadataURL(options: {parameters?: Record<string, unknown>}): string {
188
+ return `${this.props.url}?f=pjson`;
189
+ }
190
+
191
+ /**
192
+ * Form a URL to an ESRI ImageServer
193
+ // https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer/exportImage?
194
+ // bbox=${bounds[0]},${bounds[1]},${bounds[2]},${bounds[3]}&bboxSR=4326&
195
+ // size=${width},${height}&imageSR=102100&time=&format=jpgpng&pixelType=U8&
196
+ // noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_NearestNeighbor&compression=&
197
+ // compressionQuality=&bandIds=&mosaicRule=&renderingRule=&
198
+ // f=image
199
+ *
200
+ exportImageURL(options: {
201
+ bbox: [number, number, number, number];
202
+ boxSR?: string;
203
+ width: number;
204
+ height: number;
205
+ imageSR?: string;
206
+ time?: never;
207
+ format?: 'jpgpng';
208
+ pixelType?: 'U8';
209
+ noData?: never;
210
+ noDataInterpretation?: 'esriNoDataMatchAny';
211
+ interpolation?: '+RSP_NearestNeighbor';
212
+ compression?: never;
213
+ compressionQuality?: never;
214
+ bandIds?: never;
215
+ mosaicRule?: never;
216
+ renderingRule?: never;
217
+ f?: 'image';
218
+ }): string {
219
+ const bbox = `bbox=${options.bbox[0]},${options.bbox[1]},${options.bbox[2]},${options.bbox[3]}`;
220
+ const size = `size=${options.width},${options.height}`;
221
+ const arcgisOptions = {...options, bbox, size};
222
+ // @ts-expect-error
223
+ delete arcgisOptions.width;
224
+ // @ts-expect-error
225
+ delete arcgisOptions.height;
226
+ return this.getUrl('exportImage', arcgisOptions);
227
+ }
228
+
229
+ // INTERNAL METHODS
230
+
231
+ /**
232
+ * @note protected, since perhaps getWMSUrl may need to be overridden to handle certain backends?
233
+ * @note if override is common, maybe add a callback prop?
234
+ *
235
+ protected getUrl(
236
+ path: string,
237
+ options: Record<string, unknown>,
238
+ extra?: Record<string, unknown>
239
+ ): string {
240
+ let url = `${this.props.url}/${path}`;
241
+ let first = true;
242
+ for (const [key, value] of Object.entries(options)) {
243
+ url += first ? '?' : '&';
244
+ first = false;
245
+ if (Array.isArray(value)) {
246
+ url += `${key.toUpperCase()}=${value.join(',')}`;
247
+ } else {
248
+ url += `${key.toUpperCase()}=${value ? String(value) : ''}`;
249
+ }
250
+ }
251
+ return url;
252
+ }
253
+ */
254
+ function parseArcGISFeatureServerMetadata(json) {
255
+ const layers = [];
256
+ for (const layer of json.layers || []) {
257
+ layers.push({
258
+ // id: layer.id,
259
+ name: layer.name
260
+ });
261
+ }
262
+ return {
263
+ // version: json.currentVersion || '',
264
+ title: json.serviceDescription || '',
265
+ name: json.serviceDescription || '',
266
+ abstract: json.description || '',
267
+ keywords: [],
268
+ // attrribution: json.copyrightText || ''.
269
+ // crs: 'EPSG:4326',
270
+ layers
271
+ };
272
+ }
273
+ /** Sample metadata
274
+ * @see https://developers.arcgis.com/rest/services-reference/enterprise/feature-service.htm
275
+ */
276
+ // "currentVersion": 11.1,
277
+ // "serviceDescription": "Birds",
278
+ // "hasVersionedData": false,
279
+ // "supportsDisconnectedEditing: false,
280
+ // "supportsDatumTransformation": true,
281
+ // "supportsReturnDeleteResults": true,
282
+ // "supportsRelationshipsResource": true,
283
+ // "syncEnabled": false,
284
+ // "supportedExportFormats": "sqlite,filegdb,shapefile,csv,geojson",
285
+ // "hasStaticData": false,
286
+ // "maxRecordCount": 1000,
287
+ // "supportedQueryFormats": "JSON",
288
+ // "capabilities": "Query,Create,Delete,Update,Uploads,Editing,Extract,ChangeTracking,Sync",
289
+ // "description": "",
290
+ // "copyrightText": "",
291
+ // "userTypeExtensions: [
292
+ // "utilityNetwork"
293
+ // ],
294
+ // "advancedEditingCapabilities": {
295
+ // "supportsSplit": true,
296
+ // "supportsReturnServiceEditsInSourceSR": true
297
+ // },
298
+ // "spatialReference": {
299
+ // "wkid": 4326,
300
+ // "latestWkid": 4326
301
+ // },
302
+ // "initialExtent": {
303
+ // "xmin": -118.016756138237,
304
+ // "ymin": 32.8933824408207,
305
+ // "xmax": -116.532738278622,
306
+ // "ymax": 34.3261469363675,
307
+ // "spatialReference": {
308
+ // "wkid": 4326,
309
+ // "latestWkid": 4326
310
+ // }
311
+ // },
312
+ // "fullExtent": {
313
+ // "xmin": -117.855689264791,
314
+ // "ymin": 32.5702577626442,
315
+ // "xmax": -116.87086222794,
316
+ // "ymax": 34.1460567673275,
317
+ // "spatialReference": {
318
+ // "wkid": 4326,
319
+ // "latestWkid": 4326
320
+ // }
321
+ // },
322
+ // "allowGeometryUpdates": true,
323
+ // "units": "esriDecimalDegrees",
324
+ // "syncEnabled": true,
325
+ // "validationSystemLayers": {
326
+ // "validationPointErrorlayerId": 1,
327
+ // "validationLineErrorlayerId": 2,
328
+ // "validationPolygonErrorlayerId": 3,
329
+ // "validationObjectErrortableId": 5
330
+ // },
331
+ // "extractChangesCapabilities": {
332
+ // "supportsReturnIdsOnly": true,
333
+ // "supportsReturnExtentOnly": false,
334
+ // "supportsReturnAttachments": false,
335
+ // "supportsLayerQueries": false,
336
+ // "supportsSpatialFilter": false,
337
+ // "supportsReturnFeature": false,
338
+ // "supportsReturnHasGeometryUpdates": true
339
+ // },
340
+ // "syncCapabilities": {
341
+ // "supportsASync": true,
342
+ // "supportsRegisteringExistingData": true,
343
+ // "supportsSyncDirectionControl": true,
344
+ // "supportsPerLayerSync": true,
345
+ // "supportsPerReplicaSync": false,
346
+ // "supportsRollbackOnFailure": false,
347
+ // "supportedSyncDataOptions": 3
348
+ // "supportsQueryWithDatumTransformation": true,
349
+ // },
350
+ // "editorTrackingInfo": {
351
+ // "enableEditorTracking": false,
352
+ // "enableOwnershipAccessControl": false,
353
+ // "allowOthersToUpdate": true,
354
+ // "allowOthersToDelete": false
355
+ // },
356
+ // "layers": [
357
+ // {
358
+ // "id": 0,
359
+ // "name": "Sitings",
360
+ // "parentLayerId": -1,
361
+ // "defaultVisibility": true,
362
+ // "subLayerIds": null,
363
+ // "minScale": 0,
364
+ // "maxScale": 0,
365
+ // "geometryType": "esriGeometryPoint"
366
+ // },
367
+ // {
368
+ // "id": 1,
369
+ // "name": "NestingGrounds",
370
+ // "parentLayerId": -1,
371
+ // "defaultVisibility": true,
372
+ // "subLayerIds": null,
373
+ // "minScale": 0,
374
+ // "maxScale": 0,
375
+ // "geometryType": "esriGeometryPolygon"
376
+ // },
377
+ // {
378
+ // "id": 2,
379
+ // "name": "LandCover",
380
+ // "parentLayerId": -1,
381
+ // "defaultVisibility": true,
382
+ // "subLayerIds": null,
383
+ // "minScale": 0,
384
+ // "maxScale": 0,
385
+ // "geometryType": "esriGeometryPolygon"
386
+ // }
387
+ // ],
388
+ // "tables": [],
389
+ // "relationships": [
390
+ // {
391
+ // "id": 0,
392
+ // "name": "relationship_1"
393
+ // }
394
+ // ],
395
+ // "datumTransformations": [
396
+ // {
397
+ // "geoTransforms": [
398
+ // {
399
+ // "wkid": 15931,
400
+ // "latestWkid": 15931,
401
+ // "transformForward": false,
402
+ // "name": NAD_1983_NSRS2007_To_WGS_1984_1"
403
+ // }
404
+ // ]
405
+ // },
406
+ // {
407
+ // "geoTransforms": [
408
+ // {
409
+ // "wkid": 15931,
410
+ // "latestWkid": 15931,
411
+ // "transformForward": true,
412
+ // "name": NAD_1983_NSRS2007_to_WGS_1984_1"
413
+ // }
414
+ // ]
415
+ // }
416
+ // ],
417
+ // "isIndoorsService": true,
418
+ // "isLocationTrackingService": true,
419
+ // "isLocationTrackingView": true
420
+ // }
421
+ // The following is a portion of a JSON response example for a spatial reference, VCS, tolerance, resolution properties, and high model info:
422
+ // ...
423
+ // "spatialReference": {
424
+ // "wkid": 102100,
425
+ // "latestWkid": 3857,
426
+ // "vcsWkid": 115700,
427
+ // "latestVcsWkid": 115700,
428
+ // "xyTolerance": 0.001,
429
+ // "zTolerance": 0.001,
430
+ // "mTolerance": 0.001,
431
+ // "falseX": -20037700,
432
+ // "falseY": -30241100,
433
+ // "xyUnits": 1.4892314192838538E8,
434
+ // "falseZ": -100000,
435
+ // "zUnits": 10000,
436
+ // "falseM": -100000,
437
+ // "mUnits": 10000
438
+ // },
439
+ // "heightModelInfo": {
440
+ // "heightModel": "ellipsoidal",
441
+ // "vertCRS": "WGS_1984",
442
+ // "heightUnit": "meter"
443
+ // },
444
+ // ...
445
+ // // TODO - normalize metadata
446
+ // }