Good morning everyone,
I am trying to develop an application using ArcGIS JavaScript API, one of the function is draw a box on map and do the spatial query, then only the features inside or intersect with the box are display and all the rest feature should disappear.
currently I use spatial query from box and get all the feature OIDs and then add definition query like,
OBJECTID in (123, 124, 1245, .....2111)
However since our map service point to Oracle database, oracle have limitation on number of values in the list, currently is 1000, so if there are more than 1000 values in the list, then definition query won't work, and the entire layer disappear.
Can anyone point out other doable strategy to overcome such limitation in Oracle. I appreciate whoever replies.
my current codes something like this:
function SpatialQuery_Complete(event) {
console.log("selection count: " + event.features.length);
window.statusbar.visible = true;
var productionSum = 0;
var defQueryFld = "OBJECTID";
var definitionQueryWhere = defQueryFld + " IN (";
for(var i = 0; i < event.features.length; i++){
window.status= "Processing " + i + " of " + event.features.length;
definitionQueryWhere = definitionQueryWhere + event.features.attributes.OBJECTID;
if (i == (event.features.length - 1) )
definitionQueryWhere = definitionQueryWhere + ")";
else
definitionQueryWhere = definitionQueryWhere + ",";
}
svcLayer.setLayerDefinitions([null, null,definitionQueryWhere, null, null]); //set layer definition
svcLayer.setVisibleLayers([2, 5]); //turn on layer
}
Dave Zhang @GDOT
Solved! Go to Solution.
Thank you very much, Helen.
We are using JavaScript API, and a bit different from your case, but your approach point me to a very useful way to work with large selection set without limitation, I tried your way in JavaScript, it works, too. appreciate your response.
I also find another way to work without using graphics and work around of Oracle limitation. My approach is using "OR" operation in where clause:
whereClasue = “OID in (1, 2, 3, …999) or OID in (1000, 1001, 1002 … 1998) or OID in (1999, 2000, 2001 … 2997)”
DynamicLayer.setLayerDefinitions([whereClasue,null, null, null, null]);
this approach has an extra advantage, that is the map will sync with the legend.
Juncheng Zhang
We use .NET and SQL server on the web map application. Not sure about how Oracle works with ESRI JavaScript. We use query(Intersect) to select feature. The following is the sample code. Our application is more complex and I delete some code so the code below may not run well. You might get some idea on some steps.
function queryGraphic(geometry, count) {
//step 1: query polygon
var queryTask1 = new QueryTask("https://...../MapServer/0");
var query1 = new Query();
query1.returnGeometry = true;
query1.outFields = ["*"];
//query1.outFields = ["Id","BuildingName", "BuildingNumber", "EntityName"];
query1.geometry = geometry;
query1.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;
queryTask1.execute(query1);
//console.log("geometry query1 " + JSON.stringify(geometry));
queryTask1.on("complete", function (event1) {
var fset1 = event1.featureSet;
var queryFeatures = fset1.features;
var queryGeometrySet = [];
var countyFeatureLayer = new FeatureLayer("https://...../MapServer/1",
{ mode: FeatureLayer.MODE_SELECTION, outFields: ["*"], infoTemplate: infoTemplate}); //user draw polygon
countyFeatureLayer.selectFeatures(query1, FeatureLayer.SELECTION_NEW);
//console.log("countyFeatureLayer " + countyFeatureLayer);
//step 2: change symbology and add ID to list
for (var i = 0; i < queryFeatures.length; i++) {
var graphic1 = queryFeatures;
if (graphic1.geometry.type == "polygon") { //add feature is polygon
var querySymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255, 0, 0]), 2), new Color([255, 0, 0, 0.5]));
} else { //features are points
var querySymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 9,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([26, 26, 26]), 1), new Color([26, 163, 255, 0.95]));
}
//get Id
id = graphic1.attributes.Id;
console.log("point feature id " + id);
}
var layerGraphics = new Graphic(graphic1.geometry, querySymbol, infoTemplate);
map.graphics.add(layerGraphics);
queryGeometrySet.push(graphic1.geometry);
console.log("graphic1 " + JSON.stringify(graphic1));
}
}
Thank you very much, Helen.
We are using JavaScript API, and a bit different from your case, but your approach point me to a very useful way to work with large selection set without limitation, I tried your way in JavaScript, it works, too. appreciate your response.
I also find another way to work without using graphics and work around of Oracle limitation. My approach is using "OR" operation in where clause:
whereClasue = “OID in (1, 2, 3, …999) or OID in (1000, 1001, 1002 … 1998) or OID in (1999, 2000, 2001 … 2997)”
DynamicLayer.setLayerDefinitions([whereClasue,null, null, null, null]);
this approach has an extra advantage, that is the map will sync with the legend.
Juncheng Zhang