3

In ArcGIS REST Services Directory when querying a service the values that are set as floats or doubles (elevation, lat, long) return with too many significant digits if the format is JSON. For example if an elevation is 189.9 (and set to have only two decimal places in the attribute table of the original) GET JSON returns 189.9000000001. This seems to only happen where the last digit is a 0. The same thing happens with lat, long. In order to share this service with an outside user they need less significant digits returned. Is there a way to set the significant digits regardless of the 0 in the hundredths place when returning XML?

enter image description here

Returns:{
 "displayFieldName": "County",
 "fieldAliases": {
  "OBJECTID": "OBJECTID",
  "County": "County",
  "USGS_____F": "USGS_____F",
  "Date": "Date",
  "Time": "Time",
  "Depth_to_W": "Depth_to_W",
  "Water_Leve": "Water_Leve",
  "Method_of": "Method_of",
  "Accuracy_o": "Accuracy_o",
  "Lat": "Lat",
  "Long": "Long"
 },
 "geometryType": "esriGeometryPoint",
 "spatialReference": {
  "wkid": 102100,
  "latestWkid": 3857
 },
 "fields": [
  {
   "name": "OBJECTID",
   "type": "esriFieldTypeOID",
   "alias": "OBJECTID"
  },
  {
   "name": "County",
   "type": "esriFieldTypeString",
   "alias": "County",
   "length": 254
  },
  {
   "name": "USGS_____F",
   "type": "esriFieldTypeString",
   "alias": "USGS_____F",
   "length": 254
  },
  {
   "name": "Date",
   "type": "esriFieldTypeDate",
   "alias": "Date",
   "length": 8
  },
  {
   "name": "Time",
   "type": "esriFieldTypeString",
   "alias": "Time",
   "length": 254
  },
  {
   "name": "Depth_to_W",
   "type": "esriFieldTypeDouble",
   "alias": "Depth_to_W"
  },
  {
   "name": "Water_Leve",
   "type": "esriFieldTypeString",
   "alias": "Water_Leve",
   "length": 254
  },
  {
   "name": "Method_of",
   "type": "esriFieldTypeString",
   "alias": "Method_of",
   "length": 254
  },
  {
   "name": "Accuracy_o",
   "type": "esriFieldTypeString",
   "alias": "Accuracy_o",
   "length": 254
  },
  {
   "name": "Lat",
   "type": "esriFieldTypeDouble",
   "alias": "Lat"
  },
  {
   "name": "Long",
   "type": "esriFieldTypeDouble",
   "alias": "Long"
  }
 ],
 "features": [
  {
   "attributes": {
    "OBJECTID": 1110,
    "County": "HOLMES",
    "USGS_____F": "051N0010",
    "Date": 1247097600000,
    "Time": "UNKNOWN CST",
    "Depth_to_W": 189.90000000000001,
    "Water_Leve": "Feet",
    "Method_of": "Tape Down",
    "Accuracy_o": "±0.2 ft",
    "Lat": 33.102849999999997,
    "Long": -89.915080000000003
   },
   "geometry": {
    "x": -10009301.557499999,
    "y": 3908964.3601000011
   }
  }
 ]
}
  • Can you provide a query example in your question? – artwork21 Jan 5 '17 at 14:38
  • @artwork21 Hope that helps. – jaw485 Jan 5 '17 at 15:34
  • I've written a proxy servlet to reformat and pretty-print JSON, but it's not necessary for computer transfer. – Vince Jan 5 '17 at 20:39
1

In ArcMap you can specify a format for any field in the layer properties dialog. Open the Fields tab, select the field and click on the ... button after Number Format. This value should be used by ArcGIS Server too.

To specify the number of decimals for coordinates of the geometry field, a client can set the geometryPrecision parameter of the REST request, e.g. http://server/arcgis/rest/blah/blah/query?where=1=1&geometryPrecision=2&blah&blah .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.