Embodiment
Below in conjunction with the drawings and specific embodiments, the present invention is described in detail.
The method of the crucial farming season online visual forecast of regional agriculture of the present invention, comprises the following steps:
Step 1, Arcmap is utilized to make regional agriculture map base map issuing;
Step 2, the geographic information processing model of foundation crucial farming season are also issued geography and are processed service;
Step 3, drafting to region of crucial farming season;
Step 4, carry out Distance geometry area measuring;
The border of step 5, adjustment key farming season drawing area;
Step 6, determine and export crucial farming season visual net result figure.
Below for Meteorological Services of harvesting and sowing in summer in the crucial farming season of state, Linxia, Gansu Province, the concrete steps of the inventive method are described in detail.
Step 1, Arcmap is utilized to make regional agriculture map base map issuing
First, Arcmap desktop software is utilized to carry out registration and rectification to administrative region at county level, national city map, therefrom cut out the local geographic information of face layer and the zone boundary of line chart layer of setting administrative region, as shown in Figure 1, embodiment is cities and counties belonging to state, Linxia, Gansu Province, comprise the state circle 1 in state, Linxia, county's name 2 and circle of county 3, a service definition file is created after producing map base map (document), its suffix is set to .sd, be a portable file again by service definition Document encapsulation, wherein contain Service Properties, the relevant information such as function and COS,
Then, input the URL address http://< server name >:6080/arcgis/manager/ of ArcGIS Server (service managerZ-HU) in a browser, with keeper (Manager) identity logs service managerZ-HU, select the service definition file that will issue in Services tab in service managerZ-HU, click next step input service newname; In default situations, service definition file is by under being distributed to catalogue file folder specified in service managerZ-HU configuration; Clicking issue, is Map Services by service definition file distribution.
Step 2, the geographic information processing model of foundation crucial farming season are also issued geography and are processed service
Utilize the model constructor in Arcmap, cutting order is performed in ArcToolbox, arranging input parameter type is Feature set, as Fig. 2, using state, Linxia map as base map (i.e. cutting key element), input polygon (input key element) state, cutting Linxia map, input key element, cutting key element and output key element are all set to model parameter, so far, geographic information processing model is set up complete;
Run this geographic information processing model, on service managerZ-HU, be shared as geographical process service by running the result successfully, service execution mode is asynchronous execution, chooses " returning results Map Services " option.
Step 3, drafting to region of crucial farming season
3.1) the service season that selection will be drawn in control panel and paint type, wherein serve that Season select spring ploughing is sowed in spring, summer harvesting and sowing, autumn harvest autumn sowing or other opportunitys, the paint type that corresponding spring ploughing is sowed in spring has following one week suitable sowing division, be comparatively suitable for sowing division, be not suitable for sowing division and other; The paint type of corresponding summer harvesting and sowing has heading, blooms, milking maturity, will gather in, gather in, gathered in and other, and the paint type of corresponding autumn harvest autumn sowing has will be gathered in the crops, gathering in the crops and gathering in the crops;
A kind of color block of choosing that can be corresponding when selecting paint type carries out distinctiveness display on map.
3.2) the self-defined figure of reading and saving in XML file, shows on the map base map layer that is added to after completing.
3.2.1) by calling a dojo.xhrGet function in Dojo kit in HTTP request, carry out requested database server (be two different equipment from the service managerZ-HU in step 1) resource in URL mode, access obtains the address that graphical page getGraphic.aspx and URL identifies;
3.2.2) be Json character string by XML data Content Transformation, define a StringBuilder object on the backstage of page getGraphic.aspx, the path path according to XML file finds XML file; By the property content of the label in XML file and label, be spliced into a Json character string according to the AppendFormat method of StringBuilder object, finally return this Json character string;
3.2.3) to step 3.2.2) in the JSon string data that returns carry out pre-service, then pass to the call back function of load properties point in dojo.xhrGet function, call back function can be called after the database server resource of request successfully return;
3.2.4) the function graphics.add that call back function performs in ArcGIS API for javascript adds self-defined figure to map base map and shows;
3.3) define drawing tools and drafting polygon Show Styles is set
Definition drawing instrument toolbars.Draw, in ArcGIS API for Javascript, event response process function map.on loads successfully at map base map and activates drawing instrument, the color of filled polygon is set, wherein the rgb value of Fill Color is random value, as shown in Figure 3, map is clicked with mouse and draws out a polygonal region along a direction, represent " will gather in " regional extent in summer harvesting and sowing Meteorological Services with this.
3.4) drawing area call geographical process service
Using step 3.3) in the polygonal region drawn as geography process import of services parameter, call geographical process service.
Because three parameters (namely input key element, cutting key element and export key element) of geographic information processing model in step 2 are all model parameters, parameter can change flexibly, such as, select as required to arrange the map that cutting key element is state, Linxia map or certain counties and cities of subordinate, state, Linxia.
3.5) delete step 3.3) the middle polygon drawn, by step 3.4) in geographical process service operation result to be added to map base map layer, according to paint type color corresponding under COS in control panel, rendering result layer, as shown in Figure 4, if what when drawing polygon, COS was selected is summer harvesting and sowing Meteorological Services, what corresponding paint type was selected is to gather in, will gather in corresponding color is RGB (255, 0, 255), region " will be gathered in " with this color rendering, other regions simultaneously on map are covered by the polygon of different colours respectively, the distribution of summer harvesting and sowing different phase spatial visualization is represented with this, thus guiding agricultural production is carried out in order more intuitively.
Step 4, carry out Distance geometry area measuring
4.1) projective transformation
The coordinate system at map base map place is geographic coordinate system, need to be transformed into plane coordinate system (corresponding to computer screen), only be in plane coordinate system and just can carry out Distance geometry area measuring, so will projective transformation be done, carry out the conversion of coordinate system.
If calculate the conversion apart from then adopting " isogonism " to project, if the conversion that reference area then adopts " equivalance " to project.
4.2) the amount calculation of distance or area is carried out according to the line drawn or face
Judge that geometric figure type is line (polyline) or face (polygon), if just carry out lengths distance exam for line type; If simplify face operation for Noodles type needs first to carry out simplify, and then carry out area measuring.
The border of step 5, adjustment key farming season drawing area
Definition edit tool toolbars.Edit, activates drawing instrument in event response process function map.on;
Choose the region of crucial farming season generated in step 3, editor's break of region, can editor be pulled to the single break in border or translation be carried out to region entirety, such as choose " will gather in " region in summer harvesting and sowing farming season, all breaks of zone boundary are activated, both can carry out dragging editor by mouse, also can move integrally whole " will gather in " region.
Step 6, determine and export crucial farming season visual net result figure
6.1) region of crucial farming season in determining step 5 after adjustment
6.1.1) by calling a dojo.xhrGet function in Dojo kit in HTTP request, requested database server resource is carried out in URL mode, the address that the access Delete Shape page deleteFile.aspx and URL identifies, a judgement is done on Delete Shape page backstage, judge whether XML file exists, if existed, then carry out deleting the operation of this XML file;
6.1.2) attribute of polygonal region is set, mainly id and title, adopts the mode that parameter is corresponding.All polygonal regions covered on map base map after adjustment last in step 5 are read out, the corresponding id of each polygonal region, title all called after graphic of all polygonal regions, by calling dojo.toJson function in Dojo kit, will all polygonal regions be got and be converted to Json format string;
6.1.3) the Json character string of all polygonal regions is submitted to database server to preserve, an XmlDocument object is defined on the backstage of page saveGraphic.aspx, the path path of XML file is set, by the Json character string of all polygonal regions, according to the label of the SelectSingleNode method splicing XML file of XmlDocument object, with the tag attributes content of the CreateElement method of XmlDocument object splicing XML file, with this, all graphical informations are saved as XML file;
6.2) preserve and export final visualization result of crucial farming season
Call the PrintingTools service in ArcGIS API for Javascript, adopt predefined map base map layout, adjustment resolution obtains map base map image (namely by deriving such map requests), export key farming season prog chart, thus more convenient shared visual achievement.