Skip to content

Commit

Permalink
Fixed outFields and returnGeometry for query generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rick Saccoccia committed Nov 1, 2024
1 parent e40718f commit 07986a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 31 deletions.
45 changes: 16 additions & 29 deletions plugins/arcgis/service/src/FeatureQuerier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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)
Expand All @@ -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

Expand All @@ -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
}

}
1 change: 0 additions & 1 deletion plugins/arcgis/service/src/FeatureServiceAdmin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/arcgis/service/src/ObservationProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
}
Expand Down

0 comments on commit 07986a6

Please sign in to comment.