diff --git a/credits.php b/credits.php index 120ddee1..3b0accb0 100644 --- a/credits.php +++ b/credits.php @@ -1,45 +1,34 @@ - + Travel Mapping Credit and Sources - + - -
-
-

Credits and Sources

+ + +

Credits and Sources

-

Travel Mapping is the successor project to the +

Travel Mapping is the successor project to the dormant Clinched Highway Mapping (CHM) project, developed and operated by Timothy Reichard. Some underlying code and the initial highway data are from CHM.

-
-

Highway Data Sources

-

We would like to credit and thank the authors of the following sources of highway information.

-

General Map References

+

Highway Data Sources

+ +

We would like to credit and thank the authors of the +following sources of highway information.

+ +

General Map References

+
  • Path Coordinates
    • OpenStreetMap. Crowd-sourced world highway map. Map data © OpenStreetMap contributors, CC-BY-SA.
    • +
    • Coordinates from handheld GPS receiver, contributed by Oscar Voss (used to supplement OSM mapping where it is weak, mainly in parts of Alaska, and northern and western Canada)
  • General Highway Maps and Imagery @@ -59,13 +48,19 @@
-

Highway Departments and Hobbyist Sites

+ +

Highway Departments and Hobbyist Sites

- - +
  • Connecticut, USA
    • Connecticut Roads. Hobbyist site by Scott Oglesby covering highways in Connecticut.
    • @@ -442,14 +465,16 @@
    • Georgia, USA
    • Hawaii, USA
        -
      • Hawaii DOT straight-line diagrams. 2009 Hawaii DOT straight-line diagrams, for state routes in all four HDOT districts.
      • -
      • Hawaii Highways website. Unofficial website by Oscar Voss, with route lists updating some SLDs.
      • +
      • Hawaii DOT website. Official website of state Department of Transportation.
      • +
      • 2009 and 2012 Hawaii DOT straight-line diagrams, for state routes in all four HDOT districts (not currently available online).
      • +
      • Hawaii Highways. Hobbyist website by Oscar Voss, with route lists updating some SLDs.
      • +
    • Idaho, USA @@ -531,16 +556,16 @@
    • Missouri County Maps. Official county maps from the Missouri Department of Transportation.
  • - +
  • Nebraska, USA
  • Nevada, USA @@ -561,15 +586,17 @@
  • New Mexico, USA +
  • The Unofficial New Mexico Highways Page. Hobbyist site by Steve Riner, describing current and historical New Mexico state routes.
  • +
  • New York, USA
  • North Carolina, USA @@ -628,7 +655,8 @@
  • South Dakota, USA
  • Tennessee, USA @@ -675,10 +703,11 @@
  • Wisconsin County Maps. Official county maps from the Wisconsin Department of Transportation.
  • - +
  • General
    • Road Numbering Systems. Hobbyist site about the various road numbering systems around the world.
    • @@ -690,13 +719,11 @@
  • -
    -
    -

    Project Contributors

    +

    Project Contributors

    +
      -
    • Eric Bryant (yakra)
      - The Maine Drag
    • +
    • Eric Bryant (yakra)
    • Dave Filpus (dfilpus)
      Filpus Roadgeek
    • Adam Froehlig (froggie)
      @@ -713,12 +740,13 @@
    • Oscar Voss (oscar)
    -

    These contributors built on the work +

    These contributors built on the work of CHM's Collaborators.

    + diff --git a/css/travelMapping.css b/css/travelMapping.css index f83eb562..8764b4c8 100644 --- a/css/travelMapping.css +++ b/css/travelMapping.css @@ -3,7 +3,7 @@ body, html { border: 0; padding: 0; font-size: 9pt; - background-color: #EEEEFF; + background-color: #eeeeff; } table.nmptable { @@ -64,6 +64,11 @@ table.gratable tr td { text-align: left; } +table.gratable tr td .important { + background-color: #CCCCCC; + text-script: bold; +} + table.gratable tr[onclick]:hover td, table.gratable tr.user-highlight td { background-color: #CCCCCC; cursor: pointer; @@ -78,28 +83,18 @@ table.tablesorter th.sortable:hover { cursor: pointer; } -table tr.status-active td { +table tr.status-active td, table tr td.status-active { background-color: #CCFFCC; } -table tr.status-preview td { +table tr.status-preview td, table tr td.status-preview { background-color: #FFFFCC; } -table tr.status-devel td { +table tr.status-devel td, table tr td.status-devel { background-color: #FFCCCC; } -table.gratable { - font-size: 10pt; - border: 1px solid black; - border-spacing: 0px; - margin-left: auto; - margin-right: auto; - background-color: white; -} - - table.tablesorter th.headerSortUp { background-color: #DDFFDD !important; } @@ -141,4 +136,262 @@ table.gratable tr.float th { .map-loading * { cursor: progress; background-color: #999999; -} \ No newline at end of file +} + +/* from jdtstyle.css: */ +/*body { + margin-top: 10px; + position: center; + background: #ffffff; + width: 750px; + color: #000000; + font-size: 12pt; +} +*/ + +/* top line of title text at top of page */ +.title { + font-size: 24pt; + font-family: "Times New Roman", serif; + font-weight: bold; + text-align: center; + position: relative; + margin-top: 0px; + margin-bottom: 0px; + padding-top: 5px; + padding-right: 8px; + height: auto; + color: #eeeeee; + background: #000040; + border-left: 3px solid #000040; + border-right: 3px solid #000040; + border-bottom: 0px solid #000040; +} + +/* 2nd line of title text at top of page + same basic style, but smaller text */ +.title2 { + font-size: 16pt; + font-family: "Times New Roman", serif; + text-align: center; + position: relative; + padding-right: 8px; + margin-top: 0px; + margin-bottom: 0px; + height: auto; + color: #ffffff; + background: #000040; + border-left: 3px solid #000040; + border-right: 3px solid #000040; +} + +/* hyperlink in title */ +.title a { + color: #ffffff; + text-decoration: none; +} + +.title a:hover { + color: #808080; + text-decoration: none; +} + + /* hyperlink in title */ +.title2 a { + color: #ffffff; + text-decoration: none; +} + +.title2 a:hover { + color: #8080ff; + text-decoration: none; +} + + /* the menubar at the top */ +.menubar { + font-size: 10pt; + font-style: normal; + font-family: sans-serif; + text-align: center; + position: relative; + padding-right: 8px; + padding-bottom: 2px; + margin-top: 0px; + margin-bottom: 8px; + height: auto; + background: #101080; + color: #ffffff; + border: 3px solid #101080; +} + + /* hyperlink in menubar */ +.menubar a { + color: #ffffff; + text-decoration: none; +} + + /* hyperlink with mouse over it in menubar */ +.menubar a:hover { + color: #8080ff; + text-decoration: underline; +} + +/* the errorbar when a DB update is in progress */ +.errorbar { + font-size: 14pt; + font-style: normal; + font-family: sans-serif; + text-align: center; + position: relative; + padding-right: 8px; + padding-bottom: 2px; + margin-top: 0px; + margin-bottom: 8px; + height: auto; + background: #FF0000; + color: #ffffff; + border: 3px solid #101080; +} + +.main { + width: 758px; +} + +.rfloaty { +float: right; +margin-left: 10px; +} + +.lfloaty { +float: right; +margin-left: 10px; +} + +/* mini bar under menu bar */ +.minibar { + text-align: right; + width: 750px; +} + + + /* the bottom bar across all pages */ +.bottom { + position: relative; + margin-top: 0px; + margin-bottom: -10px; + width: 750px; + background: #ffffff; + padding-left: 6px; + padding-right: 6px; + border-bottom: 4px solid #000040; +} + + + /* title of section with dark blue bar underneath it */ +.heading, h1, h2 { + font-size: 18pt; + text-align: left; + font-family: "Lucida Grande", Geneva, Arial, Verdana, sans-serif; + position: relative; + margin-top: 20px; + margin-left: 0px; + margin-right: 50px; + margin-bottom: 0px; + height: auto; + color: #000000; + background: #eeeeff; + padding-left: 4px; + padding-right: 6px; + border-bottom: 3px solid #000040; +} + + /* same style heading, but with larger text */ +.headingLarge { + font-size: 28px; + font-style: bold; + text-align: left; + position: relative; + margin-top: 20px; + margin-left: 00px; + margin-bottom: 0px; + width: 100%; + height: 36px; + color: #000000; + padding-bottom: 10px; + padding-left: 6px; + padding-right: 6px; + background: #eeeeff; + border-bottom: 5px solid #000040; +} + +/* title of subsection with dark bar below it */ +.subheading { + font-size: 15pt; + text-align: left; + font-family: "Lucida Grande", Geneva, Arial, Verdana, sans-serif; + position: relative; + margin-top: 16px; + margin-left: 0px; + margin-bottom: 0px; + width: 75%; + height: auto; + color: #000000; + background: #eeeeff; + padding-left: 4px; + padding-right: 6px; + border-bottom: 2px solid #008000; +} + + + /* a box for text, with a white background and border */ +.text { + font-size: 12pt; + font-family: "Lucida Grande", Geneva, Arial, Verdana, sans-serif; + text-align: left; + position: relative; + margin-left: 50px; + margin-right: 50px; + margin-top: 10px; + margin-bottom: 8px; + background: #eeeeff; + color: #000000; + padding: 2px; + border: 2px solid #eeeeff; +} + +/* a box for text, with a gray background and dark border + info/text should always have same style text, etc- + just different coloring */ +.info { + font-size: 12pt; + font-family: "Lucida Grande", Geneva, Arial, Verdana, sans-serif; + text-align: left; + position: relative; + margin-left: 50px; + margin-top: 3px; + margin-bottom: 20px; + width: 700px; + background: #eeeeee; + color: #000000; + padding: 4px; + padding-left: 8px; + border: 2px solid #808080; +} + +/* heading font inside an info box */ +.info h3 { + font-size: 16pt; + text-align: left; +} + +/* heading font inside an info box */ +.info h4 { + font-size: 12pt; + font-style: bold; + text-align: left; +} + +.right { + width: 750px; + text-align: right; +} diff --git a/devel/datacheck.php b/devel/datacheck.php index ba83c483..70a7e639 100644 --- a/devel/datacheck.php +++ b/devel/datacheck.php @@ -1,22 +1,26 @@ + + \n"; + if ($tmsqldebug) { + echo "\n"; + } $res = $db->query($sql_command); while ($row = $res->fetch_assoc()) { - echo "".$row['route'].""; + echo "".$row['route'].""; if (strcmp($row['label1'],"") != 0) { echo $row['label1']; } @@ -26,7 +30,15 @@ function writeTable($db, $fpVal, $joins) { if (strcmp($row['label3'],"") != 0) { echo ",".$row['label3']; } - echo "".$row['code'].""; + if ((strcmp($row['code'],"VISIBLE_DISTANCE") == 0) || + (strcmp($row['code'],"LONG_DISTANCE") == 0) || + (strcmp($row['code'],"SHARP_ANGLE") == 0)) { + echo "".$row['code'].""; + } + else { + echo "".$row['code'].""; + + } if (strcmp($row['value'],"") != 0) { echo $row['value']; } @@ -35,57 +47,97 @@ function writeTable($db, $fpVal, $joins) { $res->free(); } ?> - + + + Travel Mapping Highway Data Datacheck Errors -

    Travel Mapping Highway Data Datacheck Errors

    + + +

    Travel Mapping Highway Data Datacheck Errors

    -

    Quick links: [Errors in Active Systems][Errors in Preview Systems][Errors in In-Dev Systems][Errors Marked as FPs].

    +

    Quick links: [Errors in Active Systems][Errors in Preview Systems][Errors in In-Dev Systems][Errors Marked as FPs].

    -

    See also the [Log of Unmatched -FPs from datacheckfps.csv] and +

    See also the [Log +of Unmatched FPs from datacheckfps.csv] and the [Log of Unprocessed WPTs in the Repository]. Cleaning these up are low priority tasks for the -project.

    +project. Some of these are likely fixable from the information in +the [Log of Near-Match FPs from +datacheckfps.csv].

    -

    Errors in Active Systems (not FPs)

    -

    These errors should be corrected, or reported as false positives by adding the entry from the last column to the datacheck FP list as soon as possible. Ideally, this list should always be empty.

    +

    Errors in Active Systems (not FPs)

    + +

    These errors should be + corrected, or reported as false positives by adding the entry from + the last column + to the + datacheck FP list as soon as possible. Ideally, this list + should always be empty.

    + +
    RouteWaypointsErrorInfoFP Entry to Submit
    -

    Errors in Preview Systems (not FPs)

    -

    These errors should be corrected, or reported as false positives by adding the entry from the last column to the datacheck FP list during the final review process to promote a system from 'preview' to 'active'. A system should have no entries here before activation.

    +

    Errors in Preview Systems (not FPs)

    + +

    These errors should be + corrected, or reported as false positives by adding the entry from + the last column + to the + datacheck FP list during the final review process to promote a + system from 'preview' to 'active'. A system should have no entries + here before activation. Errors shown in red should be fixed as soon as possible, while others + can wait until final preparation for system activation.

    +
    RouteWaypointsErrorInfoFP Entry to Submit
    -

    Errors in In-Development Systems (not FPs)

    -

    These errors should be corrected, or reported as false positives by adding the entry from the last column to the datacheck FP list before the system is promoted from 'devel' to 'preview'.

    +

    Errors in In-Development Systems (not FPs)

    + +

    These errors should be + corrected, or reported as false positives by adding the entry from + the last column + to the + datacheck FP list before the system is promoted from 'devel' to + 'preview'. Note: less severe errors, such as distance and angle + errors can be left until final preparation for promotion to + 'active'.

    +
    RouteWaypointsErrorInfoFP Entry to Submit
    -

    Errors Marked as FPs ("Crossed Off")

    -

    These have been marked as FPs in the datacheck FP list and can normally be safely ignored. However, if any of these are discovered to be true errors, they should be removed from the list and fixed in the highway data.

    + +

    Errors Marked as FPs ("Crossed Off")

    + +

    These have been marked as FPs + in the + datacheck FP list and can normally be safely ignored. However, + if any of these are discovered to be true errors, they should be + removed from the list and fixed in the highway data.

    +
    RouteWaypointsErrorInfoFP Entry Matched
    + close(); + $tmdb->close(); ?> diff --git a/devel/updates.php b/devel/updates.php index 8a082e28..985d354d 100644 --- a/devel/updates.php +++ b/devel/updates.php @@ -2,29 +2,12 @@ - + - + - - -= 0 && strpos($haystack, $needle, $temp) !== FALSE); - } -?> - + + Travel Mapping Highway Data Updates @@ -43,48 +26,64 @@ function endsWith($haystack, $needle) { } ); +

    Travel Mapping Highway Data Updates

    -

    Highway Data System Status Changes

    + +

    Quick links: [Highway System Status Changes][Updates to Highway Data in Active Systems].

    + + +

    Highway System Status Changes

    query($sql_command); + $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { - echo "\n"; + if (($row['statusChange'] == "active") || + ($row['statusChange'] == "preview")|| + ($row['statusChange'] == "extended") || + ($row['statusChange'] == "split")) { + $syslink = "".$row['systemName'].""; + } + else { + $syslink = $row['systemName']; + } + echo "\n"; } $res->free(); ?>
    DateCountry/RegionSystem CodeSystem DescriptionNew Status
    ".$row['date']."".$row['region']."".$row['systemName']."".$row['description']."".$row['statusChange']."
    ".$row['date']."".$row['region']."".$syslink."".htmlspecialchars($row['description']); + echo "".$row['statusChange']."
    -

    Updates to Highway Data in Active Systems

    +

    Updates to Highway Data in Active Systems

    query($sql_command); + $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { if (strcmp($row['root'],"") == 0) { - echo "\n"; + echo "\n"; } else { - echo "\n"; + echo "\n"; } } $res->free(); ?>
    DateRegionRouteFile RootDescription
    ".$row['date']."".$row['region']."".$row['route']."(NONE)".$row['description']."
    ".$row['date']."".$row['region']."".$row['route']."(NONE)".htmlspecialchars($row['description'])."
    ".$row['date']."".$row['region']."".$row['route']."".$row['root']."".$row['description']."
    ".$row['date']."".$row['region']."".$row['route']."".$row['root']."".htmlspecialchars($row['description'])."
    + close(); + $tmdb->close(); ?> diff --git a/devel/hb.php b/hb/index.php similarity index 55% rename from devel/hb.php rename to hb/index.php index 499816eb..abe8dc5e 100644 --- a/devel/hb.php +++ b/hb/index.php @@ -1,29 +1,4 @@ - 0) { - $region = $_GET['rg']; -} -if (array_key_exists("sys", $_GET) and strlen($_GET['sys']) > 0) { - $system = $_GET['sys']; -} -?> + - - + + - - - - - + + 0) { + $region = $regions[0]; + $regionName = tm_region_code_to_name($region); + } + else { + $region = ""; + $regionName = "No Region Specified"; } - function endsWith($haystack, $needle) - { - // search forward starting from end minus needle length characters - return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); + $systems = tm_qs_multi_or_comma_to_array("sys"); + if (count($systems) > 0) { + $system = $systems[0]; + $systemName = tm_system_code_to_name($system); + } + else { + $system = ""; + $systemName = "No System Specified"; } + // if a specific route is specified, that's what we'll view if (array_key_exists("r", $_GET)) { - $showingmap = 1; + $routeparam = $_GET['r']; } else { - $showingmap = 0; + $routeparam = ""; } + ?> + + + + + + <?php - if ($showingmap == 1) { + if ($routeparam != "") { $sql_command = "SELECT * FROM routes WHERE root = '" . $_GET['r'] . "'"; - $routeInfo = $db->query($sql_command)->fetch_array(); + $res = tmdb_query($sql_command); + $routeInfo = $res->fetch_array(); + $res->free(); echo $routeInfo['region'] . " " . $routeInfo['route']; if (strlen($routeInfo['banner']) > 0) { echo " " . $routeInfo['banner']; @@ -214,29 +214,28 @@ function waypointsFromSQL() { } ?>Travel Mapping Highway Browser (Draft) +\n"; - if (array_key_exists("u", $_GET)) echo "" . $_GET['u'] . "-"; - echo "Home-"; - echo "Highway Browser"; - echo "
    "; + require $_SERVER['DOCUMENT_ROOT']."/lib/tmheader.php"; + echo "

    Travel Mapping Highway Browser (Draft)

    "; + echo ""; echo ""; - echo ""; + tm_system_select(FALSE); echo ""; - echo ""; - echo "
    "; + tm_region_select(FALSE); + echo ""; + echo ""; -} else { - echo "\n"; - if (array_key_exists("u", $_GET)) echo "" . $_GET['u'] . "-"; - echo "Home-"; - echo "Highway Browser"; +} +else { + echo "\n"; + require $_SERVER['DOCUMENT_ROOT']."/lib/tmheader.php"; + } ?> - -

    Travel Mapping Highway Browser (Draft)

    \n"; echo "" . generate($_GET['r'], true) . ""; - echo "View Associated Routes"; - echo "\n"; - $sql_command = "SELECT pointName, latitude, longitude FROM waypoints WHERE root = '" . $_GET['r'] . "';"; - $res = $db->query($sql_command); + echo "View Associated Routes"; + echo "
    Waypoints
    CoordinatesWaypoint Name
    "; + $sql_command = << fetch_assoc(); + echo << + + + + + s +
    Route Stats
    Total Mileage{$row['totalMileage']} mi
    LIST Name{$routeInfo['region']} {$routeInfo['route']}{$routeInfo['banner']}{$routeInfo['abbrev']}
    Total Drivers{$row['numDrivers']} ({$row['drivenPct']} %)
    Average Mileage{$row['avgMileage']} mi ({$row['mileagePct']} %)
    +HTML; + echo "\n"; + $sql_command = <<fetch_assoc()) { # only visible points should be in this table if (!startsWith($row['pointName'], "+")) { - echo "\n"; + $colorFactor = $row['driverPercent'] / 100; + $colors = [255, 255 - round($colorFactor * 128), 255 - round($colorFactor * 128)]; + echo "\n"; } $waypointnum = $waypointnum + 1; } @@ -304,13 +354,12 @@ function initFloatingHeaders($table) {
    Waypoints
    CoordinatesName%
    (" . $row['latitude'] . "," . $row['longitude'] . ")
    (" . $row['latitude'] . "," . $row['longitude'] . "){$row['driverPercent']}
    -  Show Markers - ENDA; - if (array_key_exists("r", $_GET)) { - $sql_command = "SELECT region, route, banner, city FROM routes WHERE root = '" . $_GET['r'] . "';"; - $res = $db->query($sql_command); + if ($routeparam != "") { + echo "
    "; + $sql_command = "SELECT region, route, banner, city FROM routes WHERE root = '" .$routeparam. "';"; + $res = tmdb_query($sql_command); $row = $res->fetch_assoc(); echo $row['region'] . " " . $row['route']; if (strlen($row['banner']) > 0) { @@ -319,39 +368,46 @@ function initFloatingHeaders($table) { if (strlen($row['city']) > 0) { echo " (" . $row['city'] . ")"; } - echo ": "; $res->free(); + echo ""; + echo " Show Markers "; + echo ""; + echo "
    "; + echo "User: "; + tm_user_select(); + echo "
    "; + echo ""; + echo ""; + echo "
    \n"; } echo << -
    ENDB; -} elseif (!is_null($region) or !is_null($system)) { // we have no r=, so we will show a list of all +} elseif (($region != "") or ($system != "")) { // we have no r=, so we will show a list of all $sql_command = "SELECT * FROM routes LEFT JOIN systems ON systems.systemName = routes.systemName"; //check for query string parameter for system and region filters - if (array_key_exists("sys", $_GET) && strlen($_GET["sys"]) > 0) { - $sql_command .= " where routes.systemName = '" . $_GET["sys"] . "'"; - if (array_key_exists("rg", $_GET) && strlen($_GET["rg"]) > 0) { - $sql_command .= "and routes.region = '" . $_GET["rg"] . "'"; + if ($system != "") { + $sql_command .= " WHERE routes.systemName = '" .$system. "'"; + if ($region != "") { + $sql_command .= "AND routes.region = '" .$region. "'"; } - } else if (array_key_exists("rg", $_GET) && strlen($_GET["rg"]) > 0) { - $sql_command .= " where routes.region = '" . $_GET["rg"] . "'"; + } else if ($region != "") { + $sql_command .= " WHERE routes.region = '" .$region. "'"; } $sql_command .= ";"; - echo "\n"; echo "
    \n"; - echo "\n"; - $res = $db->query($sql_command); + echo "
    Select Route to Display (click a header to sort by that column)
    SystemRegionRoute Name.list NameLevelRoot
    \n"; + $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { - echo "\n"; + echo "\n"; } $res->free(); echo "
    Select Route to Display (click a header to sort by that column)
    TierSystemRegionRoute Name.list NameLevelRoot
    " . $row['systemName'] . "" . $row['region'] . "" . $row['route'] . $row['banner']; + echo "
    {$row['tier']}" . $row['systemName'] . "" . $row['region'] . "" . $row['route'] . $row['banner']; if (strcmp($row['city'], "") != 0) { echo " (" . $row['city'] . ")"; } - echo "" . $row['region'] . " " . $row['route'] . $row['banner'] . $row['abbrev'] . "" . $row['level'] . "" . $row['root'] . "
    " . $row['region'] . " " . $row['route'] . $row['banner'] . $row['abbrev'] . "" . $row['level'] . "" . $row['root'] . "
    \n"; @@ -368,9 +424,9 @@ function initFloatingHeaders($table) { HTML; $sql_command = "SELECT * FROM systems LEFT JOIN countries ON countryCode = countries.code"; - $res = $db->query($sql_command); + $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { - $linkJS = "window.open('hb.php?sys={$row['systemName']}')"; + $linkJS = "window.open('/hb/index.php?sys={$row['systemName']}&u={$tmuser}')"; echo ""; if (strlen($row['name']) > 15) { echo "{$row['code']}"; @@ -383,7 +439,7 @@ function initFloatingHeaders($table) { echo ""; } -$db->close(); +$tmdb->close(); ?> diff --git a/devel/smallintersection.png b/hb/smallintersection.png similarity index 100% rename from devel/smallintersection.png rename to hb/smallintersection.png diff --git a/hbtest/index.php b/hbtest/index.php deleted file mode 100644 index 4cac0d39..00000000 --- a/hbtest/index.php +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/hbtest/smallintersection.png b/hbtest/smallintersection.png deleted file mode 100644 index aff56fbe..00000000 Binary files a/hbtest/smallintersection.png and /dev/null differ diff --git a/index.php b/index.php index 008b5b87..10428aab 100644 --- a/index.php +++ b/index.php @@ -1,50 +1,159 @@ - + + Travel Mapping - + - -
    -
    - Welcome to the Travel Mapping project. - - -
    -

    Development Tools

    - -
    - -
    -
    + +

    +The most recent site update completed at US/Eastern. +

    + + +close(); +?> diff --git a/lib/jquery.tablesorter.min.js b/lib/jquery.tablesorter.min.js index b8605df1..d3ff4308 100644 --- a/lib/jquery.tablesorter.min.js +++ b/lib/jquery.tablesorter.min.js @@ -1,4 +1,4 @@ (function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:true,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'/\.|\,/g',onRenderHeader:null,selectorHeaders:'thead th',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}if(table.tBodies.length==0)return;var rows=table.tBodies[0].rows;if(rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function checkHeaderOptionsSortingLocked(table,i){if((table.config.headers[i])&&(table.config.headers[i].lockedOrder))return table.config.headers[i].lockedOrder;return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i b["+i+"]) ? 1 : 0));";};function makeSortTextDesc(i){return"((b["+i+"] < a["+i+"]) ? -1 : ((b["+i+"] > a["+i+"]) ? 1 : 0));";};function makeSortNumeric(i){return"a["+i+"]-b["+i+"];";};function makeSortNumericDesc(i){return"b["+i+"]-a["+i+"];";};function sortText(a,b){if(table.config.sortLocaleCompare)return a.localeCompare(b);return((ab)?1:0));};function sortTextDesc(a,b){if(table.config.sortLocaleCompare)return b.localeCompare(a);return((ba)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){$this.trigger("sortStart");var $cell=$(this);var i=this.column;this.order=this.count++%2;if(this.lockedOrder)this.order=this.lockedOrder;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function checkHeaderOptionsSortingLocked(table,i){if((table.config.headers[i])&&(table.config.headers[i].lockedOrder))return table.config.headers[i].lockedOrder;return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i b["+i+"]) ? 1 : 0));";};function makeSortTextDesc(i){return"((b["+i+"] < a["+i+"]) ? -1 : ((b["+i+"] > a["+i+"]) ? 1 : 0));";};function makeSortNumeric(i){return"a["+i+"]-b["+i+"];";};function makeSortNumericDesc(i){return"b["+i+"]-a["+i+"];";};function sortText(a,b){if(table.config.sortLocaleCompare)return a.localeCompare(b);return((ab)?1:0));};function sortTextDesc(a,b){if(table.config.sortLocaleCompare)return b.localeCompare(a);return((ba)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){$this.trigger("sortStart");var $cell=$(this);var i=this.column;this.order=this.count++%2;if(this.lockedOrder)this.order=this.lockedOrder;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i + + + + diff --git a/lib/tmheader.php b/lib/tmheader.php new file mode 100644 index 00000000..e645d071 --- /dev/null +++ b/lib/tmheader.php @@ -0,0 +1,37 @@ + + + +Travel Mapping +

    + +

    +Tracking Cumulative Travels +

    +END; +} +?> + + + + +Travel Mapping database update in progress. Some functionality might +not work. Please try again in a few minutes if you notice problems. +

    +END; +} +?> + + diff --git a/lib/tmjsfuncs.js b/lib/tmjsfuncs.js index c637f539..e2c2825c 100644 --- a/lib/tmjsfuncs.js +++ b/lib/tmjsfuncs.js @@ -29,8 +29,7 @@ // 2015-06-17 JDT All highways in region support // 2015-08-19 JDT Fixed a few bugs with infowindows // 2016-05-25 JDT Consolidated some changes from copies of chmviewerfunc3.js -// -// $Id: chmviewerfunc3.js 2535 2015-01-28 18:46:22Z terescoj $ +// 2016-06-27 JDT Removed code not needed by TM // // global variable to hold the map, which will be assigned a google.maps.Map reference @@ -54,7 +53,7 @@ var markerinfo = new Array(); var polypoints = new Array(); // array of connections on map as google.maps.Polyline overlays var connections = new Array(); -// array of graph edges (for graph data) +// array of graph edges (for graph data, used by HDX, which imports this code) var graphEdges = new Array(); // array of segments and clinched for "clinched by traveler" mapping var segments = new Array(); @@ -65,6 +64,8 @@ var mapClinched = false; var traveler; // boolean to determine if graph edges should be generated automatically var genEdges = false; +// boolean to determine if graph edges are in vertex adjacency lists +var usingAdjacencyLists = false; // array of objects that define color codes from names in the DB var colorCodes = new Array(); @@ -75,6 +76,7 @@ colorCodes[3] = { name: "yellow", unclinched: "rgb(255,255,128)", clinched: "rgb colorCodes[4] = { name: "teal", unclinched: "rgb(100,200,200)", clinched: "rgb(0,200,200)" }; colorCodes[5] = { name: "green", unclinched: "rgb(100,255,100)", clinched: "rgb(0,255,0)" }; colorCodes[6] = { name: "magenta", unclinched: "rgb(255,100,255)", clinched: "rgb(255,0,255)" }; +colorCodes[7] = { name: "lightsalmon", unclinched: "rgb(255,200,200)", clinched: "rgb(255,160,122)" }; // array of custom color codes to be pulled from query string parameter "colors=" var customColorCodes = new Array(); @@ -159,11 +161,14 @@ function loadmap() { var typeMapnik = new google.maps.ImageMapType(MapnikOptions); var typeBlank = new google.maps.ImageMapType(BlankOptions); - var maptypelist = ['MQOpenMap', 'MQOpenSat', 'Mapnik', google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.TERRAIN, 'Blank']; + var maptypelist = ['Mapnik', google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.TERRAIN, 'Blank']; var maptypecontroloptions = {mapTypeIds: maptypelist, position: google.maps.TOP_RIGHT, style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}; //var mapopt = {center: new google.maps.LatLng(42.664529, -73.786470), zoom: 12, mapTypeId: 'Mapnik', mapTypeControl: true, mapTypeControlOptions: maptypecontroloptions, streetViewControl: true, disableDefaultUI: true, panControl: true, zoomControl: true, scaleControl: true, overviewMapControl: true, keyboardShortcuts: true, disableDoubleClickZoom: false}; - // coordinates are Albertus Hall room 400-2 at The College of Saint Rose - var mapopt = {center: new google.maps.LatLng(42.664529, -73.786470), zoom: 16, mapTypeControl: true, mapTypeControlOptions: maptypecontroloptions}; + // OLD coordinates are Albertus Hall room 400-2 at The College of Saint Rose + //var mapopt = {center: new google.maps.LatLng(42.664529, -73.786470), zoom: 16, mapTypeControl: true, mapTypeControlOptions: maptypecontroloptions}; + + // coordinates are Roger Bacon 321 at Siena College + var mapopt = {center: new google.maps.LatLng(42.719450, -73.752063), zoom: 16, mapTypeControl: true, mapTypeControlOptions: maptypecontroloptions}; map = new google.maps.Map(document.getElementById("map"), mapopt); @@ -171,331 +176,11 @@ function loadmap() { map.mapTypes.set('MQOpenSat', typeMQOpenSat); map.mapTypes.set('Mapnik', typeMapnik); map.mapTypes.set('Blank', typeBlank); - - //document.getElementById('showHidden').checked=false; - //var showHidden = document.getElementById('showHidden').checked; - //DBG.write("loadmap: showHidden is " + showHidden); - - // check for a load query string parameter - //var qs = location.search.substring(1); - //DBG.write("qs: " + qs); - //var qsitems = qs.split('&'); - //for (var i = 0; i < qsitems.length; i++) { - //DBG.write("qsitems[" + i + "] = " + qsitems[i]); - //var qsitem = qsitems[i].split('='); - //DBG.write("qsitem[0] = " + qsitem[0]); - //if (qsitem[0] == "load") { - //var request = new XMLHttpRequest(); - //DBG.write("qsitem[1] = " + qsitem[1]); - //document.getElementById('filename').innerHTML = qsitem[1]; - //request.open("GET", qsitem[1], false); - //request.setRequestHeader("User-Agent", navigator.userAgent); - //request.send(null); - //if (request.status == 200) { - //processContents(request.responseText); - //} - //} - //} - waypointsFromSQL(); // function inserted by PHP in the index.php file - updateMap(); -} - -// when a file is selected, this will be called -function startRead() { - // first, retrieve the selected file (as a File object) - var file = document.getElementById('file').files[0]; - if (file) { - document.getElementById('filename').innerHTML = file.name; - if ((file.name.indexOf(".wpt") == -1) && - (file.name.indexOf(".pth") == -1) && - (file.name.indexOf(".nmp") == -1) && - (file.name.indexOf(".gra") == -1) && - (file.name.indexOf(".wpl") == -1)) { - document.getElementById('pointbox').innerHTML = "Unrecognized file type!"; - return; - } - document.getElementById('pointbox').innerHTML = - "Loading... (" + file.size + " bytes)"; - var reader; - try { - reader = new FileReader(); - } - catch(e) { - document.getElementById('pointbox').innerHTML = - "Error: unable to access file (Perhaps no browser support? Try recent Firefox or Chrome releases.)."; - return; - } - reader.readAsText(file, "UTF-8"); - reader.onload = fileLoaded; - //reader.onerror = fileLoadError; - } -} - - -// when the FileReader created in startRead has finished, this will be called -// to process the contents of the file -function fileLoaded(event) { - - // file done loading, read the contents - processContents(event.target.result); -} - -// process the contents of a String which came from a file or elsewhere -function processContents(fileContents) { - - // place the contents into the file contents area (will improve later) - document.getElementById('pointbox').innerHTML = "
    " + fileContents + "
    "; - - var pointboxContents = ""; - - // parse the file and process as appropriate - var fileName = document.getElementById('filename').innerHTML; - if (fileName.indexOf(".wpt") >= 0) { - document.getElementById('filename').innerHTML = fileName + " (Waypoint File)"; - pointboxContents = parseWPTContents(fileContents); - } - else if (fileName.indexOf(".pth") >= 0) { - document.getElementById('filename').innerHTML = fileName + " (Waypoint Path File)"; - pointboxContents = parsePTHContents(fileContents); - } - else if (fileName.indexOf(".nmp") >= 0) { - document.getElementById('filename').innerHTML = fileName + " (Near-Miss Point File)"; - pointboxContents = parseNMPContents(fileContents); - } - else if (fileName.indexOf(".wpl") >= 0) { - document.getElementById('filename').innerHTML = fileName + " (Waypoint List File)"; - pointboxContents = parseWPLContents(fileContents); - } - else if (fileName.indexOf(".gra") >= 0) { - document.getElementById('filename').innerHTML = fileName + " (Highway Graph File)"; - pointboxContents = parseGRAContents(fileContents); - } - - document.getElementById('pointbox').innerHTML = pointboxContents; - updateMap(); - -} - -// in case we get an error from the FileReader -function errorHandler(evt) { - - if (evt.target.error.code == evt.target.error.NOT_READABLE_ERR) { - // The file could not be read - document.getElementById('filecontents').innerHTML = "Error reading file..."; - } -} - -// parse the contents of a .gra file -// -// First line specifies the number of vertices, numV, and the number -// of edges, numE -// Next numV lines are a waypoint name (a String) followed by two -// floating point numbers specifying the latitude and longitude -// Next numE lines are vertex numbers (based on order in the file) -// that are connected by an edge followed by a String listing the -// highway names that connect those points -function parseGRAContents(fileContents) { - - var lines = fileContents.replace(/\r\n/g,"\n").split('\n'); - var counts = lines[0].split(' '); - var numV = parseInt(counts[0]); - var numE = parseInt(counts[1]); - var sideInfo = '

    ' + numV + " waypoints, " + numE + " connections.

    "; - - var vTable = ''; - - waypoints = new Array(numV); - for (var i = 0; i < numV; i++) { - var vertexInfo = lines[i+1].split(' '); - waypoints[i] = new Waypoint(vertexInfo[0], vertexInfo[1], vertexInfo[2], "", ""); - vTable += '" - } - vTable += '
    Waypoints
    #CoordinatesWaypoint Name
    ' + i + - '(' + parseFloat(vertexInfo[1]).toFixed(3) + ',' + - parseFloat(vertexInfo[2]).toFixed(3) + ')' - + "" - + waypoints[i].label + "
    '; - - var eTable = ''; - graphEdges = new Array(numE); - for (var i = 0; i < numE; i++) { - var edgeInfo = lines[i+numV+1].split(' '); - graphEdges[i] = new GraphEdge(edgeInfo[0], edgeInfo[1], edgeInfo[2]); - eTable += ''; - } - eTable += '
    Connections
    #Route Name(s)Endpoints
    ' + i + '' + edgeInfo[2] + '' - + edgeInfo[0] + ': ' + waypoints[graphEdges[i].v1].label + - ' ↔ ' + edgeInfo[1] + ': ' - + waypoints[graphEdges[i].v2].label + '
    '; - genEdges = false; - return sideInfo + vTable + '

    ' + eTable; -} - -// parse the contents of a .wpt file -// -// Consists of a series of lines each containing a waypoint name -// and an OSM URL for that point's location: -// -/* -YT1_S http://www.openstreetmap.org/?lat=60.684924&lon=-135.059652 -MilCanRd http://www.openstreetmap.org/?lat=60.697199&lon=-135.047250 -+5 http://www.openstreetmap.org/?lat=60.705383&lon=-135.054932 -4thAve http://www.openstreetmap.org/?lat=60.712623&lon=-135.050619 -*/ -function parseWPTContents(fileContents) { - - var lines = fileContents.replace(/\r\n/g,"\n").split('\n'); - graphEdges = new Array(); - waypoints = new Array(); - for (var i = 0; i < lines.length; i++) { - if (lines[i].length > 0) { - waypoints[waypoints.length] = WPTLine2Waypoint(lines[i]); - } - } - genEdges = true; - return "

    Raw file contents:

    " + fileContents + "
    "; -} - -// parse the contents of a .pth file -// -// Consists of a series of lines each containing a waypoint name and a -// latitude and a longitude, and a route name, all space-separated, or -// a line containing a waypoint name followed by a lat,lng pair in -// parens, followed by a route name -// -/* -START YT1_S 60.684924 135.059652 -YT2 MilCanRd 60.697199 135.047250 -YT2 +5 60.705383 135.054932 -YT2 4thAve 60.712623 135.050619 - -or - -START YT1_S (60.684924,135.059652) -YT2 MilCanRd (60.697199,135.047250) -YT2 +5 (60.705383,135.054932) -YT2 4thAve (60.712623,135.050619) - -*/ -function parsePTHContents(fileContents) { - - var table = ''; - var lines = fileContents.replace(/\r\n/g,"\n").split('\n'); - graphEdges = new Array(); - waypoints = new Array(); - var totalMiles = 0.0; - var segmentMiles = 0.0; - for (var i = 0; i < lines.length; i++) { - if (lines[i].length > 0) { - waypoints[waypoints.length] = PTHLine2Waypoint(lines[i]); - if (waypoints.length > 1) { // make sure we are not at the first - segmentMiles = Mileage(waypoints[waypoints.length-2].lat, - waypoints[waypoints.length-2].lon, - waypoints[waypoints.length-1].lat, - waypoints[waypoints.length-1].lon); - totalMiles += segmentMiles; - } - table += ''; - } - } - table += '
    RouteTo PointSeg.
    Miles
    Cumul.
    Miles
    ' + waypoints[waypoints.length-1].elabel + - "" + waypoints[waypoints.length-1].label + - '' + segmentMiles.toFixed(2) + - '' + totalMiles.toFixed(2) + - '
    '; - genEdges = true; - return table; -} - -// parse the contents of a .nmp file -// -// Consists of a series of lines, each containing a waypoint name -// followed by two floating point numbers representing the point's -// latitude and longitude -// -// Entries are paired as "near-miss" points, and a graph edge is -// added between each pair for viewing. -// -function parseNMPContents(fileContents) { - - var table = ''; - // all lines describe waypoints - var lines = fileContents.replace(/\r\n/g,"\n").split('\n'); - waypoints = new Array(); - for (var i = 0; i < lines.length; i++) { - if (lines[i].length > 0) { - var xline = lines[i].split(' '); - if (xline.length == 3) { - waypoints[waypoints.length] = new Waypoint(xline[0], xline[1], xline[2], "", ""); - } - } - } - // graph edges between pairs, will be drawn as connections - var numE = waypoints.length/2; - graphEdges = new Array(numE); - for (var i = 0; i < numE; i++) { - // add the edge - graphEdges[i] = new GraphEdge(2*i, 2*i+1, ""); - - // add an entry to the table to be drawn in the pointbox - var miles = Mileage(waypoints[2*i].lat, waypoints[2*i].lon, waypoints[2*i+1].lat, waypoints[2*i+1].lon).toFixed(4); - var feet = Feet(waypoints[2*i].lat, waypoints[2*i].lon, waypoints[2*i+1].lat, waypoints[2*i+1].lon).toFixed(2); - table += ""; - } - - table += "
    " - + "
    " - + "" - + waypoints[2*i].label + "(" - + waypoints[2*i].lat + "," - + waypoints[2*i].lon + ")
    " - + "" - + waypoints[2*i+1].label + "(" - + waypoints[2*i+1].lat + "," - + waypoints[2*i+1].lon + ")
    " - + miles + " mi/" - + feet + " ft
    "; - genEdges = false; - return table; -} - -// parse the contents of a .wpl file -// -// Consists of a series of lines, each containing a waypoint name -// followed by two floating point numbers representing the point's -// latitude and longitude -// -function parseWPLContents(fileContents) { - - var table = ''; - // all lines describe waypoints - var lines = fileContents.replace(/\r\n/g,"\n").split('\n'); - waypoints = new Array(); - for (var i = 0; i < lines.length; i++) { - if (lines[i].length > 0) { - var xline = lines[i].split(' '); - if (xline.length == 3) { - waypoints[waypoints.length] = new Waypoint(xline[0], xline[1], xline[2], "", ""); - } - } - } - // no edges here - graphEdges = new Array(); - genEdges = false; - return "

    Raw file contents:

    " + fileContents + "
    "; } // construct a new Waypoint object (based on similar function by Tim Reichard) -function Waypoint (label, lat, lon, errors, elabel) { +// now supporting edge adjacency lists +function Waypoint(label, lat, lon, elabel, edgeList) { this.label = label; this.lat = parseFloat(lat).toFixed(6); this.lon = parseFloat(lon).toFixed(6); @@ -503,88 +188,8 @@ function Waypoint (label, lat, lon, errors, elabel) { if (label.indexOf("+") >= 0) { this.visible = false; } - this.errors = 0; this.elabel = elabel; - return this; -} - -function CopyWaypoint(wpt) { - - return new Waypoint(wpt.label, wpt.lat, wpt.lon, wpt.errors, wpt.elabel); -} - -function WPTLine2Waypoint(line) { - - // remove extraneous spaces in the line - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - - var xline = line.split(' '); - if (xline.length < 2) { - return Waypoint('bad-line', 0, 0); - } - var label = xline[0]; - var url = xline[1]; - var latlon = Url2LatLon(url); - return new Waypoint(label, latlon[0], latlon[1], 0, ""); -} - -// convert an openstreetmap URL to a latitude/longitude -function Url2LatLon(url) { - - var latlon = new Array(0., 0.); - var floatpattern = '([-+]?[0-9]*\.?[0-9]+)'; - var latpattern = 'lat=' + floatpattern; - var lonpattern = 'lon=' + floatpattern; - - //search for lat - var matches = url.match(latpattern); - if (matches != null) { - latlon[0] = parseFloat(matches[1]).toFixed(6); - } - - //search for lon - matches = url.match(lonpattern); - if (matches != null) { - latlon[1] = parseFloat(matches[1]).toFixed(6); - } - - return latlon; -} - -function PTHLine2Waypoint(line) { - - // remove any extraneous spaces in the line - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - line = line.replace(' ', ' '); - - var xline = line.split(' '); - // check for and convert a (lat,lng) format - if ((xline.length == 3) && - (xline[2].charAt(0) == '(') && - (xline[2].indexOf(',') > 0) && - (xline[2].charAt(xline[2].length-1) == ')')) { - newlatlng = xline[2].replace('(', ''); - newlatlng = newlatlng.replace(',', ' '); - newlatlng = newlatlng.replace(')', ''); - return PTHLine2Waypoint(xline[0] + " " + xline[1] + " " + newlatlng); - } - if (xline.length < 4) { - return Waypoint('bad-line', 0, 0); - } - return new Waypoint(xline[1], xline[2], xline[3], 0, xline[0]); -} - - -function GraphEdge(v1, v2, label) { - - this.v1 = parseInt(v1); - this.v2 = parseInt(v2); - this.label = label; + this.edgeList = edgeList; return this; } @@ -607,8 +212,14 @@ function updateMap() markers[i].setMap(null); } - var showHidden = false; // document.getElementById('showHidden').checked; - var showMarkers = document.getElementById('showMarkers').checked; + var showHidden = false; + if (document.getElementById('showHidden') != null) { + showHidden = document.getElementById('showHidden').checked; + } + var showMarkers = true; + if (document.getElementById('showMarkers') != null) { + showMarkers = document.getElementById('showMarkers').checked; + } markers = new Array(); markerinfo = new Array(); @@ -647,21 +258,90 @@ function updateMap() //map.setZoom(zoom); map.fitBounds(bounds); - // if this is a graph, we draw edges as connections, - // otherwise we may be connecting waypoints in order - // to plot a path + // if this is a graph in HDX, we draw edges as connections, + // otherwise we may be connecting waypoints in order to plot a + // path if (graphEdges.length > 0) { for (var i = 0; i < graphEdges.length; i++) { - var edgePoints = new Array(2); + var numPoints; + if (graphEdges[i].via == null) { + numPoints = 2; + } + else { + numPoints = graphEdges[i].via.length/2 + 2; + } + var edgePoints = new Array(numPoints); var v1 = graphEdges[i].v1; var v2 = graphEdges[i].v2; // DBG.write("Adding edge " + i + " from " + v1 + "(" + waypoints[v1].lat + "," + waypoints[v1].lon + ") to " + v2 + "(" + waypoints[v2].lat + "," + waypoints[v2].lon + ")"); edgePoints[0] = new google.maps.LatLng(waypoints[v1].lat, waypoints[v1].lon); - edgePoints[1] = new google.maps.LatLng(waypoints[v2].lat, waypoints[v2].lon); + nextPoint = 1; + if (graphEdges[i].via != null) { + for (var j = 0; j < graphEdges[i].via.length; j+=2) { + edgePoints[nextPoint] = new google.maps.LatLng(graphEdges[i].via[j], graphEdges[i].via[j+1]); + nextPoint++; + } + } + edgePoints[nextPoint] = new google.maps.LatLng(waypoints[v2].lat, waypoints[v2].lon); connections[i] = new google.maps.Polyline({path: edgePoints, strokeColor: "#0000FF", strokeWeight: 10, strokeOpacity: 0.4, map: map}); //map.addOverlay(connections[i]); } } + else if (usingAdjacencyLists) { + var edgeNum = 0; + for (var i = 0; i < waypoints.length; i++) { + for (var j = 0; j < waypoints[i].edgeList.length; j++) { + var thisEdge = waypoints[i].edgeList[j]; + // avoid double plot by only plotting those with v1 as i + if (thisEdge.v1 == i) { + var numPoints; + if (thisEdge.via == null) { + numPoints = 2; + } + else { + numPoints = thisEdge.via.length/2 + 2; + } + var edgePoints = new Array(numPoints); + edgePoints[0] = new google.maps.LatLng(waypoints[thisEdge.v1].lat, waypoints[thisEdge.v1].lon); + nextPoint = 1; + if (thisEdge.via != null) { + for (var p = 0; p < thisEdge.via.length; p+=2) { + edgePoints[nextPoint] = new google.maps.LatLng(thisEdge.via[p], thisEdge.via[p+1]); + nextPoint++; + } + } + edgePoints[nextPoint] = new google.maps.LatLng(waypoints[thisEdge.v2].lat, waypoints[thisEdge.v2].lon); + // count the commas, which tell us how many + // concurrent routes are represented, as they will + // be comma-separated, then use that to choose a + // color to indicate the number of routes + // following the edge + concurrent = thisEdge.label.split(",").length; + color = ""; + switch (concurrent) { + case 1: + color = "#0000FF"; + break; + case 2: + color = "#00FF00"; + break; + case 3: + color = "#FF00FF"; + break; + case 4: + color = "#FFFF00"; + break; + default: + color = "#FF0000"; + break; + } + connections[edgeNum] = new google.maps.Polyline({path: edgePoints, strokeColor: color, strokeWeight: 10, strokeOpacity: 0.4, map: map}); + edgeNum++; + } + } + } + } + // connecting waypoints in order to plot a path else if (mapClinched) { // clinched vs unclinched segments mapped with different colors var nextClinchedCheck = 0; @@ -763,14 +443,16 @@ function updateMap() connections[i] = new google.maps.Polyline({path: edgePoints, strokeColor: color, strokeWeight: 10, strokeOpacity: 0.75, map: map}); } } - document.getElementById('controlboxinfo').innerHTML = clinchedMiles.toFixed(2) + " of " + totalMiles.toFixed(2) + " miles (" + (clinchedMiles/totalMiles*100).toFixed(1) + "%) clinched by " + traveler + "."; + if (document.getElementById('controlboxinfo') != null) { + document.getElementById('controlboxinfo').innerHTML = ""; //clinchedMiles.toFixed(2) + " of " + totalMiles.toFixed(2) + " miles (" + (clinchedMiles/totalMiles*100).toFixed(1) + "%) clinched by " + traveler + "."; + } } else if (genEdges) { connections[0] = new google.maps.Polyline({path: polypoints, strokeColor: "#0000FF", strokeWeight: 10, strokeOpacity: 0.75, map: map}); //map.addOverlay(connections[0]); } - // don't think this should not be needed, but an attempt to get hidden waypoints - // to be hidden when first created + // don't think this should not be needed, but an attempt to get + // hidden waypoints to be hidden when first created showHiddenClicked(); } @@ -800,7 +482,6 @@ function AddMarker(marker, markerinfo, i) { function LabelClick(i, label, lat, lon, errors) { - //var info = MarkerInfo(i, new Waypoint(label, lat, lon, errors, "")); map.panTo(new google.maps.LatLng(lat, lon)); //infowindow.setContent(info); infowindow.setContent(markerinfo[i]); @@ -838,7 +519,10 @@ function Feet(lat1, lon1, lat2, lon2) { // callback for when the showHidden checkbox is clicked function showHiddenClicked() { - var showHidden = false; //document.getElementById('showHidden').checked; + var showHidden = false; + if (document.getElementById('showHidden') != null) { + showHidden = document.getElementById('showHidden').checked; + } //DBG.write("showHiddenClicked: showHidden is " + showHidden); if (showHidden) { // add in the hidden markers diff --git a/lib/tmphpfuncs.php b/lib/tmphpfuncs.php new file mode 100644 index 00000000..631562d9 --- /dev/null +++ b/lib/tmphpfuncs.php @@ -0,0 +1,340 @@ + + element. +*/ + +// always attempt to establish a connection to the db, allow QS parameters +// to override defaults, which come from the 5 lines of tm.conf (which +// is not in source code control to protect the information there) +// +// IMPORTANT: this file should also not be accessible through the +// web server, using an entry like: +// +// +// Require all denied +// + + +$tmconffile = fopen($_SERVER['DOCUMENT_ROOT']."/lib/tm.conf", "r"); +$tmdbname = chop(fgets($tmconffile)); +$tmdbuser = chop(fgets($tmconffile)); +$tmdbpasswd = chop(fgets($tmconffile)); +$tmdbhost = chop(fgets($tmconffile)); + +// Google Maps API Key +$gmaps_api_key = chop(fgets($tmconffile)); +fclose($tmconffile); + +if (array_key_exists("dbname", $_GET)) { + $tmdbname = $_GET['dbname']; +} + +if (array_key_exists("dbuser", $_GET)) { + $tmdbuser = $_GET['dbuser']; +} + +if (array_key_exists("dbpasswd", $_GET)) { + $tmdbpasswd = $_GET['dbpasswd']; +} + +if (array_key_exists("dbhost", $_GET)) { + $tmdbhost = $_GET['dbhost']; +} + +// sqldebug QS param to tell pages to show SQL commands in HTML comments +$tmsqldebug = FALSE; + +if (array_key_exists("sqldebug", $_GET)) { + $tmsqldebug = TRUE; +} + +// get other common QS parameters + +// Note: u= is the user, stored in $tmuser variable, but this +// is set instead by the tmphpuser.php file which needs +// to be included before any other output is generated +// to avoid warnings from setcookie + +// make the connection +echo "\n"; +mysqli_report(MYSQLI_REPORT_STRICT); +try { + $tmdb = new mysqli($tmdbhost, $tmdbuser, $tmdbpasswd, $tmdbname); +} +catch ( Exception $e ) { + echo "

    Failed to connect to database ".$tmdbname." on ".$tmdbhost." Please try again later.

    "; + exit; +} + +// function to combine a query with a little error check +function tmdb_query($sql_command) { + + global $tmdb; + global $tmsqldebug; + if ($tmsqldebug) { + echo "\n"; + } + $res = $tmdb->query($sql_command); + if ($res) return $res; + die("

    Query failed: ".$sql_command."

    "); +} + +// function to call to free the DB instance (or just put this code +// at the bottom of a page + +function tmdb_close() { + global $tmdb; + $tmdb->close(); +} + +// function to generate a populated region "select" object, but only regions +// where some route exists, +function tm_region_select($multiple) { + global $tmdb; + + if ($multiple) { + echo "\n"; + } + $regions = tm_qs_multi_or_comma_to_array("rg"); + echo "\n"; + $res = tmdb_query("SELECT * FROM regions WHERE code IN (SELECT region FROM routes) ORDER BY country;"); + while ($row = $res->fetch_assoc()) { + echo "\n"; + } + $res->free(); + echo "\n"; +} + +// function to generate a populated systems "select" object +function tm_system_select($multiple) { + global $tmdb; + + if ($multiple) { + echo "\n"; + } + $systems = tm_qs_multi_or_comma_to_array("sys"); + echo "\n"; + $res = tmdb_query("SELECT * FROM systems;"); + while ($row = $res->fetch_assoc()) { + echo "\n"; + } + $res->free(); + echo "\n"; +} + +// function to generate a user selection "select" object +function tm_user_select() { + global $tmdb; + global $tmuser; + echo "\n"; +} + +// function to generate a user selection input form +function tm_user_select_form() { + // TODO: action should come as a parameter + echo "

    \n"; + echo "\n"; + tm_user_select(); + echo "\n"; + echo "

    \n"; +} + +// function to get a count from a table of rows matching a "where" clause +function tm_count_rows($table, $clause) { + global $tmdb; + $sql_command = "SELECT COUNT(*) AS c FROM ".$table." ".$clause.";"; + $res = tmdb_query($sql_command); + $row = $res->fetch_assoc(); + $ans = $row['c']; + $res->free(); + return $ans; +} + + +// function to get a sum of a column from a table +function tm_sum_column($table, $column) { + global $tmdb; + $sql_command = "SELECT SUM(".$column.") AS s FROM ".$table.";"; + global $tmsqldebug; + if ($tmsqldebug) { + echo "\n"; + } + $res = tmdb_query($sql_command); + $row = $res->fetch_assoc(); + $ans = $row['s']; + $res->free(); + return $ans; +} + +// function to get a sum of a column from a table with a "where" +function tm_sum_column_where($table, $column, $where) { + global $tmdb; + $sql_command = "SELECT SUM(".$column.") AS s FROM ".$table." WHERE ".$where.";"; + global $tmsqldebug; + if ($tmsqldebug) { + echo "\n"; + } + $res = tmdb_query($sql_command); + $row = $res->fetch_assoc(); + $ans = $row['s']; + $res->free(); + return $ans; +} + +// Function to retrieve the name of a region by code from the DB +function tm_region_code_to_name($code) { + global $tmdb; + $res = tmdb_query("SELECT * FROM regions where code = '".$code."';"); + $row = $res->fetch_assoc(); + $ans = $row['name']; + $res->free(); + return $ans; +} + +// Function to retrieve the name of a system by code from the DB +function tm_system_code_to_name($code) { + global $tmdb; + $res = tmdb_query("SELECT * FROM systems where systemName = '".$code."';"); + $row = $res->fetch_assoc(); + $ans = $row['fullName']; + $res->free(); + return $ans; +} + +// Function to get an array of either multiple or comma-separated +// qs parameters. +// +// For example, either of the following: +// rg[]=VT&rg[]=MA&rg[]=NY +// rg=VT,MA,NY +// +// should get back an array containing VT, MA, and NY +// +// special functionality: ignore "null" entry/entries +function tm_qs_multi_or_comma_to_array($param) { + + $array = array(); + if (array_key_exists($param, $_GET)) { + if (is_array($_GET[$param])) { + foreach ($_GET[$param] as $p) { + $array = array_merge($array, explode(',',$p)); + } + } + else { + $array = explode(",", $_GET[$param]); + } + } + return array_diff($array, array("null")); +} + +// Function to generate JS code to fill in customColorCodes array based +// on colors QS parameter +function tm_generate_custom_colors_array() { + + // check for custom colors query string parameters + $customColors = array(); + if (array_key_exists("colors",$_GET)) { + $customColors = explode(';',$_GET['colors']); + $colorNum = 0; + foreach ($customColors as $customColor) { + $colorEntry = array(); + $colorEntry = explode(':',$customColor); + echo "customColorCodes[".$colorNum."] = { name: \"".$colorEntry[0]."\", unclinched: \"".$colorEntry[1]."\", clinched: \"".$colorEntry[2]."\" };\n"; + $colorNum = $colorNum + 1; + } + } +} + +// get the timestamp of most recent DB update +function tm_update_time() { + global $tmdb; + global $tmdbname; + $sql_command = "SELECT create_time FROM information_schema.tables WHERE TABLE_SCHEMA = '".$tmdbname."' ORDER BY create_time DESC;"; + global $tmsqldebug; + if ($tmsqldebug) { + echo "\n"; + } + $res = tmdb_query($sql_command); + $row = $res->fetch_assoc(); + $ans = $row['create_time']; + $res->free(); + return $ans; +} + +// function to find the rank of a given traveler in a SQL result +// ranked by a given field, rank is given in a returned row (an +// associative array) as the value associated with a new key 'rank'. +function tm_fetch_user_row_with_rank($res, $rankBy) { + global $tmuser; + $nextRank = 1; + $rank = 1; + $score = 0; + $row = array(); + while($row['traveler'] != $tmuser && $row = $res->fetch_assoc()) { + if ($score != $row[$rankBy]) { + $score = $row[$rankBy]; + $rank = $nextRank; + } + $nextRank++; + //error_log("($rank, {$row['traveler']}, {$row[$rankBy]})"); + } + $row['rank'] = $rank; + return $row; +} + +// functions from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php + +function startsWith($haystack, $needle) { + // search backwards starting from haystack length characters from the end + return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; +} + +function endsWith($haystack, $needle) { + // search forward starting from end minus needle length characters + return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); +} + +?> + diff --git a/lib/tmphpuser.php b/lib/tmphpuser.php new file mode 100644 index 00000000..b51135c2 --- /dev/null +++ b/lib/tmphpuser.php @@ -0,0 +1,24 @@ + diff --git a/login.php b/login.php deleted file mode 100644 index e1ccecc4..00000000 --- a/login.php +++ /dev/null @@ -1,21 +0,0 @@ - \ No newline at end of file diff --git a/logo.svg b/logo.svg deleted file mode 100644 index afcdcf42..00000000 --- a/logo.svg +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - diff --git a/menu.svg b/menu.svg deleted file mode 100644 index b253b9ba..00000000 --- a/menu.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/shields/clinched.php b/shields/clinched.php index 1a7c61c0..321f92b0 100644 --- a/shields/clinched.php +++ b/shields/clinched.php @@ -1,72 +1,97 @@ - + + + + - Clinched Routes for <?php echo $user ?> - - + Clinched Routes for <?php echo $tmuser ?> + + + - Home - - Highway Browser - - {$user}" ?> - - + + + + - + + />All Traveled + />Clinched Only + - - + -

    Clinched Routes for :

    +Traveled Routes for $tmuser: \n"; + } + else { + echo "

    Clinched Routes for $tmuser:

    \n"; + } + +if ( $tmuser == "null") { + echo "

    Select a User to Continue

    \n"; + echo "\n"; + require $_SERVER['DOCUMENT_ROOT']."/lib/tmfooter.php"; + echo "\n"; + echo "\n"; + exit; +} +?>
    = 1)"; + } + else { + $clinched_clause = "AND ccr.clinched = 1"; + $having_clause = "HAVING (sum(ccr.clinched) >= 1)"; + } $sql = <<= 1) + {$having_clause} ORDER BY sys.tier, sys.systemName; SQL; - //echo $sql; - $db->query("SET SESSION group_concat_max_len = 5555555;"); - $res = $db->query($sql); + $tmdb->query("SET SESSION group_concat_max_len = 5555555;"); + $res = tmdb_query($sql); while($row = $res->fetch_assoc()) { - echo "

    {$row['fullName']} ({$row['clinched']} / {$row['total']})

    "; + echo "

    {$row['fullName']}\n"; + if ($cort == "c") { + echo " ({$row['clinched']} "; + } + else { + echo " ({$row['traveled']} "; + } + echo "/ {$row['total']})

    "; $rootList = explode(",", $row['clinchedRoutes']); $col = 0; foreach($rootList as $root) { - echo "".generate($root, $_GET['reload']).""; + echo "".generate($root, $_GET['reload'])."\n"; $col++; - if ($col > 8) { - echo "
    "; + if ($col > 20) { + echo "
    \n"; $col = 0; } } @@ -74,5 +99,9 @@ $res->free(); ?>
    + +close(); +?> \ No newline at end of file diff --git a/shields/generic_wide.svg b/shields/generic_wide.svg index 3c295106..05ce5dd0 100644 --- a/shields/generic_wide.svg +++ b/shields/generic_wide.svg @@ -1 +1,12 @@ -***SYS******NUMBER*** \ No newline at end of file + + + + + + ***SYS*** + + + ***NUMBER*** + + + diff --git a/shields/index.php b/shields/shieldgen.php similarity index 79% rename from shields/index.php rename to shields/shieldgen.php index 124c17c5..24956712 100644 --- a/shields/index.php +++ b/shields/shieldgen.php @@ -1,16 +1,17 @@ query($sql_command); + $res = tmdb_query($sql_command); $row = $res->fetch_assoc(); + $res->free(); if (file_exists("{$dir}/template_" . $row['systemName'] . ".svg")) { $svg = file_get_contents("{$dir}/template_" . $row['systemName'] . ".svg"); @@ -31,8 +32,19 @@ function generate($r, $force_reload = false) $svg = str_replace("***NUMBER***", $routeNum, $svg); break; + case 'usaib': + //FIXME: route type text will not render small enough in clinched shield viewer + $routeNum = explode("-", $row['route'])[1]; + if (strlen($routeNum) > 2) { + $svg = file_get_contents("{$dir}/template_usaib_wide.svg"); + } + $svg = str_replace("***NUMBER***", $routeNum, $svg); + $type = "LOOP"; + if ($row['banner'] == 'BS') $type = 'SPUR'; + $svg = str_replace("***TYPE***", $type, $svg); + break; + case 'usaus': - case 'usausb': $routeNum = str_replace("US", "", $row['route']); if (strlen($routeNum) > 2) { $svg = file_get_contents("{$dir}/template_usaus_wide.svg"); @@ -40,7 +52,19 @@ function generate($r, $force_reload = false) $svg = str_replace("***NUMBER***", $routeNum, $svg); break; - case 'usaky3': + case 'usausb': + $routeNum = str_replace("US", "", $row['route']); + $routeNum .= $row['banner'][0]; + if (strlen($routeNum) == 3) { + $svg = file_get_contents("{$dir}/template_usausb_wide.svg"); + } + if (strlen($routeNum) > 3) { + $svg = file_get_contents("{$dir}/template_usausb_wide4.svg"); + } + $svg = str_replace("***NUMBER***", $routeNum, $svg); + break; + + case 'usaky3': case 'usaky4': case 'usaky5': case 'usaky6': case 'usaky7': case 'usaky8': case 'usaky9': $routeNum = str_replace("KY", "", $row['route']); $svg = str_replace("***NUMBER***", $routeNum, $svg); break; @@ -78,7 +102,6 @@ function generate($r, $force_reload = false) case 'gbnm':case 'nirm': $routeNum = str_replace("M", "", $row['route']); - echo ""; if (strlen($routeNum) > 2) { $svg = file_get_contents("{$dir}/template_gbnm_wide.svg"); } @@ -94,7 +117,7 @@ function generate($r, $force_reload = false) $svg = str_replace("***NUMBER***", $routeNum, $svg); break; - case 'usasf':case 'usanp': + case 'usasf': case 'usanp': case 'eursf': case 'usakyp': case 'gbrtr': $lines = explode(',',preg_replace('/(?!^)[A-Z]{3,}(?=[A-Z][a-z])|[A-Z][a-z]/', ',$0', $row['route'])); $index = 0; foreach($lines as $line) { diff --git a/shields/template_eursf.svg b/shields/template_eursf.svg new file mode 100644 index 00000000..474a7923 --- /dev/null +++ b/shields/template_eursf.svg @@ -0,0 +1 @@ +***NUMBER1******NUMBER2******NUMBER3*** \ No newline at end of file diff --git a/shields/template_gbrtr.svg b/shields/template_gbrtr.svg new file mode 100644 index 00000000..a9c3e9dc --- /dev/null +++ b/shields/template_gbrtr.svg @@ -0,0 +1 @@ +***NUMBER1******NUMBER2******NUMBER3*** \ No newline at end of file diff --git a/shields/template_usaib.svg b/shields/template_usaib.svg new file mode 100644 index 00000000..f32afaba --- /dev/null +++ b/shields/template_usaib.svg @@ -0,0 +1,3 @@ +***NUMBER*** +***TYPE*** + diff --git a/shields/template_usaib_wide.svg b/shields/template_usaib_wide.svg new file mode 100644 index 00000000..0d01d353 --- /dev/null +++ b/shields/template_usaib_wide.svg @@ -0,0 +1,3 @@ +***TYPE*** +***NUMBER*** + diff --git a/shields/template_usaky4.svg b/shields/template_usaky4.svg new file mode 100644 index 00000000..cc1ef6df --- /dev/null +++ b/shields/template_usaky4.svg @@ -0,0 +1 @@ +***NUMBER*** \ No newline at end of file diff --git a/shields/template_usaky5.svg b/shields/template_usaky5.svg new file mode 100644 index 00000000..cc1ef6df --- /dev/null +++ b/shields/template_usaky5.svg @@ -0,0 +1 @@ +***NUMBER*** \ No newline at end of file diff --git a/shields/template_usaky6.svg b/shields/template_usaky6.svg new file mode 100644 index 00000000..cc1ef6df --- /dev/null +++ b/shields/template_usaky6.svg @@ -0,0 +1 @@ +***NUMBER*** \ No newline at end of file diff --git a/shields/template_usaky7.svg b/shields/template_usaky7.svg new file mode 100644 index 00000000..cc1ef6df --- /dev/null +++ b/shields/template_usaky7.svg @@ -0,0 +1 @@ +***NUMBER*** \ No newline at end of file diff --git a/shields/template_usaky8.svg b/shields/template_usaky8.svg new file mode 100644 index 00000000..cc1ef6df --- /dev/null +++ b/shields/template_usaky8.svg @@ -0,0 +1 @@ +***NUMBER*** \ No newline at end of file diff --git a/shields/template_usaky9.svg b/shields/template_usaky9.svg new file mode 100644 index 00000000..cc1ef6df --- /dev/null +++ b/shields/template_usaky9.svg @@ -0,0 +1 @@ +***NUMBER*** \ No newline at end of file diff --git a/shields/template_usakyp.svg b/shields/template_usakyp.svg new file mode 100644 index 00000000..1e797de9 --- /dev/null +++ b/shields/template_usakyp.svg @@ -0,0 +1 @@ +***NUMBER1******NUMBER2******NUMBER3*** \ No newline at end of file diff --git a/shields/template_usamd.svg b/shields/template_usamd.svg new file mode 100644 index 00000000..01486a52 --- /dev/null +++ b/shields/template_usamd.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + ***NUMBER*** + + + diff --git a/shields/template_usamd_wide.svg b/shields/template_usamd_wide.svg new file mode 100644 index 00000000..382d00d6 --- /dev/null +++ b/shields/template_usamd_wide.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + ***NUMBER*** + + diff --git a/shields/template_usanc.svg b/shields/template_usanc.svg new file mode 100644 index 00000000..c0e8e89a --- /dev/null +++ b/shields/template_usanc.svg @@ -0,0 +1,8 @@ + + + + + + ***NUMBER*** + + diff --git a/shields/template_usanc_wide.svg b/shields/template_usanc_wide.svg new file mode 100644 index 00000000..66a66e15 --- /dev/null +++ b/shields/template_usanc_wide.svg @@ -0,0 +1,8 @@ + + + + + + ***NUMBER*** + + diff --git a/shields/template_usausb_wide4.svg b/shields/template_usausb_wide4.svg new file mode 100644 index 00000000..c20145ce --- /dev/null +++ b/shields/template_usausb_wide4.svg @@ -0,0 +1 @@ +***NUMBER*** \ No newline at end of file diff --git a/shields/template_usava.svg b/shields/template_usava.svg new file mode 100644 index 00000000..fac29cf1 --- /dev/null +++ b/shields/template_usava.svg @@ -0,0 +1,8 @@ + + + + + + ***NUMBER*** + + diff --git a/shields/template_usava_wide.svg b/shields/template_usava_wide.svg new file mode 100644 index 00000000..209d04ee --- /dev/null +++ b/shields/template_usava_wide.svg @@ -0,0 +1,8 @@ + + + + + + ***NUMBER*** + + diff --git a/shields/template_usawv_wide.svg b/shields/template_usawv_wide.svg index 675bb997..8935cd49 100644 --- a/shields/template_usawv_wide.svg +++ b/shields/template_usawv_wide.svg @@ -1 +1 @@ - \ No newline at end of file +***NUMBER*** \ No newline at end of file diff --git a/stat.php b/stat.php index 78f8b558..219826d0 100644 --- a/stat.php +++ b/stat.php @@ -1,85 +1,195 @@ - - + - - - - - - -Traveler Statistics + + + + + + + Traveler Statistics + -

    Traveler Statistics

    -

    Overall Traveler Rankings

    - - - - - - - query($sql)->fetch_assoc()['totalMileage']; - $sql = << +

    Traveler Statistics

    +
    Overall Traveler Mileage
    RankUsernameMiles Traveled%
    +

    \n"; + echo "\n"; + tm_user_select(); + echo "\n"; + echo "

    \n"; + }else{ + echo << +HTML; + } + ?> + + + +
    + + + + + +HTML; + echo ""; + $sql = <<{$row['traveler']}"; + echo ""; + echo ""; + + $sql = <<{$row['clinchedMileage']} / {$totalPreviewMileage} ({$row['percentage']}%)"; + echo ""; + echo << +
    Current User
    UserActive MileageRankActive + Preview MileageRank
    {$row['clinchedMileage']} / {$totalMileage} ({$row['percentage']}%){$row['rank']}{$row['rank']}
    +
    + + + + + + + + + + + + + + query($sql); - $rank = 1; - while ($row = $res->fetch_assoc()) { - if($row['traveler'] == $user) { - $highlight = 'user-highlight'; - } else { - $highlight = ''; + $res = tmdb_query($sql); + $rank = 1; + while ($row = $res->fetch_assoc()) { + if ($row['traveler'] == $tmuser) { + $highlight = 'user-highlight'; + } else { + $highlight = ''; + } + echo << + + +HTML; + $rank++; } - echo <<free(); + + ?> + +
    Traveler Mileage in Active Systems
    RankUsernameMiles Traveled%
    {$rank}{$row['traveler']}{$row['clinchedMileage']}{$row['percentage']}%
    +
    + + + + + + + + + + + + + + fetch_assoc()) { + if ($row['traveler'] == $tmuser) { + $highlight = 'user-highlight'; + } else { + $highlight = ''; + } + echo << HTML; - $rank++; - } + $rank++; + } + $res->free(); - ?> - -
    Traveler Mileage in Active and Preview Systems
    RankUsernameMiles Traveled%
    {$rank}{$row['traveler']}{$row['clinchedMileage']}{$row['percentage']}%
    + ?> +
    + + + + \ No newline at end of file diff --git a/style.css b/style.css deleted file mode 100644 index 531c38a4..00000000 --- a/style.css +++ /dev/null @@ -1,105 +0,0 @@ -body { - margin: 0; -} - -.container { - max-width: 800px; - margin: auto; - padding-left: 10px; - padding-right: 10px; -} - -#header { - background-color: #214478; -} - -#logo { - margin: 20px 0; - display: inline-block; - vertical-align: middle; - line-height: 64px; - width: 300px; - height: 60px; - background-image: url("/logo.svg"); - background-size: contain; -} - -#hamburger { - display: none; -} - -#nav ul { - list-style-type: none; - padding-left: 0; -} - -#nav ul li a { - display: inline-block; - padding: 10px; - color: white; - text-decoration: none; -} -#nav ul li a:hover { - color: #214478; - background-color: white; -} - -@media (min-width: 500px) { - #nav ul { - display: inline; - } - - #nav ul li { - display: inline; - } - - label[for="hamburger"] { - display: none; - } - - #main { - padding-top: 20px; - } -} - -@media (max-width: 499px) { - #logo { - width: 200px; - height: 40px; - margin: 15px 0; - } - - label[for="hamburger"] { - display: inline-block; - width: 15px; - height: 15px; - background-image: url("/menu.svg"); - background-size: contain; - cursor: pointer; - vertical-align: middle; - margin-left: 10px; - margin-right: 20px; - line-height: 64px; - } - - #nav { - display: none; - } - - #hamburger:checked ~ #nav { - display: block; - } - - #nav ul { - margin-top: 0; - padding-bottom: 10px; - } - - #nav ul li { - display: block; - } - - #main { - padding-top: 10px; - } -} diff --git a/updateprod.csh b/updateprod.csh new file mode 100644 index 00000000..5fa81900 --- /dev/null +++ b/updateprod.csh @@ -0,0 +1,5 @@ +#!/bin/csh -f +scp *.php blizzard.teresco.org:/home/www/tm/ +foreach dir (user lib devel hb shields css) + scp $dir/*.{php,js,svg,css} blizzard.teresco.org:/home/www/tm/$dir +end diff --git a/updatetest.csh b/updatetest.csh new file mode 100644 index 00000000..81b00751 --- /dev/null +++ b/updatetest.csh @@ -0,0 +1,5 @@ +#!/bin/csh -f +scp *.php blizzard.teresco.org:/home/www/tmtest/ +foreach dir (user lib devel hb shields css) + scp $dir/*.{php,js,svg,css} blizzard.teresco.org:/home/www/tmtest/$dir +end diff --git a/user/index.php b/user/index.php index 82755c00..a35adeec 100644 --- a/user/index.php +++ b/user/index.php @@ -1,18 +1,15 @@ - + - + - + - + + <?php - echo "Traveler Stats for " . $user; - - // establish connection to db: mysql_ interface is deprecated, should learn new options - $db = new mysqli("localhost", "travmap", "clinch", $dbname) or die("Failed to connect to database"); - - # functions from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php - function startsWith($haystack, $needle) - { - // search backwards starting from haystack length characters from the end - return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; - } - - function endsWith($haystack, $needle) - { - // search forward starting from end minus needle length characters - return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); - } - + echo "Traveler Stats for " . $tmuser; ?> @@ -63,7 +44,7 @@ function endsWith($haystack, $needle) -

    Overall Stats

    - +
    + + + "; - $res = $db->query($sql_command); + $res = tmdb_query($sql_command); $row = $res->fetch_assoc(); $res->free(); - echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; - //Second, fetch routes driven/clinched - $sql_command = "SELECT COUNT(cr.route) AS total, COUNT(ccr.route) AS driven, SUM(ccr.clinched) AS clinched, ROUND(COUNT(ccr.route) / COUNT(cr.route) * 100,2) AS drivenPercent, ROUND(SUM(ccr.clinched) / COUNT(cr.route) * 100,2) AS clinchedPercent FROM connectedRoutes AS cr LEFT JOIN clinchedConnectedRoutes AS ccr ON cr.firstRoot = ccr.route AND traveler = '" . $user . "';"; - echo ""; - $res = $db->query($sql_command); + + //Second, fetch routes driven/clinched active only + $sql_command = "SELECT COUNT(cr.route) AS total FROM connectedRoutes AS cr LEFT JOIN systems ON cr.systemName = systems.systemName WHERE (systems.level = 'active');"; + $res = tmdb_query($sql_command); + $row = $res->fetch_assoc(); + $activeRoutes = $row['total']; + $res->free(); + + $sql_command = "SELECT COUNT(ccr.route) AS driven, SUM(ccr.clinched) AS clinched, ROUND(COUNT(ccr.route) / ".$activeRoutes." * 100,2) AS drivenPercent, ROUND(SUM(ccr.clinched) / ".$activeRoutes." * 100,2) AS clinchedPercent FROM connectedRoutes AS cr LEFT JOIN clinchedConnectedRoutes AS ccr ON cr.firstRoot = ccr.route AND traveler = '" . $tmuser . "' LEFT JOIN routes ON ccr.route = routes.root LEFT JOIN systems ON routes.systemName = systems.systemName WHERE systems.level = 'active';"; + $res = tmdb_query($sql_command); + $row = $res->fetch_assoc(); + $activeDriven = $row['driven']; + $activeDrivenPct = $row['drivenPercent']; + $activeClinched = $row['clinched']; + $activeClinchedPct = $row['clinchedPercent']; + $res->free(); + + // and active+preview + $sql_command = "SELECT COUNT(cr.route) AS total FROM connectedRoutes AS cr LEFT JOIN systems ON cr.systemName = systems.systemName WHERE (systems.level = 'active' OR systems.level = 'preview');"; + $res = tmdb_query($sql_command); + $row = $res->fetch_assoc(); + $activePreviewRoutes = $row['total']; + $res->free(); + + $sql_command = "SELECT COUNT(ccr.route) AS driven, SUM(ccr.clinched) AS clinched, ROUND(COUNT(ccr.route) / ".$activeRoutes." * 100,2) AS drivenPercent, ROUND(SUM(ccr.clinched) / ".$activeRoutes." * 100,2) AS clinchedPercent FROM connectedRoutes AS cr LEFT JOIN clinchedConnectedRoutes AS ccr ON cr.firstRoot = ccr.route AND traveler = '" . $tmuser . "' LEFT JOIN routes ON ccr.route = routes.root LEFT JOIN systems ON routes.systemName = systems.systemName WHERE (systems.level = 'active' OR systems.level = 'preview');"; + $res = tmdb_query($sql_command); $row = $res->fetch_assoc(); - echo "\n"; - $res->free; + $activePreviewDriven = $row['driven']; + $activePreviewDrivenPct = $row['drivenPercent']; + $activePreviewClinched = $row['clinched']; + $activePreviewClinchedPct = $row['clinchedPercent']; + $res->free(); + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; ?>
    Active SystemsActive+Preview Systems
    OverallMiles Driven: " . $row['clinchedMileage'] . " mi (" . $row['percentage'] . "%)Total: " . $row['totalMileage'] . " mi
    Miles Driven" . $row['clinchedActiveMileage']; + echo "/" . $row['totalActiveMileage'] . " mi ("; + echo $row['activePercentage'] . "%) Rank: TBD" . $row['clinchedActivePreviewMileage']; + echo "/" . $row['totalActivePreviewMileage'] . " mi ("; + echo $row['activePreviewPercentage'] . "%) Rank: TBD
    RoutesDriven: " . $row['driven'] . " (" . $row['drivenPercent'] . "%)Clinched: " . $row['clinched'] . " (" . $row['clinchedPercent'] . "%)Total: " . $row['total'] . "
    Routes Driven".$activeDriven." of " . $activeRoutes . " (" . $activeDrivenPct . "%) Rank: TBD".$activePreviewDriven." of " . $activePreviewRoutes . " (" . $activePreviewDrivenPct . "%) Rank: TBD
    Routes Clinched".$activeClinched." of " . $activeRoutes . " (" . $activeClinchedPct . "%) Rank: TBD".$activePreviewClinched." of " . $activePreviewRoutes . " (" . $activePreviewClinchedPct . "%) Rank: TBD

    Stats by Region

    + + + - - - + + + + + + "; - $res = $db->query($sql_command); + $sql_command = <<fetch_assoc()) { - $percent = round($row['clinchedMileage'] / $row['totalMileage'] * 100.0, 2); - echo ""; + if ( $row['totalActiveMileage'] == 0) { + $activePercent = "0.00"; + } + else { + $activePercent = round($row['clinchedActiveMileage'] / $row['totalActiveMileage'] * 100.0, 2); + $activePercent = sprintf('%0.2f', $activePercent); + } + $activePreviewPercent = round($row['clinchedActivePreviewMileage'] / $row['totalActivePreviewMileage'] * 100.0, 2); + $activePreviewPercent = sprintf('%0.2f', $activePreviewPercent); + echo ""; } $res->free(); ?> @@ -166,12 +227,11 @@ function endsWith($haystack, $needle) "; - $res = $db->query($sql_command); + $sql_command = "SELECT sys.countryCode, sys.systemName, sys.level, sys.tier, sys.fullName, COALESCE(ROUND(SUM(cr.mileage), 2),0) AS clinchedMileage, COALESCE(ROUND(SUM(r.mileage), 2), 0) AS totalMileage, COALESCE(ROUND(SUM(cr.mileage) / SUM(r.mileage) * 100, 2), 0) AS percentage FROM systems AS sys INNER JOIN routes AS r ON r.systemName = sys.systemName LEFT JOIN clinchedRoutes AS cr ON cr.route = r.root AND cr.traveler = '" . $tmuser . "' WHERE (sys.level = 'active' OR sys.level = 'preview') GROUP BY r.systemName;"; + $res = tmdb_query($sql_command); while ($row = $res->fetch_assoc()) { - echo ""; + if ($row['clinchedMileage'] == 0) continue; + echo ""; echo ""; echo ""; echo ""; @@ -180,12 +240,17 @@ function endsWith($haystack, $needle) echo ""; echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; } $res->free(); ?>
    Active Systems OnlyActive+Preview Systems
    Country RegionClinched MileageOverall MileagePercent ClinchedClinched (mi)Overall (mi)% ClinchedClinched (mi)Overall (mi)% Clinched Map
    " . $row['country'] . "" . $row['name'] . "" . $row['clinchedMileage'] . "" . $row['totalMileage'] . "" . $percent . "%
    " . $row['country'] . "" . $row['name'] . "" . sprintf('%0.2f', $row['clinchedActiveMileage']) . "" . sprintf('%0.2f', $row['totalActiveMileage']) . "" . $activePercent . "%" . sprintf('%0.2f', $row['clinchedActivePreviewMileage']) . "" . sprintf('%0.2f', $row['totalActivePreviewMileage']) . "" . $activePreviewPercent . "%
    " . $row['countryCode'] . "" . $row['systemName'] . "" . $row['fullName'] . "" . $row['clinchedMileage'] . "" . $row['totalMileage'] . "" . $row['percentage'] . "%
    + +close(); +?> + diff --git a/hbtest/mapview.php b/user/mapview.php similarity index 55% rename from hbtest/mapview.php rename to user/mapview.php index a12357da..c9dcb699 100644 --- a/hbtest/mapview.php +++ b/user/mapview.php @@ -1,20 +1,5 @@ - + + - + - + - + = 0 && strpos($haystack, $needle, $temp) !== FALSE); - } function orClauseBuilder($param, $name, $tablename = 'r') { - $array = explode(",", $_GET[$param]); + $array = array(); + if (is_array($_GET[$param])) { + foreach ($_GET[$param] as $p) { + $array = array_merge($array, explode(',',$p)); + } + } + else { + $array = explode(",", $_GET[$param]); + } + $array = array_diff($array, array("null")); $clause = "("; $i = 0; foreach($array as $item) { @@ -130,18 +136,22 @@ function orClauseBuilder($param, $name, $tablename = 'r') { if($i < sizeof($array)) $clause .= " or "; } $clause .= ")"; + if ($i == 0) { + return "TRUE"; + } return $clause; } ?> - -- -Home- -Highway Browser -

    Travel Mapping: Draft Map Overlay Viewer

    + + -
    -  Show Markers - - - 0) { - echo " " . $row[2]; - } - if (strlen($row[3]) > 0) { - echo " (" . $row[3] . ")"; - } - echo ": "; - } else if (array_key_exists("rg", $_GET)) { - echo "Displaying region: " . $_GET['rg'] . "."; - } - ?> - - - -
    +
    +
    +
    + + + + + + + + + + + + + + + +
    Select Map Options
    +  Show Markers +
    User: + +
    Region(s):
    + +
    System(s):
    + +
    + +
    +
    +
    - + + + + + + + "; - $res = mysql_query($sql_command); - while($row = mysql_fetch_array($res)) { - $link = "/devel/hb.php?u=".$_GET['u']."&r=".$row['root']; - echo "\n"; + $pct = sprintf("%0.2f",( $row['clinched'] / $row['total'] * 100) ); + echo << + + \n"; } ?>
    RouteSystemClinchedOverall%
    RouteSystemClinchedOverall%
    DUMMY000000000.00%
    "; + $sql_command .= "ORDER BY sys.tier, r.route;"; + $res = tmdb_query($sql_command); + while($row = $res->fetch_assoc()) { + $link = "/hb?u=".$_GET['u']."&r=".$row['root']; + echo "
    "; //REGION ROUTE BANNER (CITY) echo $row['region'] . " " . $row['route']; if (strlen($row['banner']) > 0) { @@ -389,11 +410,27 @@ function initFloatingHeaders($table) { if (strlen($row['city']) > 0) { echo " (" . $row['city'] . ")"; } - echo "".$row['clinched']."".$row['total']."".(round( $row['clinched'] / $row['total'] * 100, 2) )."%
    +HTML +.$row['clinched']."".$row['total']."".$pct."%
    +
    + +
    +close(); +?> diff --git a/user/region.php b/user/region.php index 97b967df..274029e4 100644 --- a/user/region.php +++ b/user/region.php @@ -1,44 +1,16 @@ -

    ERROR: 400 Missing user (u=) or region (rg=) params

    "; - exit(); - } -?> + - + + "; - $regionInfo = mysql_fetch_array(mysql_query($sql_command)); - - # functions from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php - function startsWith($haystack, $needle) - { - // search backwards starting from haystack length characters from the end - return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; + $regions = tm_qs_multi_or_comma_to_array("rg"); + if (count($regions) > 0) { + $region = $regions[0]; + $regionName = tm_region_code_to_name($region); } - - function endsWith($haystack, $needle) - { - // search forward starting from end minus needle length characters - return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); - } - - function fetchWithRank($res, $rankBy) - { - global $user; - $nextRank = 1; - $rank = 1; - $score = 0; - $row = array(); - while($row['traveler'] != $user && $row = mysql_fetch_array($res)) { - if ($score != $row[$rankBy]) { - $score = $row[$rankBy]; - $rank = $nextRank; - } - - $nextRank++; - error_log("($rank, {$row['traveler']}, {$row[$rankBy]})"); - } - $row['rank'] = $rank; - return $row; + else { + $region = ""; + $regionName = "No Region Specified"; } + $activeClause = "(systems.level='preview' OR systems.level='active')"; ?> - <?php echo $regionInfo['name']." - ".$user; ?> + <?php echo $regionName." - ".$tmuser; ?> - + - - + - + +> + +Select a User and Region to Continue\n"; + echo "\n"; + require $_SERVER['DOCUMENT_ROOT']."/lib/tmfooter.php"; + echo "\n"; + echo "\n"; + exit; +} +?>
    -  Show Markers
    @@ -312,44 +208,130 @@ function redirect($link) {
    TIP: Click on a column head to sort. Hold SHIFT in order to sort by multiple columns.
    - + + + + free(); + $link = "redirect('/user/mapview.php?u=" . $tmuser . "&rg=" . $region . "')"; + $activeTotalMileage = $row['totalActiveMileage']; + $activeClinchedMileage = $row['activeClinched']; + $activeMileagePercentage = $row['activePercentage']; + $activeMileageRank = $row['rank']; + + // and active+preview $sql_command = <<free(); + $link = "redirect('/user/mapview.php?u=" . $tmuser . "&rg=" . $region . "')"; + $activePreviewTotalMileage = $row['totalActivePreviewMileage']; + $activePreviewClinchedMileage = $row['activePreviewClinched']; + $activePreviewMileagePercentage = $row['activePreviewPercentage']; + $activePreviewMileageRank = $row['rank']; + + echo ""; + echo ""; + echo ""; + echo ""; + + // Second, fetch routes clinched/driven + $totalActiveRoutes = tm_count_rows("routes", "LEFT JOIN systems on routes.systemName = systems.systemName WHERE region = '$region' AND systems.level = 'active'"); + + $totalActivePreviewRoutes = tm_count_rows("routes", "LEFT JOIN systems on routes.systemName = systems.systemName WHERE region = '$region' AND ".$activeClause." "); + + $sql_command = <<"; - - //Second, fetch routes clinched/driven - $totalRoutes = mysql_fetch_array(mysql_query("SELECT COUNT(*) as t FROM routes LEFT JOIN systems on routes.systemName = systems.systemName WHERE region = '$region' AND systems.active = 1"))['t']; - error_log("Total Routes: $totalRoutes"); + + $res = tmdb_query($sql_command); + $row = tm_fetch_user_row_with_rank($res, 'clinchedPct'); + $res->free(); + $drivenActiveRoutes = $row['driven']; + $drivenActiveRoutesPct = $row['drivenPct']; + $clinchedActiveRoutes = $row['clinched']; + $clinchedActiveRoutesPct = $row['clinchedPct']; + $clinchedActiveRoutesRank = $row['rank']; + $sql_command = <<"; - $res = mysql_query($sql_command); - $row = fetchWithRank($res, 'clinchedPct'); - echo "\n"; + $res = tmdb_query($sql_command); + $row = tm_fetch_user_row_with_rank($res, 'clinchedPct'); + $res->free(); + $drivenActivePreviewRoutes = $row['driven']; + $drivenActivePreviewRoutesPct = $row['drivenPct']; + $clinchedActivePreviewRoutes = $row['clinched']; + $clinchedActivePreviewRoutesPct = $row['clinchedPct']; + $clinchedActivePreviewRoutesRank = $row['rank']; + + + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + ?>
    Overall Region Stats
    Overall Region Stats
    Active SystemsActive+Preview Systems
    Miles Driven" . $activeClinchedMileage; + echo "/" . $activeTotalMileage . " mi ("; + echo $activeMileagePercentage . "%) "; + echo "Rank: " . $activeMileageRank . "" . $activePreviewClinchedMileage; + echo "/" . $activePreviewTotalMileage . " mi ("; + echo $activePreviewMileagePercentage . "%) "; + echo "Rank: " . $activePreviewMileageRank . "
    OverallMiles Driven: ".$row['clinched']." mi (".$row['percentage']."%)Total: ".$row['overall']." miRank: {$row['rank']}
    RoutesDriven: " . $row['driven'] . " (" . $row['drivenPct'] . "%)Clinched: " . $row['clinched'] . " (" . $row['clinchedPct'] . "%)Total: " . $totalRoutes . "Rank: {$row['rank']}
    Routes Driven".$drivenActiveRoutes." of " . $totalActiveRoutes . " (" . $drivenActiveRoutesPct . "%) Rank: TBD".$drivenActivePreviewRoutes." of " . $totalActivePreviewRoutes . " (" . $drivenActivePreviewRoutesPct . "%) Rank: TBD
    Routes Clinched".$clinchedActiveRoutes." of " . $totalActiveRoutes . " (" . $clinchedActiveRoutesPct . "%) Rank: ". $clinchedActiveRoutesRank."".$clinchedActivePreviewRoutes." of " . $totalActivePreviewRoutes . " (" . $clinchedActivePreviewRoutesPct . "%) Rank: ". $clinchedActivePreviewRoutesRank."
    @@ -376,7 +358,6 @@ function redirect($link) { sys.tier, sys.level AS status, sys.fullName, - r.root, COALESCE(ROUND(SUM(cr.mileage), 2), 0) AS clinchedMileage, COALESCE(ROUND(SUM(r.mileage), 2), 0) AS totalMileage, COALESCE(ROUND(SUM(cr.mileage) / SUM(r.mileage) * 100, 2), 0) AS percentage @@ -384,41 +365,48 @@ function redirect($link) { INNER JOIN routes AS r ON r.systemName = sys.systemName LEFT JOIN clinchedRoutes AS cr - ON cr.route = r.root AND cr.traveler = 'xxxxxxxxxxxxxxxxx' - WHERE r.region = 'yyyyyyyyyyyyyyyyy' + ON cr.route = r.root AND cr.traveler = '{$tmuser}' + WHERE r.region = '{$region}' GROUP BY r.systemName ORDER BY sys.tier, sys.systemName; SQL; - $sql_command = str_replace("xxxxxxxxxxxxxxxxx", $user, $sql_command); - $sql_command = str_replace("yyyyyyyyyyyyyyyyy", $region, $sql_command); - echo ""; - - $res = mysql_query($sql_command); - while ($row = mysql_fetch_array($res)) { - echo ""; + $res = tmdb_query($sql_command); + while ($row = $res->fetch_assoc()) { + echo ""; echo "" . $row['systemName'] . ""; echo "" . $row['fullName'] . ""; echo "" . $row['clinchedMileage'] . ""; echo "" . $row['totalMileage'] . ""; echo "" . $row['percentage'] . "%"; - echo "HB"; + echo "HB"; } + $res->free(); ?> - - + + "; - $res = mysql_query($sql_command); - while ($row = mysql_fetch_array($res)) { - echo ""; + $sql_command = <<fetch_assoc()) { + echo ""; + echo ""; echo ""; + echo ""; echo ""; echo ""; echo ""; - echo ""; + echo ""; } + $res->free(); ?>
    Stats by Route: (" ?>Full Map)
    RouteClinched MileageTotal Mileage%Map
    Stats by Route: (" ?>Full Map)
    TierRoute#Clinched MileageTotal Mileage%Map
    {$row['tier']}".$row['route']; if (strlen($row['banner']) > 0) { echo " ".$row['banner']." "; @@ -427,15 +415,21 @@ function redirect($link) { echo " (".$row['city'].")"; } echo "{$row['systemName']}.{$row['root']}".$row['clinchedMileage']."".$row['totalMileage']."".$row['percentage']."%
    + - \ No newline at end of file +close(); +?> + diff --git a/user/system.php b/user/system.php index c12b5ab2..a713c6b1 100644 --- a/user/system.php +++ b/user/system.php @@ -1,34 +1,4 @@ - 0) { - $region = $_GET['rg']; -} -if (array_key_exists("sys", $_GET)) { - $system = $_GET['sys']; -} - -if (is_null($user) || is_null($system)) { - header('HTTP/ 400 Missing user (u=) or system(sys=) params'); - echo "

    ERROR: 400 Missing user (u=) or system (sys=) params

    "; - exit(); -} -?> + - + + "; - $regionInfo = mysql_fetch_array(mysql_query($sql_command)); + $regions = tm_qs_multi_or_comma_to_array("rg"); + if (count($regions) > 0) { + $region = $regions[0]; + $regionName = tm_region_code_to_name($region); } - - $sql_command = "SELECT * FROM systems where systemName = '".$system."'"; - echo ""; - $systemInfo = mysql_fetch_array(mysql_query($sql_command)); - - - # functions from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php - function startsWith($haystack, $needle) - { - // search backwards starting from haystack length characters from the end - return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; + else { + $region = ""; + $regionName = "No Region Specified"; } - function endsWith($haystack, $needle) - { - // search forward starting from end minus needle length characters - return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); + $systems = tm_qs_multi_or_comma_to_array("sys"); + if (count($systems) > 0) { + $system = $systems[0]; + $systemName = tm_system_code_to_name($system); } - - function fetchWithRank($res, $rankBy) - { - global $user; - $nextRank = 1; - $rank = 1; - $score = 0; - $row = array(); - while($row['traveler'] != $user && $row = mysql_fetch_array($res)) { - if ($score != $row[$rankBy]) { - $score = $row[$rankBy]; - $rank = $nextRank; - } - - $nextRank++; - error_log("($rank, {$row['traveler']}, {$row[$rankBy]})"); - } - $row['rank'] = $rank; - return $row; + else { + $system = ""; + $systemName = "No System Specified"; + $redir_url = "/user/region.php?u={$tmuser}&rg={$_GET['rg']}"; + echo ""; + echo "Please go to {$redir_url} if you are not automatically redirected."; + exit(); } - ?> <?php - if (!is_null($region)) { - echo $system; + echo $systemName." (".$system.")"; + if ($region != "") { echo " in " . $region; - } else { - echo $systemInfo['fullName']; } - echo " - ".$user; + echo " - ".$tmuser; ?> - + - + -"> + +> + + +Select a User and System to Continue\n"; + echo "\n"; + require $_SERVER['DOCUMENT_ROOT']."/lib/tmfooter.php"; + echo "\n"; + echo "\n"; + exit; +} +?>
    -  Show Markers
    - + "; - $res = mysql_query($sql_command); - $row = fetchWithRank($res, 'percentage'); - $link = "window.open('/hbtest/mapview.php?u=" . $user . "&sys=" . $system . "')"; - echo ""; + $res = tmdb_query($sql_command); + $row = tm_fetch_user_row_with_rank($res, 'clinchedMileage'); + $res->free(); + $percentage = $row['clinchedMileage'] / $system_mileage * 100; + $link = "window.open('/user/mapview.php?u=" . $user . "&sys=" . $system . "')"; + echo ""; //Second, fetch routes clinched/driven - if (is_null($region)) { - $totalRoutes = mysql_fetch_array(mysql_query("SELECT COUNT(*) as t FROM connectedRoutes WHERE systemName='$system'"))['t']; + if ($region == "") { + $totalRoutes = tm_count_rows("connectedRoutes", "WHERE systemName='".$system."'"); $sql_command = <<"; - $res = mysql_query($sql_command); - $row = fetchWithRank($res, 'clinched'); - echo "\n"; + $res = tmdb_query($sql_command); + $row = tm_fetch_user_row_with_rank($res, 'clinched'); + $res->free(); + echo ""; + echo "\n"; ?>
    System Stats
    System Stats
    OverallMiles Driven: ".$row['clinched']." mi (".$row['percentage']."%)Total: ".$row['overall']." miRank: {$row['rank']}
    Miles Driven".sprintf('%0.2f', $row['clinchedMileage'])." of ".sprintf('%0.2f', $system_mileage)." mi (".sprintf('%0.2f',$percentage)."%) Rank: {$row['rank']}
    RoutesDriven: " . $row['driven'] . " (" . round($row['driven'] / $totalRoutes * 100, 2) . - "%)Clinched: " . $row['clinched'] . " (" . round($row['clinched'] / $totalRoutes * 100, 2) . "%)Total: " . $totalRoutes . - "Rank: {$row['rank']}
    Routes Driven" . $row['driven'] . " of ".$totalRoutes." (" . round($row['driven'] / $totalRoutes * 100, 2) ."%)
    Routes Clinched" . $row['clinched'] . " of " . $totalRoutes . " (" . round($row['clinched'] / $totalRoutes * 100, 2) . "%) Rank: {$row['rank']}
    + + TIP: Click on a column head to sort. Hold SHIFT in order to sort by multiple columns. + + Statistics Per Region + + Region + Clinched Mileage + Total Mileage + % + + + +HTML; + $sql_command = <<fetch_assoc()) { + echo << + {$row['region']} + {$row['clinchedMileage']} + {$row['totalMileage']} + {$row['percentage']} + +HTML; + } + $res->free(); + echo ""; + } + ?> - - + + + @@ -414,37 +357,42 @@ function waypointsFromSQL() { "; - - $res = mysql_query($sql_command); + $res = tmdb_query($sql_command); - while ($row = mysql_fetch_array($res)) { - if (is_null($region)) { - $link = "window.open('/hbtest/mapview.php?u=" . $user . "&rte=" . $row['route'] . "')"; + while ($row = $res->fetch_assoc()) { + if ($region == "") { + $link = "window.open('/user/mapview.php?u=" . $tmuser . "&rte=" . $row['route'] . "')"; } else { - $link = "window.open('/devel/hb.php?u=" . $user . "&r=" . $row['root'] . "')"; + $link = "window.open('/hb?u=" . $tmuser . "&r=" . $row['root'] . "')"; } echo ""; echo ""; echo ""; + echo ""; + echo ""; echo ""; echo ""; echo ""; echo ""; } + $res->free(); ?>
    TIP: Click on a column head to sort. Hold SHIFT in order to sort by multiple columns.
    Statistics per RouteStatistics per Route
    Route #BannerAbbrev Section Clinched Mileage Total Mileage
    " . $row['route'] . "" . $row['routeNum'] . "" . $row['banner'] . "" . $row['abbrev'] . "" . $row['city'] . "" . $row['clinchedMileage'] . "" . $row['totalMileage'] . "" . $row['percentage'] . "%
    + - \ No newline at end of file +close(); +?> +