<?php for ($i = 0; $i < count($endpoint_apis); $i++) { $endpoint = $endpoint_apis[$i]; if ($endpoint_uis == null) { $url = $endpoint; } else { $url = $endpoint_uis[$i]; } $query0 = 'select ?lat ?lng {' . ' <' . $prefix . "/" . $uri . $separator . $resource . '> ' . '<http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?lat;' . '<http://www.w3.org/2003/01/geo/wgs84_pos#long> ?lng.' . '}'; $json0 = read_query($endpoint, $query0); $query_refer = 'select ?p ?o {' . ' <' . $prefix . "/" . $uri . $separator . $resource . '> ?p ?o.' . '} order by ?p'; $json_refer = read_query($endpoint, $query_refer); $query_referred = 'select ?s ?p {' . ' ?s ?p <' . $prefix . "/" . $uri . $separator . $resource . '>.' . '} order by ?p'; $json_referred = read_query($endpoint, $query_referred); if (count($json_refer["results"]["bindings"]) == 0 && count($json_referred["results"]["bindings"]) == 0) { continue; } if (count($json0["results"]["bindings"]) != 0) { $data = $json0["results"]["bindings"]; $lat = $data[0]["lat"]["value"] . trim(); $lng = $data[0]["lng"]["value"] . trim(); $lat = floatval($lat); $lng = floatval($lng); echo '<div>'; echo '<iframe width="350" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" '; echo 'src="http://www.openstreetmap.org/export/embed.html?bbox=' . ($lng - 0.1) . '%2C' . ($lat - 0.1) . '%2C' . ($lng + 0.1) . '%2C' . ($lat + 0.1) . '&'; echo 'layer=mapnik&marker=' . $lat . '%2C' . $lng . '" style="border: 1px solid black"></iframe>'; echo '<br/><small><a href="http://www.openstreetmap.org/?mlat=' . $lat . '&mlon=' . $lng . '#map=15/' . $lat . '/' . $lng . '" target="_blank">'; echo '大きな地図を表示</a></small>';
if ($endpoint_uis == null) { $url = $endpoint; } else { $url = $endpoint_uis[$i]; } $ep = array(); $ep['ui'] = $url; $ep['api'] = $endpoint; $res['endpoint'] = $ep; $query1 = 'select ?p ?o {' . ' <' . $prefix . "/" . $uri . $separator . $resource . '> ?p ?o.' . '} order by ?p'; $json1 = read_query($endpoint, $query1); $data = $json1["results"]["bindings"]; $refer = read_data($data, 'p', 'o'); $res['refer'] = $refer; $query2 = 'select ?s ?p {' . ' ?s ?p <' . $prefix . "/" . $uri . $separator . $resource . '>.' . '} order by ?p'; $json2 = read_query($endpoint, $query2); $data = $json2["results"]["bindings"]; $referred = read_data($data, 's', 'p'); $res['referred'] = $referred; $result['results'][] = $res; } header('Content-type: application/json'); header("Access-Control-Allow-Origin: *"); echo json_encode($result); exit; function read_data($data, $c1, $c2) { $ret = array(); for ($i = 0; $i < count($data); $i++) { $item = array(); if ($data[$i][$c1] != null) {