Select to view content in your preferred language

Differences between IdentifyTask and QueryTask

1010
2
09-27-2011 06:11 AM
BryanLynn
New Contributor III
Why does the identify task return all the data as strings and the query task return all data in it's native format? This is confusing!!

I have to have multiple functions to process my results because sometimes it is a number and sometimes it is a string. Am I missing something or is this how it was designed?

Just to make things more confusing - the query task does something funky to my numeric fields turning 0.999952 into 0.99995215999999998.

Below are some example results:
Identify results:
{
"results" : [
{
"layerId" : 0,
"layerName" : "City Survey Control Points",
"value" : "514",
"displayFieldName" : "STATION_ID",
"attributes" : {
"OBJECTID" : "514",
"STATION" : "0523",
"CORDN" : "610091.677",
"CORDE" : "2584285.79",
"NEW_ELEV88" : "968.33",
"NEW_ELEV29" : "968.76",
"ELTYPE" : "Level",
"LAT" : "355929.0023",
"LONG_" : "835505.8453",
"MAPANG" : "11307.4",
"SCALE" : "0.999952",
"REVISED" : "8/1/2011",
"ESTABLISHED" : "3/1/1994",
"DESTROYED" : "ACTIVE",
"CLT" : "81E",
"BLOCK" : "11221",
"STATO1" : "0522",
"STATO2" : "0128",
"STATO3" : "Null",
"STATO4" : "Null",
"STATO5" : "Null",
"DESC_" : "3.25\" aluminum disk set in a sidewalk, stamped \"CITY OF KNOXVILLE SURVEY CONTROL MONUMENT, 0523, 1994\"",
"LOCATION" : "The station is set in the sidewalk, on the S side of Cecil Av, between houses #1416 and #1422.",
"WITNESS" : "8.0' S of the face of curb\n4.0' N of the back of sidewalk\n32.5' SW of a fire hydrant",
"DATUM" : "NAD83(NSRS2007)",
"Shape" : "Point"
},
"geometryType" : "esriGeometryPoint",
"geometry" :
{
"x" : 2584285.78997248,
"y" : 610091.67685847,
"spatialReference" : {
"wkid" : 2915
}
}
}
]
}

Query Results:
"features" : [
{
"attributes" : {
"OBJECTID" : 514,
"STATION" : "0523",
"CORDN" : 610091.67700000003,
"CORDE" : 2584285.79,
"NEW_ELEV88" : 968.33000000000004,
"NEW_ELEV29" : 968.75999999999999,
"ELTYPE" : "Level",
"LAT" : 355929.00229999999,
"LONG_" : 835505.84530000004,
"MAPANG" : 11307.4,
"SCALE" : 0.99995215999999998,
"REVISED" : 1312156800000,
"ESTABLISHED" : 762480000000,
"DESTROYED" : 0,
"CLT" : " 81E",
"BLOCK" : "11221",
"STATO1" : "0522",
"STATO2" : "0128",
"STATO3" : null,
"STATO4" : null,
"STATO5" : null,
"DESC_" : "3.25\" aluminum disk set in a sidewalk, stamped \"CITY OF KNOXVILLE SURVEY CONTROL MONUMENT, 0523, 1994\"",
"LOCATION" : "The station is set in the sidewalk, on the S side of Cecil Av, between houses #1416 and #1422.",
"WITNESS" : "8.0' S of the face of curb\r\n4.0' N of the back of sidewalk\r\n32.5' SW of a fire hydrant",
"DATUM" : "NAD83(NSRS2007)"
}
}
]
0 Kudos
2 Replies
derekswingley1
Frequent Contributor II
This is actually a question better targeted at the REST API. If you look at the result of an identify or query task directly in your browser, you'll see that the results are what you've described:

Identify:  http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapSe...

Query: http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapSe...

They're just being passed through to you by the JS API. One thing to note is that the query result contains field types while the identify result does not.

Regarding 0.999952 turning into 0.99995215999999998, I would guess it probably has to do with floating point math, good explanation here: http://stackoverflow.com/questions/588004/is-javascripts-math-broken
0 Kudos
BryanLynn
New Contributor III
Thanks for the info.  I agree the REST API forum is a better place to post my question.  I typically work with Silverlight but switched to JS API for this project when I ran across the issue.  I realize it would exist in the Silverlight world as well, I just haven't came across it yet.
0 Kudos