foreach ($start_stations as $station) { $station_marker = $station->marker; echo "<tr>\n"; printStation($station_marker); echo "<td>\n"; if ($start_station_marker->id == $station_marker->id) { echo "<input type=\"radio\" name=\"ssta\" value=\"{$station_marker->id}\" checked/>\n"; } else { echo "<input type=\"radio\" name=\"ssta\" value=\"{$station_marker->id}\" />\n"; } echo "</td>\n"; echo "</tr>\n"; $num++; } // list alternate end stations $end_stations = findNearestStations2($ends[0]); $end_station_marker = $path_array[count($path_array) - 1]->m1; echo "<tr>\n<td colspan=\"4\"><b>End Station Choices</b></td>\n</tr>\n"; echo "<tr>\n<td> <b>Show</b> </td>\n"; echo "<td><b>Station Name</b></td>\n"; echo "<td><b>Subway Lines</b></td>\n</tr>\n"; $num = 1; foreach ($end_stations as $station) { $station_marker = $station->marker; echo "<tr>\n"; printStation($station_marker); echo "<td>\n"; if ($end_station_marker->id == $station_marker->id) { echo "<input type=\"radio\" name=\"esta\" value=\"{$station_marker->id}\" checked/>\n"; } else { echo "<input type=\"radio\" name=\"esta\" value=\"{$station_marker->id}\" />\n";
print_r($ends); echo "<br/>"; } $start_station_marker = getMarker($_GET['start']); $end_station_marker = getMarker($_GET['end']); // find the path $path = findS2SPath($start_station_marker, $end_station_marker); // add two segments to the marker $start_location = $starts[0]; $end_location = $ends[0]; // add the segment directly to the Path. // shouldn't because it's a violation of abstraction, but I haven't developed the API yet. $start_marker = new Marker($start_location->point->lat, $start_location->point->lng, "start", $start_location->getAddressString()); $segment = new Segment($start_marker, $start_station_marker, $start_station_marker->lines, distance($start_marker, $start_station_marker) / $WALKING_SPEED, "walking"); // add segment directly to the beginning of the path array_unshift($path->path, $segment); $path->time += $segment->t; // now add the last marker $end_marker = new Marker($end_location->point->lat, $end_location->point->lng, "end", $end_location->getAddressString()); $segment = new Segment($end_station_marker, $end_marker, null, distance($end_station_marker, $end_marker) / $WALKING_SPEED, "walking"); $path->addSegment($segment, null); // find three closest starting stations $start_stations = findNearestStations2($start_location); // find three closest ending stations $end_stations = findNearestStations2($end_location); } } } } } }
/** Displays the station choices for choosing alternate stations when using direction finding. @param $url<String> the URL for the form @param $start_location<Location> the starting point for the search @param $end_location<Location> the ending point for the search @param $path_array[]<Segment> the path found in the original search */ function displayStationChoices($url, $start_location, $end_location, $path_array) { global $website, $station_marker_img; $debug = false; if ($debug) { echo $start_location->desc . " to " . $end_location->desc . "<br/>"; } // list alternate start stations $start_table = new Table(null, "choicetable"); $div = new Div("alternate_choices", "<b>Start Station Choices</b><br/>\n"); $div->addDataElement($start_table); $div->addDataElement("<br/>\n"); $header_row = new Row(null, "header_row"); $header_row->addCell(new Cell("header_cell", "Show")); $header_row->addCell(new Cell("header_cell", "Station Name")); $header_row->addCell(new Cell("header_cell", "Subway Lines")); $header_row->addCell(new Cell("header_cell")); $start_table->addRow($header_row); $start_stations = findNearestStations2($start_location); $start_station_marker = $path_array[0]->m2; if ($debug) { echo "start_station_marker->id = " . $start_station_marker->id . "<br/>"; } $i = 0; foreach ($start_stations as $station) { $station_marker = $station->marker; $station_lng = $station_marker->getLng(); $station_lat = $station_marker->getLat(); if (isEven($i)) { $class_name = "rowHighlight"; } else { $class_name = "row"; } $station_row = new Row($station_marker->id, $class_name); // station marker link $station_row->addCell(new Cell("step_cell", new Link("javascript:focusOn(new GLatLng({$station_lat},{$station_lng}), map.getZoom());", new Image("images/{$station_marker_img}", "0")))); $station_row->addCell(new Cell("instruction", $station_marker->name)); // build lines cell $lines = $station_marker->getLines(); $lines_cell = new Cell("instruction"); foreach ($lines as $line) { $line_img = $line->img; $line_url = $website . $line->url; $lines_cell->addData(new Link("javascript:void(0);", new Image(null, "images/{$line_img}", $line->name, null, "20"), "window.open('{$line_url}');")); } $station_row->addCell($lines_cell); if ($start_station_marker->id == $station_marker->id) { $cell_data = "<input type=\"radio\" name=\"start\" value=\"{$station_marker->id}\" checked=\"true\"/>"; } else { $cell_data = "<input type=\"radio\" name=\"start\" value=\"{$station_marker->id}\" />"; } $station_row->addCell(new Cell("step_cell", $cell_data)); $start_table->addRow($station_row); $i++; } // list alternate end stations $div->addDataElement("<b>End Station Choices</b><br/>\n"); $end_table = new Table(null, "choicetable"); $div->addDataElement($end_table); $end_table->addRow($header_row); $end_stations = findNearestStations2($end_location); $end_station_marker = $path_array[count($path_array) - 1]->m1; if ($debug) { echo "end_station_marker->id = " . $end_station_marker->id . "<br/>"; } $i = 0; foreach ($end_stations as $station) { $station_marker = $station->marker; $station_lng = $station_marker->getLng(); $station_lat = $station_marker->getLat(); if (isEven($i)) { $class_name = "rowHighlight"; } else { $class_name = "row"; } $station_row = new Row($station_marker->id, $class_name); // station marker link $station_row->addCell(new Cell("step_cell", new Link("javascript:focusOn(new GLatLng({$station_lat},{$station_lng}), map.getZoom());", new Image("images/{$station_marker_img}", "0")))); $station_row->addCell(new Cell("instruction", $station_marker->name)); // build lines cell $lines = $station_marker->getLines(); $lines_cell = new Cell("instruction"); foreach ($lines as $line) { $line_img = $line->img; $line_url = $website . $line->url; $lines_cell->addData(new Link("javascript:void(0);", new Image(null, "images/{$line_img}", $line->name, null, "20"), "window.open('{$line_url}');")); } $station_row->addCell($lines_cell); if ($end_station_marker->id == $station_marker->id) { $cell_data = "<input type=\"radio\" name=\"end\" value=\"{$station_marker->id}\" checked=\"true\"/>"; } else { $cell_data = "<input type=\"radio\" name=\"end\" value=\"{$station_marker->id}\" />"; } $station_row->addCell(new Cell("step_cell", $cell_data)); $end_table->addRow($station_row); $i++; } echo "<form id=\"form_pick\" action=\"{$url}\" method=\"get\">\n"; echo $div->toString(); echo "<input type=\"hidden\" name=\"type\" value=\"dir_alt\" />\n"; echo "<input type=\"hidden\" name=\"sa\" value=\"" . $start_location->getAddressString() . "\" />\n"; echo "<input type=\"hidden\" name=\"da\" value=\"" . $end_location->getAddressString() . "\" />\n"; echo "<br/>\n"; #echo "<input type=\"image\" name=\"submit\" src=\"images/usebutton.png\">\n"; echo "<div id=\"usebutton\"><input class=\"btn\" type=\"submit\" id=\"submit\" value=\"Use\"></div>\n"; echo "</form>"; }
/** Displays the station choices for choosing alternate stations when using direction finding. @param $url<String> the URL for the form @param $start_location<Location> the starting point for the search @param $end_location<Location> the ending point for the search @param $path_array[]<Segment> the path found in the original search */ function displayStationChoices($url, $start_location, $end_location, $path_array) { $debug = false; if ($debug) { echo $start_location->desc . " to " . $end_location->desc . "<br/>"; } echo "<form id=\"form_pick\" action=\"{$url}\" method=\"get\">\n"; // list alternate stations echo "<table border=\"1\">\n<tbody>\n<tr>\n<td colspan=\"4\"><b>Start Station Choices</b></td>\n</tr>\n<tr>\n<td> <b>Show</b> </td>\n<td><b>Station Name</b></td>\n<td><b>Subway Lines</b></td>\n</tr>\n"; $num = 1; // grab the stations $start_stations = findNearestStations2($start_location); $start_station_marker = $path_array[0]->m2; if ($debug) { echo "start_station_marker->id = " . $start_station_marker->id . "<br/>"; } foreach ($start_stations as $station) { $station_marker = $station->marker; echo "<tr>\n"; printStation($station_marker); echo "<td>\n"; if ($start_station_marker->id == $station_marker->id) { echo "<input type=\"radio\" name=\"start\" value=\"{$station_marker->id}\" checked/>\n"; } else { echo "<input type=\"radio\" name=\"start\" value=\"{$station_marker->id}\" />\n"; } echo "</td>\n"; echo "</tr>\n"; $num++; } // list alternate end stations $end_stations = findNearestStations2($end_location); $end_station_marker = $path_array[count($path_array) - 1]->m1; if ($debug) { echo "end_station_marker->id = " . $end_station_marker->id . "<br/>"; } echo "<tr>\n<td colspan=\"4\"><b>End Station Choices</b></td>\n</tr>\n"; echo "<tr>\n<td> <b>Show</b> </td>\n"; echo "<td><b>Station Name</b></td>\n"; echo "<td><b>Subway Lines</b></td>\n</tr>\n"; $num = 1; foreach ($end_stations as $station) { $station_marker = $station->marker; echo "<tr>\n"; printStation($station_marker); echo "<td>\n"; if ($end_station_marker->id == $station_marker->id) { echo "<input type=\"radio\" name=\"end\" value=\"{$station_marker->id}\" checked/>\n"; } else { echo "<input type=\"radio\" name=\"end\" value=\"{$station_marker->id}\" />\n"; } echo "</td>\n</tr>\n"; $num++; } echo "</tbody>\n</table>\n"; // geocoder leaves out intersections! we have to fill in with the query here //correctHiddenValue($start_loc, $saddr, "saddr"); // geocoder leaves out intersections! we have to fill in with the query here //correctHiddenValue($end_loc, $daddr, "daddr"); echo "<input type=\"hidden\" name=\"type\" value=\"dir_alt\" />\n"; echo "<input type=\"hidden\" name=\"saddr\" value=\"" . $start_location->getAddressString() . "\" />\n"; echo "<input type=\"hidden\" name=\"daddr\" value=\"" . $end_location->getAddressString() . "\" />\n"; echo "<br/>\n"; echo "<input type=\"image\" name=\"submit\" src=\"images/usebutton.png\">\n"; echo "</form><br/>\n"; }
if ($logging) { logS2SQuery($_GET['start'], $_GET['end']); } // find the path $path = findS2SPath($start_marker, $end_marker); } } } if ($type == 'location') { $loc = $_GET['l']; if ($location_string != null || $location_string != "") { $loc = $location_string; } // log if ($logging) { logLocationQuery($loc); } if ($debug) { echo "location={$loc}<br/>"; } $loc = fixSearchString($loc); // check for new york and ny $fix_loc = checkString($loc, $city); $fix_loc = checkString($fix_loc, $state); $locations = getLocations2($fix_loc); if (count($locations) == 1) { // grab stations $stations = findNearestStations2($locations[0]); } } echo "<!-- type is /" . $type . "/ -->\n";