Note on converting fields specified by AE

Source: Internet
Author: User
Note on converting fields specified by AE
08-06-13 08:33:33 Author: xbt746 Source: xbt746.cnblogs.com

ArcMap
One function is label features, which means that the specified field values in the layer can be displayed as labels in the main window.
After features, right-click the layer and you will find a gray feature name, convertlabelstoannotation. This function is provided in AE,
However, you cannot find the location where the field value is set.

Create a note layer and generate a note based on the field values specified in the layer. Is a feature point conversion. It may be less efficient than the interfaces provided by AE.
I will not use that interface, so I can barely use it. In this regard, the most difficult thing is to create a new note layer. There are many attributes that need to be set, which is troublesome. below is the code

Private void converttoannotationlayer (IMAP pmap, ilayer player, string fieldname, esrigeometrytype)
...{
Ifeaturelayer pfeatlayer = player as ifeaturelayer;

Int I = pfeatlayer. featureclass. findfield ("shape ");
Ifield pshapefield = pfeatlayer. featureclass. Fields. get_field (I );
Idataset pdataset = pfeatlayer. featureclass as idataset;
Iworkspace PWS = pdataset. workspace;
Ifeatureworkspace pfeatws = PWS as ifeatureworkspace;


Igeofeaturelayer pgeofeatlayer = pfeatlayer as igeofeaturelayer;
Ifields pfields = pgeofeatlayer. featureclass. fields;

Iannotationlayerfactory pannolayerfact = new fdographicslayerfactoryclass ();
Igraphicslayerscale pgraphyscale = new graphicslayerscaleclass ();
Pgraphyscale. referencescale = 200000;
Pgraphyscale. Units = esriunits. esrimeters;
Iannotationlayer pannolayer = NULL;

Isymbolcollection2 psymcoll = new symbolcollectionclass ();
Iformattedtextsymbol ptextsymbol = new textsymbolclass ();
Irgbcolor prgb = new rgbcolorclass ();
Prgb. Red = 0;
Prgb. Blue = 0;
Prgb. Green = 0;
Ptextsymbol. Color = prgb;

/** // * Ptextsymbol. font = */


M_fontdisp.size = 8;
Ptextsymbol. font = m_fontdisp;
Ptextsymbol. horizontalalignment = esritexthorizontalalignment. esrithacenter;
Ptextsymbol. verticalalignment = esritextverticalalignment. esritvabaseline;
Ptextsymbol. characterspacing = 100;
Ptextsymbol. characterwidth = 50;
Ptextsymbol. wordspacing = 100;

// Iboundsproperties pboundprop = ptextsymbol as iboundsproperties;
/** // * Pboundprop. fixedsize = false ;*/
// Pboundprop. fixedaspectratio = true;
Isymbol psymbol = ptextsymbol as isymbol;
Isymbolidentifier2 psymident2;
Psymcoll. addsymbol (psymbol, fieldname, out psymident2 );
Isymbolcollection psymcoll1 = psymcoll as isymbolcollection;

Ioverposterproperties poverpost = new basicoverposterpropertiesclass ();

Iannotatelayerpropertiescollection pannopropcoll = new annotatelayerpropertiescollectionclass ();
Iannotatelayerproperties pannoprop;
Ilabelenginelayerproperties2 plabelengine = new labelenginelayerpropertiesclass ();
Plabelengine. annotationclassid = 0;
Plabelengine. symbol = ptextsymbol;
Plabelengine. symbolid = psymident2.id;
Pannoprop = plabelengine as iannotatelayerproperties;
Pannoprop. Class = player. Name + fieldname;
Pannoprop. labelwhichfeatures = esrilabelwhichfeatures. esriallfeatures;
Pannoprop. Priority = 0;
Iactiveview pactview = pmap as iactiveview;
Pannoprop. graphicscontainer = pactview. graphicscontainer;
Pannoprop. featurelayer = pfeatlayer;
Pannoprop. featurelinked = true;
Pannoprop. annotationmaximumscale = 10000000000000000000;
Pannoprop. annotationminimumscale = 0.00000000001;
Pannopropcoll. Add (pannoprop );
Try
...{
Pannolayer = pannolayerfact. createannotationlayer (pfeatws, pfeatlayer. featureclass. featuredataset, player. Name + "_ A _" + fieldname, pshapefield. geometrydef,
Null, pannopropcoll, pgraphyscale, psymcoll1, false, true, poverpost ,"");

}
Catch (exception S)
...{
String MEs = S. message;
}
If (pannolayer = NULL)
Return;
Int num = pfields. findfield (fieldname );
Converttoannotatebyfeature (player, num, ref pannolayer );
Pmap. addlayer (pannolayer as ilayer );
}

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.