To know what visual domain analysis is, you need to know what the visual domain is.
We're standing somewhere, all the things we can see in a circle are called visual fields. Of course there is no such thing as a visual field.
What if it's in the mountains? The visible range will be blocked by the mountain. This analysis is of great importance to the military.
In this case, the visual field exists in the form of graphics[in Graphiclayer.
This example uses the Geoprocessor class. How does the object of this class distinguish me from the visual domain analysis? And listen to my slow way.
Look at the results
Click on the location of the valley, there is a red dot, a little more than 10s, the appearance of orange noodles, orange face block is the location of the red dot can see the range (compared to the desktop of the visual domain analysis or weak point), compared to the desktop is the WYSIWYG.
This is not in the AJS 3.x, because there is a powerful 3D analysis function.
Geoprocessor class
This class is very powerful, and unlike the previous four tasks, the processing parameters it accepts are no longer a class, but an object array. In other words, what kind of parameters will be entered when dealing with them?
The official examples are as follows:
Assuming there are input_points and distance two parameters that need to be entered, then
This object is passed in the Execute () method of the Geoprocessor class:
{ <FeatureSet>, <Number>}
This is where the GP class is powerful. If an asynchronous operation is required, save the Web wait time by using submitjob () instead of the Execute () method.
The Execute () method of the Geoprocessor class returns an object that contains the following:
Two properties, we are concerned with the results property, which is the parametervalue[] type. I would like to say parametervalue this class, which is very similar to the previous result class.
ParameterValue class
It is the results property type in the return value of execute () or submitjob ().
It has three properties: DataType (String type), Declareclass, and Value (object type)
What do you mean? The result of GP processing is, of course, determined by the input parameters, so in this case, datatype is defined as "Record-set" or "Feature-record-set-layer", that is, the Value property is boxed into the FeatureSet type.
The value of the datatype determines the value type, see this table: Point I
With these preliminary knowledge, it is not difficult to explain this example and the next example.
Give a reference
require ([ "Esri/map" " esri/views/ Sceneview "" Esri/layers/graphicslayer ", "esri/graphic" "Esri/geometry/point" , /span> "Esri/symbols/simplemarkersymbol" "Esri/symbols/simplefillsymbol" Span style= "COLOR: #000000", "Esri/tasks/geoprocessor" "esri/tasks/ Support/linearunit " "Esri/tasks/support/featureset" "dojo/domready!" ", function (Map, Sceneview, Graphicslayer, Graphic, point, Simplemarkersymbol, Simplefillsymbol, Geoprocessor, Linearunit, Feat Ureset) {...});
Well, a reference to Geoprocessor.
Function framework
function(...) { varGpurl = "Https://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/ESRI_Elevation_World/GPServer/Viewshed"; varMap =NewMap ({...}); varView =NewSceneview ({...}); varGraphicslayer =NewGraphicslayer ({...)}; Map.add (Graphicslayer); varMarkersymbol =NewSimplemarkersymbol ({...}); varFillsymbol =NewSimplefillsymbol ({...}); varGP =Newgeoprocessor (Gpurl); Gp.outspatialreference= {...}; //FocusView.on ("click", computeviewshed); functioncomputeviewshed (Event) {...} functionDrawresultdata (Result) {...}}
I don't have to explain a lot when I think about this, and we focus directly on the key code of the data processing: The view's Click event and two processing functions computeviewshed () and Drawresultdata ().
The instantiation of this geoprocessor class in GP has been explained above, not so detailed.
Computeviewshed (Event) method
This method is a bit long, but the meaning of each line is clear. What it does is get the click Point, generate a red dot symbol, then get the input parameters of Gp.execute () and execute the Execute () method.
functioncomputeviewshed (Event) {Graphicslayer.removeall (); varPoint =NewPoint ({longitude:event.mapPoint.longitude, latitude:event.mapPoint.latitude}); varInputgraphic =NewGraphic ({geometry:point, symbol:markersymbol}); Graphicslayer.add (inputgraphic); varInputgraphiccontainer = []; Inputgraphiccontainer.push (inputgraphic); varFeatureSet =NewFeatureSet (); Featureset.features=Inputgraphiccontainer; varVsdistance =NewLinearunit (); Vsdistance.distance= 5; Vsdistance.units= "Miles"; varparams = { "Input_observation_point": FeatureSet,"Viewshed_distance": Vsdistance}; Gp.execute (params). then (drawresultdata);}computeviewshed () method
First, the graphics layer is zeroed to get the click Point, which is named points (an instance of the Dot class);
Then, a graphic object is formed according to this point, named Inputgraphic, to be added to the graphics layer (show click points);
After that, the parameters required to analyze the service according to the visual domain
"Input_observation_point" and "viewshed_distance", respectively, to instantiate the required parameters FeatureSet objects and Vsdistance objects for the FeatureSet class and Linearunit class data, form the params object; Execute Gp.execute (params). Finally, execute (params) then an asynchronous operation then (Drawresultdata), drawing the processing result. We already know that the results property in the object returned here is the parametervalue[] type. We just need to get the visual domain data (featureset) from it. Drawresultdata () method
function Drawresultdata (Result) { var resultfeatures = result.results[0].value.features; var viewshedgraphics = Resultfeatures.map (function(feature) { = fillsymbol; return feature; }); Graphicslayer.addmany (viewshedgraphics); View.goto ({ target:viewshedgraphics, 0 });}
Result is the object that is returned by execute (), gets the features (type graphic[]) in the value of Results[0], named Resultfeatures.
Iterate over this graphic[] variable (map () method), set the fill symbol for each graphic, and return a new graphic[] variable viewshedgraphics;
Then add this graphic[] variable to the graphics layer;
Finally, let the view jump to this graphics layer.
Summarize
Click to get this bit information--generate the required set of parameters (object type) for the desired visual domain analysis through this point, pass in Gp.execute ()--process and display the visible fields in the returned Object object.
Perfect!
ArcGIS API for JavaScript 4.2 learning Note [28] visual Domain Analysis "using the Geoprocessor class"