OpenWaterFoundation / owf-app-infomapper-ng

Open Water Foundation InfoMapper web application for menu-driven maps and visualizations, using Angular
GNU General Public License v3.0
1 stars 2 forks source link

Need layer attribute manipulation functions for popup graphs #311

Closed smalers closed 4 years ago

smalers commented 4 years ago

I have been updating the county population data and graph configurations for the Poudre application. Unfortunately, different datasets use different variations on county name, such as SAN JUAN, San Juan, and SanJuan. The first is sometimes found in data. The second is nicer and better-suited for UIs, and the third is useful for file and URL paths to avoids space. Unfortunately, I now have the situation where a popup is configured to display a graph and uses county name SanJuan but the layer uses SAN JUAN. This may come up more in the future because a map layer attribute does not agree exactly. I recommend that the following notation be allowed in the graph configuration file (the json from TSTool). Consider the following example for the existing design:

"TSID" : "County:${featureAttribute:county}.DOLA.Population-Muni.Year~dv~ts/County_${featureAttribute:county}.DOLA.Population-Muni.Year.dv",

I recommend that the following notation is supported, with the following design:

"TSID" : "County:${featureAttribute:county}.DOLA.Population-Muni.Year~dv~ts/County_${featureAttribute:county}.remove(' ').toMixedCase().DOLA.Population-Muni.Year.dv",
  1. Properties surrounded by ${ } can be modified by appending one or more functions using .( ) notation. This allows those functions to have parameters to control the function's behavior.
  2. String literals should use single quotes since double quotes are used around the property value.
  3. The functions can be chained together.
  4. Each function will do something basic. In the above example, there are two functions, one that removes a space, and one that converts the result into MixedCase. The result will be that SAN JUAN is translated into SanJuan.
  5. The list of functions can be expanded over time as needed.
  6. The person putting together the graph configuration will need to insert the additional functions when needed to make the time series data and map layer properties align.
smalers commented 4 years ago

The TSTool SetInputPeriod allows functions on time. See the DateTime class near line 2620. This is not exactly applicable but may provide some insight. When doing string searches, use a start position and keep moving that forward. Look for end position of ), process what is between start and end, and then jump forward to the end and continue processing.

smalers commented 4 years ago

I enabled graphs for municipality population using the marker layer. However, it is not behaving as I expect. In the graph configuration file, I have syntax like:

"TSID" : "Muni:${featureAttribute:MunicipalityName}.DOLA.Population-Total.Year~dv~ts/Muni_${featureAttribute:MunicipalityName}.DOLA.Population-Total.Year.dv",

This indicates that the value of the property MunicipalityName in the layer should be inserted. This seems to work. However, I tried other property names and they also work. Is the code always using the first property in the layer property list? This should not be how it works because the desired attribute for the data file may not be the first property. It coincidentally worked for county name in the counties layer.

Also, unfortunately, all of this design assumes that the attribute values in the layer file are going to match values in other data such as time series. This may not be the case for some data and additional manipulation of attribute values may be needed to align the data. I'll know more once we get counties and municipalities working.

Also, if the click popup shows a lot of attributes, it is necessary to scroll to the bottom to see the graph button which is irritating. We'll need to add filters for attributes shown so this is cleaner. Now that the attribute table for a layer can be viewed, we can trim down the popup to only useful information and action objects such as links and buttons.

I am going to need the features in this issue to fully test because there are some nuances.

smalers commented 4 years ago

The toMixedCase code is not correct. It does not work for all uppercase input like RIO GRANDE because it only changes the first character. The entire word should be lowercase except for the first character of the word. I changed the code to test and it works, but I'm not going to commit.

Another case is Mount Crested Butte municipality. The logic does not loop through all the words. See the following image. I discovered this because there are Crested Butte and Mount Crested Butte municipalities and I had to fix a query.

image

smalers commented 4 years ago

This is working. May add more modifier functions later. Close the issue.