@loaders.gl/wms 3.4.0-alpha.3 → 4.0.0-alpha.6

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 (196) hide show
  1. package/dist/dist.min.js +133 -80
  2. package/dist/es5/csw-capabilities-loader.js +1 -1
  3. package/dist/es5/csw-capabilities-loader.js.map +1 -1
  4. package/dist/es5/csw-domain-loader.js +1 -1
  5. package/dist/es5/csw-domain-loader.js.map +1 -1
  6. package/dist/es5/csw-records-loader.js +1 -1
  7. package/dist/es5/csw-records-loader.js.map +1 -1
  8. package/dist/es5/gml-loader.js +1 -1
  9. package/dist/es5/gml-loader.js.map +1 -1
  10. package/dist/es5/lerc-loader.js +1 -1
  11. package/dist/es5/lerc-loader.js.map +1 -1
  12. package/dist/es5/lib/create-image-source.js.map +1 -1
  13. package/dist/es5/lib/parsers/csw/parse-csw-capabilities.js +2 -1
  14. package/dist/es5/lib/parsers/csw/parse-csw-capabilities.js.map +1 -1
  15. package/dist/es5/lib/parsers/csw/parse-csw-domain.js +2 -1
  16. package/dist/es5/lib/parsers/csw/parse-csw-domain.js.map +1 -1
  17. package/dist/es5/lib/parsers/csw/parse-csw-records.js +6 -5
  18. package/dist/es5/lib/parsers/csw/parse-csw-records.js.map +1 -1
  19. package/dist/es5/lib/parsers/csw/parse-exception-report.js.map +1 -1
  20. package/dist/es5/lib/parsers/gml/deep-strict-equal.js.map +1 -1
  21. package/dist/es5/lib/parsers/gml/parse-gml.js +2 -1
  22. package/dist/es5/lib/parsers/gml/parse-gml.js.map +1 -1
  23. package/dist/es5/lib/parsers/wms/parse-wms-capabilities.js +2 -1
  24. package/dist/es5/lib/parsers/wms/parse-wms-capabilities.js.map +1 -1
  25. package/dist/es5/lib/parsers/wms/parse-wms-features.js +2 -2
  26. package/dist/es5/lib/parsers/wms/parse-wms-features.js.map +1 -1
  27. package/dist/es5/lib/parsers/wms/parse-wms-layer-description.js +2 -1
  28. package/dist/es5/lib/parsers/wms/parse-wms-layer-description.js.map +1 -1
  29. package/dist/es5/lib/parsers/xml/parse-xml-helpers.js.map +1 -1
  30. package/dist/es5/lib/services/arcgis/arcgis-image-service.js +1 -6
  31. package/dist/es5/lib/services/arcgis/arcgis-image-service.js.map +1 -1
  32. package/dist/es5/lib/services/arcgis/arcgis-server.js.map +1 -1
  33. package/dist/es5/lib/services/generic/image-service.js +1 -6
  34. package/dist/es5/lib/services/generic/image-service.js.map +1 -1
  35. package/dist/es5/lib/services/ogc/csw-service.js +0 -2
  36. package/dist/es5/lib/services/ogc/csw-service.js.map +1 -1
  37. package/dist/es5/lib/services/ogc/wms-service.js +62 -20
  38. package/dist/es5/lib/services/ogc/wms-service.js.map +1 -1
  39. package/dist/es5/lib/sources/data-source.js +36 -8
  40. package/dist/es5/lib/sources/data-source.js.map +1 -1
  41. package/dist/es5/lib/sources/image-source.js.map +1 -1
  42. package/dist/es5/lib/sources/tile-source.js.map +1 -1
  43. package/dist/es5/lib/wfs/parse-wfs.js +41 -0
  44. package/dist/es5/lib/wfs/parse-wfs.js.map +1 -0
  45. package/dist/es5/lib/wmts/parse-wmts.js +41 -0
  46. package/dist/es5/lib/wmts/parse-wmts.js.map +1 -0
  47. package/dist/es5/wip/arcgis-feature-service.js.map +1 -1
  48. package/dist/es5/wip/lib/wcs/parse-wcs-capabilities.js +2 -1
  49. package/dist/es5/wip/lib/wcs/parse-wcs-capabilities.js.map +1 -1
  50. package/dist/es5/wip/lib/wfs/parse-wfs-capabilities.js +2 -1
  51. package/dist/es5/wip/lib/wfs/parse-wfs-capabilities.js.map +1 -1
  52. package/dist/es5/wip/lib/wmts/parse-wmts-capabilities.js +2 -1
  53. package/dist/es5/wip/lib/wmts/parse-wmts-capabilities.js.map +1 -1
  54. package/dist/es5/wip/wcs-capabilities-loader.js +1 -1
  55. package/dist/es5/wip/wcs-capabilities-loader.js.map +1 -1
  56. package/dist/es5/wip/wfs-capabilities-loader.js +1 -1
  57. package/dist/es5/wip/wfs-capabilities-loader.js.map +1 -1
  58. package/dist/es5/wip/wms-feature-info-loader.js.map +1 -1
  59. package/dist/es5/wip/wms-layer-description-loader.js.map +1 -1
  60. package/dist/es5/wip/wmts-capabilities-loader.js +1 -1
  61. package/dist/es5/wip/wmts-capabilities-loader.js.map +1 -1
  62. package/dist/es5/wms-capabilities-loader.js +1 -1
  63. package/dist/es5/wms-capabilities-loader.js.map +1 -1
  64. package/dist/es5/wms-error-loader.js +1 -1
  65. package/dist/es5/wms-error-loader.js.map +1 -1
  66. package/dist/esm/csw-capabilities-loader.js +1 -1
  67. package/dist/esm/csw-capabilities-loader.js.map +1 -1
  68. package/dist/esm/csw-domain-loader.js +1 -1
  69. package/dist/esm/csw-domain-loader.js.map +1 -1
  70. package/dist/esm/csw-records-loader.js +1 -1
  71. package/dist/esm/csw-records-loader.js.map +1 -1
  72. package/dist/esm/gml-loader.js +1 -1
  73. package/dist/esm/gml-loader.js.map +1 -1
  74. package/dist/esm/lerc-loader.js +1 -1
  75. package/dist/esm/lerc-loader.js.map +1 -1
  76. package/dist/esm/lib/create-image-source.js.map +1 -1
  77. package/dist/esm/lib/parsers/csw/parse-csw-capabilities.js +2 -1
  78. package/dist/esm/lib/parsers/csw/parse-csw-capabilities.js.map +1 -1
  79. package/dist/esm/lib/parsers/csw/parse-csw-domain.js +2 -1
  80. package/dist/esm/lib/parsers/csw/parse-csw-domain.js.map +1 -1
  81. package/dist/esm/lib/parsers/csw/parse-csw-records.js +7 -6
  82. package/dist/esm/lib/parsers/csw/parse-csw-records.js.map +1 -1
  83. package/dist/esm/lib/parsers/csw/parse-exception-report.js.map +1 -1
  84. package/dist/esm/lib/parsers/gml/deep-strict-equal.js.map +1 -1
  85. package/dist/esm/lib/parsers/gml/parse-gml.js +2 -1
  86. package/dist/esm/lib/parsers/gml/parse-gml.js.map +1 -1
  87. package/dist/esm/lib/parsers/wms/parse-wms-capabilities.js +2 -1
  88. package/dist/esm/lib/parsers/wms/parse-wms-capabilities.js.map +1 -1
  89. package/dist/esm/lib/parsers/wms/parse-wms-features.js +2 -2
  90. package/dist/esm/lib/parsers/wms/parse-wms-features.js.map +1 -1
  91. package/dist/esm/lib/parsers/wms/parse-wms-layer-description.js +2 -1
  92. package/dist/esm/lib/parsers/wms/parse-wms-layer-description.js.map +1 -1
  93. package/dist/esm/lib/parsers/xml/parse-xml-helpers.js.map +1 -1
  94. package/dist/esm/lib/services/arcgis/arcgis-image-service.js +0 -2
  95. package/dist/esm/lib/services/arcgis/arcgis-image-service.js.map +1 -1
  96. package/dist/esm/lib/services/arcgis/arcgis-server.js.map +1 -1
  97. package/dist/esm/lib/services/generic/image-service.js +0 -2
  98. package/dist/esm/lib/services/generic/image-service.js.map +1 -1
  99. package/dist/esm/lib/services/ogc/csw-service.js +0 -2
  100. package/dist/esm/lib/services/ogc/csw-service.js.map +1 -1
  101. package/dist/esm/lib/services/ogc/wms-service.js +54 -14
  102. package/dist/esm/lib/services/ogc/wms-service.js.map +1 -1
  103. package/dist/esm/lib/sources/data-source.js +20 -0
  104. package/dist/esm/lib/sources/data-source.js.map +1 -1
  105. package/dist/esm/lib/sources/image-source.js.map +1 -1
  106. package/dist/esm/lib/sources/tile-source.js.map +1 -1
  107. package/dist/esm/lib/wfs/parse-wfs.js +28 -0
  108. package/dist/esm/lib/wfs/parse-wfs.js.map +1 -0
  109. package/dist/esm/lib/wmts/parse-wmts.js +28 -0
  110. package/dist/esm/lib/wmts/parse-wmts.js.map +1 -0
  111. package/dist/esm/wip/lib/wcs/parse-wcs-capabilities.js +2 -1
  112. package/dist/esm/wip/lib/wcs/parse-wcs-capabilities.js.map +1 -1
  113. package/dist/esm/wip/lib/wfs/parse-wfs-capabilities.js +2 -1
  114. package/dist/esm/wip/lib/wfs/parse-wfs-capabilities.js.map +1 -1
  115. package/dist/esm/wip/lib/wmts/parse-wmts-capabilities.js +2 -1
  116. package/dist/esm/wip/lib/wmts/parse-wmts-capabilities.js.map +1 -1
  117. package/dist/esm/wip/wcs-capabilities-loader.js +1 -1
  118. package/dist/esm/wip/wcs-capabilities-loader.js.map +1 -1
  119. package/dist/esm/wip/wfs-capabilities-loader.js +1 -1
  120. package/dist/esm/wip/wfs-capabilities-loader.js.map +1 -1
  121. package/dist/esm/wip/wms-feature-info-loader.js.map +1 -1
  122. package/dist/esm/wip/wms-layer-description-loader.js.map +1 -1
  123. package/dist/esm/wip/wmts-capabilities-loader.js +1 -1
  124. package/dist/esm/wip/wmts-capabilities-loader.js.map +1 -1
  125. package/dist/esm/wms-capabilities-loader.js +1 -1
  126. package/dist/esm/wms-capabilities-loader.js.map +1 -1
  127. package/dist/esm/wms-error-loader.js +1 -1
  128. package/dist/esm/wms-error-loader.js.map +1 -1
  129. package/dist/lib/create-image-source.d.ts +1 -1
  130. package/dist/lib/create-image-source.d.ts.map +1 -1
  131. package/dist/lib/parsers/csw/parse-csw-capabilities.js +1 -1
  132. package/dist/lib/parsers/csw/parse-csw-domain.js +1 -1
  133. package/dist/lib/parsers/csw/parse-csw-records.js +6 -6
  134. package/dist/lib/parsers/csw/parse-exception-report.js +1 -1
  135. package/dist/lib/parsers/gml/parse-gml.js +1 -1
  136. package/dist/lib/parsers/wms/parse-wms-capabilities.js +2 -1
  137. package/dist/lib/parsers/wms/parse-wms-features.js +1 -1
  138. package/dist/lib/parsers/wms/parse-wms-layer-description.js +1 -1
  139. package/dist/lib/services/arcgis/arcgis-image-service.d.ts +1 -2
  140. package/dist/lib/services/arcgis/arcgis-image-service.d.ts.map +1 -1
  141. package/dist/lib/services/arcgis/arcgis-image-service.js +0 -1
  142. package/dist/lib/services/generic/image-service.d.ts +2 -3
  143. package/dist/lib/services/generic/image-service.d.ts.map +1 -1
  144. package/dist/lib/services/generic/image-service.js +0 -1
  145. package/dist/lib/services/ogc/csw-service.d.ts +1 -2
  146. package/dist/lib/services/ogc/csw-service.d.ts.map +1 -1
  147. package/dist/lib/services/ogc/csw-service.js +0 -1
  148. package/dist/lib/services/ogc/wms-service.d.ts +84 -43
  149. package/dist/lib/services/ogc/wms-service.d.ts.map +1 -1
  150. package/dist/lib/services/ogc/wms-service.js +73 -27
  151. package/dist/lib/sources/data-source.d.ts +12 -2
  152. package/dist/lib/sources/data-source.d.ts.map +1 -1
  153. package/dist/lib/sources/data-source.js +22 -0
  154. package/dist/lib/sources/image-source.d.ts +6 -6
  155. package/dist/lib/sources/image-source.d.ts.map +1 -1
  156. package/dist/lib/sources/tile-source.d.ts +4 -2
  157. package/dist/lib/sources/tile-source.d.ts.map +1 -1
  158. package/dist/lib/wfs/parse-wfs.d.ts +7 -0
  159. package/dist/lib/wfs/parse-wfs.d.ts.map +1 -0
  160. package/dist/lib/wfs/parse-wfs.js +32 -0
  161. package/dist/lib/wmts/parse-wmts.d.ts +7 -0
  162. package/dist/lib/wmts/parse-wmts.d.ts.map +1 -0
  163. package/dist/lib/wmts/parse-wmts.js +35 -0
  164. package/dist/wip/lib/wcs/parse-wcs-capabilities.js +1 -1
  165. package/dist/wip/lib/wfs/parse-wfs-capabilities.js +1 -1
  166. package/dist/wip/lib/wmts/parse-wmts-capabilities.js +1 -1
  167. package/package.json +6 -6
  168. package/src/lib/create-image-source.ts +1 -1
  169. package/src/lib/parsers/csw/parse-csw-capabilities.ts +1 -1
  170. package/src/lib/parsers/csw/parse-csw-domain.ts +1 -1
  171. package/src/lib/parsers/csw/parse-csw-records.ts +6 -6
  172. package/src/lib/parsers/csw/parse-exception-report.ts +1 -1
  173. package/src/lib/parsers/gml/parse-gml.ts +1 -1
  174. package/src/lib/parsers/wms/parse-wms-capabilities.ts +2 -1
  175. package/src/lib/parsers/wms/parse-wms-features.ts +1 -1
  176. package/src/lib/parsers/wms/parse-wms-layer-description.ts +1 -1
  177. package/src/lib/services/arcgis/arcgis-image-service.ts +1 -4
  178. package/src/lib/services/generic/image-service.ts +2 -5
  179. package/src/lib/services/ogc/csw-service.ts +1 -3
  180. package/src/lib/services/ogc/wms-service.ts +165 -60
  181. package/src/lib/sources/data-source.ts +29 -2
  182. package/src/lib/sources/image-source.ts +6 -6
  183. package/src/lib/sources/tile-source.ts +4 -2
  184. package/src/lib/wfs/parse-wfs.ts +34 -0
  185. package/src/lib/wmts/parse-wmts.ts +37 -0
  186. package/src/wip/lib/wcs/parse-wcs-capabilities.ts +1 -1
  187. package/src/wip/lib/wfs/parse-wfs-capabilities.ts +1 -1
  188. package/src/wip/lib/wmts/parse-wmts-capabilities.ts +1 -1
  189. package/dist/es5/lib/services/generic/tile-service.js +0 -2
  190. package/dist/es5/lib/services/generic/tile-service.js.map +0 -1
  191. package/dist/esm/lib/services/generic/tile-service.js +0 -2
  192. package/dist/esm/lib/services/generic/tile-service.js.map +0 -1
  193. package/dist/lib/services/generic/tile-service.d.ts +0 -1
  194. package/dist/lib/services/generic/tile-service.d.ts.map +0 -1
  195. package/dist/lib/services/generic/tile-service.js +0 -1
  196. package/src/lib/services/generic/tile-service.ts +0 -0
@@ -1,7 +1,6 @@
1
1
  // loaders.gl, MIT license
2
2
 
3
3
  /* eslint-disable camelcase */
4
-
5
4
  import type {ImageType} from '@loaders.gl/images';
6
5
  import {ImageLoader} from '@loaders.gl/images';
7
6
  import {mergeLoaderOptions} from '@loaders.gl/loader-utils';
@@ -21,68 +20,87 @@ import {WMSLayerDescriptionLoader} from '../../../wip/wms-layer-description-load
21
20
  import type {WMSLoaderOptions} from '../../../wms-error-loader';
22
21
  import {WMSErrorLoader} from '../../../wms-error-loader';
23
22
 
24
- /** Static WMS parameters (not viewport or selected pixel dependent) that can be provided as defaults */
23
+ /**
24
+ * "Static" WMS parameters (not viewport or selected pixel dependent)
25
+ * These can be provided as defaults in the WMSService constructor
26
+ */
25
27
  export type WMSParameters = {
26
- /** WMS version */
28
+ /** WMS version (all requests) */
27
29
  version?: '1.3.0' | '1.1.1';
28
- /** Layers to render */
30
+ /** Layers to render (GetMap, GetFeatureInfo) */
29
31
  layers?: string[];
32
+ /** list of layers to query.. (GetFeatureInfo) */
33
+ query_layers?: string[];
34
+
30
35
  /** Coordinate Reference System (CRS) for the image (not the bounding box) */
31
36
  crs?: string;
32
- /** Requested format for the return image */
37
+ /** Requested format for the return image (GetMap, GetLegendGraphic) */
33
38
  format?: 'image/png';
34
- /** Requested MIME type of returned feature info */
39
+ /** Requested MIME type of returned feature info (GetFeatureInfo) */
35
40
  info_format?: 'text/plain' | 'application/geojson' | 'application/vnd.ogc.gml';
36
41
  /** Styling - Not yet supported */
37
42
  styles?: unknown;
38
- /** Any additional parameters specific to this WMSService */
43
+ /** Any additional parameters specific to this WMSService (GetMap) */
39
44
  transparent?: boolean;
40
45
  };
41
46
 
42
- type WMSCommonParameters = {
47
+ /** Parameters for GetCapabilities */
48
+ export type WMSGetCapabilitiesParameters = {
43
49
  /** In case the endpoint supports multiple WMS versions */
44
50
  version?: '1.3.0' | '1.1.1';
45
51
  };
46
52
 
47
- /** Parameters for GetCapabilities */
48
- export type WMSGetCapabilitiesParameters = WMSCommonParameters;
49
-
50
53
  /** Parameters for GetMap */
51
- export type WMSGetMapParameters = WMSCommonParameters & {
52
- /** Layers to render */
53
- layers: string | string[];
54
+ export type WMSGetMapParameters = {
55
+ /** In case the endpoint supports multiple WMS versions */
56
+ version?: '1.3.0' | '1.1.1';
54
57
  /** bounding box of the requested map image */
55
58
  bbox: [number, number, number, number];
56
59
  /** pixel width of returned image */
57
60
  width: number;
58
61
  /** pixels */
59
62
  height: number;
60
- /** Coordinate Reference System for the image (not the bounding box). */
63
+ /** Layers to render - can be provided in service constructor */
64
+ layers?: string | string[];
65
+ /** Coordinate Reference System for the image (not bounding box). can be provided in service constructor. */
61
66
  crs?: string;
62
- /** Styling */
67
+ /** Styling. can be provided in service constructor */
63
68
  styles?: unknown;
64
- /** Don't render background when no data */
69
+ /** Don't render background when no data. can be provided in service constructor */
65
70
  transparent?: boolean;
66
- /** requested format for the return image */
71
+ /** requested format for the return image. can be provided in service constructor */
67
72
  format?: 'image/png';
68
73
  };
69
74
 
75
+ /** GetMap parameters that are specific to the current view */
76
+ export type WMSGetMapViewParameters = {
77
+ /** pixel width of returned image */
78
+ width: number;
79
+ /** pixels */
80
+ height: number;
81
+ /** bounding box of the requested map image */
82
+ bbox: [number, number, number, number];
83
+ /** Coordinate Reference System for the image (not bounding box). can be provided in service constructor. */
84
+ crs?: string;
85
+ };
86
+
70
87
  /**
71
88
  * Parameters for GetFeatureInfo
72
89
  * @see https://imagery.pasda.psu.edu/arcgis/services/pasda/UrbanTreeCanopy_Landcover/MapServer/WmsServer?SERVICE=WMS&
73
90
  */
74
- export type WMSGetFeatureInfoParameters = WMSCommonParameters & {
91
+ export type WMSGetFeatureInfoParameters = {
92
+ /** In case the endpoint supports multiple WMS versions */
93
+ version?: '1.3.0' | '1.1.1';
75
94
  /** x coordinate for the feature info request */
76
95
  x: number;
77
96
  /** y coordinate for the feature info request */
78
97
  y: number;
79
- /** list of layers to query (could be different from rendered layers) */
80
- query_layers: string[];
81
- /** Requested MIME type of returned feature info */
98
+ /** MIME type of returned feature info. Can be specified in service constructor */
82
99
  info_format?: 'text/plain' | 'application/geojson' | 'application/vnd.ogc.gml';
83
-
84
- /** Layers to render */
85
- layers: string[];
100
+ /** list of layers to query. Required but can be specified in service constructor. */
101
+ query_layers?: string[];
102
+ /** Layers to render. Required, but can be specified in service constructor */
103
+ layers?: string[];
86
104
  /** Styling */
87
105
  styles?: unknown;
88
106
  /** bounding box of the requested map image */
@@ -92,16 +110,36 @@ export type WMSGetFeatureInfoParameters = WMSCommonParameters & {
92
110
  /** pixels */
93
111
  height: number;
94
112
  /** srs for the image (not the bounding box) */
95
- srs?: string;
96
- /** requested format for the return image */
97
- format?: 'image/png';
113
+ crs?: string;
114
+ };
115
+
116
+ /** GetMap parameters that are specific to the current view */
117
+ export type WMSGetFeatureInfoViewParameters = {
118
+ /** x coordinate for the feature info request */
119
+ x: number;
120
+ /** y coordinate for the feature info request */
121
+ y: number;
122
+ /** pixel width of returned image */
123
+ width: number;
124
+ /** pixels */
125
+ height: number;
126
+ /** bounding box of the requested map image */
127
+ bbox: [number, number, number, number];
128
+ /** srs for the image (not the bounding box) */
129
+ crs?: string;
98
130
  };
99
131
 
100
132
  /** Parameters for DescribeLayer */
101
- export type WMSDescribeLayerParameters = WMSCommonParameters;
133
+ export type WMSDescribeLayerParameters = {
134
+ /** In case the endpoint supports multiple WMS versions */
135
+ version?: '1.3.0' | '1.1.1';
136
+ };
102
137
 
103
138
  /** Parameters for GetLegendGraphic */
104
- export type WMSGetLegendGraphicParameters = WMSCommonParameters;
139
+ export type WMSGetLegendGraphicParameters = {
140
+ /** In case the endpoint supports multiple WMS versions */
141
+ version?: '1.3.0' | '1.1.1';
142
+ };
105
143
 
106
144
  //
107
145
 
@@ -109,6 +147,9 @@ export type WMSGetLegendGraphicParameters = WMSCommonParameters;
109
147
  export type WMSServiceProps = ImageSourceProps & {
110
148
  /** Base URL to the service */
111
149
  url: string;
150
+ /** In 1.3.0, replaces references to EPSG:4326 with CRS:84 */
151
+ substituteCRS84?: boolean;
152
+
112
153
  /** Default WMS parameters. If not provided here, must be provided in the various request */
113
154
  wmsParameters?: WMSParameters;
114
155
  /** Any additional service specific parameters */
@@ -122,11 +163,18 @@ export type WMSServiceProps = ImageSourceProps & {
122
163
  * - implements the ImageService interface
123
164
  * @note Only the URL parameter conversion is supported. XML posts are not supported.
124
165
  */
125
- export class WMSService extends ImageSource {
166
+ export class WMSService extends ImageSource<WMSServiceProps> {
126
167
  static type: 'wms' = 'wms';
127
168
  static testURL = (url: string): boolean => url.toLowerCase().includes('wms');
128
169
 
170
+ /** Base URL to the service */
129
171
  readonly url: string;
172
+
173
+ /** In WMS 1.3.0, replaces references to EPSG:4326 with CRS:84. But not always supported. Default: false */
174
+ substituteCRS84: boolean;
175
+ /** In WMS 1.3.0, flips x,y (lng, lat) coordinates for the supplied coordinate systems. Default: ['ESPG:4326'] */
176
+ flipCRS: string[];
177
+
130
178
  /** Default static WMS parameters */
131
179
  wmsParameters: Required<WMSParameters>;
132
180
  /** Default static vendor parameters */
@@ -153,8 +201,12 @@ export class WMSService extends ImageSource {
153
201
 
154
202
  this.url = props.url;
155
203
 
204
+ this.substituteCRS84 = props.substituteCRS84 ?? false;
205
+ this.flipCRS = ['EPSG:4326'];
206
+
156
207
  this.wmsParameters = {
157
208
  layers: undefined!,
209
+ query_layers: undefined!,
158
210
  styles: undefined,
159
211
  version: '1.3.0',
160
212
  crs: 'EPSG:4326',
@@ -174,10 +226,7 @@ export class WMSService extends ImageSource {
174
226
  }
175
227
 
176
228
  async getImage(parameters: GetImageParameters): Promise<ImageType> {
177
- // WMS 1.3.0 renamed SRS to CRS (sigh...)
178
- const wmsParameters = {...parameters, crs: parameters.srs};
179
- delete wmsParameters.srs;
180
- return await this.getMap(wmsParameters);
229
+ return await this.getMap(parameters);
181
230
  }
182
231
 
183
232
  normalizeMetadata(capabilities: WMSCapabilities): ImageSourceMetadata {
@@ -288,16 +337,17 @@ export class WMSService extends ImageSource {
288
337
  wmsParameters: WMSGetMapParameters,
289
338
  vendorParameters?: Record<string, unknown>
290
339
  ): string {
340
+ wmsParameters = this._getWMS130Parameters(wmsParameters);
291
341
  const options: Required<WMSGetMapParameters> = {
292
342
  version: this.wmsParameters.version,
293
- // layers: [],
343
+ format: this.wmsParameters.format,
344
+ transparent: this.wmsParameters.transparent,
345
+ layers: this.wmsParameters.layers,
346
+ styles: this.wmsParameters.styles,
347
+ crs: this.wmsParameters.crs,
294
348
  // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
295
349
  // width: 1200,
296
350
  // height: 900,
297
- styles: this.wmsParameters.styles,
298
- crs: this.wmsParameters.crs,
299
- format: this.wmsParameters.format,
300
- transparent: this.wmsParameters.transparent,
301
351
  ...wmsParameters
302
352
  };
303
353
  return this._getWMSUrl('GetMap', options, vendorParameters);
@@ -310,17 +360,18 @@ export class WMSService extends ImageSource {
310
360
  ): string {
311
361
  const options: Required<WMSGetFeatureInfoParameters> = {
312
362
  version: this.wmsParameters.version,
313
- // layers: this.props.layers,
363
+ // query_layers: [],
364
+ // format: this.wmsParameters.format,
365
+ info_format: this.wmsParameters.info_format,
366
+ layers: this.wmsParameters.layers,
367
+ query_layers: this.wmsParameters.query_layers,
368
+ styles: this.wmsParameters.styles,
369
+ crs: this.wmsParameters.crs,
314
370
  // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
315
371
  // width: 1200,
316
372
  // height: 900,
317
373
  // x: undefined!,
318
374
  // y: undefined!,
319
- // query_layers: [],
320
- srs: this.wmsParameters.crs,
321
- format: this.wmsParameters.format,
322
- info_format: this.wmsParameters.info_format,
323
- styles: this.wmsParameters.styles,
324
375
  ...wmsParameters
325
376
  };
326
377
  return this._getWMSUrl('GetFeatureInfo', options, vendorParameters);
@@ -372,7 +423,7 @@ export class WMSService extends ImageSource {
372
423
  * */
373
424
  protected _getWMSUrl(
374
425
  request: string,
375
- wmsParameters: WMSCommonParameters & {[key: string]: unknown},
426
+ wmsParameters: {version?: '1.3.0' | '1.1.1'; [key: string]: unknown},
376
427
  vendorParameters?: Record<string, unknown>
377
428
  ): string {
378
429
  let url = this.url;
@@ -394,34 +445,88 @@ export class WMSService extends ImageSource {
394
445
  if (key !== 'transparent' || value) {
395
446
  url += first ? '?' : '&';
396
447
  first = false;
397
- url += this._getParameterValue(wmsParameters.version!, key, value);
448
+ url += this._getURLParameter(key, value, wmsParameters);
398
449
  }
399
450
  }
400
451
 
401
452
  return encodeURI(url);
402
453
  }
403
454
 
404
- _getParameterValue(version: string, key: string, value: unknown): string {
405
- // SRS parameter changed to CRS in 1.3.0, in non-backwards compatible way (sigh...)
406
- if (key === 'crs' && version !== '1.3.0') {
407
- key = 'srs';
455
+ _getWMS130Parameters<ParametersT extends {crs?: string; srs?: string}>(
456
+ wmsParameters: ParametersT
457
+ ): ParametersT {
458
+ const newParameters = {...wmsParameters};
459
+ if (newParameters.srs) {
460
+ newParameters.crs = newParameters.crs || newParameters.srs;
461
+ delete newParameters.srs;
408
462
  }
463
+ return newParameters;
464
+ }
409
465
 
410
- key = key.toUpperCase();
466
+ // eslint-disable-complexity
467
+ _getURLParameter(key: string, value: unknown, wmsParameters: WMSParameters): string {
468
+ // Substitute by key
469
+ switch (key) {
470
+ case 'crs':
471
+ // CRS was called SRS before WMS 1.3.0
472
+ if (wmsParameters.version !== '1.3.0') {
473
+ key = 'srs';
474
+ } else if (this.substituteCRS84 && value === 'EPSG:4326') {
475
+ /** In 1.3.0, replaces references to 'EPSG:4326' with the new backwards compatible CRS:84 */
476
+ // Substitute by value
477
+ value = 'CRS:84';
478
+ }
479
+ break;
480
+
481
+ case 'srs':
482
+ // CRS was called SRS before WMS 1.3.0
483
+ if (wmsParameters.version === '1.3.0') {
484
+ key = 'crs';
485
+ }
486
+ break;
487
+
488
+ case 'bbox':
489
+ // Coordinate order is flipped for certain CRS in WMS 1.3.0
490
+ const bbox = this._flipBoundingBox(value, wmsParameters);
491
+ if (bbox) {
492
+ value = bbox;
493
+ }
494
+ break;
495
+
496
+ default:
497
+ // do nothing
498
+ }
411
499
 
412
- // TODO - in v1.3.0 only, the order of parameters for BBOX depends on whether the CRS definition has flipped axes
413
- // You will see this in the GetCapabilities request at 1.3.0 - the response should show the flipped axes.
414
- // BBOX=xmin,ymin,xmax,ymax NON-FLIPPED
415
- // BBOX=ymin,xmin,ymax,xmax FLIPPED
416
- // / EPSG:4326 needs to have flipped axes. 4326 1 WGS 84 Latitude North Longitude East
417
- // In WMS 1.1.1 EPSG:4326 is wrongly defined as having long/lat coordinate axes. In WMS 1.3.0 the correct axes lat/long are used. CRS:84 is defined by OGC as having the same datum as EPSG:4326 (that is the World Geodetic System 1984 datum ~ EPSG::6326) but axis order of long/lat.
418
- // CRS:84 was introduced with the publication of the WMS 1.3.0 specification, to overcome this issue.
500
+ key = key.toUpperCase();
419
501
 
420
502
  return Array.isArray(value)
421
503
  ? `${key}=${value.join(',')}`
422
504
  : `${key}=${value ? String(value) : ''}`;
423
505
  }
424
506
 
507
+ /** Coordinate order is flipped for certain CRS in WMS 1.3.0 */
508
+ _flipBoundingBox(
509
+ bboxValue: unknown,
510
+ wmsParameters: WMSParameters
511
+ ): [number, number, number, number] | null {
512
+ // Sanity checks
513
+ if (!Array.isArray(bboxValue) || bboxValue.length !== 4) {
514
+ return null;
515
+ }
516
+
517
+ const flipCoordinates =
518
+ // Only affects WMS 1.3.0
519
+ wmsParameters.version === '1.3.0' &&
520
+ // Flip if we are dealing with a CRS that was flipped in 1.3.0
521
+ this.flipCRS.includes(wmsParameters.crs || '') &&
522
+ // Don't flip if we are subsituting EPSG:4326 with CRS:84
523
+ !(this.substituteCRS84 && wmsParameters.crs === 'EPSG:4326');
524
+
525
+ const bbox = bboxValue as [number, number, number, number];
526
+ return flipCoordinates ? [bbox[1], bbox[0], bbox[3], bbox[2]] : bbox;
527
+ }
528
+
529
+ /** Fetches an array buffer and checks the response (boilerplate reduction) */
425
530
  protected async _fetchArrayBuffer(url: string): Promise<ArrayBuffer> {
426
531
  const response = await this.fetch(url);
427
532
  const arrayBuffer = await response.arrayBuffer();
@@ -8,16 +8,43 @@ export type DataSourceProps = {
8
8
  };
9
9
 
10
10
  /** base class of all data sources */
11
- export abstract class DataSource {
11
+ export abstract class DataSource<PropsT extends DataSourceProps> {
12
12
  /** A resolved fetch function extracted from loadOptions prop */
13
13
  fetch: (url: string, options?: RequestInit) => Promise<Response>;
14
14
  /** The actual load options, if calling a loaders.gl loader */
15
15
  loadOptions: LoaderOptions;
16
+ _needsRefresh: boolean = true;
16
17
 
17
- constructor(props: DataSourceProps) {
18
+ props: PropsT;
19
+
20
+ constructor(props: PropsT) {
21
+ this.props = {...props};
18
22
  this.loadOptions = {...props.loadOptions};
19
23
  this.fetch = getFetchFunction(this.loadOptions);
20
24
  }
25
+
26
+ setProps(props: PropsT) {
27
+ this.props = Object.assign(this.props, props);
28
+ // TODO - add a shallow compare to avoid setting refresh if no change?
29
+ this.setNeedsRefresh();
30
+ }
31
+
32
+ /** Mark this data source as needing a refresh (redraw) */
33
+ setNeedsRefresh(): void {
34
+ this._needsRefresh = true;
35
+ }
36
+
37
+ /**
38
+ * Does this data source need refreshing?
39
+ * @note The specifics of the refresh mechanism depends on type of data source
40
+ */
41
+ getNeedsRefresh(clear: boolean = true) {
42
+ const needsRefresh = this._needsRefresh;
43
+ if (clear) {
44
+ this._needsRefresh = false;
45
+ }
46
+ return needsRefresh;
47
+ }
21
48
  }
22
49
 
23
50
  /**
@@ -21,7 +21,7 @@ export type ImageSourceMetadata = {
21
21
  export type ImageSourceLayer = {
22
22
  name?: string;
23
23
  title?: string;
24
- srs?: string[];
24
+ crs?: string[];
25
25
  boundingBox?: [number, number, number, number];
26
26
  layers?: ImageSourceLayer[];
27
27
  };
@@ -37,8 +37,8 @@ export type GetImageParameters = {
37
37
  width: number;
38
38
  /** pixels */
39
39
  height: number;
40
- /** srs for the image (not the bounding box) */
41
- srs?: string;
40
+ /** crs for the image (not the bounding box) */
41
+ crs?: string;
42
42
  /** requested format for the return image */
43
43
  format?: 'image/png';
44
44
  };
@@ -61,8 +61,8 @@ export type ImageFormat = {
61
61
  width: number;
62
62
  /** pixels */
63
63
  height: number;
64
- /** srs for the image (not the bounding box) */
65
- srs?: string;
64
+ /** crs for the image (not the bounding box) */
65
+ crs?: string;
66
66
  /** requested format for the return image */
67
67
  format?: 'image/png';
68
68
  };
@@ -74,7 +74,7 @@ export type ImageSourceProps = DataSourceProps;
74
74
  * @note
75
75
  * - If geospatial, bounding box is expected to be in web mercator coordinates
76
76
  */
77
- export abstract class ImageSource extends DataSource {
77
+ export abstract class ImageSource<PropsT extends ImageSourceProps> extends DataSource<PropsT> {
78
78
  abstract getMetadata(): Promise<ImageSourceMetadata>;
79
79
  abstract getImage(parameters: GetImageParameters): Promise<ImageType>;
80
80
  }
@@ -1,7 +1,7 @@
1
1
  // loaders.gl, MIT license
2
2
 
3
3
  import type {ImageType} from '@loaders.gl/images';
4
- import {DataSource} from './data-source';
4
+ import {DataSource, DataSourceProps} from './data-source';
5
5
 
6
6
  /**
7
7
  * Normalized capabilities of an Image service
@@ -48,12 +48,14 @@ export type GetTileParameters = {
48
48
  format?: 'image/png';
49
49
  };
50
50
 
51
+ type TileSourceProps = DataSourceProps;
52
+
51
53
  /**
52
54
  * MapTileSource - data sources that allow data to be queried by (geospatial) extents
53
55
  * @note
54
56
  * - If geospatial, bounding box is expected to be in web mercator coordinates
55
57
  */
56
- export abstract class TileSource extends DataSource {
58
+ export abstract class TileSource<PropsT extends TileSourceProps> extends DataSource<PropsT> {
57
59
  abstract getMetadata(): Promise<TileSourceMetadata>;
58
60
  abstract getTile(parameters: GetTileParameters): Promise<ImageType>;
59
61
  }
@@ -0,0 +1,34 @@
1
+ // loaders.gl, MIT license
2
+
3
+ import {XMLLoader} from '@loaders.gl/xml';
4
+
5
+ export type WFSCapabilities = {};
6
+
7
+ /**
8
+ * Parses a typed data structure from raw XML for `GetCapabilities` response
9
+ * @note Error handlings is fairly weak
10
+ */
11
+ export function parseWFSCapabilities(text: string, options): WFSCapabilities {
12
+ // Remove namespaces in XML
13
+ options = {...options, xml: {...options?.xml, removeNSPrefix: true}};
14
+ const parsedXML = XMLLoader.parseTextSync?.(text, options);
15
+ const xmlCapabilities: any = parsedXML.Capabilities || parsedXML;
16
+ return uncapitalizeKeys(xmlCapabilities);
17
+ }
18
+
19
+ /** Uncapitalize all keys of an object */
20
+ function uncapitalizeKeys(object: any): any {
21
+ if (object && typeof object === 'object') {
22
+ const newObject = {};
23
+ for (const [key, value] of Object.entries(object)) {
24
+ newObject[uncapitalize(key)] = uncapitalizeKeys(value);
25
+ }
26
+ return newObject;
27
+ }
28
+ return object;
29
+ }
30
+
31
+ /** Uncapitalize first letter of a string */
32
+ function uncapitalize(str: string): string {
33
+ return typeof str === 'string' ? str.charAt(0).toLowerCase() + str.slice(1) : str;
34
+ }
@@ -0,0 +1,37 @@
1
+ // loaders.gl, MIT license
2
+
3
+ import {XMLLoader} from '@loaders.gl/xml';
4
+
5
+ export type WMTSCapabilities = {};
6
+
7
+ /**
8
+ * Parses a typed data structure from raw XML for `GetCapabilities` response
9
+ * @note Error handlings is fairly weak
10
+ */
11
+ export function parseWMTSCapabilities(text: string, options): WMTSCapabilities {
12
+ // Remove namespaces in XML
13
+ options = {...options, xml: {...options?.xml, removeNSPrefix: true}};
14
+ const parsedXML = XMLLoader.parseTextSync?.(text, options);
15
+ const xmlCapabilities: any = parsedXML.Capabilities || parsedXML;
16
+ return uncapitalizeKeys(xmlCapabilities);
17
+ }
18
+
19
+ function uncapitalizeKeys(object: any): any {
20
+ if (object && typeof object === 'object') {
21
+ const newObject = {};
22
+ for (const [key, value] of Object.entries(object)) {
23
+ newObject[uncapitalize(key)] = uncapitalizeKeys(value);
24
+ }
25
+ return newObject;
26
+ }
27
+ return object;
28
+ }
29
+
30
+ /**
31
+ * Uncapitalize first letter of a string
32
+ * @param {string} str
33
+ * @returns {string}
34
+ */
35
+ function uncapitalize(str: string): string {
36
+ return typeof str === 'string' ? str.charAt(0).toLowerCase() + str.slice(1) : str;
37
+ }
@@ -83,7 +83,7 @@ export type WCSCapabilities = {
83
83
  * @note Error handlings is fairly weak
84
84
  */
85
85
  export function parseWCSCapabilities(text: string, options): WCSCapabilities {
86
- const parsedXML = XMLLoader.parseTextSync(text, {...options, xml: {...options?.xml, removeNSPrefix: true}});
86
+ const parsedXML = XMLLoader.parseTextSync?.(text, {...options, xml: {...options?.xml, removeNSPrefix: true}});
87
87
  const xmlCapabilities: any = parsedXML.Capabilities || parsedXML;
88
88
  return xmlCapabilities;
89
89
  }
@@ -83,7 +83,7 @@ export type WFSCapabilities = {
83
83
  * @note Error handlings is fairly weak
84
84
  */
85
85
  export function parseWFSCapabilities(text: string, options): WFSCapabilities {
86
- const parsedXML = XMLLoader.parseTextSync(text, {...options, xml: {
86
+ const parsedXML = XMLLoader.parseTextSync?.(text, {...options, xml: {
87
87
  ...options?.xml,
88
88
  removeNSPrefix: true,
89
89
  uncapitalizeKeys: true
@@ -90,7 +90,7 @@ export type WMTSTileMatrixSet = {
90
90
  * @note Error handlings is fairly weak
91
91
  */
92
92
  export function parseWMTSCapabilities(text: string, options): WMTSCapabilities {
93
- const parsedXML = XMLLoader.parseTextSync(text, {...options, xml: {
93
+ const parsedXML = XMLLoader.parseTextSync?.(text, {...options, xml: {
94
94
  ...options?.xml,
95
95
  removeNSPrefix: true,
96
96
  uncapitalizeKeys: true
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=tile-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tile-service.js","names":[],"sources":["../../../../../src/lib/services/generic/tile-service.ts"],"sourcesContent":[""],"mappings":""}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=tile-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tile-service.js","names":[],"sources":["../../../../../src/lib/services/generic/tile-service.ts"],"sourcesContent":[""],"mappings":""}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=tile-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tile-service.d.ts","sourceRoot":"","sources":["../../../../src/lib/services/generic/tile-service.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";
File without changes