|
|
@ -4,6 +4,47 @@ param (
|
|
|
|
$DataSource = './Gesamtergebnis-Gemeinderatswahl-2019_stripped.csv'
|
|
|
|
$DataSource = './Gesamtergebnis-Gemeinderatswahl-2019_stripped.csv'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Get-OverpassStreet {
|
|
|
|
|
|
|
|
param (
|
|
|
|
|
|
|
|
[string]
|
|
|
|
|
|
|
|
$Name
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$cache.$Name) {
|
|
|
|
|
|
|
|
$query = @'
|
|
|
|
|
|
|
|
<osm-script>
|
|
|
|
|
|
|
|
<query into="_" type="area">
|
|
|
|
|
|
|
|
<has-kv k="name" modv="" v="Öhringen"/>
|
|
|
|
|
|
|
|
</query>
|
|
|
|
|
|
|
|
<query into="_" type="way">
|
|
|
|
|
|
|
|
<has-kv k="name" modv="" v="{0}"/>
|
|
|
|
|
|
|
|
<area-query/>
|
|
|
|
|
|
|
|
</query>
|
|
|
|
|
|
|
|
<union into="_">
|
|
|
|
|
|
|
|
<item from="_" into="_"/>
|
|
|
|
|
|
|
|
<recurse type="way-node"/>
|
|
|
|
|
|
|
|
</union>
|
|
|
|
|
|
|
|
<print e="" from="_" geometry="skeleton" ids="yes" limit="" mode="body" n="" order="id" s="" w=""/>
|
|
|
|
|
|
|
|
</osm-script>
|
|
|
|
|
|
|
|
'@ -f $Name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$overpassSplat = @{
|
|
|
|
|
|
|
|
Method = 'Post'
|
|
|
|
|
|
|
|
Uri = 'https://overpass-api.de/api/interpreter'
|
|
|
|
|
|
|
|
Body = $query
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$cache.$Name = Invoke-RestMethod @overpassSplat
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cache.$Name
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Test-Path ./cache.xml) {
|
|
|
|
|
|
|
|
$cache = Import-Clixml ./cache.xml
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$cache = @{}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data = Import-Csv $DataSource
|
|
|
|
$data = Import-Csv $DataSource
|
|
|
|
|
|
|
|
|
|
|
@ -81,29 +122,7 @@ $featureList = Import-Csv ./polling_stations.csv
|
|
|
|
$description += "`n`n"
|
|
|
|
$description += "`n`n"
|
|
|
|
$description += $electionResultString
|
|
|
|
$description += $electionResultString
|
|
|
|
|
|
|
|
|
|
|
|
$query = @'
|
|
|
|
$overpassResult = Get-OverpassStreet -Name $street
|
|
|
|
<osm-script>
|
|
|
|
|
|
|
|
<query into="_" type="area">
|
|
|
|
|
|
|
|
<has-kv k="name" modv="" v="Öhringen"/>
|
|
|
|
|
|
|
|
</query>
|
|
|
|
|
|
|
|
<query into="_" type="way">
|
|
|
|
|
|
|
|
<has-kv k="name" modv="" v="{0}"/>
|
|
|
|
|
|
|
|
<area-query/>
|
|
|
|
|
|
|
|
</query>
|
|
|
|
|
|
|
|
<union into="_">
|
|
|
|
|
|
|
|
<item from="_" into="_"/>
|
|
|
|
|
|
|
|
<recurse type="way-node"/>
|
|
|
|
|
|
|
|
</union>
|
|
|
|
|
|
|
|
<print e="" from="_" geometry="skeleton" ids="yes" limit="" mode="body" n="" order="id" s="" w=""/>
|
|
|
|
|
|
|
|
</osm-script>
|
|
|
|
|
|
|
|
'@ -f $street
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$overpassSplat = @{
|
|
|
|
|
|
|
|
Method = 'Post'
|
|
|
|
|
|
|
|
Uri = 'https://overpass-api.de/api/interpreter'
|
|
|
|
|
|
|
|
Body = $query
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$overpassResult = Invoke-RestMethod @overpassSplat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$overpassResult.osm.way.nd) {
|
|
|
|
if (!$overpassResult.osm.way.nd) {
|
|
|
|
Write-Error ('way "{0}" for polling station "{1}" probably not found' -f $street,$pollingStation.name)
|
|
|
|
Write-Error ('way "{0}" for polling station "{1}" probably not found' -f $street,$pollingStation.name)
|
|
|
@ -141,3 +160,5 @@ $output = [PSCustomObject]@{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$output | ConvertTo-Json -Depth 99 | Out-File output.geojson
|
|
|
|
$output | ConvertTo-Json -Depth 99 | Out-File output.geojson
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cache | Export-Clixml ./cache.xml
|
|
|
|