collapse

M4OPS

For our prototype mapping system try the Demo at mapping4ops.org/M4OPS.

You can also see an overview of M4OPS on YouTube.

* Forum Staff

PeterC admin PeterC
Administrator
admin webmasterOPS
Administrator

Author Topic: Colouring Feature Layers  (Read 705 times)

PeterC

  • Administrator
  • Member
  • *****
  • Posts: 483
  • Passionate about my one-place study
    • View Profile
    • Holywell-cum-Needingworth History
Colouring Feature Layers
« on: 10 February 2018, 12:46:45 »
The colour of a feature (as part of its style) is determined by various factors and settings. The first in the following list to yield a valid colour is used:
  • The currently selected "Colour Scheme" based on feature properties (see below)
  • (For points only and if wantIcons is on) The value of the color property (see the function defaultPointStyleArray)
  • The ColourSet specified for this layer in this OPS (see below)
  • The DefaultColourSetsArray (per layer) defined in M4OPS.json for all OPS
  • The default colour (red)

Colour Schemes based on feature properties (see chosenColor function)
If a feature layer has a property that varies that you want to use to colour/color features differently, here is how to create a block of conditions to specify that colour scheme:
  • In the Colours.csv file enter a block of lines that have the following fields:
    • csid: the id of the colour scheme (must be identical for all rows in this block)
    • title: the name of the colour scheme to appear in the dropdown (identical for all rows in this block, except that only the first is used)
    • keytitle: title to appear in the key (identical for all rows in this block, except that only the first is used)
    • fproperty: the feature property to be evaluated
    • comparetype: the comparison operator (<, >, =, <=, or >=)
    • comparevalue: the value to be compared with
    • keyphrase: the phrase to be used in the key before the comparevalue
      • (If the keyphrase starts with * then the comparevalue is not appended to it in the key)
    • colour: the specification of the colour as either:
    • comment: can be used for any comment, eg what the colour is
  • Make sure all the lines (conditions) for the same csid are kept together, and that they are in the right order (because the first that evaluaates to true will be used)
  • It is useful to end each block with a condition with ;;;Unknown for fproperty;comparetype;comparevalue;keyphrase so there is a Catch-all value
  • Otherwise, if no condition is met, the default colour is used
More than one colour scheme can be in the file, each represented by a block of conditions. The possible colour schemes for feature layers appear in a drop down beside the "Feature Layers" title. When one is chosen the features are coloured according to it, and a key appears.

ColourSets (see defaultColor function)
If you wish to be able to colour a feature layer according to non-standard colours, then here is how to do so for your OPS:
  • Specify the ColourSets in the ColourSets.csv file specified for this layer specified for this layer with these fields:
    • csname: the name of the ColourSet
    • pointRGB: the r,g,b string for Points (eg 255, 255, 0)
    • lineRGB: the r,g,b string for Lines
    • polygonRGB: the r,g,b string for Polygons
    • geometrycollectionRGB: the r,g,b string for Geometry Collections
    • multilineRGB: the r,g,b string for Multilines
    • multipolygonRGB: the r,g,b string for Multipolygons
    • description: a description of this ColourSet (eg the colours, or purpose)
    • comment: can be used for any comment
  • In LayerDefs_Feature.csv add the field csname and, for any layer you wish to do so, give it a value to identify the required ColourSet
  • If you wish to associate MFLs with a ColourSet, then add the field csname to OPS.csv with the value to identify the required ColourSet

Useful colours are:
Colour    rgb
To do    ???

Useful help on colours can be found in these w3schools pages:
Technical notes
  • The defaultGeometryStyleFunction is where all features in all layers get their style from, unless specifically defined otherwise.  It hides the feature if its 'hidden' property is set to true, else simply uses the defaultStyles function.
  • Any property whose name contains color or colour is treated as a colour field in display (see allProperties function)
  • The colour of a feature is the same whether it is selected or not (unlike some other aspects of style)
« Last Edit: 18 July 2018, 09:38:00 by PeterC »

 

mapping4ops.org is a Society for One-Place Studies project supported by Grassroots Giving from Skipton Building Society
Glossary | BBCodes | Feedback