Skip to content

7 Symbolization configuration in projects

The parametrization of how geometries and entity labels of vector layers are visualized is established in the file cartodroid/config/crtdrdSymbologies.xml.

7.1 General structure of the file

When defining a symbology, regardless of the geometry type, the style of the symbology itself is configured separately:

  • Style: determines colors, stroke, and transparency of geometric figures.
  • Symbology: allows establishing the style to be applied for the visualization of the geometry and for the labels.
Tag Description
symbologyConf Root element of the configuration file. It will have a nested styles element and a symbologies element.
estilos Element that groups the entry elements to define styles.
simbologias Element that groups the entry elements to define symbologies.
entry Within the estilos and simbologias elements, one or more entry elements can be nested.
In the case of styles, an entry is defined by creating an estilo tag, and in the case of symbologies, with the symb tag. Additionally, each entry element must have an associated string tag with a unique value that identifies the style/symbology.

In general, the crtdrdSymbologies.xml file will have the following structure:

<symbologyConf>
 <estilos>
 <entry>
 <string>estilo1</string>
 <estilo class="estiloPoligono">
…
 </estilo>
 </entry>
 <entry>
 <string>estilo2</string>
 <estilo class="estiloPoligono">
…
 </estilo>
 </entry>
 </estilos>
 <simbologias>
 <entry>
 <string>simbologia1</string>
 <symb class="poligono">
 …
 </symb>
 </entry>
 </simbologias>
</symbologyConf>

The following sections describe how to create a custom visualization for each Geometry type (point, line, polygon).

7.2 Relationship between styles and symbologies

There are four types of styles: text, marker, line, and polygon.

  • Text style (estiloTexto): defines color and font size.
  • Marker style (estiloMarca): defines color and optionally a background image to use as a position marker.
  • Line style (estiloLinea): color, line stroke width, terminator, etc.
  • Polygon style (estiloPoligono): in addition to the information associated with the line style, background color.

These four styles are combined to define the symbologies of vector entities. In the case of CartoDruid, different symbologies can be defined for geometries and for labels.

Each type of vector layer has an associated symbology type that directly corresponds to the style type. Thus, the polygon symbology will have an associated estiloPoligono style, the line symbology an estiloLinea style, and the point symbology an estiloMarca style. These symbologies are referenced in the layer with the <symbId> tag (or using an expression defined in the <symbologyExpression>tag).

For labels, the symbology must be of the polygon type, and will have an associated estiloTexto to establish the text format, and an estiloPoligono, to format the box that surrounds the text itself.

The following diagram shows the relationship between symbologies and styles.

Simbología

7.3 Styles and symbologies for points

7.3.1 Style definition

Tag Description
id Style identifier. Must match the string attribute defined in the entry tag.
transparencia Degree of transparency to apply.
color Color of the geometry. Must have a nested rgb element <color><rgb>0,255,255,255</rgb></color>
urlImagen Name of the image file that will be displayed to replace the default Google marker. The image must be in the /cartodroid/symbol directory.
rotation Rotation to apply to the image (degrees 0-360). Optional.

7.3.2 Symbology definition

Tag Description
id Symbology identifier. Must match the string attribute defined in the entry tag.
idEstiloPunto Style identifier that will be used for the marker.
<estilos>
  <entry>
    <string>symbSelectedPoint</string>
    <estilo class="estiloMarca">
      <id>symbSelectedPoint</id>
      <transparencia>1.0</transparencia>
      <color>
        <rgb>0,255,255,255</rgb>
      </color>
    </estilo>
  </entry>
</estilos>
      
<simbologias>
  <entry>
    <string>symbSelectedPoint</string>
    <symb class="punto">
      <id>symbSelectedPoint</id>
      <idEstiloPunto>symbSelectedPoint</idEstiloPunto>
    </symb>
  </entry>
</simbologias>
      
Mark Style Definition Point Symbology Definition

7.4 Styles and symbologies for lines

7.4.1 Style definition

Tag Description
id Style identifier. Must match the string attribute defined in the entry tag.
transparencia Degree of transparency to apply.
colorLinea Color of the geometry. Must have a nested rgb element like <color><rgb>0,255,255,255</rgb></color>.
trazo Configuration of the line stroke style. Currently, only the line width can be modified, but other visualization possibilities supported by the Google Maps API are expected to be added.
https://developers.google.com/maps/documentation/android-api/releases
Example usage:

        <trazo class="basicStroke"> 
            <anchura>3</anchura> 
        </trazo>

7.4.2 Symbology definition

Tag Description
id Symbology identifier. Must match the string attribute defined in the entry tag.
idEstiloLinea Style identifier that will be used for the line.
<estilos>
  <entry>
    <string>symbInspeccionLinea</string>
    <estilo class="estiloLinea">
      <id>symbInspeccionLinea</id>
      <transparencia>1.0</transparencia>
      <colorLinea>
        <rgb>0,255,255,255</rgb>
      </colorLinea>
      <trazo class="basicStroke">
        <anchura>3</anchura>
      </trazo>
    </estilo>
  </entry>
</estilos>
      
<simbologias>
  <entry>
    <string>symbInspeccionLinea</string>
    <symb class="linea">
      <id>symbInspeccionLinea</id>
      <idEstiloLinea>symbInspeccionLinea</idEstiloLinea>
    </symb>
  </entry>
</simbologias>
      
Line Style Definition Line Symbology Definition

7.5 Styles and symbologies for polygons

7.5.1 Style definition

Tag Description
id Style identifier. Must match the string attribute defined in the entry tag.
transparencia Degree of transparency to apply.
colorLinea Color of the geometry. Must have a nested rgb element: <color><rgb>0,255,255,255</rgb></color>
colorRelleno Background color of the geometry. Must have a nested rgb element: <colorRelleno><rgb>255,145,0,80</rgb></colorRelleno>
trazo Configuration of the line stroke style. Currently, only the line width can be modified, but other visualization possibilities supported by the Google Maps API are expected to be added.
https://developers.google.com/maps/documentation/android-api/releases
Example usage:

        <trazo class="basicStroke">
            <anchura>3</anchura>
        </trazo>

7.5.2 Symbology definition

Tag Description
id Symbology identifier. Must match the string attribute defined in the entry tag.
texto Style identifier that will be used for the geometry label. Optional (only used when the symbology is applied to labels).
idEstiloPoligono Style identifier that will be used for the line.
<estilos>
  <entry>
    <string>pend50</string>
    <estilo class="estiloPoligono">
      <id>pend50</id>
      <transparencia>1.0</transparencia>
      <colorLinea>
        <rgb>0,255,255,255</rgb>
      </colorLinea>
      <trazo class="basicStroke">
        <anchura>3</anchura>
      </trazo>
      <colorRelleno>
        <rgb>255,145,0,80</rgb>
      </colorRelleno>
    </estilo>
  </entry>
</estilos>
      
<simbologias>
  <entry>
    <string>pend50</string>
    <symb class="poligono">
      <id>pend50</id>
      <idEstiloPoligono>pend50</idEstiloPoligono>
    </symb>
  </entry>
</simbologias>
      
Polygon Style Definition Polygon Symbology Definition

7.6 Styles and symbologies for labels

7.6.1 Style definition

Tag Description
id Style identifier. Must match the string attribute defined in the entry tag.
transparencia Degree of transparency to apply.
fuente Tag that allows defining typographic attributes of the label. Currently, only size is supported. Ex:
<fuente><tamano>36</tamano></fuente>
colorTexto Font color to use. Must have a nested rgb element:
<colorTexto><rgb>255,145,0,80</rgb></colorTexto>
<entry>
  <string>idTextRojo</string>
  <estilo class="estiloTexto">
    <id>idTextRojo</id>
    <transparencia>1.0</transparencia>
    <fuente>
      <tamano>36</tamano>
    </fuente>
    <colorTexto>
      <rgb>255,0,0,255</rgb>
    </colorTexto>
    <rotacion>0.0</rotacion>
  </estilo>
</entry>
      
<entry>
  <string>label_rojas_symb</string>
  <symb class="poligono">
    <id>Default_label</id>
    <texto>idTextRojo</texto>
    <idEstiloPoligono>label_rojas_pol</idEstiloPoligono>
  </symb>
</entry>
      
Text Style Definition Label Symbology Definition

In this case, we define a polygon-type symbology label_rojas_symb that references a text-type style idTextoRojo and a polygon-type style label_rojas_pol. To use this symbology, we will have to reference it in the layer definition as follows:
<labelSymbId>label_rojas_symb</labelSymbId>.

7.7 Default styles and symbologies

The CartoDruid installation includes a file with default symbologies and styles configured in the file /Cartodroid/config/crtdrdSymbologies.xml. This configuration can be overwritten by the project simply by defining a style/symbology with the same identifier in the project's symbology file.

For example, the following symbology is used by CartoDruid to define the presentation of the polygon sketch of a valid cut. By pasting this code snippet into the project's symbology file and modifying it, you would modify the default visualization that CartoDruid gives to this type of sketch.

<entry>
 <string>symbSketchLineOK</string>
 <estilo class="estiloPoligono">
 <id>symbSketchLineOK</id>
 <transparencia>0.8</transparencia>
 <colorLinea>
 <rgb>110,230,0,255</rgb>
 </colorLinea>
 <trazo class="basicStroke">
 <anchura>2</anchura>
 </trazo>
 <colorRelleno>
 <rgb>0,0,0,0</rgb>
 </colorRelleno>
 <imagenFondo></imagenFondo>
 </estilo>
</entry>

7.8 Conditional symbologies

CartoDruid allows defining rules to calculate the symbology that should be applied to an entity. By using the symbologyExpression and labelSymbologyExpression tags in the layer definition in the crtdrdLayers.xml file, you can define an SQL expression to determine the identifier of the symbology to use (See the practical cases section for specific examples).

There is an alternative method for symbolizing based on attributes. In the layer configuration, you can nest a symbologies element, in which we define a symbology element for each different symbology we want to apply, and the SQL expression for its calculation.

For example, in this case, we are going to symbolize the SIGPAC enclosures layer by the c_uso_sigpac field, but in the case of vineyards, we want to make differences using the cap_auto field.

<es.jcyl.ita.crtcyl.core.model.VectorialLayer>
 …
<symbologies>
<es.jcyl.ita.crtcyl.core.model.style.ConditionalSymbology>
 <id>ALICIA</id>
 <name>Uso Forestal</name>
 <condition>c_uso_sigpac = 'FO'</condition>
</es.jcyl.ita.crtcyl.core.model.style.ConditionalSymbology>
<es.jcyl.ita.crtcyl.core.model.style.ConditionalSymbology>
 <id>JAIME</id>
 <name>Improductivo</name>
 <condition>c_uso_sigpac = 'IM'</condition>
</es.jcyl.ita.crtcyl.core.model.style.ConditionalSymbology>
<es.jcyl.ita.crtcyl.core.model.style.ConditionalSymbology>
 <id>CAMILO</id>
 <name>Tierra arable</name>
 <condition>c_uso_sigpac = 'TA'</condition>
</es.jcyl.ita.crtcyl.core.model.style.ConditionalSymbology>
<es.jcyl.ita.crtcyl.core.model.style.ConditionalSymbology>
 <id>PABLO</id>
 <name>Viñedo con CAP &gt; 50%</name>
 <condition>c_uso_sigpac = 'VI' AND CAP_AUTO &gt; 50</condition>
</es.jcyl.ita.crtcyl.core.model.style.ConditionalSymbology>
<es.jcyl.ita.crtcyl.core.model.style.ConditionalSymbology>
 <id>SOFIA</id>
 <name>Viñedo con CAP &lt;= 50%</name>
 <condition>c_uso_sigpac = 'VI' AND CAP_AUTO &lt;= 50</condition>
</es.jcyl.ita.crtcyl.core.model.style.ConditionalSymbology>
</symbologies>
 …
</es.jcyl.ita.crtcyl.core.model.VectorialLayer>

These rules are applied in the order in which they are defined in the XML, that is, for each geometry, the rules are evaluated in sequence and the symbology of the first satisfied rule is applied. If none of the cases are met, the default symbology of the layer, defined in the symbId attribute, is used.

The advantage over using the symbologyExpression tag is that by being able to describe each rule separately and give it a name, CartoDruid can use this information to display a map legend. When clicking on the symbology box in the TOC, a screen with the description of the styles opens.

The following screens show how these rules are applied to the enclosure layers and the legend that is generated from the rules.

SIGPAC enclosures layer symbolized by use and CAP coefficient Legend calculated from symbology rules