本文整理汇总了PHP中MemModel::size方法的典型用法代码示例。如果您正苦于以下问题:PHP MemModel::size方法的具体用法?PHP MemModel::size怎么用?PHP MemModel::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemModel
的用法示例。
在下文中一共展示了MemModel::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: geoLookup
function geoLookup($lat, $long, $radius, &$resultsLabel)
{
global $FLICKRSERVICE;
$resURI = DBPEDIA_URI_ROOT . wikipediaEncode($_REQUEST['item']);
$locationURI = FLICKRWRAPPR_LOCATION_URI_ROOT . $_REQUEST['lat'] . '/' . $_REQUEST['long'] . '/' . $_REQUEST['radius'];
$dataURI = FLICKRWRAPPR_LOCATION_DATA_URI_ROOT . $_REQUEST['lat'] . '/' . $_REQUEST['long'] . '/' . $_REQUEST['radius'];
/* Initialize result model */
$resultModel = new MemModel();
$resultModel->addNamespace('foaf', 'http://xmlns.com/foaf/0.1/');
$resultModel->addNamespace('dcterms', 'http://purl.org/dc/terms/');
$resultModel->addNamespace('rdfs', 'http://www.w3.org/2000/01/rdf-schema#');
//$resultModel->addNamespace('geonames', 'http://www.geonames.org/ontology#');
$resultModel->addNamespace('geo', 'http://www.w3.org/2003/01/geo/wgs84_pos#');
$resultModel->addNamespace('georss', 'http://www.georss.org/georss/');
/* Perform flickr search */
$flickrPhotos = $FLICKRSERVICE->getFlickrPhotos('', $lat, $long, $radius / 1000);
/* Process found photos */
foreach ($flickrPhotos as $flickrPhoto) {
/* Provide the picture itself (small version) */
$resultModel->add(new Statement(new Resource($locationURI), new Resource("http://xmlns.com/foaf/0.1/depiction"), new Resource($flickrPhoto['imgsmall'])));
/* Provide its page on flickr */
$resultModel->add(new Statement(new Resource($flickrPhoto['imgsmall']), new Resource("http://xmlns.com/foaf/0.1/page"), new Resource($flickrPhoto['flickrpage'])));
}
if ($resultModel->size() > 0) {
/* Add metadata for location */
$resultModel->add(new Statement(new Resource($locationURI), new Resource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), new Resource("http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing")));
$latLiteral = new Literal($lat);
$latLiteral->setDatatype("http://www.w3.org/2001/XMLSchema#float");
$resultModel->add(new Statement(new Resource($locationURI), new Resource("http://www.w3.org/2003/01/geo/wgs84_pos#lat"), $latLiteral));
$longLiteral = new Literal($long);
$longLiteral->setDatatype("http://www.w3.org/2001/XMLSchema#float");
$resultModel->add(new Statement(new Resource($locationURI), new Resource("http://www.w3.org/2003/01/geo/wgs84_pos#long"), $longLiteral));
$radiusLiteral = new Literal($radius);
$radiusLiteral->setDatatype("http://www.w3.org/2001/XMLSchema#double");
$resultModel->add(new Statement(new Resource($locationURI), new Resource("http://www.georss.org/georss/radius"), $radiusLiteral));
/* Add metadata for document */
$resultModel->add(new Statement(new Resource($dataURI), new Resource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), new Resource("http://xmlns.com/foaf/0.1/Document")));
$resultsLabel = "Photos taken within {$radius} meters of geographic location lat={$lat} long={$long}";
$resultModel->add(new Statement(new Resource($dataURI), new Resource("http://www.w3.org/2000/01/rdf-schema#label"), new Literal($resultsLabel, "en")));
$resultModel->add(new Statement(new Resource($dataURI), new Resource("http://xmlns.com/foaf/0.1/primaryTopic"), new Resource($locationURI)));
$resultModel->add(new Statement(new Resource($dataURI), new Resource("http://purl.org/dc/terms/license"), new Resource(FLICKR_TOS_URL)));
$resultModel->add(new Statement(new Resource($dataURI), new Resource("http://xmlns.com/foaf/0.1/maker"), new Resource(FLICKRWRAPPR_HOMEPAGE)));
$resultModel->add(new Statement(new Resource(FLICKRWRAPPR_HOMEPAGE), new Resource("http://www.w3.org/2000/01/rdf-schema#label"), new Literal("flickr(tm) wrappr", "en")));
}
return $resultModel;
}