This is PowerShell code for vpm, not at all guaranteed to run, but might be useful for anyone trying to recreate the data.
param($area)
if (!$area) {
$area = '*menuires*'
}
write-host "Loading data for [$area]"
function strip([string]$s) {
$s -replace "[`n`r`t]",' ' -replace ' ',' ' -replace "[`n`r`t ]+$",'' -replace "^[`n`r`t ]+",''
}
function getnumber([string]$data, [string]$unit) {
#test: (getnumber " 5,47 m/s" "m/s") == 5.47
$data = $data -replace ',','.' -replace '^ +','' -replace ' +$',''
if ($data -match '\?\?') {
$null
} elseif ($data -match "([0-9.]+) $unit") {
[double]($Matches[1])
}
}
$fields = @{
"Height of valley station" = 'hbot';
"Height of middle station(s)" = 'hmid';
"Height of mountain station" = 'htop';
"Vertical rise" = 'vert';
"Route distance" = 'length';
"Horizontal length" = 'horz';
"Average incline" = 'incline';
"Largest incline" = 'incmax';
"Number of pillars" = 'pillars';
"Year of closing down" = 'closed';
"Track width" = 'trkwidth';
"Driving station" = '';
"Tension station" = '';
"Tension type" = '';
"Tension way" = '';
"Rope manufacturer" = '';
"Length of rope" = '';
"Total weight of rope" = '';
"Rope diameter" = '';
"Electrical engineering" = '';
"Drive power (Start)" = '';
"Drive power (Operation)" = '';
"Brake power" = '';
"Grip type" = '';
"Cab manufacturer" = '';
"Cab model" = '';
"Seat cover" = 'covered';
"Seat heater" = 'heated';
"Number of cabs" = 'cabins';
"Persons per cab" = '';
"Cab distance..." = '';
"Cab interval..." = '';
"Maximum capacity" = '';
"Travel time" = 'time';
"Driving speed line" = 'speed';
"Transport uphill" = '';
"Transport downhill" = '';
"Drive direction" = '';
"Garage type" = '';
"Garage place" = '';
"Situation of entrance" = '';
"Situation of exit" = '';
"Construction period" = '';
}
# make template object
$objfields = @("replaced","name","place","type","url") + [string[]]($fields.values | ? { $_ -ne '' })
$base = 'http://www.seilbahntechnik.net'
# Get the summary page
# this is loose search:
# $h = http-get-html "$base/en/lifts/searchresult.php?sprache=en&suchoption=volltext&eingabe=$area"
# this is place only:
$area_search = "*$area*"
$h = http-get-html "$base/en/lifts/searchresult.php?eOrt=$area_search&eLiftname=&eLand=&eArt=&eHersteller=&eBaujahr=&toleranz=AND&sort_by1=Ort&sort_by2=Liftname&sort_dir=ASC&sprache=en&suchoption=erweitert"
$n = $h.DocumentNode.CreateNavigator()
# find all "details" links
$details_anchors = $n.Select('//img[contains(@src,"details")]/parent::a');
# and call them "lifts"
$lift_urls = $details_anchors | % {
$out = 1 | select url,replaced
$out.url = $_.GetAttribute('href','')
$out.replaced = $_.Select('./parent::td/preceding-sibling::td/img[contains(@alt,"Replaced")]').Count
$out
}
if (!$lift_urls) {
throw "no lifts"
}
write-host "Got $($lift_urls.count) lifts"
$raw = $lift_urls | % {
$out = 1|select $objfields
$url = $_.url
$out.url = "$base$url"
$out.replaced = $_.replaced
$h1 = (http-get-html $out.url).DocumentNode
$gitbl = '//b[contains(., "General information")]/ancestor::table[1]'
$out.place = strip ($h1.SelectSingleNode($gitbl+'/descendant::td[contains(.,"Place (skiresort)")]/following-sibling::td').innertext)
$out.name = strip ($h1.SelectSingleNode($gitbl+'/descendant::td[contains(.,"Name of lift")]/following-sibling::td').innertext)
$out.type = strip ($h1.SelectSingleNode($gitbl+'/descendant::td[contains(.,"Type")]/following-sibling::td').innertext)
$tds = $h1.SelectNodes('//b[contains(., "Technical data")]/ancestor::td[1]/parent::tr/following-sibling::tr/td')
$e = $tds.GetEnumerator()
if (!$e) {
write-host "WARNING: no enumerator"
continue
}
[void]$e.MoveNext()
[void]$e.MoveNext()
while ($true) {
$fieldtext = strip $e.Current.InnerText
if (!$e.MoveNext()) { write-error "odd"; break; }
$value = strip $e.Current.InnerText
if (!$e.MoveNext()) { break; }
$field = $fields[$fieldtext]
if ($field) {
#write-host "[$field] = [$value]"
$out.$field = $value
} else {
#write-host "[$fieldtext] = [$value]"
}
}
if ($out.closed) {
write-host "$($out.name) closed in $($out.closed)";
continue
}
$replaced_str = ''
if ($_.replaced) {
$replaced_str = ' [RIP]'
}
write-host "$($out.name)$replaced_str $($out.type) $($out.time) $($out.vert) $($out.speed)"
$out
}
$lifts = $raw | % {
$out = 1 | select replaced,valid,name,place,type,url,vert,time,vpm,speed,length,speed_raw,vert_raw,time_raw,length_raw
$out.name = $_.name
$out.place = $_.place
$out.type = $_.type
$out.url = $_.url
$out.speed_raw = $_.speed
$out.vert_raw = $_.vert
$out.time_raw = $_.time
$out.speed_raw = $_.speed
$out.length_raw = $_.length
$out.replaced = $_.replaced -eq '1'
if ($out.replaced) {
$out.valid = 0
} else {
$time = getnumber $_.time min
$speed = getnumber $_.speed "m/s"
$vert = getnumber $_.vert m
$length = getnumber $_.length m
write-host "$($_.name) $($_.type) t=$time, l=$length, s=$speed, "
$time_est = $null
$add_est = $false
if ($length -and $speed) {
$time_est = $length / $speed / 60
# warn if more than 20sec time diff
if ($time -and [math]::abs($time - $time_est) -gt 0.3) {
write-host ("WARNING: Estimated time ({0,5:##,#} mins) != recorded ({1,5:##,#} mins). $($_.name)" -f $time,$time_est)
# write-host "WARNING: $($_.name) time est: [$length] / [$speed] = $time_est mins != $time mins"
# write-host (" Err ratio = {0,5:##.#} diff = {1,5:##.#} mins" -f ($time_est/$time*100),($time - $time_est))
$add_est = $true
}
}
if (!$time -and $time_est) {
# write-host "time est: [$length] / [$speed]"
$time = $time_est
}
if ($time -and $vert) {
$vpm = $vert / $time
$out.vert = $vert
$out.vpm = $vpm
$out.time = $time
$out.speed = $speed
$out.length = $length
$out.valid = 1
if ($add_est) {
$out2 = awf-clone $out
$out2.time = $time_est
$out2.vpm = ($vert / $time_est)
$out2.name += " [*]"
$out2
}
} else {
$out.valid = 0
write-warning "$($_.name): [$($_.vert)] [$($_.time)] [$($_.speed)] [$($_.length)]`n"
}
}
$out
}
$lifts = $lifts | sort -desc vpm
# create dokuwiki table
$filename = "vpm/$area.txt" -replace " ","_"
$table = $lifts | % {
"==== Lift data for places matching `"$area`" ===="
"^ Lift ^ Type ^ Vertical Rise ^ Ride Time\\ (min) ^ Vert Per Minute\\ (m/min) ^ Line Speed\\ (m/sec) ^ Line length\\ (m) ^ Link ^"
} {
if ($_.valid) {
$vert = "{0,5:N0}" -f [math]::round($_.vert)
$type = $_.type
$time = "{0,6:N2}" -f $_.time
$vpm = "{0,6:N1}" -f $_.vpm
if ($_.speed_raw -match '\?\? m/s') {
$speed = " ?"
} else {
$speed = "{0,6:N1}" -f [double]$_.speed
}
$length = "{0,6:N0}" -f [math]::round($_.length)
"| $($_.Name) | $type | $vert | $time | $vpm | $speed | $length | [[$($_.url)|link]] |"
} else {
if ($_.Replaced) {
$note = 'RIP'
} else {
$note = 'N/A'
}
"| $($_.Name)\\ [$note] | $($_.type) | $($_.vert_raw) | $($_.time_raw) | N/A | $($_.speed_raw) | $($_.length_raw) | [[$($_.url)|link]] |"
}
}
$table | out-file -enc utf8 "$filename"
$table -join "`n" | set-clipboard
cat $filename | % { $_ -replace 'http:.*htm\|','' }