Skip to content

Commit 6379dae

Browse files
committed
Undo revert of FeatureQuerier
1 parent 157d209 commit 6379dae

File tree

2 files changed

+50
-42
lines changed

2 files changed

+50
-42
lines changed

plugins/arcgis/service/src/FeatureQuerier.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ export class FeatureQuerier {
6767
params: { f: 'json' }
6868
});
6969

70-
this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse.toString)
71-
const result = queryResponse as QueryObjectResult
72-
response(result);
70+
this._console.info('ArcGIS response for ' + queryUrl + ' ' + JSON.stringify(queryResponse, null, 2))
71+
response(queryResponse as QueryObjectResult)
7372
}
7473

7574
/**
@@ -91,9 +90,8 @@ export class FeatureQuerier {
9190
params: { f: 'json' }
9291
});
9392

94-
this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse)
95-
const result = queryResponse as QueryObjectResult
96-
response(result)
93+
this._console.info('ArcGIS response for ' + queryUrl + ' ' + JSON.stringify(queryResponse, null, 2))
94+
response(queryResponse as QueryObjectResult)
9795
}
9896

9997
/**
@@ -108,13 +106,19 @@ export class FeatureQuerier {
108106
queryUrl.searchParams.set('outFields', this.outFields([field]));
109107
queryUrl.searchParams.set('returnGeometry', 'false');
110108
this._console.info('ArcGIS query: ' + queryUrl)
111-
112-
const queryResponse = await request(queryUrl.toString(), {
113-
authentication: this._identityManager
114-
});
115-
this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse)
116-
const result = queryResponse as QueryObjectResult
117-
response(result)
109+
110+
try {
111+
const queryResponse = await request(queryUrl.toString(), {
112+
authentication: this._identityManager,
113+
params: { f: 'json' }
114+
115+
});
116+
117+
this._console.info('ArcGIS response for ' + queryUrl + ' ' + JSON.stringify(queryResponse, null, 2))
118+
response(queryResponse as QueryObjectResult)
119+
} catch (err) {
120+
console.error("could not query", err)
121+
}
118122
}
119123

120124
/**

plugins/arcgis/service/src/ObservationsSender.ts

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -270,20 +270,22 @@ export class ObservationsSender {
270270
* @param objectId The arc object id of the observation.
271271
*/
272272
private async sendAttachment(attachment: ArcAttachment, objectId: number) {
273-
const file = path.join(this._attachmentDirectory, attachment.contentLocator!)
274-
275-
const fileName = this.attachmentFileName(attachment)
276-
this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file)
277-
278-
const readStream = await fs.openAsBlob(file)
279-
const test = new File([readStream], fileName)
280-
281-
addAttachment({
282-
url: this._url,
283-
authentication: this._identityManager,
284-
featureId: objectId,
285-
attachment: test
286-
}).catch((error) => this._console.error(error));
273+
if (attachment.contentLocator) {
274+
const file = path.join(this._attachmentDirectory, attachment.contentLocator!)
275+
276+
const fileName = this.attachmentFileName(attachment)
277+
this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file)
278+
279+
const readStream = await fs.openAsBlob(file)
280+
const attachmentFile = new File([readStream], fileName)
281+
282+
addAttachment({
283+
url: this._url,
284+
authentication: this._identityManager,
285+
featureId: objectId,
286+
attachment: attachmentFile
287+
}).catch((error) => this._console.error(error));
288+
}
287289
}
288290

289291
/**
@@ -293,21 +295,23 @@ export class ObservationsSender {
293295
* @param attachmentId The observation arc attachment id.
294296
*/
295297
private async updateAttachment(attachment: ArcAttachment, objectId: number, attachmentId: number) {
296-
const file = path.join(this._attachmentDirectory, attachment.contentLocator!)
297-
298-
const fileName = this.attachmentFileName(attachment)
299-
this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file)
300-
301-
const readStream = await fs.openAsBlob(file)
302-
const test = new File([readStream], fileName)
303-
304-
updateAttachment({
305-
url: this._url,
306-
authentication: this._identityManager,
307-
featureId: objectId,
308-
attachmentId,
309-
attachment: test
310-
}).catch((error) => this._console.error(error));
298+
if (attachment.contentLocator) {
299+
const file = path.join(this._attachmentDirectory, attachment.contentLocator!)
300+
301+
const fileName = this.attachmentFileName(attachment)
302+
this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file)
303+
304+
const readStream = await fs.openAsBlob(file)
305+
const attachmentFile = new File([readStream], fileName)
306+
307+
updateAttachment({
308+
url: this._url,
309+
authentication: this._identityManager,
310+
featureId: objectId,
311+
attachmentId,
312+
attachment: attachmentFile
313+
}).catch((error) => this._console.error(error));
314+
}
311315
}
312316

313317
/**

0 commit comments

Comments
 (0)