Ejemplo n.º 1
0
 protected function getJsonForStaticLocation(Location $location, array $params, $iconUrl, $visitedIconUrl, Parser $parser)
 {
     $jsonObj = $location->getJSONObject($params['title'], $params['label'], $iconUrl, '', '', $visitedIconUrl);
     $jsonObj['title'] = $parser->parse($jsonObj['title'], $parser->getTitle(), new ParserOptions())->getText();
     $jsonObj['text'] = $parser->parse($jsonObj['text'], $parser->getTitle(), new ParserOptions())->getText();
     $hasTitleAndtext = $jsonObj['title'] !== '' && $jsonObj['text'] !== '';
     $jsonObj['text'] = ($hasTitleAndtext ? '<b>' . $jsonObj['title'] . '</b><hr />' : $jsonObj['title']) . $jsonObj['text'];
     $jsonObj['title'] = strip_tags($jsonObj['title']);
     if ($params['pagelabel']) {
         $jsonObj['inlineLabel'] = Linker::link(Title::newFromText($jsonObj['title']));
     }
     return $jsonObj;
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider latLongValueProvider
  */
 public function testGivenLatLongInConstructor_getCoordinatesReturnsIt(LatLongValue $latLong)
 {
     $location = new Location($latLong);
     $this->assertTrue($latLong->equals($location->getCoordinates()));
 }
Ejemplo n.º 3
0
 protected function setLink(Location $location, $link)
 {
     $link = substr($link, 5);
     $location->setLink($this->getExpandedLink($link));
 }
Ejemplo n.º 4
0
    /**
     * Returns the KML representing the provided location.
     * 
     * @since 0.7.3
     * 
     * @param Location $location
     *
     * @return string
     */
    protected function getKMLForLocation(Location $location)
    {
        $name = '<name><![CDATA[ ' . $location->getTitle() . ']]></name>';
        $description = '<description><![CDATA[ ' . $location->getText() . ']]></description>';
        $coordinates = $location->getCoordinates();
        // lon,lat[,alt]
        $coordinates = Xml::element('coordinates', array(), $coordinates->getLongitude() . ',' . $coordinates->getLatitude() . ',' . $coordinates->getAltitude());
        return <<<EOT
\t\t<Placemark>
\t\t\t{$name}
\t\t\t{$description}
\t\t\t<Point>
\t\t\t\t{$coordinates}
\t\t\t</Point>
\t\t</Placemark>
\t\t
EOT;
    }
Ejemplo n.º 5
0
 /**
  * Returns the locations found in the provided result row.
  *
  * @since 0.7.3
  *
  * @param SMWResultArray[] $row
  */
 protected function handleResultRow(array $row)
 {
     $locations = array();
     $properties = array();
     $title = '';
     $text = '';
     // Loop through all fields of the record.
     foreach ($row as $i => $resultArray) {
         /* SMWPrintRequest */
         $printRequest = $resultArray->getPrintRequest();
         // Loop through all the parts of the field value.
         while (($dataValue = $resultArray->getNextDataValue()) !== false) {
             if ($dataValue->getTypeID() == '_wpg' && $i == 0) {
                 list($title, $text) = $this->handleResultSubject($dataValue);
             } else {
                 if ($dataValue->getTypeID() == '_str' && $i == 0) {
                     $title = $dataValue->getLongText($this->outputmode, null);
                     $text = $dataValue->getLongText($this->outputmode, smwfGetLinker());
                 } else {
                     if ($dataValue->getTypeID() == '_gpo') {
                         $dataItem = $dataValue->getDataItem();
                         $polyHandler = new PolygonHandler($dataItem->getString());
                         $this->geoShapes[$polyHandler->getGeoType()][] = $polyHandler->shapeFromText();
                     } else {
                         if ($dataValue->getTypeID() != '_geo' && $i != 0 && !$this->isHeadersHide()) {
                             $properties[] = $this->handleResultProperty($dataValue, $printRequest);
                         } else {
                             if ($printRequest->getMode() == SMWPrintRequest::PRINT_PROP && $printRequest->getTypeID() == '_geo') {
                                 $dataItem = $dataValue->getDataItem();
                                 $location = Location::newFromLatLon($dataItem->getLatitude(), $dataItem->getLongitude());
                                 $locations[] = $location;
                             }
                         }
                     }
                 }
             }
         }
     }
     if (count($properties) > 0 && $text !== '') {
         $text .= $this->subjectSeparator;
     }
     $icon = $this->getLocationIcon($row);
     $this->geoShapes['locations'] = array_merge($this->geoShapes['locations'], $this->buildLocationsList($locations, $text, $icon, $properties, Title::newFromText($title)));
 }
Ejemplo n.º 6
0
 protected function assertHasJsonKeyWithValue(Location $polygon, $key, $value)
 {
     $json = $polygon->getJSONObject();
     $this->assertArrayHasKey($key, $json);
     $this->assertEquals($value, $json[$key]);
 }