The Slice Map Service uses the flex API to edit and update the slice map.

Source: Internet
Author: User

ArcGIS flex API 2.0 began to support access to the feature service of ArcGIS Server 10 for editing.

Flex:

Minwidth = "955" minheight = "600"
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"
>





Url = "http: // localhost: 8399/ArcGIS/rest/services/SDE/World/mapserver "/
>






Map = "{map }"
Graphicslayer = "{drawlayer }"
Drawend = "drawtool_drawend (event)"/>

Url = "http: // localhost: 8399/ArcGIS/rest/services/SDE/World/featureserver/0"

Editscomplete = "{featurelayer0_editscomplete (event )}"
Fault = "trace (event)"/>

Url = "http: // localhost: 8080/arcobjectsserver/rest/update_cache"

Result = "httpupdatecache_resulthandler (event )"
Fault = "trace (event)"/>

 

After the data is updated, update the cut chart through the Web Service developed based on ArcObjects.

Java:

Private string result (string objectids ){
String result = "false ";

Iservercontext servercontext = NULL;
Try {
Resourcebundle RB = resourcebundle. getbundle ("wuyf. config ");

String host = RB. getstring ("host ");
String username = RB. getstring ("username ");
String Password = RB. getstring ("password ");
String service = RB. getstring ("map_server ");
Int layerid = integer. valueof (RB. getstring ("layer_id "));

Serverinitializer = new serverinitializer ();
Serverinitializer. initializeserver (host, username, password );
Serverconnection conn = new serverconnection ();
Conn. Connect (host );

Iserverobjectmanager som = conn. getserverobjectmanager ();
Servercontext = som. createservercontext (service, "mapserver ");

Mapserver = (mapserver) servercontext. getserverobject ();
Ifeaturelayer fealayer = (ifeaturelayer) mapserver. getlayer (
Mapserver. getdefamapmapname (), layerid );
Ifeatureclass feaclass = fealayer. getfeatureclass ();

String mapname = mapserver. getdefamapmapname ();
Map map = (MAP) mapserver. getmap (mapname );
Ilodinfos lodinfos = mapserver. getcachedescriptioninfo (
Map. getname (). gettilecacheinfo (). getlodinfos ();
String layers = "";
For (INT I = 0, Count = map. getlayercount (); I <count; I ++ ){
String layername = map. getlayer (I). getname ();
If (layers! = ""){
Layers + = ";";
}
Layers + = layername;
}
String levels = "";
For (INT I = 0, Count = lodinfos. getcount (); I <count; I ++ ){
Ilodinfo lodinfo = lodinfos. getelement (I );
If (levels! = ""){
Levels + = ";";
}
Levels + = string. Format ("% F", lodinfo. getscale ());
}

String [] IDs = objectids. Split (",");
String where = "";
For (INT I = 0, Count = IDs. length; I <count; I ++ ){
If (where! = ""){
Where + = "and ";
}
Where + = "objectid =" + IDs [I];
}
Queryfilter filter = (queryfilter) servercontext
. Createobject (queryfilter. getclsid ());
Filter. setwhereclause (where );

Ifeaturecursor feacursor = feaclass. Search (filter, false );
Ifeature FEA = feacursor. nextfeature ();
While (FEA! = NULL ){
Igeometry GEO = FEA. getshape ();
Ienvelope Env = GEO. getenvelope ();

Geoprocessor Gp = (geoprocessor) servercontext
. Createobject (geoprocessor. getclsid ());
GP. setoverwriteoutput (true );

Managemapservercachetiles MC = new managemapservercachetiles ();

Vararray Var = (vararray) servercontext. Createobject (vararray
. Getclsid ());
Var. Add (host );
Var. Add (service );
Var. Add (mapname );
Var. Add (layers );
Var. Add (levels );
Var. Add ("recreate all tiles ");
String extent =
String. Format ("% F", ENV. getxmin () + "" +
String. Format ("% F", ENV. getymin () + "" +
String. Format ("% F", ENV. getxmax () + "" +
String. Format ("% F", ENV. getymax ());
Var. Add (extent );

// Note: to execute this GP, you need to add the SOC account to the agsadmin group.
Igeoprocessorresult gpresult = gp.exe cute (MC. gettoolname () + "_" + MC. gettoolboxalias (), VAR, null );
If (GP. getmessagecount ()> 0 ){
For (INT I = 0, Count = GP. getmessagecount (); I <count; I ++ ){
System. Err. Print (GP. getmessage (I ));
}
}

FEA = feacursor. nextfeature ();
}

Result = "true ";
} Catch (exception ex ){
Ex. printstacktrace ();
} Finally {
Try {
Servercontext. releasecontext ();
} Catch (exception ex ){
Ex. printstacktrace ();
}
}

Return result;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.