Example #1
0
 static function getPostcodeData($postcode)
 {
     $data = sparql_get(self::$endpoint, "\n\tSELECT ?p ?lat ?long ?wlabel ?dlabel WHERE {\n\t\t?p <http://www.w3.org/2000/01/rdf-schema#label> '{$postcode}' .\n\t\t?p <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?lat .\n\t\t?p <http://www.w3.org/2003/01/geo/wgs84_pos#long> ?long .\n\t\t?p <http://data.ordnancesurvey.co.uk/ontology/postcode/ward> ?w .\n\t\t?w <http://www.w3.org/2004/02/skos/core#prefLabel> ?wlabel .\n\t\t?p <http://data.ordnancesurvey.co.uk/ontology/postcode/district> ?d .\n\t\t?d <http://www.w3.org/2004/02/skos/core#prefLabel> ?dlabel .\n\t}\n\t\t");
     if (count($data) == 1) {
         return $data[0];
     } else {
         return null;
     }
 }
Example #2
0
function getLatLongFromBuildingNumber($bno)
{
    require_once '../inc/sparqllib.php';
    $data = sparql_get("http://sparql.data.southampton.ac.uk", "\n\tSELECT ?lat ?lon WHERE {\n\t\t<http://id.southampton.ac.uk/building/{$bno}> <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?lat .\n\t\t<http://id.southampton.ac.uk/building/{$bno}> <http://www.w3.org/2003/01/geo/wgs84_pos#long> ?lon .\n\t}\n\t", '../');
    if (count($data) == 1) {
        return $data[0];
    } else {
        return null;
    }
}
Example #3
0
 public function get_subjects()
 {
     $query = "SELECT DISTINCT ?uri WHERE { ?uri rdf:type ?type . }";
     $data = sparql_get($this->endpoint, $query);
     $ret = array();
     foreach ($data as $row) {
         $ret[] = "" . $row['uri'];
     }
     return $ret;
 }
Example #4
0
function getTimes($uri)
{
    if ($uri['s'] == 'http://id.southampton.ac.uk/point-of-service/42-cafe') {
        return;
    }
    global $endpoint;
    //echo "<h1>".$uri['l']." (".$uri['s'].")</h1>";
    $allopen = sparql_get($endpoint, "\nPREFIX gr: <http://purl.org/goodrelations/v1#>\n\nSELECT ?day ?opens ?closes ?start ?end WHERE {\n  <" . $uri['s'] . "> gr:hasOpeningHoursSpecification ?o.\n  OPTIONAL { ?o gr:validFrom ?start . }\n  OPTIONAL { ?o gr:validThrough ?end . }\n  ?o gr:hasOpeningHoursDayOfWeek ?day .\n  ?o gr:opens ?opens .\n  ?o gr:closes ?closes .\n}\n\t");
    processOpeningTimes($allopen, $uri['s']);
}
Example #5
0
function getRoutes($from, $to)
{
    global $endpoint;
    $routes = sparql_get($endpoint, "\nPREFIX soton: <http://id.southampton.ac.uk/ns/>\nPREFIX foaf: <http://xmlns.com/foaf/0.1/>\nPREFIX skos: <http://www.w3.org/2004/02/skos/core#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX naptan: <http://transport.data.gov.uk/def/naptan/>\n\nSELECT DISTINCT ?sstoplabel ?dstoplabel ?routecode ?routelabel ?sstoprouteseq ?dstoprouteseq WHERE {\n  ?route skos:notation ?routecode .\n  ?route rdfs:label ?routelabel .\n  ?sstoproute soton:inBusRoute ?route .\n  ?dstoproute soton:inBusRoute ?route .\n  ?sstoproute soton:busRouteSequenceNumber ?sstoprouteseq .\n  ?dstoproute soton:busRouteSequenceNumber ?dstoprouteseq .\n  ?sstoproute soton:busStoppingAt ?sstop .\n  ?dstoproute soton:busStoppingAt ?dstop .\n  ?sstop a naptan:BusStop .\n  ?sstop foaf:based_near <{$from}> .\n  ?sstop rdfs:label ?sstoplabel .\n  ?dstop a naptan:BusStop .\n  ?dstop foaf:based_near <{$to}> .\n  ?dstop rdfs:label ?dstoplabel .\n  FILTER ( ?dstoprouteseq > ?sstoprouteseq )\n} ORDER BY ?routecode (?dstoprouteseq - ?sstoprouteseq)\n\t");
    foreach ($routes as $route) {
        $code = $route['routecode'];
        if ($code != $oldcode) {
            $oldstopcount = 0;
            $oldcode = $code;
        }
        $stopcount = $route['dstoprouteseq'] - $route['sstoprouteseq'];
        if ($oldstopcount == 0 || $oldstopcount + 1 == $stopcount) {
            $stops[$code]['from'][] = $route['sstoplabel'];
            $stops[$code]['to'][] = $route['dstoplabel'];
            if ($oldstopcount == 0) {
                $shortest[$code] = $stopcount;
            }
            $oldstopcount = $stopcount;
        }
        /*
        		echo $route['sstoplabel'];
        		echo $route['dstoplabel'];
        		echo $route['routecode'];
        		echo $route['routelabel'];
        		echo $route['sstoprouteseq'];
        		echo $route['dstoprouteseq'];
        */
    }
    asort($shortest);
    echo "<table>";
    echo "<tr><th>Bus Route</th><th>From</th><th>To</th></tr>";
    foreach (array_keys($shortest) as $code) {
        echo "<tr>";
        echo "<td>{$code}</td>";
        echo "<td><ul>";
        $stops[$code]['from'] = array_reverse(array_unique($stops[$code]['from']));
        foreach ($stops[$code]['from'] as $from) {
            echo "<li>{$from}</li>";
        }
        echo "</ul></td>";
        echo "<td><ul>";
        $stops[$code]['to'] = array_unique($stops[$code]['to']);
        foreach ($stops[$code]['to'] as $to) {
            echo "<li>{$to}</li>";
        }
        echo "</ul></td>";
        echo "</tr>";
    }
    echo "</table>";
}
Example #6
0
 static function getOxPoints($q)
 {
     $tpoints = sparql_get(self::$endpoint, "\n\tPREFIX oxp: <http://ns.ox.ac.uk/namespace/oxpoints/2009/02/owl#>\n\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\tPREFIX dc: <http://purl.org/dc/elements/1.1/>\n\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\n\tSELECT ?pos ?poslabel ?type WHERE {\n\t  ?pos a ?type .\n\t  ?pos dc:title ?label .\n\t    ?pos oxp:occupies ?c .\n\t    ?c geo:lat ?lat .\n\t    ?c geo:long ?long .\n\t    ?pos dc:title ?poslabel .\n\t}\n\t\t");
     //OPTIONAL { ?pos <http://www.w3.org/2004/02/skos/core#hiddenLabel> ?hiddenlabel . }
     $points = array();
     foreach ($tpoints as $point) {
         if (!preg_match('/' . $q . '/i', $point['label']) && !preg_match('/' . $q . '/i', $point['poslabel'])) {
             // && !preg_match('/'.$q.'/i', $point['hiddenlabel']))
             continue;
         }
         $point['icon'] = self::getIcon($point);
         $point['label'] = '';
         $points[] = $point;
     }
     return $points;
 }
Example #7
0
 static function getMatches($q)
 {
     $tpoints = sparql_get(self::$endpoint, "\nPREFIX school: <http://education.data.gov.uk/def/school/>\nPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\nSELECT ?pos ?lat ?long ?label ?type WHERE {\n  ?pos school:typeOfEstablishment ?type .\n  {\n    { ?pos school:typeOfEstablishment school:TypeOfEstablishment_TERM_Higher_Education_Institutions . }\n    UNION\n    { ?pos school:typeOfEstablishment school:TypeOfEstablishment_TERM_Further_Education . }\n  } .\n  ?pos rdfs:label ?label .\n  ?pos geo:lat ?lat .\n  ?pos geo:long ?long .\n}\n\t\t");
     $points = array();
     foreach ($tpoints as $point) {
         if (!preg_match('/' . $q . '/i', $point['label'])) {
             // && !preg_match('/'.$q.'/i', $point['hiddenlabel']))
             continue;
         }
         $point['icon'] = self::getIcon($point);
         if ($point['icon'] == null) {
             continue;
         }
         $points[] = $point;
     }
     return $points;
 }
 static function processSouthamptonURI($uri)
 {
     $allpos = self::getURIInfo($uri);
     echo "<div id='content'>";
     $computer = false;
     if (!isset($allpos[0]['icon'])) {
         if (substr($uri, 0, 33) == "http://id.southampton.ac.uk/room/") {
             $icon = self::$iconpath . 'Education/computers.png';
             $computer = "true";
         } else {
             $icon = "";
         }
     } else {
         $icon = $allpos[0]['icon'];
     }
     $icon = self::convertIcon($icon);
     $page = sparql_get(self::$endpoint, "\n\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\n\t\tSELECT DISTINCT ?page WHERE {\n\t\t\t<{$uri}> foaf:page ?page .\n\t\t} ORDER BY ?page\n\t\t");
     //if(count($page) > 0)
     echo "<h2><img class='icon' src='" . ($icon != "" ? $icon : "img/blackness.png") . "' />" . $allpos[0]['name'];
     if (preg_match('/http:\\/\\/id\\.southampton\\.ac\\.uk\\/.*/', $uri)) {
         //print_r($page[0]);
         //echo "<a class='odl' href='".$page[0]['page']."'>Visit page</a>";
         echo "<a class='odl' href='" . $uri . "'>Visit page</a>";
     }
     echo "</h2>";
     if ($computer) {
         $allpos = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t<{$uri}> <http://purl.org/openorg/hasFeature> ?f .\n\t\t\t?f a ?ft .\n\t\t\t?ft rdfs:label ?label .\n\t\t\tFILTER ( REGEX(?label, '^(WORKSTATION|SOFTWARE) -') )\n\t\t} ORDER BY ?label\n\t\t\t");
     } else {
         $allpos = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t?o gr:availableAtOrFrom <{$uri}> .\n\t\t\t?o gr:includes ?ps .\n\t\t\t?ps a gr:ProductOrServicesSomeInstancesPlaceholder .\n\t\t\t?ps rdfs:label ?label .\n\t\t} ORDER BY ?label \n\t\t\t");
     }
     if (count($allpos) == 0) {
         $allpos = sparql_get(self::$endpoint, "\n\t\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t\t?o gr:availableAtOrFrom <{$uri}> .\n\t\t\t\t?o gr:includes ?ps .\n\t\t\t\t?ps a gr:ProductOrService .\n\t\t\t\t?ps rdfs:label ?label .\n\t\t\t} ORDER BY ?label \n\t\t\t");
     }
     if (count($allpos) > 0) {
         echo "<h3> Offers:</h3>";
         echo "<ul class='offers'>";
         foreach ($allpos as $point) {
             echo "<li>" . $point['label'] . "</li>";
         }
         echo "</ul>";
     }
     if (preg_match('/http:\\/\\/id\\.southampton\\.ac\\.uk\\/point-of-service\\/parking-(.*)/', $uri, $matches)) {
         echo "<iframe style='border:none' src='parking.php?uri=" . $_GET['uri'] . "' />";
         echo "</div>";
         die;
     }
     $allpos = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT * WHERE {\n\t\t\t<{$uri}> gr:hasOpeningHoursSpecification ?time .\n\t\t\tOPTIONAL { ?time gr:validFrom ?start . }\n\t\t\tOPTIONAL { ?time gr:validThrough ?end . }\n\t\t\t?time gr:hasOpeningHoursDayOfWeek ?day .\n\t\t\t?time gr:opens ?opens .\n\t\t\t?time gr:closes ?closes .\n\t\t} ORDER BY ?start ?end ?day ?opens ?closes\n\t\t");
     //	OPTIONAL { <$uri> <http://purl.org/dc/terms/description> ?desc }
     if (count($allpos) > 0) {
         $today = $_GET['date'];
         //echo "<div id='openings'>";
         //echo "<h3>Opening detail:</h3>";
         foreach ($allpos as $point) {
             if ($point['start'] != '') {
                 $start = strtotime($point['start']);
                 $start = date('d/m/Y', $start);
             } else {
                 $start = '';
             }
             if ($point['end'] != '') {
                 $end = strtotime($point['end']);
                 $end = date('d/m/Y', $end);
             } else {
                 $end = '';
             }
             $open = strtotime($point['opens']);
             $open = date('H:i', $open);
             $close = strtotime($point['closes']);
             $close = date('H:i', $close);
             $ot[$start . "-" . $end][$point['day']][] = $open . "-" . $close;
         }
         $weekday = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
         //echo "<table id='openings' style='font-size:0.8em'>";
         //echo "<tr>";
         foreach ($weekday as $day) {
             $short_day = substr($day, 0, 3);
             //echo "<th>".$short_day."</th>";
         }
         //echo "<th>Valid Dates</th>";
         //echo "</tr>";
         $now = strtotime($today . ' 12:00');
         foreach ($ot as $valid => $otv) {
             list($from, $to) = explode('-', $valid);
             if ($from == '') {
                 $from = $now - 86400;
             } else {
                 $from = mktime(0, 0, 0, substr($from, 3, 2), substr($from, 0, 2), substr($from, 7, 4));
             }
             if ($to == '') {
                 $to = $now + 86400;
             } else {
                 $to = mktime(0, 0, 0, substr($to, 3, 2), substr($to, 0, 2), substr($to, 7, 4));
             }
             if ($to < $now) {
                 continue;
             }
             if ($from > $now + 60 * 60 * 24 * 30) {
                 continue;
             }
             $current = $from <= $now && $to >= $now;
             if ($current) {
                 //echo "<tr class='current'>"; //start of row
                 foreach ($weekday as $day) {
                     //echo "<td width=\"350\">";
                     if (array_key_exists('http://purl.org/goodrelations/v1#' . $day, $otv)) {
                         foreach ($otv['http://purl.org/goodrelations/v1#' . $day] as $dot) {
                             if ($dot == '00:00-00:00') {
                                 $dot = '24 hour';
                             }
                             //echo $dot."<br/>";
                             if ($day == date('l', $now)) {
                                 $todayopening[] = "<li>{$dot}</li>";
                             }
                         }
                     }
                     //echo "</td>";
                 }
             } else {
                 //echo "<tr>";
             }
             //echo "<td>".$valid."</td>";
             //echo "</tr>";
         }
         //echo "</table>";
         //echo "</div>";
         if ($todayopening != null) {
             echo "<div id='todayopenings'>";
             echo "<h3>Opening hours on " . date('l jS F Y', $now) . ":</h3>";
             echo "<ul style='padding-top:8px;'>";
             foreach ($todayopening as $opening) {
                 echo $opening;
             }
             echo "</ul>";
             echo "</div>";
         }
     }
     //if($allpos[0]['desc'] != null)
     //{
     //	echo '<div style="font-size:0.7em; text-align:justify">'.$allpos[0]['desc'].'</div>';
     //}
     if (substr($uri, 0, strlen('http://id.sown.org.uk/')) == 'http://id.sown.org.uk/') {
         self::processSownURI($uri);
     }
     echo "</div>";
     return true;
 }
Example #9
0
<?php

require_once "sparqllib.php";
$select = "?restaurant ?name_Dish ?dish ?classes";
if (isset($_GET['form_restaurant'])) {
    $filter = "filter(regex(?restaurant,\"" . $_GET['form_restaurant'] . "\",\"i\"))";
    $results = 'restaurants';
    $select = "?restaurant";
} else {
    if (isset($_GET['form_dish'])) {
        $filter = "filter(regex(?name_Dish,\"" . $_GET['form_dish'] . "\",\"i\"))";
        $results = 'dish';
    }
}
$data = sparql_get("http://www.linkedfood.org:8890/sparql/", "prefix lgdo: <http://linkedgeodata.org/ontology/>\r\n\t\t\t\t\t\tprefix gr: <http://purl.org/goodrelations/v1#>\r\n\t\t\t\t\t\tselect distinct " . $select . "\r\n\t\t\t\t\t\twhere {?link a lgdo:Restaurant . ?link rdfs:label ?restaurant . ?link gr:offers ?dish . \r\n\t\t\t\t\t\t?dish rdfs:label ?name_Dish . ?dish a ?classes " . $filter . "}\r\n\t\t\t\t\t\t");
if (!isset($data)) {
    print sparql_errno() . ": " . sparql_error() . "\n";
    exit;
}
foreach ($data as $row) {
    if ($select == '?restaurant') {
        $data_sparql[] = array($data->fields()[0] => $row[$data->fields()[0]]);
    } else {
        $data_sparql[] = array($data->fields()[0] => $row[$data->fields()[0]], $data->fields()[1] => $row[$data->fields()[1]], $data->fields()[2] => $row[$data->fields()[2]], $data->fields()[3] => $row[$data->fields()[3]]);
    }
}
if (isset($data_sparql)) {
    $json[$results] = $data_sparql;
    $information = json_encode($json);
    echo $information;
} else {
Example #10
0
 static function processSouthamptonURI($uri)
 {
     $wifi = false;
     $res = false;
     if (substr($uri, strlen($uri) - 5, 5) == '#wifi') {
         $uri = substr($uri, 0, strlen($uri) - 5);
         $wifi = true;
     }
     if (substr($uri, strlen($uri) - 12, 12) == '#residential') {
         $uri = substr($uri, 0, strlen($uri) - 12);
         $res = true;
     }
     $allpos = self::getURIInfo($uri);
     echo "<div id='content'>";
     $computer = false;
     if ($allpos['icon'] == '') {
         if ($wifi && $allpos['type'] == "http://vocab.deri.ie/rooms#Building") {
             $icon = self::$iconpath . "Offices/wifi.png";
             $name = 'Wi-Fi Internet Access in Building ' . $allpos['notation'];
         } else {
             if ($res) {
                 $icon = self::$iconpath . "Restaurants-and-Hotels/lodging_0star.png";
                 $name = $allpos['name'];
             } else {
                 if ($allpos['ftype'] == "http://id.southampton.ac.uk/location-feature/Shower") {
                     $icon = self::$iconpath . "Offices/shower.png";
                     $name = $allpos['label'];
                 } else {
                     if (substr($uri, 0, 33) == "http://id.southampton.ac.uk/room/") {
                         $icon = self::$iconpath . "Education/computers.png";
                         $name = $allpos['name'];
                         $computer = "true";
                     } else {
                         $icon = "";
                         $name = $allpos['name'];
                     }
                 }
             }
         }
     } else {
         $icon = $allpos['icon'];
         $name = $allpos['name'];
     }
     $icon = self::convertIcon($icon);
     $page = sparql_get(self::$endpoint, "\n\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\n\t\tSELECT DISTINCT ?page WHERE {\n\t\t\t<{$uri}> foaf:page ?page .\n\t\t} ORDER BY ?page\n\t\t");
     //if(count($page) > 0)
     echo "<h2><img class='icon' src='" . ($icon != "" ? $icon : "img/blackness.png") . "' />" . $name;
     if (preg_match('/http:\\/\\/id\\.southampton\\.ac\\.uk\\/.*/', $uri) && !$wifi) {
         //print_r($page[0]);
         //echo "<a class='odl' href='".$page[0]['page']."'>Visit page</a>";
         echo "<a class='odl' href='" . $uri . "'>Visit page</a>";
     }
     echo "</h2>";
     if ($computer) {
         $allpos = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t<{$uri}> <http://purl.org/openorg/hasFeature> ?f .\n\t\t\t?f a ?ft .\n\t\t\t?ft rdfs:label ?label .\n\t\t\tFILTER ( REGEX(?label, '^(WORKSTATION|SOFTWARE) -') )\n\t\t} ORDER BY ?label\n\t\t\t");
     } else {
         if ($wifi) {
             $allpos = array(array('label' => 'Wi-Fi Access'));
         } else {
             $allpos = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t?o gr:availableAtOrFrom <{$uri}> .\n\t\t\t?o gr:includes ?ps .\n\t\t\t?ps a gr:ProductOrServicesSomeInstancesPlaceholder .\n\t\t\t?ps rdfs:label ?label .\n\t\t} ORDER BY ?label \n\t\t\t");
         }
     }
     if (count($allpos) == 0) {
         $allpos = sparql_get(self::$endpoint, "\n\t\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t\t?o gr:availableAtOrFrom <{$uri}> .\n\t\t\t\t?o gr:includes ?ps .\n\t\t\t\t?ps a gr:ProductOrService .\n\t\t\t\t?ps rdfs:label ?label .\n\t\t\t} ORDER BY ?label \n\t\t\t");
     }
     if (count($allpos) > 0) {
         echo "<h3> Offers: (click to filter) </h3>";
         echo "<ul class='offers'>";
         foreach ($allpos as $point) {
             echo "<li onclick=\"setInputBox('^" . str_replace(array("(", ")"), array("\\(", "\\)"), $point['label']) . "\$'); updateFunc();\">" . $point['label'] . "</li>";
         }
         echo "</ul>";
     }
     if ($wifi) {
         $allpos = sparql_get(self::$endpoint, "\n\t\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\t\tSELECT DISTINCT ?r ?label WHERE {\n\t\t          ?r <http://purl.org/openorg/hasFeature> ?f .\n        \t\t  ?f a <http://id.southampton.ac.uk/syllabus/feature/RSC-_WIRELESS_NETWORK> .\n        \t\t  ?r spacerel:within <{$uri}> .\n\t\t\t  ?r <http://www.w3.org/2004/02/skos/core#notation> ?label\n\t\t\t} ORDER BY ?label\n\t\t\t");
         echo "<h3> Rooms with known coverage </h3>";
         echo "<ul class='offers'>";
         foreach ($allpos as $room) {
             $labelparts = explode('-', $room['label']);
             echo "<li style='background-color:white'><a href='" . $room['r'] . "'>" . $labelparts[1] . "</a></li>";
         }
         echo "</ul>";
     }
     if (preg_match('/http:\\/\\/id\\.southampton\\.ac\\.uk\\/point-of-service\\/parking-(.*)/', $uri, $matches)) {
         echo "<iframe style='border:none' src='parking.php?uri=" . $_GET['uri'] . "' />";
         echo "</div>";
         die;
     }
     $allpos = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT * WHERE {\n\t\t\t<{$uri}> gr:hasOpeningHoursSpecification ?time .\n\t\t\tOPTIONAL { ?time gr:validFrom ?start . }\n\t\t\tOPTIONAL { ?time gr:validThrough ?end . }\n\t\t\t?time gr:hasOpeningHoursDayOfWeek ?day .\n\t\t\t?time gr:opens ?opens .\n\t\t\t?time gr:closes ?closes .\n\t\t} ORDER BY ?start ?end ?day ?opens ?closes\n\t\t");
     if (count($allpos) > 0) {
         //echo "<div id='openings'>";
         //echo "<h3>Opening detail:</h3>";
         foreach ($allpos as $point) {
             if ($point['start'] != '') {
                 $start = strtotime($point['start']);
                 $start = date('d/m/Y', $start);
             } else {
                 $start = '';
             }
             if ($point['end'] != '') {
                 $end = strtotime($point['end']);
                 $end = date('d/m/Y', $end);
             } else {
                 $end = '';
             }
             $open = strtotime($point['opens']);
             $open = date('H:i', $open);
             $close = strtotime($point['closes']);
             $close = date('H:i', $close);
             $ot[$start . "-" . $end][$point['day']][] = $open . "-" . $close;
         }
         $weekday = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
         //echo "<table id='openings' style='font-size:0.8em'>";
         //echo "<tr>";
         foreach ($weekday as $day) {
             $short_day = substr($day, 0, 3);
             //echo "<th>".$short_day."</th>";
         }
         //echo "<th>Valid Dates</th>";
         //echo "</tr>";
         foreach ($ot as $valid => $otv) {
             list($from, $to) = explode('-', $valid);
             $now = mktime();
             if ($from == '') {
                 $from = $now - 86400;
             } else {
                 $from = mktime(0, 0, 0, substr($from, 3, 2), substr($from, 0, 2), substr($from, 7, 4));
             }
             if ($to == '') {
                 $to = $now + 86400;
             } else {
                 $to = mktime(0, 0, 0, substr($to, 3, 2), substr($to, 0, 2), substr($to, 7, 4));
             }
             if ($to < $now) {
                 continue;
             }
             if ($from > $now + 60 * 60 * 24 * 30) {
                 continue;
             }
             $current = $from <= $now && $to >= $now;
             if ($current) {
                 //echo "<tr class='current'>"; //start of row
                 foreach ($weekday as $day) {
                     //echo "<td width=\"350\">";
                     if (array_key_exists('http://purl.org/goodrelations/v1#' . $day, $otv)) {
                         foreach ($otv['http://purl.org/goodrelations/v1#' . $day] as $dot) {
                             if ($dot == '00:00-00:00') {
                                 $dot = '24 hour';
                             }
                             //echo $dot."<br/>";
                             if ($day == date('l', $now)) {
                                 $todayopening[] = "<li>{$dot}</li>";
                             }
                         }
                     }
                     //echo "</td>";
                 }
             } else {
                 //echo "<tr>";
             }
             //echo "<td>".$valid."</td>";
             //echo "</tr>";
         }
         //echo "</table>";
         //echo "</div>";
         if ($todayopening != null) {
             echo "<div id='todayopenings'>";
             echo "<h3>Today's opening hours:</h3>";
             echo "<ul style='padding-top:8px;'>";
             foreach ($todayopening as $opening) {
                 echo $opening;
             }
             echo "</ul>";
             echo "</div>";
         }
     }
     if (substr($uri, 0, strlen('http://id.sown.org.uk/')) == 'http://id.sown.org.uk/') {
         self::processSownURI($uri);
     }
     echo "</div>";
     return true;
 }
Example #11
0
<?php

/**
 *
 * This file generates a set of polygons to display as buildings.
 * Its output should be a KML document, which can be rendered by google maps.
 *
 */
error_reporting(0);
$pathtoroot = "../";
include_once $pathtoroot . "inc/sparqllib.php";
$endpoint = "http://sparql.data.southampton.ac.uk";
$sites = sparql_get($endpoint, "\nSELECT DISTINCT ?name ?outline ?hfeature ?lfeature ?number WHERE {\n  ?url a <http://vocab.deri.ie/rooms#Building> .\n  ?url <http://purl.org/dc/terms/spatial> ?outline .\n  ?url <http://www.w3.org/2000/01/rdf-schema#label> ?name .\n  OPTIONAL { ?url <http://purl.org/openorg/hasFeature> ?hfeature . \n           ?hfeature <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://id.southampton.ac.uk/ns/PlaceFeature-ResidentialUse> }\n  OPTIONAL { ?url <http://purl.org/openorg/lacksFeature> ?lfeature . \n           ?lfeature <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://id.southampton.ac.uk/ns/PlaceFeature-ResidentialUse> }\n  OPTIONAL { ?url <http://www.w3.org/2004/02/skos/core#notation> ?number . }\n} \n");
echo '<?xml version="1.0"?>';
?>
<kml xmlns="http://earth.google.com/kml/2.2">
	<Document>
		<name>University of Southampton Buildings</name>
		<PolyStyle id="residentialStyle">
			<color>ffcc0000</color>
			<colorMode>normal</colorMode>
		</PolyStyle>
		<PolyStyle id="nonResidentialStyle">
			<color>ff0000cc</color>
			<colorMode>normal</colorMode>
		</PolyStyle>
<?php 
foreach ($sites as $site) {
    ?>
		<Placemark>
			<name><?php 
Example #12
0
<?php

/**
 *
 * This file generates a set of polygons to display as sites.
 * Its output should be a KML document, which can be rendered by google maps.
 *
 */
error_reporting(0);
$pathtoroot = "../";
include_once $pathtoroot . "inc/sparqllib.php";
$endpoint = "http://sparql.data.southampton.ac.uk";
$sites = sparql_get($endpoint, "\nSELECT DISTINCT ?name ?outline WHERE {\n  ?url a <http://www.w3.org/ns/org#Site> .\n  ?url <http://purl.org/dc/terms/spatial> ?outline .\n  ?url <http://www.w3.org/2000/01/rdf-schema#label> ?name .\n} \n");
echo '<?xml version="1.0"?>';
?>
<kml xmlns="http://earth.google.com/kml/2.2">
	<Document>
		<name>University of Southampton Sites</name>
<?php 
foreach ($sites as $site) {
    ?>
		<Placemark>
			<name><?php 
    echo $site['name'];
    ?>
</name>
			<description/>  
			<Polygon>
				<outerBoundaryIs>
					<LinearRing>
						<tessellate>1</tessellate>
Example #13
0
<?php

require_once "sparqllib.php";
$data = sparql_get("http://www.linkedfood.org:8890/sparql/", "select distinct ?name_Dish ?dish ?classes\r\n\t\t\t\t\t\t\twhere {?dish rdf:type gr:Offering . ?dish rdfs:label ?name_Dish . ?dish a ?classes }\r\n\t\t\t\t\t\t\torder by(?name_Dish)\r\n\t\t\t\t\t\t");
if (!isset($data)) {
    print sparql_errno() . ": " . sparql_error() . "\n";
    exit;
}
foreach ($data as $row) {
    $data_sparql[] = array($data->fields()[0] => $row[$data->fields()[0]], $data->fields()[1] => $row[$data->fields()[1]], $data->fields()[2] => $row[$data->fields()[2]]);
}
$json['results'] = $data_sparql;
$information = json_encode($json);
echo $information;
Example #14
0
 static function processSouthamptonURI($uri)
 {
     $wifi = false;
     $res = false;
     if (substr($uri, strlen($uri) - 5, 5) == '#wifi') {
         $uri = substr($uri, 0, strlen($uri) - 5);
         $wifi = true;
     }
     if (substr($uri, strlen($uri) - 12, 12) == '#residential') {
         $uri = substr($uri, 0, strlen($uri) - 12);
         $res = true;
     }
     $allpos = self::getURIInfo($uri);
     echo "<div id='content'>";
     $computer = false;
     if ($allpos['icon'] == '') {
         if ($wifi && $allpos['type'] == "http://vocab.deri.ie/rooms#Building") {
             $icon = self::$iconpath . "Offices/wifi.png";
             $name = 'Wi-Fi Internet Access in Building ' . $allpos['notation'];
         } else {
             if ($res) {
                 $icon = self::$iconpath . "Restaurants-and-Hotels/lodging_0star.png";
                 $name = $allpos['name'];
             } else {
                 if ($allpos['ftype'] == "http://id.southampton.ac.uk/location-feature/Shower") {
                     $icon = self::$iconpath . "Offices/shower.png";
                     $name = $allpos['label'];
                 } else {
                     if (substr($uri, 0, 33) == "http://id.southampton.ac.uk/room/") {
                         $icon = self::$iconpath . "Education/computers.png";
                         $name = $allpos['name'];
                         $computer = "true";
                     } else {
                         $icon = "";
                         $name = $allpos['name'];
                     }
                 }
             }
         }
     } else {
         $icon = $allpos['icon'];
         $name = $allpos['name'];
     }
     $icon = self::convertIcon($icon);
     $page = sparql_get(self::$endpoint, "\n\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\n\t\tSELECT DISTINCT ?page WHERE {\n\t\t\t<{$uri}> foaf:page ?page .\n\t\t} ORDER BY ?page\n\t\t");
     //if(count($page) > 0)
     echo "<h2><img class='icon' src='" . ($icon != "" ? $icon : "img/blackness.png") . "' />" . $name;
     if (preg_match('/http:\\/\\/id\\.southampton\\.ac\\.uk\\/.*/', $uri) && !$wifi) {
         //print_r($page[0]);
         //echo "<a class='odl' href='".$page[0]['page']."'>Visit page</a>";
         echo "<a class='odl' href='" . $uri . "'>Visit page</a>";
     }
     echo "</h2>";
     $allpos = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT * WHERE {\n\t\t\t<{$uri}> gr:hasOpeningHoursSpecification ?time .\n\t\t\tOPTIONAL { ?time gr:validFrom ?start . }\n\t\t\tOPTIONAL { ?time gr:validThrough ?end . }\n\t\t\t?time gr:hasOpeningHoursDayOfWeek ?day .\n\t\t\t?time gr:opens ?opens .\n\t\t\t?time gr:closes ?closes .\n\t\t} ORDER BY ?start ?end ?day ?opens ?closes\n\t\t");
     self::processOpeningTimes($allpos);
     if ($computer) {
         $allpos = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t<{$uri}> <http://purl.org/openorg/hasFeature> ?f .\n\t\t\t?f a ?ft .\n\t\t\t?ft rdfs:label ?label .\n\t\t\tFILTER ( REGEX(?label, '^(WORKSTATION|SOFTWARE) -') )\n\t\t} ORDER BY ?label\n\t\t\t");
     } else {
         if ($wifi) {
             $allpos = array(array('label' => 'Wi-Fi Access'));
         } else {
             $allpos = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t?o gr:availableAtOrFrom <{$uri}> .\n\t\t\t?o gr:includes ?ps .\n\t\t\t?ps a gr:ProductOrServicesSomeInstancesPlaceholder .\n\t\t\t?ps rdfs:label ?label .\n\t\t} ORDER BY ?label \n\t\t\t");
         }
     }
     if (count($allpos) == 0) {
         $allpos = sparql_get(self::$endpoint, "\n\t\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t\t?o gr:availableAtOrFrom <{$uri}> .\n\t\t\t\t?o gr:includes ?ps .\n\t\t\t\t?ps a gr:ProductOrService .\n\t\t\t\t?ps rdfs:label ?label .\n\t\t\t} ORDER BY ?label \n\t\t\t");
     }
     if (count($allpos) > 0) {
         echo "<h3> Offers: (click to show on map) </h3>";
         echo "<ul class='offers'>";
         foreach ($allpos as $point) {
             echo "<li onclick=\"setInputBox('^" . str_replace(array("(", ")"), array("\\(", "\\)"), $point['label']) . "\$'); updateFunc();\">" . $point['label'] . "</li>";
         }
         echo "</ul>";
     }
     if ($wifi) {
         $allpos = sparql_get(self::$endpoint, "\n\t\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\t\tSELECT DISTINCT ?r ?label WHERE {\n\t\t          ?r <http://purl.org/openorg/hasFeature> ?f .\n        \t\t  ?f a <http://id.southampton.ac.uk/syllabus/feature/RSC-_WIRELESS_NETWORK> .\n        \t\t  ?r spacerel:within <{$uri}> .\n\t\t\t  ?r <http://www.w3.org/2004/02/skos/core#notation> ?label\n\t\t\t} ORDER BY ?label\n\t\t\t");
         echo "<h3> Rooms with known coverage </h3>";
         echo "<ul class='offers'>";
         foreach ($allpos as $room) {
             $labelparts = explode('-', $room['label']);
             echo "<li style='background-color:white'><a href='" . $room['r'] . "'>" . $labelparts[1] . "</a></li>";
         }
         echo "</ul>";
     }
     if (preg_match('/http:\\/\\/id\\.southampton\\.ac\\.uk\\/point-of-service\\/parking-(.*)/', $uri, $matches)) {
         echo "<iframe style='border:none' src='parking.php?uri=" . $_GET['uri'] . "' />";
         echo "</div>";
         die;
     }
     if (substr($uri, 0, strlen('http://id.sown.org.uk/')) == 'http://id.sown.org.uk/') {
         self::processSownURI($uri);
     }
     echo "</div>";
     return true;
 }
Example #15
0
 static function processSouthamptonURI($uri)
 {
     $allpos = self::getURIInfo($uri);
     echo "<div id='content'>";
     $computer = false;
     if (!isset($allpos[0]['icon'])) {
         if ($allpos[0]['type'] == "http://id.southampton.ac.uk/location-feature/Shower") {
             $icon = self::$iconpath . "Offices/shower.png";
         } else {
             if (substr($uri, 0, 33) == "http://id.southampton.ac.uk/room/") {
                 $icon = self::$iconpath . "Education/computers.png";
                 $computer = "true";
             } else {
                 $icon = "";
             }
         }
     } else {
         $icon = $allpos[0]['icon'];
     }
     $page = sparql_get(self::$endpoint, "\n\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\n\t\tSELECT DISTINCT ?page WHERE {\n\t\t\t<{$uri}> foaf:page ?page .\n\t\t} ORDER BY ?page\n\t\t");
     //if(count($page) > 0)
     echo "<h2><img class='icon' src='" . ($icon != "" ? $icon : "img/blackness.png") . "' />" . $allpos[0]['name'];
     if (preg_match('/http:\\/\\/id\\.southampton\\.ac\\.uk\\/.*/', $uri)) {
         //print_r($page[0]);
         //echo "<a class='odl' href='".$page[0]['page']."'>Visit page</a>";
         echo "<a class='odl' href='" . $uri . "'>Visit page</a>";
     }
     echo "</h2>";
     if ($computer) {
         $allpos = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t<{$uri}> <http://purl.org/openorg/hasFeature> ?f .\n\t\t\t?f a ?ft .\n\t\t\t?ft rdfs:label ?label .\n\t\t\tFILTER ( REGEX(?label, '^(WORKSTATION|SOFTWARE) -') )\n\t\t} ORDER BY ?label\n\t\t\t");
     } else {
         $allpos = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t?o gr:availableAtOrFrom <{$uri}> .\n\t\t\t?o gr:includes ?ps .\n\t\t\t?ps a gr:ProductOrServicesSomeInstancesPlaceholder .\n\t\t\t?ps rdfs:label ?label .\n\t\t} ORDER BY ?label \n\t\t\t");
     }
     if (count($allpos) == 0) {
         $allpos = sparql_get(self::$endpoint, "\n\t\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\t\tSELECT DISTINCT ?label WHERE {\n\t\t\t\t?o gr:availableAtOrFrom <{$uri}> .\n\t\t\t\t?o gr:includes ?ps .\n\t\t\t\t?ps a gr:ProductOrService .\n\t\t\t\t?ps rdfs:label ?label .\n\t\t\t} ORDER BY ?label \n\t\t\t");
     }
     self::processOffers($allpos);
     if (preg_match('/http:\\/\\/id\\.southampton\\.ac\\.uk\\/point-of-service\\/parking-(.*)/', $uri, $matches)) {
         echo "<iframe style='border:none' src='parking.php?uri=" . $_GET['uri'] . "' />";
         echo "</div>";
         die;
     }
     $allopen = sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\t\tPREFIX gr: <http://purl.org/goodrelations/v1#>\n\n\t\tSELECT DISTINCT * WHERE {\n\t\t\t<{$uri}> gr:hasOpeningHoursSpecification ?time .\n\t\t\tOPTIONAL { ?time gr:validFrom ?start . }\n\t\t\tOPTIONAL { ?time gr:validThrough ?end . }\n\t\t\t?time gr:hasOpeningHoursDayOfWeek ?day .\n\t\t\t?time gr:opens ?opens .\n\t\t\t?time gr:closes ?closes .\n\t\t} ORDER BY ?start ?end ?day ?opens ?closes\n\t\t");
     self::processOpeningTimes($allopen);
     if (substr($uri, 0, strlen('http://id.sown.org.uk/')) == 'http://id.sown.org.uk/') {
         self::processSownURI($uri);
     }
     echo "</div>";
     return true;
 }
Example #16
0
<?php

require_once "sparqllib.php";
$data = sparql_get("http://www.linkedfood.org:8890/sparql/", "prefix lgdo: <http://linkedgeodata.org/ontology/>\r\n\t\t\t\t\t\tselect ?restaurant ?dish \r\n\t\t\t\t\t\twhere {\r\n\t\t\t\t\t\t\t\t?link a lgdo:Restaurant . ?link rdfs:label ?restaurant . \r\n\t\t\t\t\t\t\t\t?link gr:offers ?dish . ?dish rdfs:label ?dish_name}\r\n\t\t\t\t\t\t");
if (!isset($data)) {
    print sparql_errno() . ": " . sparql_error() . "\n";
    exit;
}
foreach ($data as $row) {
    $data_sparql[] = array($data->fields()[0] => $row[$data->fields()[0]], $data->fields()[1] => $row[$data->fields()[1]]);
}
$json['results'] = $data_sparql;
$information = json_encode($json);
echo $information;
?>
	
Example #17
0
function Gethotspots($value)
{
    global $endpoint;
    global $iconcats;
    $cats = explode(',', $value['CHECKBOXLIST']);
    $q = trim($value['SEARCHBOX']);
    if ($q == '') {
        $filter = "FILTER ( BOUND(?lon) && BOUND(?lat) )";
    } else {
        $filter = "FILTER ( BOUND(?lon) && BOUND(?lat) && (REGEX( ?plabel, '{$q}', 'i') || REGEX( ?title, '{$q}', 'i')) )";
    }
    // Iterator for the response array.
    $i = 0;
    $lat = $value['lat'];
    $lon = $value['lon'];
    $pois1 = sparql_get($endpoint, "\nPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\nPREFIX org: <http://www.w3.org/ns/org#>\n\nSELECT DISTINCT ?id ?title ?lat ?lon ?icon ?page {\n  ?rstop <http://id.southampton.ac.uk/ns/inBusRoute> ?route .\n  ?rstop <http://id.southampton.ac.uk/ns/busStoppingAt> ?id .\n  ?route <http://www.w3.org/2004/02/skos/core#notation> ?code .\n  ?id rdfs:label ?title .\n  ?id geo:lat ?lat .\n  ?id geo:long ?lon .\n  ?id <http://purl.org/openorg/mapIcon> ?icon .\n  ?id <http://id.southampton.ac.uk/ns/mobilePage> ?page .\n  FILTER ( ( REGEX( ?title, '{$q}', 'i') || REGEX( ?code, '{$q}', 'i')\n  ) && REGEX( ?code, '^U', 'i') )\n} ORDER BY (((?lat - {$lat})*(?lat - {$lat})*2.1) + ((?lon - {$lon})*(?lon - {$lon})))\n");
    $pois2 = sparql_get($endpoint, "\nPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\nPREFIX org: <http://www.w3.org/ns/org#>\nPREFIX gr: <http://purl.org/goodrelations/v1#>\nPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\nSELECT DISTINCT ?id ?title ?lat ?lon ?icon ?www ?phone ?email ?bname ?sname ?page WHERE {\n  ?id a gr:LocationOfSalesOrServiceProvisioning .\n  ?id rdfs:label ?title .\n  OPTIONAL { ?offering a gr:Offering .\n             ?offering gr:availableAtOrFrom ?id .\n             ?offering gr:includes ?ps .\n             ?ps rdfs:label ?plabel .\n           }\n  OPTIONAL { ?id spacerel:within ?b .\n             ?b geo:lat ?lat . \n             ?b geo:long ?lon .\n             ?b a <http://vocab.deri.ie/rooms#Building> .\n             ?b rdfs:label ?bname .\n             OPTIONAL { ?b spacerel:within ?bs .\n                        ?bs a org:Site .\n                        ?bs rdfs:label ?sname .\n                      }\n           }\n  OPTIONAL { ?id spacerel:within ?s .\n             ?s geo:lat ?lat . \n             ?s geo:long ?lon .\n             ?s a org:Site .\n             ?s rdfs:label ?sname .\n           }\n  OPTIONAL { ?id geo:lat ?lat .\n             ?id geo:long ?lon .\n           }\n  OPTIONAL { ?id <http://purl.org/openorg/mapIcon> ?icon . }\n  OPTIONAL { ?id foaf:homepage ?www . }\n  OPTIONAL { ?id foaf:phone ?phone . }\n  OPTIONAL { ?id foaf:mailbox ?email . }\n  OPTIONAL { ?id <http://id.southampton.ac.uk/ns/mobilePage> ?page . }\n  {$filter}\n} ORDER BY (((?lat - {$lat})*(?lat - {$lat})*2.1) + ((?lon - {$lon})*(?lon - {$lon})))\n");
    //SELECT DISTINCT ?name ?outline ?hfeature ?lfeature ?number WHERE {
    $qbd = trim(str_replace(array('building', 'buildin', 'buildi', 'build', 'buil', 'bui', 'bu', 'b'), '', strtolower($q)));
    $pois3 = sparql_get($endpoint, "\nPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\nPREFIX org: <http://www.w3.org/ns/org#>\n\nSELECT DISTINCT ?id ?title ?lat ?lon ?number ?sname WHERE {\n  ?id a <http://vocab.deri.ie/rooms#Building> .\n  ?id rdfs:label ?title .\n  OPTIONAL { ?id <http://www.w3.org/2004/02/skos/core#notation> ?number . }\n  OPTIONAL { ?id spacerel:within ?s .\n             ?s a org:Site .\n             ?s rdfs:label ?sname .\n           }\n  ?id geo:lat ?lat .\n  ?id geo:long ?lon .\n  FILTER ( REGEX( ?title, '{$q}', 'i') || REGEX( ?number, '{$qbd}', 'i') )\n} ORDER BY (((?lat - {$lat})*(?lat - {$lat})*2.1) + ((?lon - {$lon})*(?lon - {$lon})))\n");
    foreach (array_merge((array) $pois3, (array) $pois2, (array) $pois1) as $poi) {
        if (!isset($poi['icon']) && isset($poi['number'])) {
            if (preg_match('/^[1-9][0-9]?$/', $poi['number'])) {
                $poi['icon'] = "http://google-maps-icons.googlecode.com/files/black" . str_pad($poi['number'], 2, 0, STR_PAD_LEFT) . ".png";
            } else {
                $poi['icon'] = "http://google-maps-icons.googlecode.com/files/blackblank.png";
            }
        }
        if (!isset($poi['bname']) && isset($poi['number'])) {
            $poi['bname'] = "Building " . $poi['number'];
        }
        $latdiff = ($poi['lat'] - $lat) * 111.24824;
        $londiff = ($poi['lon'] - $lon) * 70.19765;
        $poi['distance'] = sqrt($latdiff * $latdiff + $londiff * $londiff);
        if (isset($pois[$poi['id']])) {
        } else {
            $pois[$poi['id']] = $poi;
        }
    }
    usort($pois, 'sortpoints');
    /* Process the $pois result */
    // if $pois array is empty, return empty array.
    if (empty($pois)) {
        $response["hotspots"] = array();
    } else {
        // Put each POI information into $response["hotspots"] array.
        foreach ($pois as $poi) {
            if ($i >= 100) {
                break;
            }
            if ($poi['distance'] > $value['radius'] / 1000) {
                break;
            }
            if (!in_cat($iconcats, $poi['icon'], $cats)) {
                continue;
            }
            // If not used, return an empty actions array.
            $poi["actions"] = array();
            // Store the integer value of "lat" and "lon" using predefined function ChangetoIntLoc.
            $poi["lat"] = ChangetoIntLoc($poi["lat"]);
            $poi["lon"] = ChangetoIntLoc($poi["lon"]);
            // Change to Int with function ChangetoInt.
            $poi["type"] = 0;
            //ChangetoInt( $poi["type"] );
            $poi["dimension"] = 2;
            //ChangetoInt( $poi["dimension"] );
            // Change to demical value with function ChangetoFloat
            $poi["distance"] = ChangetoFloat($poi["distance"]);
            // Put the poi into the response array.
            $response["hotspots"][$i] = $poi;
            $i++;
        }
        //foreach
    }
    //else
    return $response["hotspots"];
}
Example #18
0
<?php

require_once "sparqllib.php";
$data = sparql_get("http://rdf.ecs.soton.ac.uk/sparql/", "\nPREFIX foaf: <http://xmlns.com/foaf/0.1/>\nSELECT * WHERE { ?person a foaf:Person . ?person foaf:name ?name } LIMIT 5\n");
if (!isset($data)) {
    print "<p>Error: " . sparql_errno() . ": " . sparql_error() . "</p>";
}
print "<table class='example_table'>";
print "<tr>";
foreach ($data->fields() as $field) {
    print "<th>{$field}</th>";
}
print "</tr>";
foreach ($data as $row) {
    print "<tr>";
    foreach ($data->fields() as $field) {
        print "<td>{$row[$field]}</td>";
    }
    print "</tr>";
}
print "</table>";
Example #19
0
 static function getURIInfo($uri)
 {
     return sparql_get(self::$endpoint, "\n\t\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\tPREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>\n\t\tPREFIX org: <http://www.w3.org/ns/org#>\n\n\t\tSELECT DISTINCT ?name ?icon ?type WHERE {\n\t\t    OPTIONAL { <{$uri}> rdfs:label ?name . }\n\t\t    OPTIONAL { <{$uri}> <http://purl.org/openorg/mapIcon> ?icon . }\n\t\t    OPTIONAL { <{$uri}> <http://purl.org/openorg/hasFeature> ?feature . \n\t\t        OPTIONAL { ?feature a ?type . }\n\t\t        OPTIONAL { ?feature rdfs:label ?label . }\n\t\t    }\n\t\t}\n\t\t");
 }
<?php

require_once "sparqllib.php";
$data = sparql_get("http://www.linkedfood.org:8890/sparql/", "prefix lgdo: <http://linkedgeodata.org/ontology/>\r\n\t\t\t\t\t\t\tselect distinct ?restaurant\r\n\t\t\t\t\t\t\twhere {\r\n\t\t\t\t\t\t\t\t\t?link a lgdo:Restaurant . ?link rdfs:label ?restaurant\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\torder by(?restaurant)\r\n\t\t\t\t\t\t");
if (!isset($data)) {
    print sparql_errno() . ": " . sparql_error() . "\n";
    exit;
}
foreach ($data as $row) {
    $data_sparql[] = array($data->fields()[0] => $row[$data->fields()[0]]);
}
$json['results'] = $data_sparql;
$information = json_encode($json);
echo $information;
?>
	
<?php

require_once "sparqllib.php";
$data = sparql_get("http://www.linkedfood.org:8890/sparql/", "prefix lgdo: <http://linkedgeodata.org/ontology/>\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tselect distinct ?restaurant ?dish ?name_Dish ?classes\r\n\t\t\t\t\t\t\twhere {\r\n\t\t\t\t\t\t\t\t\t?link a lgdo:Restaurant . ?link rdfs:label ?restaurant . ?link gr:offers ?dish . \r\n\t\t\t\t\t\t\t\t\t?dish rdfs:label ?name_Dish . ?dish a ?classes\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\torder by(?restaurant)\r\n\t\t\t\t\t\t");
if (!isset($data)) {
    print sparql_errno() . ": " . sparql_error() . "\n";
    exit;
}
foreach ($data as $row) {
    $data_sparql[] = array($data->fields()[0] => $row[$data->fields()[0]], $data->fields()[1] => $row[$data->fields()[1]], $data->fields()[2] => $row[$data->fields()[2]], $data->fields()[3] => $row[$data->fields()[3]]);
}
$json['results'] = $data_sparql;
$information = json_encode($json);
echo $information;
?>