Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { queryFeatures } = require("@esri/arcgis-rest-feature-layer");
const fs = require("fs");
const fetch = require('node-fetch');
require('isomorphic-form-data')
const outFileName = `./output/${Date.now()}.geojson`
const outFile = fs.createWriteStream(outFileName);
const serviceUrl = "https://services.arcgis.com/uUvqNMGPm7axC2dD/arcgis/rest/services/Boating_Access_Sites/FeatureServer/0/query";
// const params = {
// outSR: "4326",
// returnGeometry: true,
// f: "geojson"
// };
queryFeatures({
url: serviceUrl,
outSR: "4326",
returnGeometry: true,
f: "geojson",
rawResponse: true,
fetch: fetch
}).then((resp) => {
//Access any response methods, or ReadableStream body
//https://developer.mozilla.org/en-US/docs/Web/API/Response
const stream = resp.body
stream.pipe(outFile);
stream.on('data', (data) => {
console.log("Buffering: ", data)
});
stream.on('end', () => {
console.log(`Finished: ${outFileName}`);
params: IParamsQueryMetadata
): Promise {
const fields = config['metadata-layer'].fields;
const FIELD_NAME_SRC_DATE = fields[0].fieldname;
const FIELD_NAME_SRC_PROVIDER = fields[1].fieldname;
const FIELD_NAME_SRC_NAME = fields[2].fieldname;
const FIELD_NAME_SRC_RES = fields[3].fieldname;
const FIELD_NAME_SRC_ACC = fields[4].fieldname;
const queryUrl = this.getQueryUrl(params.releaseNum, params.zoom);
const outFields = fields.map((d) => d.fieldname);
try {
const queryResponse = (await queryFeatures({
url: queryUrl,
geometry: params.pointGeometry,
geometryType: 'esriGeometryPoint',
spatialRel: 'esriSpatialRelIntersects',
outFields,
returnGeometry: false,
f: 'json',
})) as IQueryFeaturesResponse;
const feature: IFeature =
queryResponse.features && queryResponse.features.length
? queryResponse.features[0]
: null;
const date = feature.attributes[FIELD_NAME_SRC_DATE];
const provider = feature.attributes[FIELD_NAME_SRC_PROVIDER];
return new Promise((resolve, reject) => {
if (dispatchers && dispatchers.url) {
queryFeatures({
url: dispatchers.url,
where: "userId = '" + name + "'",
authentication: destinationAuthentication
}).then(
(results: any) => {
if (results && results.features) {
if (results.features.length === 0) {
addFeatures({
url: dispatchers.url,
features: [
{
attributes: {
name: fullName,
userId: name
}
}
async getRNumsFromDetectionLayer(
pointInfo: IMapPointInfo,
zoomLevel: number
): Promise> {
const queryUrl = this.changeDetectionLayerUrl + '/query';
const fields = config['change-detection-layer'].fields;
const FIELD_NAME_ZOOM = fields[0].fieldname;
const FIELD_NAME_RELEASE_NUM = fields[1].fieldname;
const FIELD_NAME_RELEASE_NAME = fields[2].fieldname;
try {
const queryResponse = (await queryFeatures({
url: queryUrl,
geometry: pointInfo.geometry,
geometryType: 'esriGeometryPoint',
spatialRel: 'esriSpatialRelIntersects',
where: `${FIELD_NAME_ZOOM} = ${zoomLevel}`,
outFields: [FIELD_NAME_RELEASE_NUM],
orderByFields: FIELD_NAME_RELEASE_NAME,
returnGeometry: false,
f: 'json',
})) as IQueryFeaturesResponse;
const rNums: Array =
queryResponse.features && queryResponse.features.length
? queryResponse.features.map((feature: IFeature) => {
return feature.attributes[FIELD_NAME_RELEASE_NUM];
})
(results: any) => {
if (results && results.features) {
if (results.features.length === 0) {
addFeatures({
url: dispatchers.url,
features: [
{
attributes: {
name: fullName,
userId: name
}
}
],
authentication: destinationAuthentication
}).then(
addResults => {
if (addResults && addResults.addResults) {
resolve(true);
} else {
reject(