points.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. .. _mbstyle_cookbook.points:
  2. Points
  3. ======
  4. Points are seemingly the simplest type of shape, possessing only position and no other dimensions. MBStyle has a ``circle`` type that can be styled to represent a point.
  5. .. _mbstyle_cookbook_points_attributes:
  6. Example points layer
  7. --------------------
  8. The :download:`points layer <artifacts/mbstyle_cookbook_point.zip>` used for the examples below contains name and population information for the major cities of a fictional country. For reference, the attribute table for the points in this layer is included below.
  9. .. list-table::
  10. :widths: 30 40 30
  11. :header-rows: 1
  12. * - ``fid`` (Feature ID)
  13. - ``name`` (City name)
  14. - ``pop`` (Population)
  15. * - point.1
  16. - Borfin
  17. - 157860
  18. * - point.2
  19. - Supox City
  20. - 578231
  21. * - point.3
  22. - Ruckis
  23. - 98159
  24. * - point.4
  25. - Thisland
  26. - 34879
  27. * - point.5
  28. - Synopolis
  29. - 24567
  30. * - point.6
  31. - San Glissando
  32. - 76024
  33. * - point.7
  34. - Detrania
  35. - 205609
  36. :download:`Download the points shapefile <artifacts/mbstyle_cookbook_point.zip>`
  37. .. _mbstyle_cookbook_points_simplepoint:
  38. Simple point
  39. ------------
  40. This example specifies points be styled as red circles with a diameter of 6 pixels.
  41. .. figure:: ../../sld/cookbook/images/point_simplepoint.png
  42. Simple point
  43. Code
  44. ~~~~
  45. :download:`Download the "Simple point" MBStyle JSON <artifacts/mbstyle_simple_point_circle.json>`
  46. .. code-block:: json
  47. :linenos:
  48. {
  49. "version": 8,
  50. "name": "point-circle-test",
  51. "layers": [
  52. {
  53. "id": "point",
  54. "type": "circle",
  55. "paint": {
  56. "circle-radius": 3,
  57. "circle-color": "#FF0000",
  58. "circle-pitch-scale": "map"
  59. }
  60. }
  61. ]
  62. }
  63. Details
  64. ~~~~~~~
  65. There is one layer in this MBStyle, which is the simplest possible situation. The "version" must always be set to 8. Layers is required for any MBStyle as an array. "id" is required and is a unique name for that layer. For our examples we will be setting the "type" to "circle".
  66. .. _mbstyle_cookbook_points_simplepointwithstroke:
  67. Simple point with stroke
  68. ------------------------
  69. This example adds a stroke (or border) around the :ref:`mbstyle_cookbook_points_simplepoint`, with the stroke colored black and given a thickness of 2 pixels.
  70. .. figure:: ../../sld/cookbook/images/point_simplepointwithstroke.png
  71. Simple point with stroke
  72. Code
  73. ~~~~
  74. :download:`Download the "Simple point with stroke" MBStyle JSON <artifacts/mbstyle_simple_point_circle_stroke.json>`
  75. .. code-block:: json
  76. :linenos:
  77. {
  78. "version": 8,
  79. "name": "point-circle-test",
  80. "layers": [
  81. {
  82. "id": "point",
  83. "type": "circle",
  84. "paint": {
  85. "circle-radius": 3,
  86. "circle-color": "#FF0000",
  87. "circle-pitch-scale": "map",
  88. "circle-stroke-color": "#000000",
  89. "circle-stroke-width": 2
  90. }
  91. }
  92. ]
  93. }
  94. Details
  95. ~~~~~~~
  96. This example is similar to the :ref:`mbstyle_cookbook_points_simplepoint` example. **Lines 12-13** specify the stroke,
  97. with **line 12** setting the color to black (``'#000000'``) and **line 13** setting the width to 2 pixels.