TypeScript code:
const url = '<REDACTED>/server/services/CRSMS/results_views/MapServer/WFSServer';
wfsUtils.getCapabilities(url).then((capabilities: __esri.WFSCapabilities) => {
console.log(capabilities);
wfsUtils.getWFSLayerInfo(capabilities).then((layerInfo: __esri.WFSLayerInfo) => {
console.log(layerInfo);
}).catch(err => console.error(err));
}).catch(err => console.error(err));
Full error object:
{
"name": "wfs-layer:getWFSLayerTypeInfo-error",
"message": "An error occurred while getting info about the feature type 'CRSMS_Results:State_Segment_Results'",
"details": {
"error": {
"stack": "TypeError: e[0].toFixed is not a function\n at http://localhost:4200/default-src_app_countermeasure-selection_countermeasure-selection_module_ts.js:1220:24\n at Generator.next (<anonymous>)\n at asyncGeneratorStep (http://localhost:4200/vendor.js:488874:24)\n at _next (http://localhost:4200/vendor.js:488896:9)\n at ZoneDelegate.invoke (http://localhost:4200/polyfills.js:10741:26)\n at Object.onInvoke (http://localhost:4200/vendor.js:150275:33)\n at ZoneDelegate.invoke (http://localhost:4200/polyfills.js:10740:52)\n at Zone.run (http://localhost:4200/polyfills.js:10503:43)\n at http://localhost:4200/polyfills.js:11645:36\n at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:10775:31)",
"message": "e[0].toFixed is not a function"
}
}
}
I tracked down the line in wfsUtils.js that attempts to call e[0].toFixed, and the error seems to stem from trying to run toFixed on an array.
This is the object assigned to const "l" (that's a lower case "L") in the _ function in wfsUtils.js
{
"type": "LineString",
"coordinates": [
[
[
-72.65184826276831,
41.68332079297852
],
[
-72.6518375426355,
41.6833402003078
],
[
-72.65164952810201,
41.68368523520941
],
[
-72.65134688182289,
41.68423819295341
],
[
-72.65133217881116,
41.68426533549341
],
[
-72.6511336731859,
41.68463172535813
],
[
-72.65111840159392,
41.68465905375734
]
]
]
}
This gets interpreted as a 'lineString', type, and a switch/case assigns l.coordinates[0] to e
It seems like this is the issue. With these coordinates, the assignment should go a level deeper: l.coordinates[0][0] (which is what the switch/case uses for types MultiLineString and Polygon.
The question here is this -- is my service returning the wrong type and/or coordinates data, or is wfsUtils handling this wrong?
Any help or clues would be appreciated. Thanks!
(Using ArcGIS JS API 4.22 via npm package in an Angular 12.1 application)
What technology is used to create the WFS service?
Do you have a public URL available of the WFS service? If not, it might be easiest to work with Esri Support.