/** * @see ItemParameterManipulation::doManipulation * * @since 0.7.2 */ public function doManipulation(&$value, Parameter $parameter, array &$parameters) { $parts = $this->metaDataSeparator === false ? array($value) : explode($this->metaDataSeparator, $value); $value = array_shift($parts); $value = new MapsLocation($value); if ($title = array_shift($parts)) { $value->setTitle($title); } if ($text = array_shift($parts)) { $value->setText($text); } if ($icon = array_shift($parts)) { $value->setIcon($icon); } if ($this->toJSONObj) { $value = $value->getJSONObject(); } }
/** * Returns the KML representing the provided location. * * @since 0.7.3 * * @param MapsLocation $location * * @return string */ protected function getKMLForLocation(MapsLocation $location) { $name = '<name><![CDATA[ ' . $location->getTitle() . ']]></name>'; $description = '<description><![CDATA[ ' . $location->getText() . ']]></description>'; // lon,lat[,alt] $coordinates = Xml::element('coordinates', array(), $location->getLongitude() . ',' . $location->getLatitude() . ',' . $location->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; }
/** * Returns the locations found in the provided result row. * * @since 0.7.3 * * @param array $row Array of SMWResultArray * * @return array of MapsLocation */ protected function handleResultRow(array $row) { $locations = array(); $properties = array(); $title = ''; $text = ''; // Loop throught all fields of the record. foreach ($row as $i => $resultArray) { /* SMWPrintRequest */ $printRequest = $resultArray->getPrintRequest(); // Loop throught 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, $GLOBALS['wgUser']->getSkin()); } else { if ($dataValue->getTypeID() != '_geo' && $i != 0) { $properties[] = $this->handleResultProperty($dataValue, $printRequest); } else { if ($printRequest->getMode() == SMWPrintRequest::PRINT_PROP && $printRequest->getTypeID() == '_geo') { $dataItem = $dataValue->getDataItem(); $location = MapsLocation::newFromLatLon($dataItem->getLatitude(), $dataItem->getLongitude()); if ($location->isValid()) { $locations[] = $location; } } } } } } } if (count($properties) > 0 && $text !== '') { $text .= $this->subjectSeparator; } $icon = $this->getLocationIcon($row); return $this->buildLocationsList($locations, $title, $text, $icon, $properties); }
/** * Returns the locations found in the provided result row. * * @since 0.7.3 * * @param array $row Array of SMWResultArray * * @return array of MapsLocation */ protected function handleResultRow(array $row) { $locations = array(); $properties = array(); $title = ''; $text = ''; // Loop throught all fields of the record. foreach ($row as $i => $resultArray) { /* SMWPrintRequest */ $printRequest = $resultArray->getPrintRequest(); // Loop throught 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) { $properties[] = $this->handleResultProperty($dataValue, $printRequest); } else { if ($printRequest->getMode() == SMWPrintRequest::PRINT_PROP && $printRequest->getTypeID() == '_geo') { $dataItem = $dataValue->getDataItem(); $location = MapsLocation::newFromLatLon($dataItem->getLatitude(), $dataItem->getLongitude()); if ($location->isValid()) { $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))); }
/** * Returns if the rectangle is valid. * * @since 2.0 * * @return boolean */ public function isValid() { return $this->rectangleSouthWest->isValid() && $this->rectangleNorthEast->isValid(); }