I have a script in a **Work Order Management System** ([Maximo][1]) that performs a **[spatial query][2]**. Details: 1. Takes the X&Y coordinates of a work order in Maximo 2. [Generates a URL][3] from the coordinates (including other spatial query information) 3. Executes the URL via a separate script/library (LIB_HTTPCLIENT) 4. Performs a **spatial query** in an [ESRI REST feature service][4] (in a separate [GIS system][5]) 5. [JSON text][6] is returned to Maximo with the attributes of the zone that the work order intersected 6. The zone number is parsed from the JSON text via a separate script/library (LIB_PARSE_JSON) 7. Inserts the zone number into the work order record -------------------------------- **Jython main automation script** from psdi.mbo import MboConstants from java.util import HashMap #Get the y and x coordinates(UTM projection) from the WOSERVICEADDRESS table via the SERVICEADDRESS system relationship #The datatype of the LatitydeY and LongitudeX is decimal: 1234567.8335815760, 123456.4075621164 #Convert the decimals to integers, and then strings, for the purpose of generating the URL (I don't think the URL can have decimal places) laty = str(mbo.getInt("SERVICEADDRESS.LatitudeY")) longx = str(mbo.getInt("SERVICEADDRESS.LONGITUDEX")) #Verify if the numbers are legitimate UTM coordinates if len(laty) == 7 and len(longx) == 6: #Assemble the URL (including the longx and the laty). Note: The coordinates are flipped in the url url="http://something.com/arcgis/rest/services/something/Zones/MapServer/15/query?geometry=" + longx + "%2C" + laty + "&geometryType=esriGeometryPoint&spatialRel=esriSpatialRelIntersects&outFields=*&returnGeometry=false&f=pjson" #Get the JSON text from the feature service (the JSON text contains the zone value) ctx = HashMap() ctx.put("url",url) service.invokeScript("LIB_HTTPCLIENT",ctx) json_text = str(ctx.get("response")) #Parse the zone value from the JSON text ctx = HashMap() ctx.put("json_text",json_text) service.invokeScript("LIB_PARSE_JSON",ctx) parsed_val = str(ctx.get("parsed_val")) #Enter the zone value into the zone field in the work order mbo.setValue("DESCRIPTION","Waste Zone: "+parsed_val,MboConstants.NOACCESSCHECK) **Jython library (LIB_HTTPCLIENT)** from psdi.iface.router import HTTPHandler from java.util import HashMap from java.lang import String handler = HTTPHandler() map = HashMap() map.put("URL",url) map.put("HTTPMETHOD","GET") responseBytes = handler.invoke(map,None) response = String(responseBytes,"utf-8") **JavaScript library (LIB_PARSE_JSON)** #The field name (ZONE) is hardcoded in the LIB_PARSE_JSON. I'm not sure if this is best practice or not. var obj = JSON.parse(json_text); parsed_val = obj.features[0].attributes.ZONE -------------------------- How can this code be improved? [1]: https://www.ibm.com/products/maximo [2]: https://stackoverflow.com/questions/56587515/maximo-spatial-query [3]: https://i.sstatic.net/dO2nk.png [4]: https://enterprise.arcgis.com/en/server/10.5/publish-services/windows/what-is-a-feature-service-.htm [5]: https://www.esri.com/en-us/arcgis/about-arcgis/overview [6]: https://i.sstatic.net/xmJXS.png