banniere

Le portail francophone de la géomatique


Toujours pas inscrit ? Mot de passe oublié ?
Nom d'utilisateur    Mot de passe              Toujours pas inscrit ?   Mot de passe oublié ?

Annonce

#1 Mon 24 July 2006 16:44

Grégory GADRAS
Participant occasionnel
Date d'inscription: 13 Apr 2006
Messages: 17

Symbologie en VB (ArcGIS 9.1)

Bonjour à tous,

Je cherche à afficher une couche de ponctuels en lui affectant une symbologie particulière suivant la valeur d'un champ (choix de symbole et de couleur).
Si quelqu'un aurait un bout de code...

Merci d'avance,

Grégory.

Hors ligne

 

#2 Tue 25 July 2006 08:52

janyv
Participant assidu
Lieu: Montreuil, France
Date d'inscription: 8 Feb 2006
Messages: 356

Re: Symbologie en VB (ArcGIS 9.1)

Bonjour,

je n'ai pas de bout de code tout fait à te proposer, mais, pour essayer de t'aiguiller, regarde dans les diagrammes d'ArcGIS, particulièrement celui de la library <esricarto> qui contient une description de l'interface <IUniqueValueRenderer>.

Il y a un exemple assez complet (pour VBA que tu pourrais adaper) lorsque tu parcours la Library Reference d'ArcGIS Developer Help (Library Reference->esriCarto->Interfaces->IU->iUniqueValueRenderer Interface).

à +

yvan.


Si tu ne sais pas demande, si tu sais partage smile

Hors ligne

 

#3 Tue 25 July 2006 16:30

Grégory GADRAS
Participant occasionnel
Date d'inscription: 13 Apr 2006
Messages: 17

Re: Symbologie en VB (ArcGIS 9.1)

Bonjour Yvan,

Je te remercie pour l'info, qui m'a bien aiguillé! J'obtiens bien dans la table des matières la symbologie associée cependant mes ponctuels n'ont pas cette symbologie... Le résultat est un carré rouge qui englobe chaque ponctuel.

Si quelqu'un a une idée...

Merci,

Grégory.


Sub CreateAndApplyUVRenderer()
     
     '** Paste into VBA
     '** Creates a UniqueValuesRenderer and applies it to first layer in the map.
     '** Layer must have "Name" field

     Dim pApp As Application
     Dim pDoc As IMxDocument
     Set pDoc = ThisDocument
     Dim pMap As IMap
     Set pMap = pDoc.FocusMap

     Dim pLayer As ILayer
     Set pLayer = pMap.Layer(0)
     Dim pFLayer As IFeatureLayer
     Set pFLayer = pLayer
     Dim pLyr As IGeoFeatureLayer
     Set pLyr = pFLayer
     
     Dim pFeatCls As IFeatureClass
     Set pFeatCls = pFLayer.FeatureClass
     Dim pQueryFilter As IQueryFilter
     Set pQueryFilter = New QueryFilter 'empty supports: SELECT *
     Dim pFeatCursor As IFeatureCursor
     Set pFeatCursor = pFeatCls.Search(pQueryFilter, False)

     '** Make the color ramp we will use for the symbols in the renderer
     Dim rx As IRandomColorRamp
     Set rx = New RandomColorRamp
     rx.MinSaturation = 20
     rx.MaxSaturation = 40
     rx.MinValue = 85
     rx.MaxValue = 100
     rx.StartHue = 76
     rx.EndHue = 188
     rx.UseSeed = True
     rx.Seed = 43
     
     '** Make the renderer
     Dim pRender As IUniqueValueRenderer, n As Long
     Set pRender = New UniqueValueRenderer
     
     Dim symd As ISimpleFillSymbol
     Set symd = New SimpleFillSymbol
     symd.Style = esriSFSSolid
     symd.Outline.Width = 0.4
     
     '** These properties should be set prior to adding values
     pRender.FieldCount = 1
     pRender.Field(0) = "Name"
     pRender.DefaultSymbol = symd
     pRender.UseDefaultSymbol = True
     
     Dim pFeat As IFeature
     n = pFeatCls.FeatureCount(pQueryFilter)
     '** Loop through the features
     Dim i As Integer
     i = 0
     Dim ValFound As Boolean
     Dim NoValFound As Boolean
     Dim uh As Integer
     Dim pFields As IFields
     Dim iField As Integer
     Set pFields = pFeatCursor.Fields
     iField = pFields.FindField("Name")
     Do Until i = n
         Dim symx As ISimpleFillSymbol
         Set symx = New SimpleFillSymbol
         symx.Style = esriSFSSolid
         symx.Outline.Width = 0.4
         Set pFeat = pFeatCursor.NextFeature
         Dim x As String
         x = pFeat.Value(iField) '*new Cory*
         '** Test to see if we've already added this value
         '** to the renderer, if not, then add it.
         ValFound = False
         For uh = 0 To (pRender.ValueCount - 1)
           If pRender.Value(uh) = x Then
             NoValFound = True
             Exit For
           End If
         Next uh
         If Not ValFound Then
             pRender.AddValue x, "Name", symx
             pRender.Label(x) = x
             pRender.Symbol(x) = symx
         End If
         i = i + 1
     Loop
     
     '** now that we know how many unique values there are
     '** we can size the color ramp and assign the colors.
     rx.Size = pRender.ValueCount
     rx.CreateRamp (True)
     Dim RColors As IEnumColors, ny As Long
     Set RColors = rx.Colors
     RColors.Reset
     For ny = 0 To (pRender.ValueCount - 1)
         Dim xv As String
         xv = pRender.Value(ny)
         If xv <> "" Then
             Dim jsy As ISimpleFillSymbol
             Set jsy = pRender.Symbol(xv)
             jsy.Color = RColors.Next
             pRender.Symbol(xv) = jsy
         End If
     Next ny

     '** If you didn't use a color ramp that was predefined
     '** in a style, you need to use "Custom" here, otherwise
     '** use the name of the color ramp you chose.
     pRender.ColorScheme = "Custom"
     pRender.FieldType(0) = True
     Set pLyr.Renderer = pRender
     pLyr.DisplayField = "Name"

     '** This makes the layer properties symbology tab show
     '** show the correct interface.
     Dim hx As IRendererPropertyPage
     Set hx = New UniqueValuePropertyPage
     pLyr.RendererPropertyPageClassID = hx.ClassID

     '** Refresh the TOC
     pDoc.ActiveView.ContentsChanged
     pDoc.UpdateContents
     
     '** Draw the map
     pDoc.ActiveView.Refresh
     
End Sub

Dernière modification par Grégory GADRAS (Tue 25 July 2006 16:33)

Hors ligne

 

#4 Wed 26 July 2006 10:18

janyv
Participant assidu
Lieu: Montreuil, France
Date d'inscription: 8 Feb 2006
Messages: 356

Re: Symbologie en VB (ArcGIS 9.1)

Essaye d'utiliser l'interface esriDisplay::ISimpleMarkerSymbol à la place de esriDisplay::ISimpleFillSymbol car cette dernière effectue un simple remplissage d'une entité surfacique. En revanche, ISimpleMarkerSymbol te permet de définir quelques symboles ponctuels simples (carré, cerclé, losange,...)  avec la propriété Style qui accepte une constante parmi celles définies par esriSimpleMarkerStyle.

à +

yvan.


Si tu ne sais pas demande, si tu sais partage smile

Hors ligne

 

#5 Wed 26 July 2006 11:11

Grégory GADRAS
Participant occasionnel
Date d'inscription: 13 Apr 2006
Messages: 17

Re: Symbologie en VB (ArcGIS 9.1)

Salut Yvan,

On m'avait orienté hier sur la même approche que toi et ça marche nickel je te remercie.

Je voudrais même pousser un peu plus loin dans ma recherche, en fait j'aimerais une symbologie avec des objets graphiques (imagettes) suivant la valeur des champs et non me limiter à un simple ponctuel.
Il semblerait que ça soit avec PictureFillSymbol... mais comment?

Si tu as ou quelqu'un d'autre a une idée je suis preneur, en tout cas merci à toi aussi pour ton aide!!!

Grégory.

Hors ligne

 

#6 Wed 26 July 2006 14:02

janyv
Participant assidu
Lieu: Montreuil, France
Date d'inscription: 8 Feb 2006
Messages: 356

Re: Symbologie en VB (ArcGIS 9.1)

Bonjour Grégory,

Content que tu aies pu aboutir. Maintenant, pour la cerise sur le gâteau et une symbologie ponctuelle par imagette, je te conseille d'utiliser plutôt l'interface esridisplay::IPictureMarkerSymbol qui hérite de esridisplay::IMarkerSymbol, çà devrait marcher !

à +

yvan.


Si tu ne sais pas demande, si tu sais partage smile

Hors ligne

 

#7 Thu 27 July 2006 09:23

Grégory GADRAS
Participant occasionnel
Date d'inscription: 13 Apr 2006
Messages: 17

Re: Symbologie en VB (ArcGIS 9.1)

Bonjour,

Je suis en train de tester IPictureMarkerSymbol et j'ai un problème tout d'abord avec les fichiers BMP ensuite même avec l'EMF le code tourne mais l'imagette ne s'affiche pas... Si quelqu'un a déjà tester l'exemple de code suivant: http://edndoc.esri.com/arcobjects/9.1/d … Symbol.htm  et peut me faire un retour, merci.

Grégory.

Hors ligne

 

#8 Thu 27 July 2006 16:36

janyv
Participant assidu
Lieu: Montreuil, France
Date d'inscription: 8 Feb 2006
Messages: 356

Re: Symbologie en VB (ArcGIS 9.1)

Bonjour Grégory,

As-tu affecté une valeur à la propritété IMarkerSymbol:Size (en unités de points, soit 1/72 de pouce) ?


Si tu ne sais pas demande, si tu sais partage smile

Hors ligne

 

#9 Thu 27 July 2006 17:53

Grégory GADRAS
Participant occasionnel
Date d'inscription: 13 Apr 2006
Messages: 17

Re: Symbologie en VB (ArcGIS 9.1)

Bonjour Ivan,

Non je n'ai point fait cela, comment dois je procéder?

Grégory.

Hors ligne

 

#10 Thu 27 July 2006 19:34

janyv
Participant assidu
Lieu: Montreuil, France
Date d'inscription: 8 Feb 2006
Messages: 356

Re: Symbologie en VB (ArcGIS 9.1)

Gregory,

je ne suis pas sûr que ce soit la solution à ton problème mais on ne sait jamais.

- Dim pMarkerSym as esriDisplay.IMarkerSymbol
- Set pMarkerSym = ton pointeur sur IPictureMarkerSymbol
pMarkerSym.Size = 12.0 (par exemple).

En espérant que ce soit la bonne !

à +

yvan.


Si tu ne sais pas demande, si tu sais partage smile

Hors ligne

 

#11 Fri 28 July 2006 08:22

janyv
Participant assidu
Lieu: Montreuil, France
Date d'inscription: 8 Feb 2006
Messages: 356

Re: Symbologie en VB (ArcGIS 9.1)

Bonjour,

Tu peux aussi faire "plus court" :

Dim pPictMrk as esriDisplay.IMarkerSymbol

set pPictMrk = new esriDisplay.PictureMarkerSymbol
' ...
' ...
ppPictMrk.Size = 12.0
' ...
' ...

yvan.


Si tu ne sais pas demande, si tu sais partage smile

Hors ligne

 

Pied de page des forums

Powered by FluxBB