ArcGIS add element class code

Source: Internet
Author: User
Tags ipoint
Code
Sub Addpoint ()
Dim Pmxdoc As Imxdocument

Dim Pmap As IMAP
Dim Pfeaturelayer As Ifeaturelayer
Dim Pfeatureclass As Ifeatureclass
Dim P As Ipoint
Dim Pfeature As Ifeature
Set Pmxdoc = Thisdocument
Set Pmap = Pmxdoc. focusmap
Set Pfeaturelayer = Pmap. layer ( 0 )

Set Pfeatureclass = Pfeaturelayer. featureclass
Set Pfeature = Pfeatureclass. createfeature
' Coordinates of the added Vertex
Set P =   New Point
P.x =   76374.006
P. Y =   - 3660.849
Set Pfeature. Shape = P
Pfeature. Value ( 2 ) =   " 111 "
Pfeature. Value ( 3 ) =   " Add Test "
Pfeature. Store

End sub

When developing ArcGIS Server todayCodeDynamically add elements to detect errors. You can use VBA to try the results. As a result, VBA is successfully tried.

Add code in Java.

Code
Int Minx = Integer. parseint (parammap. Get ( " Map0_minx " ). Tostring ());
Int Miny = Integer. parseint (parammap. Get ( " Map0_miny " ). Tostring ());


Webpoint tmpextent =   New Webpoint ();
Tmpextent. setx (Minx );
Tmpextent. sety (miny );
Tmpextent = (Webpoint) tmpextent. tomapgeometry (WM );


Agslocalmapresource mapresource = (Agslocalmapresource) Context
. Getresources (). Get ( " Ags0 " );


Ifeaturelayer featurelayer = Getfeaturelayer (mapresource );
Iservercontext servercontext = Mapresource. getservercontext ();
Ipoint webpoint = (Ipoint) servercontext. Createobject (point. getclsid ());
Webpoint. setx (tmpextent. getx ());
Webpoint. sety (tmpextent. Gety ());
If (Featurelayer ! =   Null ){

Ifeatureclass featurecls = Featurelayer. getfeatureclass ();
System. Out. println ( " Aliasname: "   + Featurecls. getaliasname ());

Idataset DS = New Idatasetproxy (featurecls );
Iworkspace WS = New Iworkspaceproxy (Ds. getworkspace ());

Iworkspaceedit WSE = New Iworkspaceeditproxy (WS );
// Iworkspaceedit WSE = (iworkspaceedit) WS;
// WSe. startediting (false );
WSe. starteditoperation ();


Ifeature feature = Featurecls. createfeature ();
Feature. setshapebyref (igeometry) webpoint );
Feature. setvalue ( 2 , " 123456 " );
Feature. setvalue ( 3 , " Add Test " );
Feature. Store ();
WSe. stopeditoperation ();
// WSe. stopediting (true );
}

Context. Refresh ();

 

 

Errors in Java are listed below:

Automatic exception: 0x80004005-unspecified error
At com. ESRI. ArcGIS. InterOP. Dispatch. vtblinvoke (unknown source)
At com. ESRI. ArcGIS. Geodatabase. ifeatureclassproxy. createfeature (unknown source)

Finally, I found no problem. Later I typed ArcGIS Server SP 6. The problem was solved. It turns out to be a patch issue.

 

 

 

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.