栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Maximo / GIS空间查询

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Maximo / GIS空间查询

Maximo
76脚本功能

(pdf)的“库脚本”部分中修改代码:

#What the script does:#     1. Takes the X&Y coordinates of a work order in Maximo#     2. Generates a URL from the coordinates#     3. Executes the URL via a separate script/library (LIB_HTTPCLIENT)#     4. Performs a spatial query in an ESRI REST feature service (a separate GIS system)#     5. Returns JSON text to Maximo with the attributes of the zone that the work #        order intersected#     6. Parses the zone number from the JSON text#     7. Inserts the zone number into the work order recordfrom psdi.mbo import MboConstantsfrom java.util import HashMapfrom com.ibm.json.java import JSONObjectfield_to_update = "ZONE"gis_field_name = "ROADS_ZONE"def get_coords():    """    Get the y and x coordinates(UTM projection) from the WOSERVICEADDRESS table    via the SERVICEADDRESS system relationship.    The datatype of the LatitdeY and LongitudeX fields is decimal.    """    laty  = mbo.getDouble("SERVICEADDRESS.LatitudeY")    longx = mbo.getDouble("SERVICEADDRESS.LongitudeX")    #Test values    #laty  = 4444444.7001941890    #longx = 666666.0312127020    return laty, longxdef is_latlong_valid(laty, longx):    #Verify if the numbers are legitimate UTM coordinates    return (4000000 <= laty <= 5000000 and 600000 <= longx <= 700000)def make_url(laty, longx, gis_field_name):    """    Assembles the URL (including the longx and the laty).    Note: The coordinates are flipped in the url.    """    url = (        "http://hostname.port"        "/arcgis/rest/services/Example"        "/Zones/MapServer/15/query?"        "geometry={0}%2C{1}&"        "geometryType=esriGeometryPoint&"        "spatialRel=esriSpatialRelIntersects&"        "outFields={2}&"        "returnGeometry=false&"        "f=pjson"    ).format(longx, laty, gis_field_name)    return urldef fetch_zone(url):    # Get the JSON text from the feature service (the JSON text contains the zone value).    ctx = HashMap()    ctx.put("url", url)    service.invokescript("LIBHTTPCLIENT", ctx)    json_text = str(ctx.get("response"))    # Parse the zone value from the JSON text    obj = JSONObject.parse(json_text)    parsed_val = obj.get("features")[0].get("attributes").get(gis_field_name)    return parsed_valtry:    laty, longx = get_coords()    if not is_latlong_valid(laty, longx):        service.log('Invalid coordinates')    else:        url = make_url(laty, longx, gis_field_name)        zone = fetch_zone(url)        #Insert the zone value into the zone field in the work order        mbo.setValue(field_to_update, zone, MboConstants.NOACCESSCHECK)        service.log(zone)except:    #If the script fails, then set the field value to null.    mbo.setValue(field_to_update, None, MboConstants.NOACCESSCHECK)    service.log("An exception occurred")

LIBHTTPCLIENT :(可重用的Jython
库脚本)

from psdi.iface.router import HTTPHandlerfrom java.util import HashMapfrom java.lang import Stringhandler = HTTPHandler()map = HashMap()map.put("URL", url)map.put("HTTPMETHOD", "GET")responseBytes = handler.invoke(map, None)response = String(responseBytes, "utf-8")


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/377933.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号