AnsweredAssumed Answered

How to improve Feature layer selectFeatures response time and reliability of result set.

Question asked by mk_swati on Mar 6, 2017
Latest reply on Mar 6, 2017 by alfarrar3

I am following the example code available at https://community.esri.com/thread/162053 to implement the scenario to filter down till parcel level. I have 50 districts, 100 sub districts, 10000 villages and more than 4 million parcels. I am using ArcGIS API 3.19 with ArcGIS Server 10.2.1 and my data resides in SQL Server.
So far I have created four features layers one for each level.

Districts = new FeatureLayer("http://localhost:6080/arcgis/rest/services/Province/SelectService/MapServer/3", { 
mode: FeatureLayer.MODE_SELECTION, outFields: ["*"] });
subDistrict = new FeatureLayer("http://localhost:6080/arcgis/rest/services/Province/SelectService/MapServer/2", {
mode: FeatureLayer.MODE_SELECTION, outFields: ["*"] });
Village = new FeatureLayer("http://localhost:6080/arcgis/rest/services/Province/SelectService/MapServer/1", {
mode: FeatureLayer.MODE_SELECTION, outFields: ["*"] });
Parcels = new FeatureLayer("http://localhost:6080/arcgis/rest/services/Province/SelectService/MapServer/0", {
mode: FeatureLayer.MODE_SELECTION, outFields: ["*"] });

My filter function which is called on change event of combobox and filter the child combobox along with zoom to that level.

applyFilter function(displayValue, which){ 
Districts.clearSelection();
SubDistricts.clearSelection();
Village.clearSelection();
Parcels.clearSelection();
var query = new Query();
var thePoly, theExtent;
if(which == "District"){
this.subDistrictDijit.reset();
this.villageDijit.reset();
this.parcelDijit.reset();
query.where = "DISTRICT='" + (displayValue).toString() + "'";
console.info(query.where);
query.returnGeometry = true;
Districts.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (features) {
thePoly = features[0].geometry;
theExtent = thePoly.getExtent().expand(2); //Zoom out slightly from the polygon's extent
app.map.setExtent(theExtent);
});
esriRequest({
url: "http://localhost:6080/arcgis/rest/services/Province/SelectService/MapServer/2/query?where=DISTRICT='" +
displayValue.toString() + "'&outFields=SUBDISTRICT&returnGeometry=false&orderByFields=SUBDISTRICT&returnDistinctValues=true&f=json",
content:{
f:'json'
},
handleAs:'json',
callbackParamName:'callback',
timeout:15000
}).then(lang.hitch(this,function(response){
var store2 = new Memory({data:[]});
this.subDistrictDijit.set('store',store2);
var data = array.map(response.features,lang.hitch(this,function(feat, index){
var name = feat.attributes.SUBDISTRICT;
var dataItem = {
id:index,
name:name
};
return dataItem;
}));
store2 = new Memory({data:data});
this.subDistrictDijit.set('store',store2);
this.subDistrictDijit.set('placeholder', 'Select SUBDISTRICT');


}));
}else if(which == "SUBDISTRICT"){
this.villageDijit.reset();
this.parcelDijit.reset();
var subDistrict = (displayValue).toString();
query.where = "SUBDISTRICT='" + taluka + "'";
console.info(query.where);
query.returnGeometry = true;
SubDistricts.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (features) {
thePoly = features[0].geometry;
theExtent = thePoly.getExtent().expand(2); //Zoom out slightly from the polygon's extent
app.map.setExtent(theExtent);
});
esriRequest({
url: "http://localhost:6080/arcgis/rest/services/Province/SelectService/MapServer/1/query?where=SUBDISTRICT='" +
displayValue.toString() + "'&outFields=VILLAGE&returnGeometry=false&orderByFields=VILLAGE&returnDistinctValues=true&f=json",
content:{
f:'json'
},
handleAs:'json',
callbackParamName:'callback',
timeout:20000
}).then(lang.hitch(this,function(response){
var store2 = new Memory({data:[]});
this.villageDijit.set('store',store2);
var data = array.map(response.features,lang.hitch(this,function(feat, index){
var name = feat.attributes.VILLAGE;
var dataItem = {
id:index,
name:name
};
return dataItem;
}));
store2 = new Memory({data:data});
this.villageDijit.set('placeholder', 'Select Village');
this.VillageDijit.set('store',store2);

}));
} else if(which == "Village"){
this.parcelDijit.reset();
var village = (displayValue).toString();
query.where = "VILLAGE='" + village + "'";
console.info(query.where);
query.returnGeometry = true;
Village.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (features) {
thePoly = features[0].geometry;
theExtent = thePoly.getExtent().expand(2); //Zoom out slightly from the polygon's extent
app.map.setExtent(theExtent);
});
esriRequest({
url: "http://localhost:6080/arcgis/rest/services/Province/SelectService/MapServer/0/query?where=VILLAGE='" +
displayValue.toString() + "'&outFields=SURVEY_NO&returnGeometry=false&orderByFields=SURVEY_NO&returnDistinctValues=true&f=json",
content:{
f:'json'
},
handleAs:'json',
callbackParamName:'callback',
timeout:15000
}).then(lang.hitch(this,function(response){
var store2 = new Memory({data:[]});
this.parcelDijit.set('store',store2);
var data = array.map(response.features,lang.hitch(this,function(feat, index){
var name = feat.attributes.SURVEY_NO;
var dataItem = {
id:index,
name:name
};
return dataItem;
}));
store2 = new Memory({data:data});
this.parcelDijit.set('placeholder', 'Select Parcel Survey No');
this.parcelDijit.set('store',store2);

}));
}else if(which == "Parcel"){
var parcel = (displayValue).toString();
query.where = "SURVEY_NO='" + parcel + "' AND VILLAGE='" + this.villageDijit.displayedValue.toString() + "'" ;
console.info(query.where);
query.returnGeometry = true;
Parcels.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (features) {
thePoly = features[0].geometry;
theExtent = thePoly.getExtent().expand(2); //Zoom out slightly from the polygon's extent
app.map.setExtent(theExtent);
});
}
}



Now the problem with my above approach is that some time is works well that is combobox filled with distinct records from JSON returned from feature selection but some time it doesn't work.I guess it is because of the number of records in parcel table that take too much time to respond. I need suggestion how to improve the response time to get response from parcel feature service.

 

Do I need to make separate service for each district? Or there is any other option to filter the dataset for faster processing.

Thanks,

Outcomes