Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to read asset layers from configuration. #4119

Merged
merged 4 commits into from
Oct 20, 2022
Merged

Conversation

dracos
Copy link
Member

@dracos dracos commented Sep 23, 2022

This adds the option to read asset layer configuration from the configuration file, instead of in the JavaScript. This will make the config file quite a bit bigger (but could include it from another file, I imagine), but should make it a bit easier to add or change asset layers without having to update the code. Also a step towards making it configurable elsewhere in future. I've done Lincolnshire in this PR as a starting example, you'd need the config given below in order to have all the same layers that were present in the JS. This won't (yet) handle every layer, but should handle all standard ones.

COBRAND_FEATURES:
  asset_layers:
    lincolnshire:
      - wfs_url: "https://tilma.staging.mysociety.org/mapserver/lincs"
        asset_type: 'spot'
        max_resolution: 2.388657133579254
        asset_id_field: 'Confirm_CA'
        attributes:
          central_asset_id: 'Confirm_CA'
          asset_details: 'Asset_Id'
        geometryName: 'msGeometry'
        srsName: "EPSG:3857"
        body: "Lincolnshire County Council"
      - wfs_feature: "SL_Bollards"
        asset_category: "Bollards (lit)"
        asset_item: 'bollard'
      - wfs_feature: "Public_Transport_Stops"
        asset_group: [ "Bus stops and shelters" ]
        asset_item: 'bus stop or shelter'
      - wfs_feature: "SL_Street_Light_Units"
        asset_category: "Street light"
        asset_item: 'street light'
        filter_key: 'Type'
        filter_value: [ "SL: Bulkhead Lighting", "SL: Refuge Beacon", "SL: Street Lighting Unit" ]
      - wfs_feature: "SL_Street_Light_Units"
        asset_category: "Subway light"
        asset_item: 'light'
        filter_key: 'Type'
        filter_value: "SL: Subway Lighting Unit"
      - wfs_feature: "LCC_Drainage-GulliesOffletsManholes"
        asset_category: "Blocked drain"
        asset_item: 'drain'
      - wfs_feature: "ST_All_Structures"
        asset_category: "Damaged dyke, ditch or culvert"
        asset_item: 'culvert'
        filter_key: 'Type'
        filter_value: [ "ST: Culvert 1 Cell", "ST: Culvert 2+ Cells", "ST: Culvert/Pipe" ]
      - wfs_feature: "SL_Lit_Signs"
        asset_category: "Sign (lit)"
        asset_item: 'street sign'
      - wfs_feature: "ST_All_Structures"
        asset_category: [ "Bridge", "Bridge or Structure" ]
        asset_item: 'bridge'
        filter_key: 'Type'
        filter_value: [ "ST: Bridge", "ST: Bridge Ped/Cycle 1 Span", "ST: Bridge Ped/Cycle 2+ Spans", "ST: Bridge Vehicular 1 Span", "ST: Bridge Vehicular 2-3 Spans", "ST: Bridge Vehicular 4+ Spans" ]
      - wfs_feature: "Safety_Barriers"
        asset_category: ["Roadside safety barrier", "Missing safety fence"]
        asset_item: 'barrier or fence'
        filter_key: 'Type'
        filter_value: "ST: Safety Barrier"
        stylemap: fixmystreet.assets.lincolnshire.barrier_stylemap
        max_resolution: 1.194328566789627
      - wfs_feature: "Carriageway"
        asset_category: [ "Advertisement (e.g. an A-board)", "Damaged/missing cats eye", "Damaged road edge, encroaches less than 100mm", "Damaged road edge, encroaches more than 100mm", "Fallen tree or branch", "Loose chippings", "Manhole/drain cover on road/cycleway", "Pothole on road/cycleway", "Road Markings", "Other road surface issue" ]
        asset_item: 'road'
        asset_item_message: ''
        stylemap: fixmystreet.assets.stylemap_invisible
        disable_pin_snapping: true
      - wfs_feature: "NSG"
        always_visible: true
        non_interactive: true
        max_resolution: 9.554628534317017
        usrn: { attribute: 'Site_Code', field: 'site_code' }
        stylemap: fixmystreet.assets.stylemap_invisible
        nearest_radius: 20
      - wfs_feature: "LLPG"
        max_resolution: 0.5971642833948135
        non_interactive: true
        always_visible: true
        stylemap: fixmystreet.assets.lincolnshire.llpg_stylemap

@codecov
Copy link

codecov bot commented Sep 23, 2022

Codecov Report

Merging #4119 (e165e1c) into master (95a43c1) will increase coverage by 10.29%.
The diff coverage is 91.66%.

@@             Coverage Diff             @@
##           master    #4119       +/-   ##
===========================================
+ Coverage   72.81%   83.10%   +10.29%     
===========================================
  Files          56      371      +315     
  Lines        4756    26031    +21275     
  Branches        0     3982     +3982     
===========================================
+ Hits         3463    21633    +18170     
- Misses       1293     3190     +1897     
- Partials        0     1208     +1208     
Impacted Files Coverage Δ
web/cobrands/bathnes/assets.js 81.39% <ø> (ø)
web/cobrands/bexley/assets.js 91.66% <ø> (ø)
web/cobrands/bristol/assets.js 95.23% <ø> (ø)
web/cobrands/bromley/assets.js 93.75% <ø> (ø)
web/cobrands/buckinghamshire/assets.js 60.95% <ø> (ø)
web/cobrands/centralbedfordshire/assets.js 35.29% <ø> (ø)
web/cobrands/cheshireeast/assets.js 87.50% <ø> (ø)
web/cobrands/fixmystreet-uk-councils/roadworks.js 95.45% <ø> (ø)
web/cobrands/hackney/assets.js 92.85% <ø> (ø)
web/cobrands/hampshire/assets.js 70.00% <ø> (ø)
... and 333 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@chrismytton chrismytton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really cool!

Couple of bits that we discussed on the senior devs call last week:

  • Would be handy to have a script that could pull the current asset config from staging/live somehow
  • Could do with documenting the various options that fixmystreet.assets.add accepts, in particular the difference between wfs_url and http_wfs_url

@dracos dracos marked this pull request as ready for review October 5, 2022 12:31
@dracos dracos force-pushed the config-asset-layer branch 2 times, most recently from 0533bac to 90934d1 Compare October 11, 2022 11:01
For most/all these cases, I could have used wfs_url/wfs_feature, but
that way then requires a CORS pre-flight request, which a GET does not.
Use Lincolnshire as an example.

Add a /_dev/ page to view the configuration to ease development setup.
@dracos dracos force-pushed the config-asset-layer branch 2 times, most recently from 31a9b7f to 5810046 Compare October 18, 2022 14:31
@dracos dracos merged commit e165e1c into master Oct 20, 2022
@github-pages github-pages bot temporarily deployed to github-pages October 20, 2022 09:58 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants