createdb transitdata | createdb transitdata |
createlang -d transitdata plpgsql | createlang -d transitdata plpgsql |
psql -d transitdata -f /var/www/lib/postgis.sql | psql -d transitdata -f /var/www/lib/postgis.sql |
# curl https://github.com/maxious/ACTBus-ui/raw/master/transitdata.cbrfeed.sql.gz -o transitdata.cbrfeed.sql.gz | # curl https://github.com/maxious/ACTBus-ui/raw/master/transitdata.cbrfeed.sql.gz -o transitdata.cbrfeed.sql.gz |
#made with pg_dump transitdata | gzip -c > transitdata.cbrfeed.sql.gz | #made with pg_dump transitdata | gzip -c > transitdata.cbrfeed.sql.gz |
gunzip /var/www/transitdata.cbrfeed.sql.gz | gunzip /var/www/transitdata.cbrfeed.sql.gz |
psql -d transitdata -f /var/www/transitdata.cbrfeed.sql | psql -d transitdata -f /var/www/transitdata.cbrfeed.sql |
#createuser transitdata -SDRP | #createuser transitdata -SDRP |
#password transitdata | #password transitdata |
#psql -d transitdata -c "GRANT SELECT ON TABLE agency,calendar,calendar_dates,routes,stop_times,stops,trips\ | #psql -d transitdata -c "GRANT SELECT ON TABLE agency,calendar,calendar_dates,routes,stop_times,stops,trips TO transitdata;" |
#,servicealerts_alerts,servicealerts_informed TO transitdata;" | #psql -d transitdata -c "GRANT SELECT,INSERT ON TABLE myway_observations,myway_timingdeltas,myway_routes,myway_stops TO transitdata;" |
#psql -d transitdata -c "GRANT SELECT,INSERT ON TABLE myway_observations,myway_routes,myway_stops,myway_timingdeltas TO transitdata;" | #psql -d transitdata -c "GRANT SELECT,INSERT,UPDATE ON TABLE servicealerts_alerts,servicealerts_informed TO transitdata;" |
#psql -d transitdata -c "GRANT SELECT,INSERT,UPDATE ON TABLE myway_routes,myway_stops TO transitdata;" | #psql -d transitdata -c "GRANT USAGE,SELECT ON SEQUENCE servicealerts_alerts_id_seq TO transitdata;" |
##psql -d transitdata -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO transitdata;" | ##psql -d transitdata -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO transitdata;" |
## INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") | ## INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") |
##SELECT '', 'public', 'shapes', 'shape_pt', ST_CoordDim(shape_pt), ST_SRID(shape_pt), GeometryType(shape_pt) | ##SELECT '', 'public', 'shapes', 'shape_pt', ST_CoordDim(shape_pt), ST_SRID(shape_pt), GeometryType(shape_pt) |
##FROM shapes LIMIT 1; | ##FROM shapes LIMIT 1; |
php /var/www/updatedb.php | php /var/www/updatedb.php |
<?php | <?php |
header('Content-type: text/css'); | header('Content-type: text/css'); |
ob_start("compress"); | ob_start("compress"); |
function compress($buffer) { | function compress($buffer) { |
/* remove comments */ | /* remove comments */ |
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); | $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); |
/* remove tabs, spaces, newlines, etc. */ | /* remove tabs, spaces, newlines, etc. */ |
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer); | $buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer); |
return $buffer; | return $buffer; |
} | } |
echo ' | echo ' |
.ui-li-thumb, .ui-li-icon { position: relative; } | .ui-li-thumb, .ui-li-icon { position: relative; } |
.ui-navbar { | .ui-navbar { |
width: 100%; | width: 100%; |
} | } |
.ui-btn-inner { | .ui-btn-inner { |
white-space: normal !important; | white-space: normal !important; |
} | } |
.ui-li-heading { | .ui-li-heading { |
white-space: normal !important; | white-space: normal !important; |
} | } |
.ui-listview-filter { | .ui-listview-filter { |
margin: 0 !important; | margin: 0 !important; |
} | } |
.ui-icon-navigation { | .ui-icon-navigation { |
background-image: url(images/113-navigation.png); | background-image: url(images/113-navigation.png); |
background-position: 1px 0; | background-position: 1px 0; |
} | } |
.ui-icon-beaker { | .ui-icon-beaker { |
background-image: url(images/91-beaker-2.png); | background-image: url(images/91-beaker-2.png); |
background-position: 1px 0; | background-position: 1px 0; |
} | } |
#footer { | #footer { |
text-size: 0.75em; | text-size: 0.75em; |
text-align: center; | text-align: center; |
} | } |
body { | body { |
background-color: #F0F0F0; | background-color: #F0F0F0; |
} | } |
#jqm-homeheader { | #jqm-homeheader { |
text-align: center; | text-align: center; |
} | } |
.viaPoints { | .viaPoints { |
display: none; | display: none; |
text-size: 0.2em; | text-size: 0.2em; |
} | } |
.min-width-480px .viaPoints { | .min-width-480px .viaPoints { |
display: inline; | display: inline; |
} | } |
#extrainfo { | #extrainfo { |
visibility: hidden; | visibility: hidden; |
display: none; | display: none; |
} | } |
#servicewarning { | .servicewarning { |
padding: 1em; | padding: 1em; |
margin-bottom: 0.5em; | margin-bottom: 0.5em; |
text-size: 0.2em; | text-size: 0.2em; |
background-color: #FF9; | background-color: #FF9; |
-moz-border-radius: 15px; | -moz-border-radius: 15px; |
border-radius: 15px; | border-radius: 15px; |
} | } |
#footer { | #footer { |
clear:both; | clear:both; |
text-align:center; | text-align:center; |
} | } |
// source http://webaim.org/techniques/skipnav/ | // source http://webaim.org/techniques/skipnav/ |
#skip a, #skip a:hover, #skip a:visited | #skip a, #skip a:hover, #skip a:visited |
{ | { |
position:absolute; | position:absolute; |
left:0px; | left:0px; |
top:-500px; | top:-500px; |
width:1px; | width:1px; |
height:1px; | height:1px; |
overflow:hidden; | overflow:hidden; |
} | } |
#skip a:active, #skip a:focus | #skip a:active, #skip a:focus |
{ | { |
position:static; | position:static; |
width:auto; | width:auto; |
height:auto; | height:auto; |
}'; | }'; |
//if (false) | //if (false) |
echo ' | echo ' |
// adaptive layout from jQuery Mobile docs site | // adaptive layout from jQuery Mobile docs site |
.type-interior .content-secondary { | .type-interior .content-secondary { |
border-right: 0; | border-right: 0; |
border-left: 0; | border-left: 0; |
margin: 10px -15px 0; | margin: 10px -15px 0; |
background: #fff; | background: #fff; |
border-top: 1px solid #ccc; | border-top: 1px solid #ccc; |
} | } |
.type-home .ui-content { | .type-home .ui-content { |
margin-top: 5px; | margin-top: 5px; |
} | } |
.type-interior .ui-content { | .type-interior .ui-content { |
padding-bottom: 0; | padding-bottom: 0; |
} | } |
.content-secondary .ui-collapsible-contain { | .content-secondary .ui-collapsible-contain { |
padding: 10px 15px; | padding: 10px 15px; |
} | } |
.content-secondary .ui-collapsible-heading { | .content-secondary .ui-collapsible-heading { |
margin: 0 0 30px; | margin: 0 0 30px; |
} | } |
.content-secondary .ui-collapsible-heading-collapsed, | .content-secondary .ui-collapsible-heading-collapsed, |
.content-secondary .ui-collapsible-content { | .content-secondary .ui-collapsible-content { |
padding:0; | padding:0; |
margin: 0; | margin: 0; |
} | } |
/* hires ahoy */ | /* hires ahoy */ |
@media all and (min-width: 650px){ | @media all and (min-width: 650px){ |
.content-secondary { | .content-secondary { |
text-align: left; | text-align: left; |
float: left; | float: left; |
width: 45%; | width: 45%; |
background: none; | background: none; |
border-top: 0; | border-top: 0; |
} | } |
.content-secondary, | .content-secondary, |
.type-interior .content-secondary { | .type-interior .content-secondary { |
margin: 30px 0 20px 2%; | margin: 30px 0 20px 2%; |
padding: 20px 4% 0 0; | padding: 20px 4% 0 0; |
background: none; | background: none; |
} | } |
.type-index .content-secondary { | .type-index .content-secondary { |
padding: 0; | padding: 0; |
} | } |
.type-index .content-secondary .ui-listview { | .type-index .content-secondary .ui-listview { |
margin: 0; | margin: 0; |
} | } |
.content-primary { | .content-primary { |
width: 45%; | width: 45%; |
float: right; | float: right; |
margin-top: 30px; | margin-top: 30px; |
margin-right: 1%; | margin-right: 1%; |
padding-right: 1%; | padding-right: 1%; |
} | } |
.content-primary ul:first-child { | .content-primary ul:first-child { |
margin-top: 0; | margin-top: 0; |
} | } |
.type-interior .content-primary { | .type-interior .content-primary { |
padding: 1.5em 6% 3em 0; | padding: 1.5em 6% 3em 0; |
margin: 0; | margin: 0; |
} | } |
/* fix up the collapsibles - expanded on desktop */ | /* fix up the collapsibles - expanded on desktop */ |
.content-secondary .ui-collapsible-heading { | .content-secondary .ui-collapsible-heading { |
display: none; | display: none; |
} | } |
.content-secondary .ui-collapsible-contain { | .content-secondary .ui-collapsible-contain { |
margin:0; | margin:0; |
} | } |
.content-secondary .ui-collapsible-content { | .content-secondary .ui-collapsible-content { |
display: block; | display: block; |
margin: 0; | margin: 0; |
padding: 0; | padding: 0; |
} | } |
.type-interior .content-secondary .ui-li-divider { | .type-interior .content-secondary .ui-li-divider { |
padding-top: 1em; | padding-top: 1em; |
padding-bottom: 1em; | padding-bottom: 1em; |
} | } |
.type-interior .content-secondary { | .type-interior .content-secondary { |
margin: 0; | margin: 0; |
padding: 0; | padding: 0; |
} | } |
} | } |
@media all and (min-width: 750px){ | @media all and (min-width: 750px){ |
.type-home .ui-content, | .type-home .ui-content, |
.type-interior .ui-content { | .type-interior .ui-content { |
background-position: 39%; | background-position: 39%; |
} | } |
.content-secondary { | .content-secondary { |
width: 34%; | width: 34%; |
} | } |
.content-primary { | .content-primary { |
width: 56%; | width: 56%; |
padding-right: 1%; | padding-right: 1%; |
} | } |
.type-interior .ui-content { | .type-interior .ui-content { |
background-position: 34%; | background-position: 34%; |
} | } |
} | } |
@media all and (min-width: 1200px){ | @media all and (min-width: 1200px){ |
.type-home .ui-content{ | .type-home .ui-content{ |
background-position: 38.5%; | background-position: 38.5%; |
} | } |
.type-interior .ui-content { | .type-interior .ui-content { |
background-position: 30%; | background-position: 30%; |
} | } |
.content-secondary { | .content-secondary { |
width: 30%; | width: 30%; |
padding-right:6%; | padding-right:6%; |
margin: 30px 0 20px 5%; | margin: 30px 0 20px 5%; |
} | } |
.type-interior .content-secondary { | .type-interior .content-secondary { |
margin: 0; | margin: 0; |
padding: 0; | padding: 0; |
} | } |
.content-primary { | .content-primary { |
width: 50%; | width: 50%; |
margin-right: 5%; | margin-right: 5%; |
padding-right: 3%; | padding-right: 3%; |
} | } |
.type-interior .content-primary { | .type-interior .content-primary { |
width: 60%; | width: 60%; |
} | } |
} | } |
'; | '; |
ob_end_flush(); | ob_end_flush(); |
?> | ?> |
<?php | <?php |
/* | /* |
* Copyright 2010,2011 Alexander Sadleir | * Copyright 2010,2011 Alexander Sadleir |
Licensed under the Apache License, Version 2.0 (the "License"); | Licensed under the Apache License, Version 2.0 (the "License"); |
you may not use this file except in compliance with the License. | you may not use this file except in compliance with the License. |
You may obtain a copy of the License at | You may obtain a copy of the License at |
http://www.apache.org/licenses/LICENSE-2.0 | http://www.apache.org/licenses/LICENSE-2.0 |
Unless required by applicable law or agreed to in writing, software | Unless required by applicable law or agreed to in writing, software |
distributed under the License is distributed on an "AS IS" BASIS, | distributed under the License is distributed on an "AS IS" BASIS, |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
See the License for the specific language governing permissions and | See the License for the specific language governing permissions and |
limitations under the License. | limitations under the License. |
*/ | */ |
// SELECT array_to_string(array(SELECT REPLACE(name_2006, ',', '\,') as name FROM suburbs order by name), ',') | // SELECT array_to_string(array(SELECT REPLACE(name_2006, ',', '\,') as name FROM suburbs order by name), ',') |
$suburbs = explode(",", "Acton,Ainslie,Amaroo,Aranda,Banks,Barton,Belconnen,Bonner,Bonython,Braddon,Bruce,Calwell,Campbell,Chapman,Charnwood,Chifley,Chisholm,City,Conder,Cook,Curtin,Deakin,Dickson,Downer,Duffy,Dunlop,Evatt,Fadden,Farrer,Fisher,Florey,Flynn,Forrest,Franklin,Fraser,Fyshwick,Garran,Gilmore,Giralang,Gordon,Gowrie,Greenway,Griffith,Gungahlin,Hackett,Hall,Harrison,Hawker,Higgins,Holder,Holt,Hughes,Hume,Isaacs,Isabella Plains,Kaleen,Kambah,Kingston,Latham,Lawson,Lyneham,Lyons,Macarthur,Macgregor,Macquarie,Mawson,McKellar,Melba,Mitchell,Monash,Narrabundah,Ngunnawal,Nicholls,Oaks Estate,O'Connor,O'Malley,Oxley,Page,Palmerston,Parkes,Pearce,Phillip,Pialligo,Red Hill,Reid,Richardson,Rivett,Russell,Scullin,Spence,Stirling,Symonston,Tharwa,Theodore,Torrens,Turner,Wanniassa,Waramanga,Watson,Weetangera,Weston,Yarralumla"); | $suburbs = explode(",", "Acton,Ainslie,Amaroo,Aranda,Banks,Barton,Belconnen,Bonner,Bonython,Braddon,Bruce,Calwell,Campbell,Chapman,Charnwood,Chifley,Chisholm,City,Conder,Cook,Curtin,Deakin,Dickson,Downer,Duffy,Dunlop,Evatt,Fadden,Farrer,Fisher,Florey,Flynn,Forrest,Franklin,Fraser,Fyshwick,Garran,Gilmore,Giralang,Gordon,Gowrie,Greenway,Griffith,Gungahlin,Hackett,Hall,Harrison,Hawker,Higgins,Holder,Holt,Hughes,Hume,Isaacs,Isabella Plains,Kaleen,Kambah,Kingston,Latham,Lawson,Lyneham,Lyons,Macarthur,Macgregor,Macquarie,Mawson,McKellar,Melba,Mitchell,Monash,Narrabundah,Ngunnawal,Nicholls,Oaks Estate,O'Connor,O'Malley,Oxley,Page,Palmerston,Parkes,Pearce,Phillip,Pialligo,Red Hill,Reid,Richardson,Rivett,Russell,Scullin,Spence,Stirling,Symonston,Tharwa,Theodore,Torrens,Turner,Wanniassa,Waramanga,Watson,Weetangera,Weston,Yarralumla"); |
function staticmap($mapPoints, $collapsible = true, $twotone = false, $path = false, $numbered = false) { | function staticmap($mapPoints, $collapsible = true, $twotone = false, $path = false, $numbered = false) { |
$markers = ""; | $markers = ""; |
$height = 300; | $height = 300; |
$width = $height; | $width = $height; |
$index = 0; | $index = 0; |
if (sizeof($mapPoints) < 1) | if (sizeof($mapPoints) < 1) |
return "map error"; | return "map error"; |
if (sizeof($mapPoints) === 1) { | if (sizeof($mapPoints) === 1) { |
$markers = "markers={$mapPoints[0][0]},{$mapPoints[0][1]}"; | $markers = "markers={$mapPoints[0][0]},{$mapPoints[0][1]}"; |
} else { | } else { |
if (!$numbered) { | if (!$numbered) { |
$markers = "markers="; | $markers = "markers="; |
} | } |
if ($path) { | if ($path) { |
$markers.= "markers={$mapPoints[0][0]},{$mapPoints[0][1]}&path="; | $markers.= "markers={$mapPoints[0][0]},{$mapPoints[0][1]}&path="; |
} | } |
foreach ($mapPoints as $index => $mapPoint) { | foreach ($mapPoints as $index => $mapPoint) { |
if ($twotone && $index == 0) { | if ($twotone && $index == 0) { |
$markers = "markerd=color:red|".$mapPoint[0] . "," . $mapPoint[1]."&markers="; | $markers = "markerd=color:red|".$mapPoint[0] . "," . $mapPoint[1]."&markers="; |
} else { | } else { |
if ($numbered) { | if ($numbered) { |
$label = ($index > 9 ? 9 : $index); | $label = ($index > 9 ? 9 : $index); |
$markers.= "markers=label:$label|" . $mapPoint[0] . "," . $mapPoint[1]; | $markers.= "markers=label:$label|" . $mapPoint[0] . "," . $mapPoint[1]; |
if ($index + 1 != sizeof($mapPoints)) { | if ($index + 1 != sizeof($mapPoints)) { |
$markers.= "&"; | $markers.= "&"; |
} | } |
} else { | } else { |
$markers.= $mapPoint[0] . "," . $mapPoint[1]; | $markers.= $mapPoint[0] . "," . $mapPoint[1]; |
if ($index + 1 != sizeof($mapPoints)) { | if ($index + 1 != sizeof($mapPoints)) { |
$markers.= "|"; | $markers.= "|"; |
} | } |
} | } |
$index++; | $index++; |
} | } |
} | } |
} | } |
$output = ""; | $output = ""; |
if ($collapsible) | if ($collapsible) |
$output.= '<div class="map" data-role="collapsible" data-collapsed="true"><h3>Open Map...</h3>'; | $output.= '<div class="map" data-role="collapsible" data-collapsed="true"><h3>Open Map...</h3>'; |
if (isIOSDevice()) $output.= '<img class="hiresmap" src="http://maps.googleapis.com/maps/api/staticmap?size=' . $width . 'x' . $height . '&' . $markers . '&scale=2&sensor=true" width=' . $width . ' height=' . $height . '>'; | if (isIOSDevice()) $output.= '<img class="hiresmap" src="http://maps.googleapis.com/maps/api/staticmap?size=' . $width . 'x' . $height . '&' . $markers . '&scale=2&sensor=true" width=' . $width . ' height=' . $height . ' alt="map of stop location">'; |
else $output.= '<img class="lowresmap" src="http://maps.googleapis.com/maps/api/staticmap?size=' . $width . 'x' . $height . '&' . $markers . '&scale=1&format=jpg&sensor=true" width=' . $width . ' height=' . $height . '>'; | else $output.= '<img class="lowresmap" src="http://maps.googleapis.com/maps/api/staticmap?size=' . $width . 'x' . $height . '&' . $markers . '&scale=1&format=jpg&sensor=true" width=' . $width . ' height=' . $height . ' alt="map of stop location">'; |
if ($collapsible) | if ($collapsible) |
$output.= '</div>'; | $output.= '</div>'; |
return $output; | return $output; |
} | } |
function distance($lat1, $lng1, $lat2, $lng2, $roundLargeValues = false) { | function distance($lat1, $lng1, $lat2, $lng2, $roundLargeValues = false) { |
$pi80 = M_PI / 180; | $pi80 = M_PI / 180; |
$lat1*= $pi80; | $lat1*= $pi80; |
$lng1*= $pi80; | $lng1*= $pi80; |
$lat2*= $pi80; | $lat2*= $pi80; |
$lng2*= $pi80; | $lng2*= $pi80; |
$r = 6372.797; // mean radius of Earth in km | $r = 6372.797; // mean radius of Earth in km |
$dlat = $lat2 - $lat1; | $dlat = $lat2 - $lat1; |
$dlng = $lng2 - $lng1; | $dlng = $lng2 - $lng1; |
$a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2); | $a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2); |
$c = 2 * atan2(sqrt($a), sqrt(1 - $a)); | $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); |
$km = $r * $c; | $km = $r * $c; |
if ($roundLargeValues) { | if ($roundLargeValues) { |
if ($km < 1) | if ($km < 1) |
return floor($km * 1000); | return floor($km * 1000); |
else | else |
return round($km, 2) . "k"; | return round($km, 2) . "k"; |
} | } |
else | else |
return floor($km * 1000); | return floor($km * 1000); |
} | } |
function decodePolylineToArray($encoded) { | function decodePolylineToArray($encoded) { |
// source: http://latlongeeks.com/forum/viewtopic.php?f=4&t=5 | // source: http://latlongeeks.com/forum/viewtopic.php?f=4&t=5 |
$length = strlen($encoded); | $length = strlen($encoded); |
$index = 0; |