static function visibleCategory($icon, $cats) { global $iconcats; if ($iconcats == null) { include_once "inc/categories.php"; } return in_cat($iconcats, $icon, $cats); }
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"]; }