public function toGeoJSON() { $str = ""; $str .= "{\"type\":\"Feature\", \"id\":\"" . $this->fid . "\", \"crs\":"; if (!$this->geometry || !$this->geometry->srs) { $str .= "null, "; } else { $str .= "{\"type\":\"name\", \"properties\":{\"name\":\"" . $this->geometry->srs . "\"}}, "; } $str .= "\"geometry\": "; if ($this->geometry) { $str .= $this->geometry->toGeoJSON(); } else { $str .= "\"\""; } $prop = array(); $str .= ", \"properties\": "; $cnt = 0; foreach ($this->properties as $key => $value) { $prop[$key] = preg_replace('/\\r\\n|\\r|\\n/', '\\n', $value); $cnt++; } $json = new Mapbender_JSON(); $str .= $json->encode($prop); $str .= "}"; return $str; }
public function returnUrl() { $mbjson = new Mapbender_JSON(); if ($this->isSaved) { return $mbjson->encode(array("outputFileName" => TMPDIR . "/" . $this->outputFileName)); } else { return $mbjson->encode(array("error" => "Possibly no map urls delivered.")); } }
function sendErrorMessage($data) { $resObj = array(); $response = "error"; $resObj["errorMessage"] = $data; $resObj["response"] = $response; header("Content-Type:application/x-json"); $json = new Mapbender_JSON(); echo $json->encode($resObj); die; }
private function readConfig($jsonConfFile) { $admin = new administration(); $mbjson = new Mapbender_JSON(); $jsonStr = file_get_contents(dirname(__FILE__) . "/../" . $jsonConfFile); if ($jsonStr == false) { $e = new mb_exception("mbPdfFactory: config file could not be read."); die("config not found."); } $jsonConf = $mbjson->decode($admin->char_encode($jsonStr)); return $jsonConf; }
public function decorate() { $mmPerPt = 0.3527; $this->pdf->objPdf->setTextColor(0, 0, 0); $this->pdf->objPdf->setFont($this->conf->font_family, "", $this->conf->font_size); $currentX = $this->conf->x_ul; $currentY = $this->conf->y_ul; $json = new Mapbender_JSON(); $wmsLegendArray = $json->decode($_POST["legend_url"]); if (!is_array($wmsLegendArray)) { //TODO: error message return; } for ($i = 0; $i < count($wmsLegendArray); $i++) { $layerLegendObj = $wmsLegendArray[$i]; if (!is_object($layerLegendObj)) { continue; } foreach ($layerLegendObj as $title => $layerLegendArray) { if (!is_array($layerLegendArray)) { continue; } // Title $titleFontSize = $this->conf->font_size + 1; $this->pdf->objPdf->setFont($this->conf->font_family, "", $titleFontSize); $this->pdf->objPdf->Text($currentX, $currentY, html_entity_decode(utf8_decode($title))); // $currentY += $mmPerPt * $this->conf->font_size; $currentY += $titleFontSize; $this->pdf->objPdf->setFont($this->conf->font_family, "", $this->conf->font_size); for ($j = 0; $j < count($layerLegendArray); $j++) { // Legend $currentLegendObj = $layerLegendArray[$j]; $this->pdf->objPdf->Text($currentX, $currentY, html_entity_decode(utf8_decode($currentLegendObj->title))); //$currentY += $mmPerPt * $this->conf->font_size; $currentY += $this->conf->font_size; // store current legend image temporarily $legendFilename = TMPDIR . "/legend_" . substr(md5(uniqid(rand())), 0, 7) . ".png"; $saveLegend = new SaveLegend($currentLegendObj->legendUrl, $legendFilename); list($width, $height) = getimagesize($legendFilename); $width = $width / $this->pdf->objPdf->k; $height = $height / $this->pdf->objPdf->k; try { $this->pdf->objPdf->Image($legendFilename, $currentX, $currentY - 3.5, $width * $this->conf->scale); } catch (Exception $E) { $e = new mb_exception("Can't write Legend Image to pdf: " . $E->getmessage); } $currentY += $height * $this->conf->scale; } $currentY += 5; } } $this->pdf->unlink($legendFilename); }
# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. require_once dirname(__FILE__) . "/../../core/globalSettings.php"; require_once dirname(__FILE__) . "/../classes/class_json.php"; $json = new Mapbender_JSON(); $line1 = $_REQUEST["line1"]; $line2 = $_REQUEST["line2"]; #$lineList = $_REQUEST["lines"]; $floatPattern = "-?\\d+(\\.\\d+)?"; $pointPattern = $floatPattern . " " . $floatPattern; $linePattern = "LINESTRING \\(" . $pointPattern . ",( )*" . $pointPattern . "(,( )*" . $pointPattern . ")*\\)"; $pattern = "/" . $linePattern . "/"; #if (!preg_match($pattern, $lineList)) { # echo "not a line."; # die(); #} if (!preg_match($pattern, $line1)) { echo "Line 1 not a line."; die; }
public function toGeoJSON() { $str = ""; $str .= "{\"type\":\"Feature\", \"id\":\"" . $this->fid . "\", \"geometry\": "; if ($this->geometry) { $str .= $this->geometry->toGeoJSON(); } else { $str .= "\"\""; } $prop = array(); $str .= ", \"properties\": "; $cnt = 0; foreach ($this->properties as $key => $value) { $prop[$key] = $value; $cnt++; } $json = new Mapbender_JSON(); $str .= $json->encode($prop); $str .= "}"; return $str; }
<?php require_once dirname(__FILE__) . "/../../core/globalSettings.php"; require_once dirname(__FILE__) . "/../classes/class_user.php"; require_once dirname(__FILE__) . "/../classes/class_wmc.php"; require_once dirname(__FILE__) . "/../classes/class_wmcToXml.php"; require_once dirname(__FILE__) . "/../classes/class_json.php"; require_once dirname(__FILE__) . "/../classes/class_administration.php"; $ajaxResponse = new AjaxResponse($_POST); $json = new Mapbender_JSON(); $userId = Mapbender::session()->get("mb_user_id"); $currentUser = new User($userId); $wmc = new wmc(); $resultObj = array(); switch ($ajaxResponse->getMethod()) { // gets available WMCs case "getWmc": $showPublic = $ajaxResponse->getParameter("showPublic"); //$e = new mb_notice("mod_loadwmc_server.php: showPublic: ".$showPublic); $resultObj["wmc"] = $wmc->selectByUser($currentUser, $showPublic); $ajaxResponse->setResult($resultObj); $ajaxResponse->setSuccess(true); break; // gets XML document of a WMC // gets XML document of a WMC case "getWmcDocument": $wmcId = $ajaxResponse->getParameter("id"); $doc = $wmc->getDocument($wmcId); if (!$doc) { $ajaxResponse->setMessage(_mb("The WMC document could not be found.")); $ajaxResponse->setSuccess(false);
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /********** Configuration*************************************************/ require_once dirname(__FILE__) . "/../php/mb_validatePermission.php"; require_once dirname(__FILE__) . "/../classes/class_json.php"; include dirname(__FILE__) . "/../include/dyn_js.php"; $tab_ids = array(); include dirname(__FILE__) . "/../include/dyn_php.php"; echo "var tab_titles = [];\n"; for ($i = 0; $i < count($tab_ids); $i++) { $sql = "SELECT gettext(\$1, e_title) AS e_title FROM gui_element WHERE fkey_gui_id = \$2 AND e_id = \$3"; $v = array(Mapbender::session()->get("mb_lang"), $gui_id, $tab_ids[$i]); $t = array("s", "s", "s"); $res = db_prep_query($sql, $v, $t); $row = db_fetch_array($res); echo "tab_titles[" . $i . "] = '" . $row["e_title"] . "';\n"; } $json = new Mapbender_JSON(); $output = $json->encode($tab_ids); echo "var tab_ids = " . $output . ";"; if (!isset($expandable) || !$expandable) { include dirname(__FILE__) . "/mod_tab.js"; } else { include dirname(__FILE__) . "/mod_tab_expandable.js"; }
$msg_obj["buttonLabelLineContinueOn"] = _mb("finish line"); $msg_obj["buttonLabelPolygonOff"] = _mb("add polygon"); $msg_obj["buttonLabelPolygonOn"] = _mb("close polygon"); $msg_obj["buttonLabelMoveBasepointOff"] = _mb("move basepoint"); $msg_obj["buttonLabelMoveBasepointOn"] = _mb("move basepoint"); $msg_obj["buttonLabelInsertBasepointOff"] = _mb("Insert basepoint"); $msg_obj["buttonLabelInsertBasepointOn"] = _mb("Insert basepoint"); $msg_obj["buttonLabelDeleteBasepointOff"] = _mb("Delete basepoint"); $msg_obj["buttonLabelDeleteBasepointOn"] = _mb("Delete basepoint"); $msg_obj["buttonLabelClearListOff"] = _mb("clear list of geometries"); $msg_obj["buttonLabelClearListOn"] = _mb("clear list of geometries"); $msg_obj["buttonLabelMergeOff"] = _mb("Merge two polygons into a single polygon (will be added to the geometry list)"); $msg_obj["buttonLabelMergeOn"] = _mb("Merge two polygons into a single polygon (will be added to the geometry list)"); $msg_obj["buttonLabelSplitOff"] = _mb("Split a polygon/line by a line (the new polygons/lines will be added to the geometry list)"); $msg_obj["buttonLabelSplitOn"] = _mb("Split a polygon/line by a line (the new polygons/lines will be added to the geometry list)"); $msg_obj["buttonLabelDifferenceOff"] = _mb("Combine two polygons (to create en- and exclave or to compute the difference)"); $msg_obj["buttonLabelDifferenceOn"] = _mb("Split geometries"); $msg_obj["buttonLabelMergeLineOff"] = _mb("Merge two lines into a single line"); $msg_obj["buttonLabelMergeLineOn"] = _mb("Merge two lines into a single line"); $msg_obj["buttonDig_wfs_title"] = _mb("save / update / delete"); $msg_obj["buttonDig_remove_title"] = _mb("remove from workspace"); $msg_obj["buttonDig_removeDb_title"] = _mb("remove from database"); $msg_obj["buttonDig_clone_title"] = _mb("clone this geometry"); $msg_obj["closePolygon_title"] = _mb("click the first basepoint to close the polygon"); $msg_obj["measureTagLabelCurrent"] = _mb("Current: "); $msg_obj["measureTagLabelTotal"] = _mb("Total: "); $msg_obj["digitizeDefaultGeometryName"] = _mb("new"); $json = new Mapbender_JSON(); $output = $json->encode($msg_obj); header("Content-type:application/x-json; charset=utf-8"); echo $output;
} $resultArray = array("id" => $row["wms_id"], "title" => $row["wms_title"], "abstract" => $row["wms_abstract"], "getCapabilitiesUrl" => $wmsUrl, "version" => $row["wms_version"]); array_push($resultObj["wms"], $resultArray); } } else { if ($command == "getWMSByGUI") { $resultObj["wms"] = array(); $sql = "SELECT DISTINCT wms_id, wms_title, gettext(\$1, wms_abstract) as wms_abstract, wms_getcapabilities, wms_version "; $sql .= "FROM wms, gui_wms WHERE wms.wms_id = gui_wms.fkey_wms_id AND fkey_gui_id = \$2"; $v = array(Mapbender::session()->get("mb_lang"), $guiId); $t = array("s", "s"); $res = db_prep_query($sql, $v, $t); while ($row = db_fetch_array($res)) { $owsproxy = $admin->getWMSOWSstring($row["wms_id"]); if ($owsproxy && $owsproxy != "") { $owsproxyUrl = OWSPROXY . "/" . session_id() . "/" . $owsproxy . "?"; $wmsUrl = $owsproxyUrl; } else { $wmsUrl = $row["wms_getcapabilities"]; } $resultArray = array("id" => $row["wms_id"], "title" => $row["wms_title"], "abstract" => $row["wms_abstract"], "getCapabilitiesUrl" => $wmsUrl, "version" => $row["wms_version"]); array_push($resultObj["wms"], $resultArray); } } } } } } $json = new Mapbender_JSON(); $output = $json->save_encode($resultObj); echo $output;
# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/../classes/class_json.php"; $json = new Mapbender_JSON(); // see http://trac.osgeo.org/mapbender/ticket/79 ini_set('session.bug_compat_42', 0); ini_set('session.bug_compat_warn', 0); Mapbender::session()->set("mb_user_gui", $gui_id); ob_start(); header('Content-type: application/x-javascript'); // // Define global variables (TODO: move to mapbender object later on) // echo "Mapbender.sessionId = '" . session_id() . "';\n"; echo "var mb_nr = Mapbender.sessionId;\n"; echo "Mapbender.sessionName = '" . session_name() . "';\n"; echo "var mb_session_name = Mapbender.sessionName;\n"; echo "Mapbender.loginUrl = '" . Mapbender::session()->get("mb_login") . "';\n"; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
function getAllUserColumns($userId) { $userArray = array(); $sql = "SELECT * FROM mb_user WHERE mb_user_id = \$1"; $v = array($userId); $t = array('s'); $res = db_prep_query($sql, $v, $t); while ($row = db_fetch_array($res)) { foreach ($row as $key => $value) { if (is_int($key) == false) { array_push($userArray, array("id" => $key, "value" => $value)); } } } $json = new Mapbender_JSON(); $output = $json->encode($userArray); header("Content-type:text/plain; charset=utf-8"); return $output; }
<?php # License: # Copyright (c) 2009, Open Source Geospatial Foundation # This program is dual licensed under the GNU General Public License # and Simplified BSD license. # http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt require_once dirname(__FILE__) . "/../../core/globalSettings.php"; require_once dirname(__FILE__) . "/../classes/class_json.php"; $json = new Mapbender_JSON(); $startPoint = null; $endPoint = null; $points = array(); $lineArray = array(); function isLinestring($string) { $floatPattern = "-?\\d+(\\.\\d+)?"; $pointPattern = $floatPattern . " " . $floatPattern; $linePattern = "LINESTRING \\(" . $pointPattern . ",( )*" . $pointPattern . "(,( )*" . $pointPattern . ")*\\)"; if (preg_match("/" . $linePattern . "/", $string)) { return true; } return false; } if (!isLinestring($_REQUEST["line1"]) or !isLinestring($_REQUEST["line2"])) { die("not a line."); } $line1Text = $_REQUEST["line1"]; $line2Text = $_REQUEST["line2"]; // find intersection points $intersection_sql = sprintf("SELECT ST_AsText(multipoint.geom) as point, " . " ST_AsText(ST_StartPoint('%s'::geometry)) AS startpoint," . " ST_AsText(ST_EndPoint('%s'::geometry)) AS endpoint " . " FROM ST_Dump((SELECT ST_AsText(ST_Intersection('%s'::geometry,'%s'::geometry)))) AS multipoint" . " ORDER BY ST_Line_Locate_Point('%s'::geometry,ST_AsText(multipoint.geom)::geometry) ASC;", $line1Text, $line1Text, $line1Text, $line2Text, $line1Text);
/** * Returns an array of JavaScript statements * * @return String[] */ public function toJavaScript() { $skipWmsArray = array(); if (func_num_args() === 1) { if (!is_array(func_get_arg(0))) { throw new Exception("Invalid argument, must be array."); } $skipWmsArray = func_get_arg(0); } // will contain the JS code to create the maps // representing the state stored in this WMC $wmcJsArray = array(); // set general extension data if (count($this->generalExtensionArray) > 0) { $json = new Mapbender_JSON(); array_push($wmcJsArray, "restoredWmcExtensionData = " . $json->encode($this->generalExtensionArray) . ";"); } // reset WMS data array_push($wmcJsArray, "wms = [];"); array_push($wmcJsArray, "wms_layer_count = 0;"); // add WMS for main map frame $wmsArray = $this->mainMap->getWmsArray(); // find the WMS in the main map which is equal to the WMS // in the overview map $overviewWmsIndex = null; $ovWmsArray = array(); if ($this->overviewMap !== null) { $ovWmsArray = $this->overviewMap->getWmsArray(); $overviewWmsIndex = 0; for ($i = 0; $i < count($ovWmsArray); $i++) { for ($j = 0; $j < count($wmsArray); $j++) { if ($ovWmsArray[$i]->equals($wmsArray[$j]) && !in_array($j, $skipWmsArray)) { $overviewWmsIndex = $j; $wmsIndexOverview = $i; break; } } } } // for all wms... for ($i = 0; $i < count($wmsArray); $i++) { if (in_array($i, $skipWmsArray)) { continue; } array_push($wmcJsArray, $wmsArray[$i]->createJsObjFromWMS_()); $this->incrementLoadCount($wmsArray[$i]); } // delete existing map objects... // array_push($wmcJsArray, "mb_mapObj = [];"); // .. and add the overview map (if exists) and set map request if ($this->overviewMap !== null) { $wmcJsArray = array_merge($wmcJsArray, $this->overviewMap->toJavaScript("{wms:wms,wmsIndexOverview:" . $overviewWmsIndex . "}")); } // .. and add main map .. $wmcJsArray = array_merge($wmcJsArray, $this->mainMap->toJavaScript("{wms:wms,wmsIndexOverview:null}")); // set visibility of ov map WMS (may be different from main) if ($this->overviewMap !== null) { for ($i = 0; $i < count($ovWmsArray[$wmsIndexOverview]->objLayer); $i++) { $visStr = "try { Mapbender.modules['" . $this->overviewMap->getFrameName() . "'].wms[0].handleLayer(" . "'" . $ovWmsArray[$wmsIndexOverview]->objLayer[$i]->layer_name . "', " . "'visible', " . ($ovWmsArray[$wmsIndexOverview]->objLayer[$i]->gui_layer_visible ? 1 : 0) . ")} catch (e) {};"; array_push($wmcJsArray, $visStr); } array_push($wmcJsArray, "try { Mapbender.modules['" . $this->overviewMap->getFrameName() . "'].restateLayers(" . $ovWmsArray[$wmsIndexOverview]->wms_id . ");} catch (e) {};"); } // .. request the map array_push($wmcJsArray, "Mapbender.modules['" . $this->mainMap->getFrameName() . "'].setMapRequest();"); if ($this->overviewMap !== null) { array_push($wmcJsArray, "try {Mapbender.modules['" . $this->overviewMap->getFrameName() . "'].setMapRequest()} catch (e) {};"); } array_push($wmcJsArray, "eventAfterLoadWMS.trigger();"); return $wmcJsArray; }
function __toString() { $json = new Mapbender_JSON(); return $json->encode($this->confArray); }
if (db_error()) { return "Could not get Categories from db"; } $i = 0; while ($row = db_fetch_array($res)) { $i++; $str .= "<label for=\"{$prefix}_wmcIsoTopicCategory_{$row[0]}\">" . "<input class=\"wmcIsoTopicCategory\" id=\"{$prefix}_wmcIsoTopicCategory_{$row[0]}\" " . "type=\"checkbox\" />{$row[1]}</label>"; } return $str; } $originalI18nObj = array("labelNewOrOverwrite" => "New / overwrite", "labelNewWmc" => "(new WMC)", "labelName" => "Name", "labelAbstract" => "Abstract", "labelKeywords" => "Keywords", "labelCategories" => "Categories", "labelCancel" => "Abort", "labelSave" => "Save", "title" => $e_title, "labelSaveInSession" => "Save configuration"); $translatedI18nObj = array(); foreach ($originalI18nObj as $key => $value) { $translatedI18nObj[$key] = _mb($value); } $json = new Mapbender_JSON(); $saveWmcCategoryString = createIsoTopicCategoryString($e_id, $languageCode); $originalI18nObjJson = $json->encode($originalI18nObj); $translatedI18nObjJson = $json->encode($translatedI18nObj); $labelNewOrOverwrite = $translatedI18nObj["labelNewOrOverwrite"]; $labelNewWmc = $translatedI18nObj["labelNewWmc"]; $labelName = $translatedI18nObj["labelName"]; $labelAbstract = $translatedI18nObj["labelAbstract"]; $labelKeywords = $translatedI18nObj["labelKeywords"]; $labelCategories = $translatedI18nObj["labelCategories"]; echo <<<HTML var wmcSaveFormHtml = '<form><fieldset>' + \t'<label for="{$e_id}_wmctype">{$labelNewOrOverwrite}</label>' + \t'<select class="ui-corner-all" id="{$e_id}_wmctype">' + \t'<option value="">{$labelNewWmc}</option></select>' +
public function parseGeoJSON($geoJSON, $kmlId) { // $e = new mb_notice("GEOJSON: " . $geoJSON); $json = new Mapbender_JSON(); $geometryFromGeoJSON = $json->decode($geoJSON); $id = 0; if (gettype($geometryFromGeoJSON) == "object" && $geometryFromGeoJSON->type == "FeatureCollection") { if ($geometryFromGeoJSON->crs->type == "EPSG" && $geometryFromGeoJSON->crs->properties->code) { $epsg = $geometryFromGeoJSON->crs->properties->code; } // create Placemarks for ($i = 0; $i < count($geometryFromGeoJSON->features); $i++) { $e = new mb_notice("parsing plm #" . $i . "...length of placemarkArray: " . count($this->placemarkArray)); $feature = $geometryFromGeoJSON->features[$i]; if (gettype($feature) == "object" && $feature->type == "Feature") { if ($feature->geometry->crs->type == "EPSG") { $epsg = $feature->geometry->crs->properties->code; } if (!$epsg) { $e = new mb_notice("EPSG is not set! Aborting...(" . $epsg . ")"); } $geometry = $feature->geometry; $currentGeometry = false; //TODO: missing Polygon and MultiGeometry switch ($geometry->type) { case "LineString": $coordinateList = ""; for ($j = 0; $j < count($geometry->coordinates); $j++) { if ($j > 0) { $coordinateList .= " "; } $coordinateList .= implode(",", $geometry->coordinates[$j]); } $currentGeometry = new KMLLine($coordinateList, $epsg); break; case "Point": $coordinateList = implode(",", $geometry->coordinates); $currentGeometry = new KMLPoint($coordinateList, $epsg); break; } if ($currentGeometry) { $currentPlacemark = new KMLPlacemark($currentGeometry); if (gettype($feature->properties) == "object") { foreach ($feature->properties as $key => $value) { $currentPlacemark->setProperty($key, $value); } $currentPlacemark->setProperty("Mapbender:kml", true); $currentPlacemark->setProperty("Mapbender:name", "unknown"); $currentPlacemark->setProperty("Mapbender:id", $kmlId); $currentPlacemark->setProperty("Mapbender:placemarkId", $id); $e = new mb_notice("adding to placemarkArray (current length: " . count($this->placemarkArray) . ")"); array_push($this->placemarkArray, $currentPlacemark); $e = new mb_notice("added...new length: " . count($this->placemarkArray)); $id++; } } } } } return true; }
$xml .= 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '; $xml .= 'xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2/CSW-discovery.xsd"> '; $xml .= '> '; $xml .= '<csw:Query typeNames="csw:Record">'; $xml .= '<csw:ElementSetName>summary</csw:ElementSetName>'; $xml .= '</csw:Query>'; $xml .= '</csw:GetRecords>'; #$xml .= '</GetRecords>'; //parse xml for validating it before sending $data = stripslashes($xml); $dataXMLObject = new SimpleXMLElement($xml); $xml = $dataXMLObject->asXML(); return $xml; } function getrecords_post($url, $postData) { $connection = new connector(); $connection->set("httpType", "post"); $connection->set("httpContentType", "text/xml"); $connection->set("httpPostData", $postData); $e = new mb_notice("CAT REQUEST: " . $url . "\n\n" . $postData); $data = $connection->load($url); if (!$data) { $e = new mb_exception("CAT getrecords returned no result: " . $url . "\n" . $postData); return null; } return $data; } $json = new Mapbender_JSON(); $output = $json->encode($resultObj); echo $output;
$x = trim(floatval($row["rechtsw"])); $y = trim(floatval($row["hochw"])); $obj["landparcels"][$landparcelId] = array("x" => $x, "y" => $y); } } $obj["limited"] = isOverLimit($counter, $numberOfResults, $numberOfResults); } else { if ($command == "getDistricts") { $obj["districts"] = array(); $sql = "SELECT DISTINCT gemschl, name FROM public.gemarkungen WHERE gkz = \$1 ORDER BY name"; $v = array($communeId); $t = array("i"); $res = db_prep_query($sql, $v, $t); while ($row = db_fetch_array($res)) { $districtID = trim($row["gemschl"]); $districtName = trim($row["name"]); $obj["districts"][$districtID] = $districtName; } $obj["limited"] = false; } else { // unknown command $e = new mb_exception("unknown command: " . $command); } } } } } } $json = new Mapbender_JSON(); $output = $json->encode($obj); echo $output;
} } else { echo "please specify wfs conf id."; die; } $obj = new WfsConf(); $obj->load($wfsConfIdArray); $json = new Mapbender_JSON(); $output = $json->encode($obj->confArray); echo $output; } elseif ($command == "getWfsConfsForThisApplication") { // get all WFS conf IDs for this application $availableWfsConfIds = $user->getWfsConfByPermission(Mapbender::session()->get("mb_user_gui")); $obj = new WfsConf(); $obj->load($availableWfsConfIds); $json = new Mapbender_JSON(); $output = $json->encode($obj->confArray); echo $output; } else { if ($command == "getSearchResults") { $wfs_conf_id = $_REQUEST["wfs_conf_id"]; $backlink = $_REQUEST["backlink"]; $frame = $_REQUEST["frame"]; $filter = $_REQUEST["filter"]; $url = $_REQUEST["url"]; $typename = $_REQUEST["typename"]; $destSrs = $_REQUEST["destSrs"]; $wfsConf = WfsConfiguration::createFromDb($wfs_conf_id); if (is_null($wfsConf)) { sendErrorMessage("Invalid WFS conf: " . $wfs_conf_id); }
private function updateGeometry($currentNode, $geometry) { $json = new Mapbender_JSON(); $currentNode_SimpleXML = simplexml_import_dom($currentNode); $currentTypeXml = mb_strtoupper($currentNode->nodeName); $currentTypeGeoJson = mb_strtoupper($geometry->type); if ($currentTypeGeoJson != $currentTypeXml) { $e = new mb_exception("class_kml: geometry type mismatch: geoJSON: " . $currentTypeGeoJson . "; XML: " . $currentTypeXml); return false; } if ($currentTypeXml == "POLYGON") { // GML 3 $gmlNode = $currentNode_SimpleXML->{"exterior"}->{"LinearRing"}->{"posList"}; $kmlNode = $currentNode_SimpleXML->{"outerBoundaryIs"}->{"LinearRing"}->{"coordinates"}; if ($gmlNode && $gmlNode->asXML()) { $currentNode_SimpleXML->{"exterior"}->{"LinearRing"}->{"posList"} = preg_replace("/,/", " ", preg_replace("/\\[|\\]/", "", $json->encode($geometry->coordinates))); } else { if ($kmlNode && $kmlNode->asXML()) { $currentNode_SimpleXML->{"outerBoundaryIs"}->{"LinearRing"}->{"coordinates"} = preg_replace("/\\],/", " ", preg_replace("/\\][^,]|\\[/", "", $json->encode($geometry->coordinates))); } } } elseif ($currentTypeXml == "POINT") { $gmlNode = $currentNode_SimpleXML->{"pos"}; $kmlNode = $currentNode_SimpleXML->{"coordinates"}; // GML 3 if ($gmlNode && $gmlNode->asXML()) { $currentNode_SimpleXML->{"pos"} = preg_replace("/,/", " ", preg_replace("/\\[|\\]/", "", $json->encode($geometry->coordinates))); } else { if ($kmlNode && $kmlNode->asXML()) { $currentNode_SimpleXML->{"coordinates"} = preg_replace("/\\[|\\]/", "", $json->encode($geometry->coordinates)); } } } elseif ($currentTypeXml == "LINESTRING") { $gmlNode = $currentNode_SimpleXML->{"posList"}; $kmlNode = $currentNode_SimpleXML->{"coordinates"}; // GML 3 if ($gmlNode && $gmlNode->asXML()) { $currentNode_SimpleXML->{"posList"} = preg_replace("/,/", " ", preg_replace("/\\[|\\]/", "", $json->encode($geometry->coordinates))); } else { if ($kmlNode && $kmlNode->asXML()) { $currentNode_SimpleXML->{"coordinates"} = preg_replace("/\\[|\\]/", "", $json->encode($geometry->coordinates)); } } } return true; }
/** * Creates a GML object from a GeoJSON (http://www.geojson.org) String * * @return Gml * @param $geoJson String */ public function createFromGeoJson($geoJson, $gml) { $json = new Mapbender_JSON(); $jsonObj = $json->decode($geoJson); // check if valid feature collection if (strtoupper($jsonObj->type) != "FEATURECOLLECTION" || !is_array($jsonObj->features)) { $e = new mb_exception("Not a valid GeoJSON Feature Collection: " . $geoJson); return null; } $gml->featureCollection = new FeatureCollection(); foreach ($jsonObj->features as $currentFeature) { $feature = new Feature(); if (!is_object($currentFeature->crs) || $currentFeature->crs->type !== "name") { $e = new mb_exception("Feature doesn't have a SRS."); return null; } $srs = $currentFeature->crs->properties->name; // set geometry if (is_object($currentFeature->geometry)) { $currentGeometry = $currentFeature->geometry; switch (strtoupper($currentGeometry->type)) { case "POLYGON": $geometry = new GMLPolygon(); for ($i = 0; $i < count($currentGeometry->coordinates); $i++) { $currentRing = $currentGeometry->coordinates[$i]; foreach ($currentRing as $coords) { if (in_array($srs, $geometry->latLonSrs)) { list($y, $x) = $coords; } else { list($x, $y) = $coords; } // exterior ring if (0 == $i) { $geometry->addPoint($x, $y); } else { $geometry->addPointToRing($i, $x, $y); } } } break; case "POINT": $geometry = new GMLPoint(); if (in_array($srs, $geometry->latLonSrs)) { list($y, $x) = $currentGeometry->coordinates; } else { list($x, $y) = $currentGeometry->coordinates; } $geometry->setPoint($x, $y); break; case "MULTIPOINT": $geometry = new GMLMultiPoint(); for ($i = 0; $i < count($currentGeometry->coordinates); $i++) { $currentPoint = $currentGeometry->coordinates[$i]; if (in_array($srs, $geometry->latLonSrs)) { list($y, $x) = $currentPoint; } else { list($x, $y) = $currentPoint; } $geometry->addPoint($x, $y); } break; case "LINESTRING": $geometry = new GMLLine(); for ($i = 0; $i < count($currentGeometry->coordinates); $i++) { $currentLinePoint = $currentGeometry->coordinates[$i]; if (in_array($srs, $geometry->latLonSrs)) { list($y, $x) = $currentLinePoint; } else { list($x, $y) = $currentLinePoint; } $geometry->addPoint($x, $y); } break; case "MULTIPOLYGON": $geometry = new GMLMultiPolygon(); for ($i = 0; $i < count($currentGeometry->coordinates); $i++) { $currentPolygon = $currentGeometry->coordinates[$i]; for ($j = 0; $j < count($currentPolygon); $j++) { $currentRing = $currentPolygon[$j]; foreach ($currentRing as $coords) { if (in_array($srs, $geometry->latLonSrs)) { list($y, $x) = $coords; } else { list($x, $y) = $coords; } // exterior ring if (0 == $j) { $geometry->addPoint($x, $y, $i); } else { $geometry->addPointToRing($i, $j - 1, $x, $y); } } } } break; case "MULTILINESTRING": // not tested! $geometry = new GMLMultiLine(); for ($i = 0; $i < count($currentGeometry->coordinates); $i++) { $currentLine = $currentGeometry->coordinates[$i]; foreach ($currentLine as $currentLinePoint) { if (in_array($srs, $geometry->latLonSrs)) { list($y, $x) = $currentLinePoint; } else { list($x, $y) = $currentLinePoint; } $geometry->addPoint($x, $y, $i); } } break; case "GEOMETRYCOLLECTION": $e = new mb_exception($currentGeometry->type . " are not supported!"); return null; break; default: $e = new mb_exception($currentGeometry->type . " is not a valid geometry type"); return null; break; } // add the geometry to the feature $geometry->srs = $srs; $feature->geometry = $geometry; } else { $e = new mb_exception("This feature does not have a geometry."); return null; } // set fid and properties if (is_object($currentFeature->properties)) { foreach ($currentFeature->properties as $pName => $pValue) { if ("fid" == $pName) { $feature->fid = $pValue; } else { $feature->properties[$pName] = $pValue; } } } $gml->featureCollection->addFeature($feature); } return $gml; }
<?php require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/../classes/class_administration.php"; require_once dirname(__FILE__) . "/../classes/class_wfs.php"; require_once dirname(__FILE__) . "/../classes/class_json.php"; require_once dirname(__FILE__) . "/../classes/class_universal_wfs_factory.php"; $json = new Mapbender_JSON(); $obj = $json->decode($_REQUEST['obj']); //workflow: switch ($obj->action) { case 'getServices': $obj->services = getServices($obj); sendOutput($obj); break; case 'getWfsConfData': $obj->wfsConf = getWfsConfData($obj->wfs); sendOutput($obj); break; case 'getGuis': $obj->id = getGuis($obj); sendOutput($obj); break; case 'getAssignedConfs': $obj->assignedConfs = getAssignedConfs($obj); sendOutput($obj); break; case 'getUpdateUrl': $obj->url = getUpdateUrl($obj); sendOutput($obj); break;
* and Simplified BSD license. * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt */ require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/../classes/class_administration.php"; require_once dirname(__FILE__) . "/../classes/class_wmc.php"; require_once dirname(__FILE__) . "/../classes/class_json.php"; require_once dirname(__FILE__) . "/../classes/class_lzw_decompress.php"; $ajaxResponse = new AjaxResponse($_POST); if ($ajaxResponse->getMethod() != "saveWMC") { $ajaxResponse->setSuccess(false); $ajaxResponse->setMessage("method invalid"); $ajaxResponse->send(); exit; } $json = new Mapbender_JSON(); // get data from POST and SESSION $userId = Mapbender::session()->get("mb_user_id"); $mapObject = $ajaxResponse->getParameter('mapObject'); $lzwCompressed = $ajaxResponse->getParameter('lzwCompressed'); $saveInSession = $ajaxResponse->getParameter('saveInSession'); $extensionData = $json->decode($ajaxResponse->getParameter('extensionData')); $attributes = $ajaxResponse->getParameter('attributes'); $overwrite = $ajaxResponse->getParameter('overwrite'); $overwrite = $overwrite == "1" ? true : false; //for debugging, write mapObject to file if ($lzwCompressed == 'true') { //$e = new mb_exception('mod_savewmc_server.php: mapObject: '.implode(',',$mapObject)); $mapObject = lzw_decompress($mapObject); //$e = new mb_exception('mod_savewmc_server.php: mapObject uncompressed: '.$mapObject); //$filename = TMPDIR."/formerly_compressed_json.txt";//will be set to new one cause ?
<?php require_once dirname(__FILE__) . "/../classes/class_json.php"; $json = new Mapbender_JSON(); $queryObj = $json->decode($_REQUEST['queryObj']); if ($queryObj->sessionName && $queryObj->sessionId) { session_name($queryObj->sessionName); session_id($queryObj->sessionId); session_start(); session_write_close(); } require_once dirname(__FILE__) . "/../classes/class_user.php"; require_once dirname(__FILE__) . "/../classes/class_administration.php"; /** * encodes and delivers the data * * @param object the un-encoded object */ function sendOutput($out) { global $json; $output = $json->encode($out); header("Content-Type: text/x-json"); echo $output; } $resultObj = array(); $data = array(); $e = new mb_notice("command: " . $queryObj->command); $user = new User(); switch ($queryObj->command) { case 'delete':
if (isset($_REQUEST["hostName"]) & $_REQUEST["hostName"] != "") { //validate to some hosts $testMatch = $_REQUEST["hostName"]; //look for whitelist in mapbender.conf $HOSTNAME_WHITELIST_array = explode(",", HOSTNAME_WHITELIST); if (!in_array($testMatch, $HOSTNAME_WHITELIST_array)) { echo "Requested hostname <b>" . $testMatch . "</b> not whitelist! Please control your mapbender.conf."; $e = new mb_notice("Whitelist: " . HOSTNAME_WHITELIST); $e = new mb_notice($testMatch . " not found in whitelist!"); die; } $hostName = $testMatch; $testMatch = NULL; } if ($outputFormat == 'json') { $classJSON = new Mapbender_JSON(); } if ($languageCode == 'en') { $pathToSearchScript = '/portal/en/service/search.html?cat=dienste&searchfilter='; } if ($type == 'keywords') { $sql = "select a.keyword, sum(a.count) from ("; $sql .= "(select keyword, count(*) from keyword INNER JOIN layer_keyword ON (layer_keyword.fkey_keyword_id = keyword.keyword_id) GROUP BY keyword.keyword) union "; $sql .= "(select keyword, count(*) from keyword INNER JOIN wmc_keyword ON (wmc_keyword.fkey_keyword_id = keyword.keyword_id) GROUP BY keyword.keyword) union "; $sql .= "(select keyword, count(*) from keyword INNER JOIN wfs_featuretype_keyword ON (wfs_featuretype_keyword.fkey_keyword_id = keyword.keyword_id)"; $sql .= " GROUP BY keyword.keyword)) as a WHERE a.keyword <> '' GROUP BY a.keyword ORDER BY sum DESC LIMIT \$1"; $showName = 'keyword'; } if ($type == 'topicCategories') { $sql = "select a.md_topic_category_code_" . $languageCode . ", a.md_topic_category_id,sum(a.count) from ("; $sql .= "(select md_topic_category_code_" . $languageCode . ",md_topic_category_id, count(*) from md_topic_category INNER JOIN layer_md_topic_category ON (layer_md_topic_category.fkey_md_topic_category_id = md_topic_category.md_topic_category_id) GROUP BY md_topic_category.md_topic_category_code_" . $languageCode . ",md_topic_category.md_topic_category_id) union ";
#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $ # Copyright (C) 2002 CCGIS # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/../classes/class_json.php"; require_once dirname(__FILE__) . "/../classes/class_mb_exception.php"; $buttonObj = array(); $sql = "SELECT e_id, gettext(\$1, e_title) AS e_title FROM gui_element, " . "(SELECT v.var_value AS current_e_id FROM gui_element AS e, " . "gui_element_vars AS v WHERE e.e_id = v.fkey_e_id AND " . "e.fkey_gui_id = v.fkey_gui_id AND e.e_id = 'tabs' AND " . "v.var_name LIKE 'tab_ids%' AND e.fkey_gui_id = \$2) " . "AS gui_element_temp WHERE gui_element_temp.current_e_id = e_id " . "AND fkey_gui_id = \$3"; $v = array(Mapbender::session()->get("mb_lang"), Mapbender::session()->get("mb_user_gui"), Mapbender::session()->get("mb_user_gui")); $t = array("s", "s", "s"); $res = db_prep_query($sql, $v, $t); while ($row = db_fetch_array($res)) { array_push($buttonObj, array("id" => $row["e_id"], "title" => $row["e_title"])); } $json = new Mapbender_JSON(); $output = $json->encode($buttonObj); header("Content-type:text/plain; charset=utf-8"); echo $output;
$regTimeEnd = NULL; $maxResults = 5; #$searchBbox = "-180.0,-90.0,180.0,90.0"; $searchBbox = NULL; $searchTypeBbox = "intersects"; //outside / inside $accessRestrictions = "false"; $languageCode = "de"; $outputFormat = 'json'; #$searchResources = "wms,wfs,wmc,georss"; #$searchResources = "wms"; $searchPages = "1"; $resultTarget = "debug"; $preDefinedMaxResults = array(5, 10, 15, 20, 25, 30); $searchEPSG = "EPSG:31466"; $classJSON = new Mapbender_JSON(); #$tempFolder = "/tmp"; $tempFolder = TMPDIR; $orderBy = "rank"; //rank or title or id or date $hostName = $_SERVER['HTTP_HOST']; //read the whole query string: $searchURL = $_SERVER['QUERY_STRING']; //decode it ! $searchURL = urldecode($searchURL); //control if some request variables are not set and set them explicit to NULL $checkForNullRequests = array("registratingDepartments", "isoCategories", "inspireThemes", "customCategories", "regTimeBegin", "regTimeEnd", "timeBegin", "timeEnd", "searchBbox", "searchTypeBbox", "searchResources", "orderBy", "hostName"); for ($i = 0; $i < count($checkForNullRequests); $i++) { if (!$_REQUEST[$checkForNullRequests[$i]] or $_REQUEST[$checkForNullRequests[$i]] == 'false' or $_REQUEST[$checkForNullRequests[$i]] == 'undefined') { $_REQUEST[$checkForNullRequests[$i]] = ""; $searchURL = delTotalFromQuery($checkForNullRequests[$i], $searchURL);