shinichi

Find or Query or other option?

Discussion created by shinichi on Jan 16, 2013
Latest reply on Mar 13, 2013 by SHarihar-esristaff
Hi

Can anyone tell me how to solve this?

Assume you have a vehicle tracking records from Oct.1 to Dec. 31 with wind speed information.
All data is saved in geodatabase and up in ArcGIS Server 10.1 as feature layer.
A time slider show the locations of a car with wind speed.

When a user change a time-range (eg. Oct.2 - Oct.4), first query task (for count) calculate the number of features within the range.
There are usually more than 1000 results even two days (eg. 1750) (I don't want to change this limit though).

I used another query task (executeforIds) to keep all records in hand but reduce the amount with modulus (1/10) which is still enough number for making a chart for an overall trend of wind speed.
With the reduced number of layersIds (175 points), third query find layers' attribute to retrieve wind data.
However, I also want to provide an option to download a whole dataset in csv.

Here, I used findtask to retrieve attribute dataset within the time-range.
    try {
        //console.log(app.objIDs);
        var attribs;
        csvdata = "";

        var find = new esri.tasks.FindTask("http://gcoosmaps.tamu.edu/arcgis/rest/services/Glider/Waveglider_USM_CTD_WM/MapServer");
        var params = new esri.tasks.FindParameters();
        params.layerIds = [0];
        params.searchFields = ["OBJECTID"];

        for (var i = 0; i < app.objIDs.length; i++) {
            params.searchText = app.objIDs[i];
            find.execute(params, function (results) {
                attribs = results[0].feature.attributes;
                csvdata += attribs.Date_Central + ',' + attribs.Longitude + "," + attribs.Latitude + "," + attribs.windspeed + "\n";
                console.log(csvdata); //1
            }, function (error) {
                alert("Error");
            });
        }
    } catch (error) {
        alert("Change the time range first");
    }
    console.log(csvdata); //2
    setTimeout(function () {
        formatData(app.csvdata);
    }, (3 * 1000));


csvdata was undefined at console.log2, although all csvdata (in console.log1) show data in console.
Issue seems timing of find.execute complete, so I added setTimeout.

This seems work but when i increase the time-range, it won't obviously.

Is there anyway to keep all records (1000 - 200,000) in a specific time range and export to csv?
Any ideas/help appreciated!

Thanks
Shin

Outcomes