ParksFinder - Query Returns all Features

1686
3
12-17-2012 07:20 AM
BrianLord1
Occasional Contributor
I am in the process of configuring the ParksFinder template from the Local Government resource center.  I have gotten everything to work except for that when I try to select parks that are within the 1 mile buffer the query returns all the parks in my map service.

I have changed the spatial reference throughout my app to match my services.  When I use Firebug I can see the extent sent through the query seems to be correct, but the query always returns all the park features.

The spatial reference I am currently using is "wkid: 103779".  I have also reomved all references to esri services including the routing functionality, so I am not sure why there would be an issue with my spatial reference.  I have tested out some attribute queries and they all work, so it is definitely an issue with the spatial relationship portion of the query statement.

Here is the code for my query task...
/function for drawing the buffer
function DoBuffer(bufferDistance, mapPoint) {
    if (mapPoint && bufferDistance) {
        var params = new esri.tasks.BufferParameters();
        params.distances = [bufferDistance];
        params.unit = esri.tasks.GeometryService.UNIT_STATUTE_MILE;
        params.bufferSpatialReference = map.spatialReference;
        params.outSpatialReference = map.spatialReference;
        params.geometries = [mapPoint];
        params.unionResults = true;
        geometryService.buffer(params, ShowBuffer);
        features = [];
    }
}

//function for Displaying the buffer
function ShowBuffer(geometries) {
    ClearBuffer();
    var lineColor = new dojo.Color();
    lineColor.setColor(rendererColor);
    var fillColor = new dojo.Color();
    fillColor.setColor(rendererColor);
    fillColor.a = 0.55;
    var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,
        new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
        lineColor, 2),
        fillColor);
    dojo.forEach(geometries, function (geometry) {
        AddGraphic(map.getLayer(tempBufferLayer), symbol, geometry);
    });

    map.setExtent(geometries[0].getExtent().expand(1.2));
    QueryLayer(geometries[0]);
}



//function for getting the features and their length with in the buffer region
function QueryLayer(geometry) {
    var cityName = "CITY OF BIG LAKE";
            var qTask = 'qTask';
            qTask = new esri.tasks.QueryTask(devPlanLayerURL);
            var query = new esri.tasks.Query();
            query.geometry = geometry;
            query.outFields = ["*"];
            query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_WITHIN;
            query.returnGeometry = true;

            qTask.execute(query, function (featureset) {
                if (dojo.byId('spanParkActivityContainer')) {
                    dojo.byId('spanParkActivityContainer').style.display = 'none';
                }
                dojo.byId('spanParkListContainer').innerHTML = 'Found ' + featureset.features.length + ' park(s) near the address';
                CreateDistance(featureset);
        });
    }


Anyone ever experience an issue like this before?  Any help would be greatly appreciated.
0 Kudos
3 Replies
JeffSmith
Esri Contributor
Mark,
What version of ArcGIS Server are you using?  There are several known issues unique to 10.0 or 10.1 related to Rest queries on map services with joins.  I suspect this is what you are running into and I can provide more information once I know what version you have.

Jeff
0 Kudos
JacobDeuel1
New Contributor II
I am also experiencing this issue.  I am using ArcGIS for Server 10.1.
0 Kudos
JeffSmith
Esri Contributor
If you are using AGS 10.1 SP1, my recommendation would be to move the Parks feature class to an ArcSDE gdb and keep the ParkRecInfo table in a fgdb.  When you do this, make sure to adjust the join in the MXD so it references the correct table. 

There are a couple of bugs involved in this that are working against each other.  The Rest query operation returns all results when the feature class and joined table are both in a fgdb.  This should be fixed in AGS 10.2.  If they are both moved to an ArcSDE gdb, the Rest query works but the Find operation fails.  This is fixed by moving the table to a fgdb.  If the Search function in the app still fails, please review this KB to verify you have the alias configured properly.
0 Kudos