/**
  * tests if the manual set namespaceprefix 'foo' overwrites the prefix 'rdf' defined in
  * the default_prefixes array.
  */
 function testOverwritingDefaultManual()
 {
     $_SESSION['test'] = 'Overwriting default manual test';
     $model = new MemModel();
     $pars = new N3Parser();
     $model = $pars->parse2model($this->_generateModelString());
     $ser = new RdfSerializer();
     $string = $ser->serialize($model);
     $model2 = new MemModel();
     $model2->load($string);
     $this->assertEqual($model2->parsedNamespaces[RDF_NAMESPACE_URI], 'rdf');
     $model2->addNamespace('foo', RDF_NAMESPACE_URI);
     $this->assertEqual($model2->parsedNamespaces[RDF_NAMESPACE_URI], 'foo');
     $model2->removeNamespace(RDF_NAMESPACE_URI);
     //$this->assertEqual($model2->parsedNamespaces[RDF_NAMESPACE_URI] , null);
 }
Esempio n. 2
0
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;
}