<?php // display that map function get_coordinates() { // get coordinates $mylatitude = ""; $mylongitude = ""; global $wpdb; $table_name = $wpdb->prefix . "mylocation"; // query table row if id is equal to one $mycoords = $wpdb->get_results("SELECT longitude, latitude FROM {$table_name} WHERE id = 1"); } get_coordinates(); function display_map() { // yoh!! $frontlat = ""; $frontlong = ""; //if id = 1 in the database exist, execute the function baby global $wpdb; $table_name = $wpdb->prefix . "mylocation"; $id = $wpdb->get_results("SELECT id FROM {$table_name}"); $coord = $wpdb->get_results("SELECT longitude, latitude FROM {$table_name}"); foreach ($coord as $coordinate) { $frontlat = $coordinate->latitude; $frontlong = $coordinate->longitude; } if ($id = 1) { $map = "http://maps.googleapis.com/maps/api/staticmap?center={$frontlat},{$frontlong}&zoom=14&size=400x400&markers=color:red|label:A|{$frontlat},{$frontlong}"; echo "<div class='front-map'>\n <h3 class='current-loc'>I am currently here...</h3><br />";
/* parse airways data */ $fp = fopen('faa/AWY.txt', 'r'); $airways = array(); $total = 0; $updated = 0; $skipped = 0; while ($line = fgets($fp)) { $type = substr($line, 0, 4); if ($type == 'AWY2') { $airway_name = trim(substr($line, 4, 5)); $fix_name = trim(substr($line, 113, 5)); $pub_cat = trim(substr($line, 64, 15)); $lat = trim(substr($line, 81, 14)); $lng = trim(substr($line, 95, 14)); $lat = get_coordinates($lat); $lng = get_coordinates($lng); if (empty($fix_name) || empty($lat) || empty($lng)) { //$skipped++; continue; } $sql = "SELECT * \r\n\t\t\t\tFROM `phpvms_navdata`\r\n\t\t\t\tWHERE `name`='{$fix_name}' AND `airway`='{$airway_name}'"; $res = mysql_query($sql); if (mysql_num_rows($res) == 0) { continue; } $row = mysql_fetch_object($res); if (!$row) { continue; } // Only update is there a within a 2% difference $lat_diff = abs(abs($lat / $row->lat) * 100 - 100);
function text_geometry_from_file($filepath) { global $name; $xml = simplexml_load_file($filepath); $region = $xml->Document->Placemark; $name = $region->name; // detect if polygon or multipolygon $is_multi = !empty($region->MultiGeometry); if ($is_multi) { $region = $region->MultiGeometry; } $polygons_list = array(); $is_line = empty($region->Polygon); $polygons = $is_line ? $region->LineString : $region->Polygon; for ($i = 0; $i < count($polygons); $i++) { // retrieve polygon outer boundary points $outerboundary = '(' . get_coordinates($is_line ? $polygons[$i]->coordinates : $polygons[$i]->outerBoundaryIs->LinearRing->coordinates, $is_line) . ')'; // Check if they are some inner rings if (!$is_line) { $innerboundaries = array(); $innerrings = $polygons[$i]->innerBoundaryIs; for ($j = 0; $j < count($innerrings); $j++) { $innerboundaries[] = '(' . get_coordinates($innerrings[$j]->LinearRing->coordinates) . ')'; } } $polygons_list[] = $outerboundary . (isset($innerboundaries) && count($innerboundaries) ? ',' . implode(',', $innerboundaries) : ''); } if (!$is_multi) { return 'POLYGON(' . $polygons_list[0] . ')'; } else { return 'MULTIPOLYGON((' . implode('),(', $polygons_list) . '))'; } }
function show_leafletjs($devices, $requests, $rid = 0) { # http://leafletjs.com/download.html $defaultzoom = 16; $requestcoordinates = get_coordinates($requests); ?> <div id="map"></div> <script src="include/leaflet.js"></script> <script> function onLocationFound(e) { var radius = e.accuracy / 2; L.marker(e.latlng).addTo(map) .bindPopup("You are within " + radius + " meters from this point"); L.circle(e.latlng, radius).addTo(map); } function onLocationError(e) { /*alert(e.message);*/ } <?php #print_r($requestcoordinates); /* floatval($r['latitude']), floatval($r['longitude']), $r['sname'], $r['battery'], $r['charging'], $r['type'], rdate */ print "var map = L.map('map').setView([" . $requestcoordinates[0][0] . "," . $requestcoordinates[0][1] . "], " . $defaultzoom . ");"; ?> L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png", { attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' }).addTo(map); var LeafIcon = L.Icon.extend({ options: { iconSize: [50, 50], iconAnchor: [25, 25], popupAnchor: [5, -5] } }); var carxIcon = new LeafIcon({iconUrl: 'img/car.svg'}), xIcon = new LeafIcon({iconUrl: 'img/unknown.svg'}), personxIcon = new LeafIcon({iconUrl: 'img/person.svg'}), phonexIcon = new LeafIcon({iconUrl: 'img/phone.svg'}), laptopxIcon = new LeafIcon({iconUrl: 'img/laptop.svg'}); <?php foreach ($requestcoordinates as $r) { print ' L.marker( [' . $r[0] . ', ' . $r[1] . '], {icon: ' . $r[5] . 'xIcon}).bindPopup( "' . $r[2] . ' at ' . $r[6] . ' (batt: ' . $r[3] . ')"' . ').addTo(map); '; } ?> map.on('locationfound', onLocationFound); map.on('locationerror', onLocationError); <?php # Disable geolocation if looking for a specific request if (0 == $rid) { print 'map.locate({setView: false, maxZoom: ' . $defaultzoom . '});'; } ?> </script> <?php }
//$labs[1] = 129; //$date_from = "2011-06-01"; //$date_to = "2012-01-01"; $ip = 0; sort($labs); $tname = getGlobalTestName($test_type_id); $testTypeMapping = TestTypeMapping::getTestTypeById($test_type_id, $_SESSION['user_id']); $mapping_list = array(); $mapping_list = get_test_mapping_list_by_string($testTypeMapping->labIdTestId); $i = 0; $theprevdata = array(); $thetatdata = array(); $labname = array(); $xc = array(); $yc = array(); foreach ($labs as $lab) { $theprevdata[$i] = get_prevalence_data_per_test_per_lab_dir($mapping_list[$lab], $lab, $date_from, $date_to); $thetatdata[$i] = get_tat_data_per_test_per_lab_dir_new($mapping_list[$lab], $lab, $date_from, $date_to, $ip); $tem = get_lab_config_by_id($lab); $labname[$i] = $tem->name; $tem = get_coordinates($lab); $xc[$i] = $tem[0]; $yc[$i] = $tem[1]; $i++; } $i = 0; foreach ($labs as $lb) { $ret[$i] = array('lab' => $lb, 'labname' => $labname[$i], 'xc' => $xc[$i], 'yc' => $yc[$i], 'prev' => $theprevdata[$i], 'tat' => $thetatdata[$i], 'date_from' => $newDate = date("d F Y", strtotime($date_from)), 'date_to' => $newDate = date("d F Y", strtotime($date_to)), 'testname' => $tname); $i++; } echo json_encode($ret);
<li><a href='./listUsers.php'>View All Users</a></li> <li><a href='./compatibility_survey/survey.php'>Compatibility Survey</a></li> <li><a href='./editProfile.php'>Edit Profile</a></li> <li><a href='/logout.php'>Log Out</a></li> </ul> </div> </nav> <?php $addr1 = "1521 1st Ave, Seattle, WA"; $addr2 = "1301 Alaskan Way, Seattle, WA"; $parts1 = parseAddress($addr1); $parts2 = parseAddress($addr2); // $coord1 = get_coordinates("Seattle", "1521 1st Ave", "Washington"); $coord1 = get_coordinates($parts1[1], $parts1[0], $parts1[2]); $coord2 = get_coordinates($parts2[1], $parts2[0], $parts2[2]); echo $parts1[1] . " - " . $parts1[0] . " - " . $parts1[2] . "<br>"; echo $parts2[1] . " - " . $parts2[0] . " - " . $parts2[2] . "<br>"; if ($coord1 && $coord2) { $dist = GetDrivingDistance($coord1['lat'], $coord2['lat'], $coord1['long'], $coord2['long']); echo 'Distance: <b>' . $dist['distance'] . '</b><br>Travel time duration: <b>' . $dist['time'] . '</b>'; } else { echo 'Bad address.'; } ?> <div style:"text-align:center; display:block; margin:auto;"> <b>Origin: </b> <select id="start"> <option value="<?php echo $addr1; ?>
<li><a href="home.php">Home</a></li> <li><a href="deliveries.php">Deliveries</a></li> <li class="active"><a href="#">Invoices</a></li> <li><a href="users.php">Users</a></li> <li><a href="logout.php">Logout</a></li> </ul> </div> </nav> <div class="container"> <?php foreach ($delData as $row) { $parts = parseAddress($row["pick_up_location"]); $coord1 = get_coordinates($parts[1], $parts[0], $parts[2]); $parts = parseAddress($row["drop_off_location"]); $coord2 = get_coordinates($parts[1], $parts[0], $parts[2]); $distanceKM = ""; $miles = ""; $distanceMI = ""; if (!$coord1 || !$coord2) { $distanceKM = 'Bad address(es).'; $distanceMI = $distanceKM; } else { $dist = GetDrivingDistance($coord1['lat'], $coord2['lat'], $coord1['long'], $coord2['long']); $distanceKM = $dist["distance"]; // echo $distanceKM . "<br>"; $parts = explode(" ", $distanceKM); $km = str_replace(",", "", $parts[0]); $miles = round($km / 1.6093442, 1); $distanceMI = $miles . " miles"; // echo $distanceMI . "<br>";