query against features from imported shapefile

1976
4
Jump to solution
02-09-2016 09:57 PM
LefterisKoumis
Occasional Contributor III

i use the addshapefile widget to add a widget to the map and then I tried to run a query to capture features of the shapefile that intercept the buffer around a line segment. However I get the message:

"FeatureLayer::selectFeatures - query contains one or more unsupported parameters".

Can the feature layer from the shapefile be used for query?

Thank you.

myfeaturelayer is the feature layer from the shapefile created from:

arrayUtils.forEach(featureCollection.layers, lang.hitch(this, function (layer) {
        var infoTemplate = new InfoTemplate("Details", "${*}");
        var featureLayer = new FeatureLayer(layer, {
          infoTemplate: infoTemplate
        });

Buffer Widget:

The resultEvent is the geometry of a line

var myquery = new Query();
  myquery.geometry = resultEvent;
  myquery.returnGeometry = true;
  myquery.outFields = ["*"];
  myquery.outSpatialReference = this.map.spatialReference;
  myquery.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;
  this.myfeatureLayer.selectFeatures(myquery,FeatureLayer.SELECTION_NEW);
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   When you create a FeatureLayer from a feature collection you are limited to what functionality it has as noted in the FeatureLayer Help:

Creates a new instance of a feature layer using a FeatureCollection object. The feature layer, when initialized with a feature collection object has the following behavior:

  • Edits are applied on the client not posted to the server.
  • The feature layer generates a unique object id for new features.
  • Does not support queries that need to be performed on the server, e.g. queries with a where clause or non-extent based spatial queries.
  • The feature layer toJson method returns an object with the same properties as the feature collection. The returned object includes all the features that are in the layer when the method is called. This method can be used to access a serializable representation of the features that can be saved on the server.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   When you create a FeatureLayer from a feature collection you are limited to what functionality it has as noted in the FeatureLayer Help:

Creates a new instance of a feature layer using a FeatureCollection object. The feature layer, when initialized with a feature collection object has the following behavior:

  • Edits are applied on the client not posted to the server.
  • The feature layer generates a unique object id for new features.
  • Does not support queries that need to be performed on the server, e.g. queries with a where clause or non-extent based spatial queries.
  • The feature layer toJson method returns an object with the same properties as the feature collection. The returned object includes all the features that are in the layer when the method is called. This method can be used to access a serializable representation of the features that can be saved on the server.
LefterisKoumis
Occasional Contributor III

Thank you Robert. Got one more question. the text in bold states "queries with a where clause or non-extent based spatial queries".

The query that I am using has no where clause.  If I replace the geometry of the query with an extent to create an extent based query, will that work?

var queryExtent = new esri.geometry.Extent(x-tol,y-tol,x+tol,y+tol,evt.mapPoint.spatialReference);
        myquery.geometry = queryExtent;
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

  Based on the use notes, that should work.

0 Kudos
LefterisKoumis
Occasional Contributor III

I just checked it. It does work. Thank you.

0 Kudos