/** * Returns the KML for the query result. * * @since 0.7.3 * * @param SMWQueryResult $res * @param integer $outputmode * * @return string */ protected function getKML(SMWQueryResult $res, $outputmode) { $queryHandler = new SMQueryHandler($res, $outputmode, $this->params['linkabsolute'], $this->params['pagelinktext'], false); $queryHandler->setText($this->params['text']); $queryHandler->setTitle($this->params['title']); $queryHandler->setSubjectSeparator(''); $formatter = new MapsKMLFormatter($this->params); $formatter->addPlacemarks($queryHandler->getLocations()); return $formatter->getKML(); }
/** * Converts the data in the coordinates parameter to JSON-ready objects. * These get stored in the locations parameter, and the coordinates on gets deleted. * * @since 1.0 * * @param array &$params * @param SMQueryHandler $queryHandler */ protected function handleMarkerData(array &$params, SMQueryHandler $queryHandler) { if (is_object($params['centre'])) { $params['centre'] = $params['centre']->getJSONObject(); } $iconUrl = MapsMapper::getFileUrl($params['icon']); $visitedIconUrl = MapsMapper::getFileUrl($params['visitedicon']); $params['locations'] = $this->getJsonForStaticLocations($params['staticlocations'], $params, $iconUrl, $visitedIconUrl); unset($params['staticlocations']); $this->addShapeData($queryHandler->getShapes(), $params, $iconUrl, $visitedIconUrl); if ($params['format'] === 'openlayers') { $params['layers'] = MapsDisplayMapRenderer::evilOpenLayersHack($params['layers']); } }
/** * Builds up and returns the HTML for the map, with the queried coordinate data on it. * * @param SMWQueryResult $res * @param $outputmode * * @return array or string */ public final function getResultText( SMWQueryResult $res, $outputmode ) { if ( $this->fatalErrorMsg === false ) { global $wgParser; $params = $this->params; $queryHandler = new SMQueryHandler( $res, $outputmode ); $queryHandler->setShowSubject( $params['showtitle'] ); $queryHandler->setTemplate( $params['template'] ); $this->handleMarkerData( $params, $queryHandler->getLocations() ); $locationAmount = count( $params['locations'] ); if ( $params['forceshow'] || $locationAmount > 0 ) { // We can only take care of the zoom defaulting here, // as not all locations are available in whats passed to Validator. if ( $params['zoom'] === false && $locationAmount <= 1 ) { $params['zoom'] = $this->service->getDefaultZoom(); } $mapName = $this->service->getMapId(); // MediaWiki 1.17 does not play nice with addScript, so add the vars via the globals hook. if ( version_compare( $GLOBALS['wgVersion'], '1.18', '<' ) ) { $GLOBALS['egMapsGlobalJSVars'] += $this->service->getConfigVariables(); } SMWOutputs::requireHeadItem( $mapName, $this->service->getDependencyHtml() . $configVars = Skin::makeVariablesScript( $this->service->getConfigVariables() ) ); foreach ( $this->service->getResourceModules() as $resourceModule ) { SMWOutputs::requireResource( $resourceModule ); } $result = $this->getMapHTML( $params, $wgParser, $mapName ) . $this->getJSON( $params, $wgParser, $mapName ); return array( $result, 'noparse' => true, 'isHTML' => true ); } else { return ''; } } else { return $this->fatalErrorMsg; } }