From 07986a6f78d31bd75a50ba7216b83864377e2edf Mon Sep 17 00:00:00 2001 From: Rick Saccoccia Date: Fri, 1 Nov 2024 10:12:47 -0600 Subject: [PATCH] Fixed outFields and returnGeometry for query generation --- plugins/arcgis/service/src/FeatureQuerier.ts | 45 +++++++------------ .../arcgis/service/src/FeatureServiceAdmin.ts | 1 - .../service/src/ObservationProcessor.ts | 2 +- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/plugins/arcgis/service/src/FeatureQuerier.ts b/plugins/arcgis/service/src/FeatureQuerier.ts index 9944d7e46..defc76698 100644 --- a/plugins/arcgis/service/src/FeatureQuerier.ts +++ b/plugins/arcgis/service/src/FeatureQuerier.ts @@ -59,13 +59,14 @@ export class FeatureQuerier { queryUrl.searchParams.set('where', `${this._config.observationIdField} = ${observationId}`); } queryUrl.searchParams.set('outFields', this.outFields(fields)) - queryUrl.searchParams.set('returnGeometry', this.returnGeometry(geometry)) - + queryUrl.searchParams.set('returnGeometry', geometry === false ? 'false' : 'true') + this._console.info('ArcGIS query: ' + queryUrl) + const queryResponse = await request(queryUrl.toString(), { authentication: this._identityManager }); - this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse) + this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse.toString) const result = JSON.parse(queryResponse) as QueryObjectResult response(result); } @@ -80,9 +81,13 @@ export class FeatureQuerier { const queryUrl = new URL(this._url) queryUrl.searchParams.set('where', `${this._config.observationIdField} IS NOT NULL`); queryUrl.searchParams.set('outFields', this.outFields(fields)); - queryUrl.searchParams.set('returnGeometry', this.returnGeometry(geometry)); + queryUrl.searchParams.set('returnGeometry', geometry === false ? 'false' : 'true'); + + this._console.info('ArcGIS query: ' + queryUrl) + const queryResponse = await request(queryUrl.toString(), { - authentication: this._identityManager + authentication: this._identityManager, + params: { f: 'json' } }); this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse) @@ -100,7 +105,9 @@ export class FeatureQuerier { queryUrl.searchParams.set('where', `${field} IS NOT NULL`); queryUrl.searchParams.set('returnDistinctValues', 'true'); queryUrl.searchParams.set('outFields', this.outFields([field])); - queryUrl.searchParams.set('returnGeometry', this.returnGeometry(false)); + queryUrl.searchParams.set('returnGeometry', 'false'); + this._console.info('ArcGIS query: ' + queryUrl) + const queryResponse = await request(queryUrl.toString(), { authentication: this._identityManager @@ -116,31 +123,11 @@ export class FeatureQuerier { * @returns out fields */ private outFields(fields?: string[]): string { - let outFields = '&outFields=' if (fields != null && fields.length > 0) { - for (let i = 0; i < fields.length; i++) { - if (i > 0) { - outFields += "," - } - outFields += fields[i] - } - } else{ - outFields += '*' - } - return outFields - } - - /** - * Build the return geometry query parameter - * @param fields query fields - * @returns out fields - */ - private returnGeometry(geometry?: boolean): string { - let returnGeometry = '' - if (geometry != null && !geometry) { - returnGeometry = '&returnGeometry=false' + return fields.join(','); + } else { + return '*'; } - return returnGeometry } } \ No newline at end of file diff --git a/plugins/arcgis/service/src/FeatureServiceAdmin.ts b/plugins/arcgis/service/src/FeatureServiceAdmin.ts index 50f15b1fd..701e8e76a 100644 --- a/plugins/arcgis/service/src/FeatureServiceAdmin.ts +++ b/plugins/arcgis/service/src/FeatureServiceAdmin.ts @@ -111,7 +111,6 @@ export class FeatureServiceAdmin { } } - // TODO - where does New_field and New_field_2 come from with each startup? if (addFields.length > 0) { this.addFields(service, featureLayer, addFields) } diff --git a/plugins/arcgis/service/src/ObservationProcessor.ts b/plugins/arcgis/service/src/ObservationProcessor.ts index 01cff2f63..1ab69d3c2 100644 --- a/plugins/arcgis/service/src/ObservationProcessor.ts +++ b/plugins/arcgis/service/src/ObservationProcessor.ts @@ -313,7 +313,7 @@ export class ObservationProcessor { const identityManager = await getIdentityManager(featureServiceConfig, new HttpClient(console)) const layerProcessor = new FeatureLayerProcessor(info, config, identityManager,this._console); this._layerProcessors.push(layerProcessor); - clearTimeout(this._nextTimeout); // TODO why is this needed? + // clearTimeout(this._nextTimeout); // TODO why is this needed? // this.scheduleNext(config); // TODO why is this needed when processAndScheduleNext is called upstream and ends with scheduleNext() This causes a query before updateLayer. } }