You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
5.8 KiB

7 years ago
  1. ## INSTALL
  2. ```sh
  3. git clone https://github.com/plepe/openstreetbrowser.git
  4. cd openstreetbrowser
  5. npm install
  6. composer install
  7. git submodule init
  8. git submodule update
  9. cp conf.php-dist conf.php
  10. nano conf.php
  11. npm run build
  12. modulekit/build_cache
  13. bin/download_dependencies
  14. ```
  15. ### Upgrade
  16. ```sh
  17. cd openstreetbrowser
  18. git pull
  19. npm update
  20. git submodule init
  21. git submodule update
  22. npm run build
  23. ```
  24. ## DEVELOPMENT
  25. ### Develop categories
  26. ```
  27. rm -r node_modules/openstreetbrowser-categories-main
  28. git clone https://github.com/plepe/openstreetbrowser-categories-main.git node_modules/openstreetbrowser-categories-main
  29. ```
  30. You are welcome to send pull requests via Github!
  31. ### Category definition
  32. There are currently two types of categories: `index` (for sub categories) and `overpass` (for OpenStreetMap data, loaded via an Overpass API request). Each of them is defined via a JSON structure. They can be combined into a single file.
  33. #### Category 'index'
  34. File: dir.json
  35. ```json
  36. {
  37. "type": "index",
  38. "subCategories": [
  39. {
  40. "id": "foo"
  41. },
  42. {
  43. "id": "bar",
  44. "type": "overpass",
  45. "query": "node[amenity=bar]"
  46. }
  47. ]
  48. }
  49. ```
  50. This will define a category with the id 'dir' (from the file name) with two sub-categories: 'foo' (which will be loaded from the file `foo.json`) and 'bar' (which is defined inline as category of type 'overpass' and will show all nodes with the tag 'amenity' set to value 'bar' - see below for more details).
  51. #### Category 'overpass'
  52. File: foo.json
  53. ```json
  54. {
  55. "type": "overpass",
  56. "query": {
  57. "12": "(node[highway~'^(motorway_junction)$'];way[highway~'^(motorway|trunk)$'];)",
  58. "14": "(node[highway~'^(motorway_junction|mini_roundabout|crossing)$'];way[highway~'^(motorway|trunk|primary)$'];)",
  59. "16": "(node[highway];way[highway];)"
  60. }
  61. "feature": {
  62. "style": {
  63. "color": "{% if tags.highway == 'motorway' %}#ff0000{% elseif tags.highway == 'trunk' %}#ff7f00{% elseif tags.highway == 'primary' %}#ffff00{% else %}#0000ff{% endif %}"
  64. },
  65. "markerSign": "{% if tags.highway == 'motorway_junction' %}↗{% elseif tags.highway == 'mini_roundabout' %}↻{% elseif tags.highway == 'crossing' %}▤{% endif %}",
  66. "title": "{{ localizedTag(tags, 'name') |default(localizedTag(tags, 'operator')) | default(localizedTag(tags, 'ref')) | default(trans('unnamed')) }}",
  67. "description": "{{ tagTrans('highway', tags.highway) }}",
  68. "body": "Foo value: {{ const.foo }}"
  69. },
  70. "const": {
  71. "foo": "foo value"
  72. }
  73. }
  74. ```
  75. This will define a category with the id 'foo' (from the file name). It will show some highway amenities, depending on the current zoom level.
  76. The following values are possible for categories (the only mandatory value is query):
  77. * query: either a string or an object of strings with the minimal zoom level as index. Give the Overpass API queries without the header (e.g. `[out:json]` or bounding box) and footer (e.g. `out meta geom` or so).
  78. * minZoom: Show layer only from the given zoom level (default: 14). If `query` is an object and `minZoom` is not set, the lowest zoom level of a query will be used.
  79. * maxZoom: Show layer only up to the given zoom level (default: no limit).
  80. * feature: an object describing how the feature will be formated resp. styled.
  81. * style: a Leaflet style.
  82. * stroke: Whether to draw stroke along the path. Set it to false or empty string to disable borders on polygons or circles. (boolean, true)
  83. * weight: Stroke width in pixels (number, 3)
  84. * color: Stroke color (string, '#3388ff')
  85. * opacity: Stroke opacity (number, 1.0)
  86. * lineCap: shape at end of the stroke (string, 'round')
  87. * lineJoin: shape at corners of the stroke (string, 'round')
  88. * dashArray: stroke dash pattern (string, null)
  89. * dashOffset: distrance into the dash pattern to start dash (string, null)
  90. * fill: whether to fill the path with color. Set it to false or empty string to disable filling on polygons or circles. (boolean, depends)
  91. * fillColor: Fill color. Defaults to the value of the color option. (string)
  92. * fillOpacity: Fill opacity. (number, 0.2)
  93. * fillRule: define how the inside of a shape is determined. (string, 'evenodd')
  94. * smoothFactor: (unclosed ways only) How much to simplify the polyline on each zoom level. (number, 1.0)
  95. * noClip: (unclosed ways only) Disable polyline clipping. (boolean, false)
  96. * nodeFeature: (nodes only) Which type of feature to show on nodes. Valid values: 'Marker', 'Circle', 'CircleMarker'. (string, 'CircleMarker')
  97. * radius: (nodes with nodeFeature 'Circle' or 'CircleMarker' only) Radius of the circle (for 'Circle': in meters, for 'CircleMarker': in pixels, default: 10). (number)
  98. * title: the title of the feature popup, the object in the list and the details page. (default: localized tags for 'name', 'operator' or 'ref', default: 'unknown')
  99. * body: the body for the feature popup and the details page.
  100. * description: a short description shown in the list next to the title.
  101. * popupDescription: like description, but an alternative if the description in popups should be different from the list.
  102. * markerSign: a HTML string which will be shown within the marker and in the list. (default: '')
  103. * priority: a numeric value by which the elements in the list will be sorted (lower values first)
  104. * const: an object variable which is available as prefix in twig functions.
  105. All values in the "feature" section may use the [TwigJS language](doc/TwigJS.md) for evaluation.
  106. ### Hooks
  107. With the function `register_hook` you can hook into several functions. The following hooks are available:
  108. * `state-get`: modules can add values into the current state. Parameters: `state`: an object, which can be modified by modules.
  109. * `state-apply`: when a state is applied to the app. Parameters: `state`: state which should be applied.