The user inputs some text parameters. The GP script runs a bunch of Python on the server that's basically some fairly straightforward math & field calculations. The input layer is on a point layer stored in SDE. The first step of the GP script is to make a copy of the point data that is put in the JOBID/%scratchworksace%, so that the user isn't writing to the SDE layer (the GP service only has viewer access, anyway). This results is a essentially the copy of the input points with a new field that ranks the points. So depending on the user inputs, the points will rank out differently. The results are brought into the map. They look great and I can query them individually, but I want the user to be able to access the whole table of results and interact with it a la ArcMap desktop.
Possible to add a step at the end of GP to copy those scratch result points to a permanent feature class which is published through its own .mxd which is published to it's own .msd which is its own service on your server with a known path. The python script will also re-save the .mxd after the old data has been overwritten with the new query data or even increment a number at the end of the feature class name (ie. results1, results2, etc.), re-export to .msd, restart the service, and clear the REST cache and that one service will just be dynamically changed each time they run a query. Just the first idea that came to mind. There's probably better alternatives.
Yes -- that's a good thought. It could run into problems if there are concurrent users, though, no?
That could cause some issues, yes, but there's always ways around that depending on how you decide to do it. Bad thing about round-about ideas like mine are the performance factors.
Erik, The only way you are going to get a datagrid displayed for this GP process data is to do a custom widget. Which like you stated is probably a little deep for you. The eSearch does not support displaying attributes of a layer that does not come from a MapService.
If I am successful, I'll be sure to make the results available for interested folks.
I'm interested. How can I learn more?
Hi Frederic,If you are interested in getting into the Flex coding...
I am definately interested. I sent you a message with more details. Thanks.
<?xml version="1.0" encoding="utf-8"?> <viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:esri="http://www.esri.com/2008/ags" xmlns:viewer="com.esri.viewer.*" xmlns:supportClasses="com.esri.ags.skins.supportClasses.*" xmlns:renderers="com.esri.ags.renderers.*" widgetConfigLoaded="init()"> <fx:Script> <![CDATA[ import com.esri.ags.FeatureSet; import com.esri.ags.Graphic; import com.esri.ags.Map; import com.esri.ags.events.ExtentEvent; import com.esri.ags.events.GeoprocessorEvent; import com.esri.ags.geometry.Extent; import com.esri.ags.geometry.Geometry; import com.esri.ags.geometry.MapPoint; import com.esri.ags.layers.GraphicsLayer; import com.esri.ags.renderers.supportClasses.UniqueValueInfo; import com.esri.ags.symbols.SimpleFillSymbol; import com.esri.ags.tasks.supportClasses.*; import com.esri.ags.tasks.supportClasses.JobInfo; import com.esri.ags.tasks.supportClasses.LinearUnit; import com.esri.ags.tasks.supportClasses.ParameterValue; import com.esri.ags.utils.GraphicUtil; import com.esri.ags.utils.WebMercatorUtil; import flash.events.Event; import flash.utils.flash_proxy; import flashx.textLayout.tlf_internal; import mx.collections.ArrayCollection; import mx.collections.IList; import mx.controls.Alert; import mx.core.mx_internal; import mx.events.CloseEvent; import mx.events.EffectEvent; import mx.events.FlexEvent; import mx.events.ListEvent; import mx.rpc.Fault; import mx.rpc.events.FaultEvent; import mx.utils.ArrayUtil; import mx.utils.ObjectUtil; import spark.events.GridEvent; import spark.events.TextOperationEvent; [Bindable] private var taskurl:String; private var myGraphicsLayer:GraphicsLayer; [Bindable] private var resultAttributes: ArrayCollection; private var selGraphic:Graphic; private var fs: FeatureSet; private var highlightedGraphic:Graphic; private var requestObject:Object; [Bindable] public var inputArr:Array = new Array(); private var inputFR:FileReference = new FileReference(); public function init():void { if (configXML) // checking for valid content in the configuration file { myGraphicsLayer = new GraphicsLayer(); taskurl = configXML.taskurl; } else { Alert.show("Problem with config.xml file") } map.doubleClickZoomEnabled= true; } //geoprocessor fault handler private function gp_faultHandler(event:FaultEvent):void { Alert.show(event.fault.message.toString() ); } //parameter input submit button handler private function submit_clickHandler(event:MouseEvent):void { myGraphicsLayer.clear(); var requestObject:Object = createRequestObject(); gp.submitJob(requestObject); // CursorManager.setBusyCursor(); setCurrentState("Processing",true); } //creates the request object from the input parameter values private function createRequestObject():Object { var metric1:String = met1.text; var metric2:String = met2.selectedItem; var metric3:String = met3.text; requestObject ={ "Metric_1":metric1, "Metric_2":metric2, "Metric_3":metric3}; return requestObject; } //fires when geoprocessor finishes. retrives result data protected function gp_jobCompleteHandler(event:GeoprocessorEvent):void { if (event.jobInfo.jobStatus == JobInfo.STATUS_SUCCEEDED) { gp.addEventListener(GeoprocessorEvent.GET_RESULT_DATA_COMPLETE, onGetResult); gp.getResultData(gp.submitJobLastResult.jobId, "Result"); } else { Alert.show("Geoprocessing Error"); } } //fires when the results have been received. renders the results & grahics to map, gets attributes protected function onGetResult(event : GeoprocessorEvent) : void { myGraphicsLayer.renderer = ResultRenderer(); //this is a separate unique value renderer compenent var pv:ParameterValue = event.parameterValue; fs = new FeatureSet; fs = pv.value as FeatureSet; for each(var graphic:Graphic in fs.features) { myGraphicsLayer.add(graphic); } map.addLayer(myGraphicsLayer); var resultAttribute:Array = fs.attributes; resultAttributes= new ArrayCollection(resultAttribute); } //selects result graphic when clicked on and finds matching record in datagrid protected function graphic_clickHandler(event:MouseEvent):void { selGraphic = Graphic(event.target); for each(var attributes : Object in resultsGrid.dataProvider) { if (attributes === selGraphic.attributes) { resultsGrid.selectedIndex = (resultsGrid.dataProvider as ArrayCollection).getItemIndex(attributes) } } resultsGrid.ensureCellIsVisible(resultsGrid.selectedIndex); resultsGrid.setSelectedIndex(resultsGrid.selectedIndex); } //helper function to find the graphic from the selected datagrid row protected function findGraphicByAttribute(attributes : Object) : Graphic { for each( var foundGraphic : Graphic in myGraphicsLayer.graphicProvider) { if ( foundGraphic.attributes.OBJECTID === attributes.OBJECTID) { return foundGraphic; } } return null; } //zoom to the selected point when datagrid row is double clicked protected function resultsGrid_gridDoubleClickHandler(event:GridEvent):void { var pt:MapPoint = null; pt = highlightedGraphic.geometry as MapPoint; if (map.scale > 80000) map.scale = 50000; map.centerAt(pt); } ]]> </fx:Script> <fx:Declarations> <esri:Geoprocessor id="gp" jobComplete="gp_jobCompleteHandler(event)" fault="gp_faultHandler(event)" processSpatialReference="{map.spatialReference}" outSpatialReference="{map.spatialReference}" showBusyCursor="false" url="{taskurl}" useAMF="false" updateDelay="2000" /> </fx:Declarations> <viewer:WidgetTemplate id="myWidget" width="450" height="600" > <s:Group id="widgetGrp" width="100%" height="100%"> <s:Group id="paramsArea"> <s:TextInput id="met1" x="68" y="48" width="210" height="20"/> <s:ComboBox id="met2" x="120" y="75" selectedItem="{}"> <s:ArrayCollection> <fx:String></fx:String> <fx:String>AND</fx:String> <fx:String>AND NOT</fx:String> <fx:String>OR</fx:String> </s:ArrayCollection> </s:ComboBox> <s:TextInput id="met3" x="68" y="105" width="210" height="20"/> <s:Button id="submit" x="300" y="720" label="Submit" click="submit_clickHandler(event)"/> </s:Group> <s:Group id="resultsArea"> <s:DataGrid id="resultsGrid" width="100%" height="98%" dataProvider="{resultAttributes}" mouseFocusEnabled="true" verticalScrollPolicy="auto" doubleClickEnabled="true" gridDoubleClick="resultsGrid_gridDoubleClickHandler(event)" bottom="24"> <s:columns> <s:ArrayList> <s:GridColumn dataField="Field1" width="250"/> <s:GridColumn dataField="Field2" width="65"/> <s:GridColumn dataField="Field3" width="100"/> </s:ArrayList> </s:columns> </s:DataGrid> </s:Group> </s:Group> </viewer:WidgetTemplate> </viewer:BaseWidget>
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.