achirkin / qua-view

Web app written in Haskell (GHCJS) for visualizing building geometry

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow to change default visualization color

achirkin opened this issue · comments

On some screens color of the buildings looks too bright that it becomes difficult to distinguish buildings from background. Also it would be useful to show certain types of building blocks in special color.

The solution should have two levels:

  • Scenario level: specify default color for static and and active building blocks, as well as for lines.
  • Object level: specify visualization color per building block

Step 1:
The first solution relies on changes introduced to scenario representation by issue #3.
We add another object to the root of scenario JSON file:

[root]
  - geometry: ...
  - properties:
       - defaultBlockColor: "#RRGGBB"
       - defaultStaticColor: "#RRGGBB"
       - defaultLineColor: "#RRGGBB"

So we need to add these properties to the City data type, and use these properties to render the city in the CityView module.

Step 2:
Each building is a GeoJSON Feature object, so it has properties field inside. We can use this field to store default visualization color:

[feature]
  - geometry: ...
  - properties:
       - viewColor: "#RRGGBB"

We can use something like JS foreign function field accessor + Hs parser function to get color property from the object.

Then the more complicated part begins.

Step 3:
I use a prepared array of building colors to render property colors of buildings in a city.
This is rather weird solution. So one option is to update and use this color array all the time (not only when any building is selected). Another option is to rework this behavior to access colors directly from building objects.

Congratulations! Everything seems to be working. I am uploading new JS to server - let's test it!