<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Buffer query results vary in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/buffer-query-results-vary/m-p/1226427#M79152</link>
    <description>&lt;P&gt;I'll follow this post up with more details and a jsbin, but right now I was wondering if there is something obvious with this issue and what I can do to troubleshoot it further. I have a layerView query that executes on a buffer. Sometimes, maybe 40% of the time, the query results excludes a few of the buffered parcels by not adding its graphic (as shown in image A), other times the parcel is completely excluded from the query results. My next troubleshooting is to perform the query directly in ArcGIS execute form and try to reproduce the results I'm seeing here.&lt;/P&gt;&lt;P&gt;image A&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GregoryBologna_0-1666904236967.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/54666i24D279051CE7C8C8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GregoryBologna_0-1666904236967.png" alt="GregoryBologna_0-1666904236967.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;image B&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GregoryBologna_1-1666904376768.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/54667iF63D5D82C0702672/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GregoryBologna_1-1666904376768.png" alt="GregoryBologna_1-1666904376768.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The basic workflow here is to query geometry with a buffer size and units (like feet), then add graphics to view and update a table with the results of the query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function queryLayerView() {
	const queryObject = mapLayerView.createQuery();
	queryObject.geometry = sketchGeometryMode();
	queryObject.units = unitType;
	queryObject.distance = bufferSize;
	queryObject.spatialRelationship = 'intersects'; // this is default
	//queryObject.returnGeometry = true;
	queryObject.outSpatialReference = view.spatialReference;
	//queryObject.returnQueryGeometry = true;
	//queryObject.returnTrueCurves = true;
	//queryObject.returnZ = false;
	//queryObject.returnM = false;
	queryObject.outFields = ['*']; // all required fields for dataTable export
	//queryObject.orderByFields = ['PAR_SUBDIVISION', 'TAXPARCELTYPE'];
	queryObject.orderByFields = ['TAXPARCELTYPE', 'PAR_SUBDIVISION'];
	//queryObject.returnExtentOnly = false;
	//queryObject.returnExceededLimitFeatures = true;
	//queryObject.quantizationParameters = {
	//	mode: "view",
	//	originPosition: "upper-left",
	// 	tolerance: 4820,
	// 	extent: mapLayerView.fullExtent
	// },

	// Negate query when user unselects all tax parcel types
	if (taxParcelTypesSelectedString != '') {
		queryObject.where = `TAXPARCELTYPE IN(${taxParcelTypesSelectedString})`;
	} else {
		queryObject.where = `TAXPARCELTYPE NOT IN(${taxParcelTypesDefaultString})`;
	}

	let el = document.getElementById('calcite-block-instruction');
	if (el) {
		el.heading =
			'Now use the Buffer selection slider to create ' +
			'a geodesic buffer around the parcel boundary of your point.' +
			'Highlighted parcels will be saved to a table for downloading.';
	}
	let sub_count = {};

	// If you query a layerView each time the view extent changes, 
	// then you must wait until the layerView's updating property 
	// becomes false to make sure the layerView finished fetching 
	// the features for that extent.
	bufferLayerViewUpdatingFlag = true;
	reactiveUtils.whenOnce(() =&amp;gt; !mapLayerView.updating)
		.then(() =&amp;gt; {
			bufferLayerViewUpdatingFlag = false;
		});

	bufferSymbolData = []; // reset
	let symbol_id = 0;
	return mapLayerView
		.queryFeatures(queryObject)
		.then((layerView) =&amp;gt; {
			if (!bufferLayerViewUpdatingFlag) {
				view.graphics.removeAll();

				let newlayerView = layerView;

				layerView.features.forEach((feature) =&amp;gt; {
					let p = feature.attributes.PAR_SUBDIVISION;
					sub_count[p] = (sub_count[p] || 0) + 1;
				});

				layerView.features.forEach((feature) =&amp;gt; {
					let par = feature.attributes.PARID;
					let sub = feature.attributes.PAR_SUBDIVISION;
					let tax = feature.attributes.TAXPARCELTYPE;

					let isSubject = lookupSubjectParid(par);

					if (bufferSymbolData.find((n) =&amp;gt; (n.sub === sub) &amp;amp; (n.tax != 'PARCEL')))
						if (sub_count[sub] &amp;gt; 1) return;

					let symbolColor = '';

					let taxParcelType = feature.attributes.TAXPARCELTYPE;
					let rgb = taxParcelTypeColors.filter((obj) =&amp;gt; {
						if (obj)
							if (Object.keys(obj)[0] === taxParcelType)
								return obj[taxParcelType];
					});
					if (rgb &amp;amp;&amp;amp; rgb.length &amp;gt; 0) symbolColor = rgb[0][taxParcelType];

					let symbol = {
						type: 'simple-fill',
						outline: { color: [11, 53, 51, 1] },
						color: !isSubject ? symbolColor : symbolColorSubject,
					};
					let g = new Graphic({
						geometry: feature.geometry,
						//attributes: feature.attributes, // not needed for coloring
						symbol: symbol,
					});
					view.graphics.add(g);

					if (showBufferMapIntersectsRank &amp;amp;&amp;amp; !isSubject) {

						view.graphics.add(g);

					}
					bufferSymbolData.push({ par: par, sub: sub, tax: tax, symbol: symbol_id });
				});

				// Exlude the selected parcel address in data table
				if (newlayerView.features &amp;amp;&amp;amp; newlayerView.features.length &amp;gt; 0) {
					updateDataTable(newlayerView, bufferSymbolData)
						.then(ScrollLastAccordionIntoView)
						.catch((error) =&amp;gt; {
							console.error(error);
							throw new PaoException('queryLayerView', error);
						});
				}
			}
			return true;
			//}
		}, console.error)
		.then(() =&amp;gt; {
			symbol_id = 0;
		});
} // end

// set the geometry query on the visible mapLayerView
let debouncedRunQuery = promiseUtils.debounce(function () {
	if (!sketchGeometry) {
		return;
	}
	updateBufferPolygon(bufferSize);

	// clear highlighting when shared parcel lines and distance = 0
	if (bufferSize === 0) {

		view.graphics.removeAll();
		clearDataTable();
		return;
	}
	return promiseUtils.eachAlways([queryLayerView()]);
}); // end&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Oct 2022 21:44:34 GMT</pubDate>
    <dc:creator>GregoryBologna</dc:creator>
    <dc:date>2022-10-27T21:44:34Z</dc:date>
    <item>
      <title>Buffer query results vary</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/buffer-query-results-vary/m-p/1226427#M79152</link>
      <description>&lt;P&gt;I'll follow this post up with more details and a jsbin, but right now I was wondering if there is something obvious with this issue and what I can do to troubleshoot it further. I have a layerView query that executes on a buffer. Sometimes, maybe 40% of the time, the query results excludes a few of the buffered parcels by not adding its graphic (as shown in image A), other times the parcel is completely excluded from the query results. My next troubleshooting is to perform the query directly in ArcGIS execute form and try to reproduce the results I'm seeing here.&lt;/P&gt;&lt;P&gt;image A&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GregoryBologna_0-1666904236967.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/54666i24D279051CE7C8C8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GregoryBologna_0-1666904236967.png" alt="GregoryBologna_0-1666904236967.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;image B&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GregoryBologna_1-1666904376768.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/54667iF63D5D82C0702672/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GregoryBologna_1-1666904376768.png" alt="GregoryBologna_1-1666904376768.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The basic workflow here is to query geometry with a buffer size and units (like feet), then add graphics to view and update a table with the results of the query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function queryLayerView() {
	const queryObject = mapLayerView.createQuery();
	queryObject.geometry = sketchGeometryMode();
	queryObject.units = unitType;
	queryObject.distance = bufferSize;
	queryObject.spatialRelationship = 'intersects'; // this is default
	//queryObject.returnGeometry = true;
	queryObject.outSpatialReference = view.spatialReference;
	//queryObject.returnQueryGeometry = true;
	//queryObject.returnTrueCurves = true;
	//queryObject.returnZ = false;
	//queryObject.returnM = false;
	queryObject.outFields = ['*']; // all required fields for dataTable export
	//queryObject.orderByFields = ['PAR_SUBDIVISION', 'TAXPARCELTYPE'];
	queryObject.orderByFields = ['TAXPARCELTYPE', 'PAR_SUBDIVISION'];
	//queryObject.returnExtentOnly = false;
	//queryObject.returnExceededLimitFeatures = true;
	//queryObject.quantizationParameters = {
	//	mode: "view",
	//	originPosition: "upper-left",
	// 	tolerance: 4820,
	// 	extent: mapLayerView.fullExtent
	// },

	// Negate query when user unselects all tax parcel types
	if (taxParcelTypesSelectedString != '') {
		queryObject.where = `TAXPARCELTYPE IN(${taxParcelTypesSelectedString})`;
	} else {
		queryObject.where = `TAXPARCELTYPE NOT IN(${taxParcelTypesDefaultString})`;
	}

	let el = document.getElementById('calcite-block-instruction');
	if (el) {
		el.heading =
			'Now use the Buffer selection slider to create ' +
			'a geodesic buffer around the parcel boundary of your point.' +
			'Highlighted parcels will be saved to a table for downloading.';
	}
	let sub_count = {};

	// If you query a layerView each time the view extent changes, 
	// then you must wait until the layerView's updating property 
	// becomes false to make sure the layerView finished fetching 
	// the features for that extent.
	bufferLayerViewUpdatingFlag = true;
	reactiveUtils.whenOnce(() =&amp;gt; !mapLayerView.updating)
		.then(() =&amp;gt; {
			bufferLayerViewUpdatingFlag = false;
		});

	bufferSymbolData = []; // reset
	let symbol_id = 0;
	return mapLayerView
		.queryFeatures(queryObject)
		.then((layerView) =&amp;gt; {
			if (!bufferLayerViewUpdatingFlag) {
				view.graphics.removeAll();

				let newlayerView = layerView;

				layerView.features.forEach((feature) =&amp;gt; {
					let p = feature.attributes.PAR_SUBDIVISION;
					sub_count[p] = (sub_count[p] || 0) + 1;
				});

				layerView.features.forEach((feature) =&amp;gt; {
					let par = feature.attributes.PARID;
					let sub = feature.attributes.PAR_SUBDIVISION;
					let tax = feature.attributes.TAXPARCELTYPE;

					let isSubject = lookupSubjectParid(par);

					if (bufferSymbolData.find((n) =&amp;gt; (n.sub === sub) &amp;amp; (n.tax != 'PARCEL')))
						if (sub_count[sub] &amp;gt; 1) return;

					let symbolColor = '';

					let taxParcelType = feature.attributes.TAXPARCELTYPE;
					let rgb = taxParcelTypeColors.filter((obj) =&amp;gt; {
						if (obj)
							if (Object.keys(obj)[0] === taxParcelType)
								return obj[taxParcelType];
					});
					if (rgb &amp;amp;&amp;amp; rgb.length &amp;gt; 0) symbolColor = rgb[0][taxParcelType];

					let symbol = {
						type: 'simple-fill',
						outline: { color: [11, 53, 51, 1] },
						color: !isSubject ? symbolColor : symbolColorSubject,
					};
					let g = new Graphic({
						geometry: feature.geometry,
						//attributes: feature.attributes, // not needed for coloring
						symbol: symbol,
					});
					view.graphics.add(g);

					if (showBufferMapIntersectsRank &amp;amp;&amp;amp; !isSubject) {

						view.graphics.add(g);

					}
					bufferSymbolData.push({ par: par, sub: sub, tax: tax, symbol: symbol_id });
				});

				// Exlude the selected parcel address in data table
				if (newlayerView.features &amp;amp;&amp;amp; newlayerView.features.length &amp;gt; 0) {
					updateDataTable(newlayerView, bufferSymbolData)
						.then(ScrollLastAccordionIntoView)
						.catch((error) =&amp;gt; {
							console.error(error);
							throw new PaoException('queryLayerView', error);
						});
				}
			}
			return true;
			//}
		}, console.error)
		.then(() =&amp;gt; {
			symbol_id = 0;
		});
} // end

// set the geometry query on the visible mapLayerView
let debouncedRunQuery = promiseUtils.debounce(function () {
	if (!sketchGeometry) {
		return;
	}
	updateBufferPolygon(bufferSize);

	// clear highlighting when shared parcel lines and distance = 0
	if (bufferSize === 0) {

		view.graphics.removeAll();
		clearDataTable();
		return;
	}
	return promiseUtils.eachAlways([queryLayerView()]);
}); // end&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 21:44:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/buffer-query-results-vary/m-p/1226427#M79152</guid>
      <dc:creator>GregoryBologna</dc:creator>
      <dc:date>2022-10-27T21:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Buffer query results vary</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/buffer-query-results-vary/m-p/1226615#M79160</link>
      <description>&lt;P&gt;Update to this issue. I have identified the reason why some&amp;nbsp;&lt;SPAN&gt;buffered parcels are not selected. The&amp;nbsp;&lt;SPAN class=""&gt;layerView&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;features&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;length is zero. Finding this info,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#returnGeometry" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#returnGeometry&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;If&amp;nbsp;true, the&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FeatureSet.html#queryGeometry" target="_blank" rel="noopener"&gt;query geometry&lt;/A&gt;&amp;nbsp;will be returned with the query results. It is useful for getting the buffer geometry generated when querying features by&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#distance" target="_blank" rel="noopener"&gt;distance&lt;/A&gt;&amp;nbsp;or getting the query geometry projected in the&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#outSpatialReference" target="_blank" rel="noopener"&gt;outSpatialReference&lt;/A&gt;&amp;nbsp;of the query. The query geometry is returned only for&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatures" target="_blank" rel="noopener"&gt;client-side queries&lt;/A&gt;&amp;nbsp;and&amp;nbsp;&lt;A href="http://doc.arcgis.com/en/arcgis-online/share-maps/hosted-web-layers.htm" target="_blank" rel="noopener"&gt;hosted feature services&lt;/A&gt;&amp;nbsp;and if the layer's&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities" target="_blank" rel="noopener"&gt;capabilities.query.supportsQueryGeometry&lt;/A&gt;&amp;nbsp;is&amp;nbsp;true.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Setting&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;returnQueryGeometry&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;true so far appears to resolve this issue.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 14:30:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/buffer-query-results-vary/m-p/1226615#M79160</guid>
      <dc:creator>GregoryBologna</dc:creator>
      <dc:date>2022-10-28T14:30:38Z</dc:date>
    </item>
  </channel>
</rss>

