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.

167 lines
8.2 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. => [more detailed Installation instructions](doc/INSTALL.md)
  16. ### Upgrade
  17. ```sh
  18. cd openstreetbrowser
  19. git pull
  20. npm update
  21. git submodule init
  22. git submodule update
  23. npm run build
  24. ```
  25. ## DEVELOPMENT
  26. ### Develop categories
  27. ```
  28. rm -r node_modules/openstreetbrowser-categories-main
  29. git clone https://github.com/plepe/openstreetbrowser-categories-main.git node_modules/openstreetbrowser-categories-main
  30. ```
  31. You are welcome to send pull requests via Github!
  32. ### Category definition
  33. 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 (old) or YAML (recommended) structure. They can be combined into a single file.
  34. Check out the [tutorial](./doc/Tutorial.md)!
  35. #### Category 'index'
  36. File: dir.json
  37. ```json
  38. {
  39. "type": "index",
  40. "subCategories": [
  41. {
  42. "id": "foo"
  43. },
  44. {
  45. "id": "bar",
  46. "type": "overpass",
  47. "query": "node[amenity=bar]"
  48. }
  49. ]
  50. }
  51. ```
  52. or File: dir.yaml
  53. ```yaml
  54. type: index
  55. subCategories:
  56. - id: foo
  57. - id: bar
  58. type: overpass
  59. query: node[amenity=bar]
  60. ```
  61. 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).
  62. #### Category 'overpass'
  63. File: foo.json
  64. ```json
  65. {
  66. "type": "overpass",
  67. "query": {
  68. "12": "(node[highway~'^(motorway_junction)$'];way[highway~'^(motorway|trunk)$'];)",
  69. "14": "(node[highway~'^(motorway_junction|mini_roundabout|crossing)$'];way[highway~'^(motorway|trunk|primary)$'];)",
  70. "16": "(node[highway];way[highway];)"
  71. },
  72. "feature": {
  73. "style": {
  74. "color": "{% if tags.highway == 'motorway' %}#ff0000{% elseif tags.highway == 'trunk' %}#ff7f00{% elseif tags.highway == 'primary' %}#ffff00{% else %}#0000ff{% endif %}"
  75. },
  76. "markerSign": "{% if tags.highway == 'motorway_junction' %}↗{% elseif tags.highway == 'mini_roundabout' %}↻{% elseif tags.highway == 'crossing' %}▤{% endif %}",
  77. "title": "{{ localizedTag(tags, 'name') |default(localizedTag(tags, 'operator')) | default(localizedTag(tags, 'ref')) | default(trans('unnamed')) }}",
  78. "description": "{{ tagTrans('highway', tags.highway) }}",
  79. "body": "Foo value: {{ const.foo }}"
  80. },
  81. "const": {
  82. "foo": "foo value"
  83. }
  84. }
  85. ```
  86. 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.
  87. The following values are possible for categories (the only mandatory value is query):
  88. * 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).
  89. * 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.
  90. * maxZoom: Show layer only up to the given zoom level (default: no limit).
  91. * feature: an object describing how the feature will be formatted resp. styled.
  92. * style: a Leaflet style.
  93. * stroke: Whether to draw stroke along the path. Set it to false or empty string to disable borders on polygons or circles. (boolean, true)
  94. * width: Stroke width, optionally with unit ('px' for width in screen pixels (default) or 'm' for width in world meters). Default: '3px'.
  95. * color: Stroke color (string, '#3388ff')
  96. * opacity: Stroke opacity (number, 1.0)
  97. * offset: Offset stroke to left or right ('px' for width in screen pixels (default) or 'm' for width in world meters). Default: '0px'.
  98. * lineCap: shape at end of the stroke (string, 'round')
  99. * lineJoin: shape at corners of the stroke (string, 'round')
  100. * dashArray: stroke dash pattern (string, null)
  101. * dashOffset: distrance into the dash pattern to start dash (string, null)
  102. * fill: whether to fill the path with color. Set it to false or empty string to disable filling on polygons or circles. (boolean, depends)
  103. * fillColor: Fill color. Defaults to the value of the color option. (string)
  104. * fillOpacity: Fill opacity. (number, 0.2)
  105. * fillRule: define how the inside of a shape is determined. (string, 'evenodd')
  106. * smoothFactor: (unclosed ways only) How much to simplify the polyline on each zoom level. (number, 1.0)
  107. * noClip: (unclosed ways only) Disable polyline clipping. (boolean, false)
  108. * nodeFeature: (nodes only) Which type of feature to show on nodes. Valid values: 'Marker', 'Circle', 'CircleMarker'. (string, 'CircleMarker')
  109. * radius: (nodes with nodeFeature 'Circle' or 'CircleMarker' only) Radius of the circle (for 'Circle': in meters, for 'CircleMarker': in pixels, default: 10). (number)
  110. * pattern: false/empty: no pattern, 'arrowHead', 'dash', 'marker'
  111. * pattern-offset: Offset of the first pattern symbol, from the start point of the line. Default: 0.
  112. * pattern-endOffset: Minimum offset of the last pattern symbol, from the end point of the line. Default: 0.
  113. * pattern-repeat: Repetition interval of the pattern symbols. Defines the distance between each consecutive symbol's anchor point.
  114. * pattern-polygon: true/false (arrowHead only)
  115. * pattern-pixelSize: size of pattern (arrowHead and dash only)
  116. * pattern-headAngle: Angle of the digits (arrowHead only)
  117. * pattern-angleCorrection: degrees (arrowHead and marker only)
  118. * pattern-rotate: false (marker only)
  119. * pattern-path-*: Options for the path, e.g. pattern-path-width, pattern-path-color.
  120. * pane: show vector on the specified pane (usually defined: 'overlayPane' (default), 'hover', 'selected', 'casing')
  121. * 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')
  122. * body: the body for the feature popup and the details page.
  123. * description: a short description shown in the list next to the title.
  124. * popupDescription: like description, but an alternative if the description in popups should be different from the list.
  125. * markerSign: a HTML string which will be shown within the marker and in the list. (default: '')
  126. * priority: a numeric value by which the elements in the list will be sorted (lower values first)
  127. * preferredZoom: At which max. zoom level will the map zoom when showing details
  128. * const: an object variable which is available as prefix in twig functions.
  129. All values in the "feature" section may use the [TwigJS language](doc/TwigJS.md) for evaluation.
  130. ### Hooks
  131. With the function `register_hook` you can hook into several functions. The following hooks are available:
  132. * `state-get`: modules can add values into the current state. Parameters: `state`: an object, which can be modified by modules.
  133. * `state-apply`: when a state is applied to the app. Parameters: `state`: state which should be applied.
  134. * `show-details`: called when details are being displayed. Parameters: data (see properties in doc/TwigJS.md), category, dom, callback.
  135. * `hide-details`: called when the details page is left. No parameters.
  136. * `show-popup`: called when a popup is being displayed. Parameters: data (see properties in doc/TwigJS.md), category, dom, callback.
  137. * `options_save`: called when options are saved. Parameters: options (the new object), old_options (before save)
  138. * `initFinish`: called when the app initialization finishes
  139. ### New locale
  140. * Add language code to the `$languages` array in conf.php (and conf.php-dist)
  141. * Create file `locales/CODE.js` with:
  142. ```js
  143. global.locale = {
  144. id: 'CODE',
  145. moment: require('moment'),
  146. // replace 'en' by 'CODE', when a translation for date-format has been submitted
  147. osmDateFormatTemplates: require('openstreetmap-date-format/templates/en')
  148. }
  149. require('moment/locale/CODE')
  150. ```
  151. * Run `npm run build-locales`