|
|
@ -50,7 +50,12 @@ $data = Import-Csv $DataSource
|
|
|
|
|
|
|
|
|
|
|
|
$greenParty = ($data[0].PSObject.Properties.Name -like '*Grüne*')[0]
|
|
|
|
$greenParty = ($data[0].PSObject.Properties.Name -like '*Grüne*')[0]
|
|
|
|
|
|
|
|
|
|
|
|
$partyMapping = $data | Where-Object Description -eq 'Color'
|
|
|
|
$dataMeasure = $data.$greenParty
|
|
|
|
|
|
|
|
| Where-Object {$_ -match '%$'}
|
|
|
|
|
|
|
|
| ForEach-Object {$_ -replace '%$'}
|
|
|
|
|
|
|
|
| Measure-Object -Minimum -Maximum
|
|
|
|
|
|
|
|
$minimumResultValue = $dataMeasure.Minimum
|
|
|
|
|
|
|
|
$maximumResultValue = $dataMeasure.Maximum
|
|
|
|
|
|
|
|
|
|
|
|
# nested array instead of hashtable, because hashtable keys are case-insensitive
|
|
|
|
# nested array instead of hashtable, because hashtable keys are case-insensitive
|
|
|
|
$replacementList = @(
|
|
|
|
$replacementList = @(
|
|
|
@ -88,27 +93,21 @@ $featureList = Import-Csv ./polling_stations.csv
|
|
|
|
$_.Formatted + "`t" + $_.Party
|
|
|
|
$_.Formatted + "`t" + $_.Party
|
|
|
|
}) -join "`n"
|
|
|
|
}) -join "`n"
|
|
|
|
|
|
|
|
|
|
|
|
$greenResult = ($electionResultArray | Where-Object Party -eq $greenParty).ResultValue
|
|
|
|
$greenResultValue = ($electionResultArray | Where-Object Party -eq $greenParty).ResultValue
|
|
|
|
|
|
|
|
|
|
|
|
$opacity = ($greenResult - 20) / 5 * 0.6 + 0.4
|
|
|
|
$colorGreen = (($greenResultValue - $minimumResultValue) * (100 - 220)) / ($maximumResultValue - $minimumResultValue) + 220
|
|
|
|
$opacity = $opacity -gt 1.0 ? 1.0 : $opacity
|
|
|
|
$color = "rgb(0, $colorGreen, 0)"
|
|
|
|
$opacity = $opacity -lt 0.4 ? 0.4 : $opacity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$weight = ($greenResult - 20) / 5 * 10 + 5
|
|
|
|
$opacity = (($greenResultValue - $minimumResultValue) * (1.0 - 0.4)) / ($maximumResultValue - $minimumResultValue) + 0.4
|
|
|
|
$weight = $weight -gt 15 ? 15 : $weight
|
|
|
|
|
|
|
|
$weight = $weight -lt 5 ? 5 : $weight
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$party = $electionResultArray[0].Party
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$electionResultString = 'no data available'
|
|
|
|
$electionResultString = 'no data available'
|
|
|
|
$opacity = 0.5
|
|
|
|
$opacity = 0.5
|
|
|
|
$party = $null
|
|
|
|
$color = '#ff00ff'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$umapOptiones = [PSCustomObject]@{
|
|
|
|
$umapOptiones = [PSCustomObject]@{
|
|
|
|
#color = ($using:partyMapping).$party
|
|
|
|
color = $color
|
|
|
|
color = $partyMapping.$party ?? '#ff00ff'
|
|
|
|
weight = 10
|
|
|
|
weight = $weight
|
|
|
|
|
|
|
|
opacity = $opacity
|
|
|
|
opacity = $opacity
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|