[Mapbender-commits] r1349 - in trunk/mapbender: conf http/css http/javascripts http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu May 24 06:02:47 EDT 2007


Author: christoph
Date: 2007-05-24 06:02:47 -0400 (Thu, 24 May 2007)
New Revision: 1349

Added:
   trunk/mapbender/conf/gazetteerSQL.conf
   trunk/mapbender/http/css/gazetteerSQL_ALB.css
   trunk/mapbender/http/css/gazetteerSQL_ALK.css
   trunk/mapbender/http/css/gazetteerSQL_Address.css
   trunk/mapbender/http/javascripts/mod_gazetteerSQL_client.php
   trunk/mapbender/http/php/mod_gazetteerSQL_server.php
Log:
sql gazetteer (no documentation yet)

Added: trunk/mapbender/conf/gazetteerSQL.conf
===================================================================
--- trunk/mapbender/conf/gazetteerSQL.conf	                        (rev 0)
+++ trunk/mapbender/conf/gazetteerSQL.conf	2007-05-24 10:02:47 UTC (rev 1349)
@@ -0,0 +1,12 @@
+<?php
+# postgres-db-params
+$host = "<host>";
+$port = "5432";
+$dbname = "<dbname>";
+$user = "<user>";
+$password = "<password>";
+
+$connstring = "host=$host port=$port dbname=$dbname user=$user password=$password";
+
+#define("SQL_SEARCH_DBNAME", "");
+?>

Added: trunk/mapbender/http/css/gazetteerSQL_ALB.css
===================================================================
--- trunk/mapbender/http/css/gazetteerSQL_ALB.css	                        (rev 0)
+++ trunk/mapbender/http/css/gazetteerSQL_ALB.css	2007-05-24 10:02:47 UTC (rev 1349)
@@ -0,0 +1,81 @@
+	    body{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectCommune{
+	    	position:absolute;
+	    	top:10px;
+	    	left:5px;
+	    	width:150px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectStreet{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .selectDistrict{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .divOwner{
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    }
+	    .inputOwner{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 55px;
+	    }
+	    .divParcel{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:125px;
+	    	left:5px;
+	    }
+	    .inputParcel1{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .inputParcel2{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .divResults{
+	    	position:absolute;
+	    	top:90px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    a:link {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:visited {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:active {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
\ No newline at end of file

Added: trunk/mapbender/http/css/gazetteerSQL_ALK.css
===================================================================
--- trunk/mapbender/http/css/gazetteerSQL_ALK.css	                        (rev 0)
+++ trunk/mapbender/http/css/gazetteerSQL_ALK.css	2007-05-24 10:02:47 UTC (rev 1349)
@@ -0,0 +1,79 @@
+	    body{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectCommune{
+	    	position:absolute;
+	    	top:10px;
+	    	left:5px;
+	    	width:150px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectStreet{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .selectDistrict{
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .divOwner{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:125px;
+	    	left:5px;
+	    }
+	    .inputOwner{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 100px;
+	    }
+	    .divParcel{
+	    	position:absolute;
+	    	top:125px;
+	    	left:5px;
+	    }
+	    .inputParcel1{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .inputParcel2{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .divResults{
+	    	position:absolute;
+	    	top:160px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    a:link {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:visited {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:active {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
\ No newline at end of file

Added: trunk/mapbender/http/css/gazetteerSQL_Address.css
===================================================================
--- trunk/mapbender/http/css/gazetteerSQL_Address.css	                        (rev 0)
+++ trunk/mapbender/http/css/gazetteerSQL_Address.css	2007-05-24 10:02:47 UTC (rev 1349)
@@ -0,0 +1,82 @@
+	    body{
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectCommune{
+	    	position:absolute;
+	    	top:10px;
+	    	left:5px;
+	    	width:150px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    }
+	    .selectStreet{
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .selectDistrict{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:40px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    .divOwner{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:125px;
+	    	left:5px;
+	    }
+	    .inputOwner{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 100px;
+	    }
+	    .divParcel{
+			visibility:hidden;
+	    	position:absolute;
+	    	top:125px;
+	    	left:5px;
+	    }
+	    .inputParcel1{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .inputParcel2{
+			visibility:hidden;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 30px;
+	    }
+	    .divResults{
+	    	position:absolute;
+	    	top:120px;
+	    	left:5px;
+	    	font-family : Arial, Helvetica, sans-serif;
+	    	font-size: 11px;
+	    	width: 150px;
+	    }
+	    a:link {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:visited {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
+	    a:active {
+	    	text-decoration: none;
+	    	font-family: Arial, Helvetica, sans-serif;
+	    	color: black;
+	    }
\ No newline at end of file

Added: trunk/mapbender/http/javascripts/mod_gazetteerSQL_client.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_gazetteerSQL_client.php	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_gazetteerSQL_client.php	2007-05-24 10:02:47 UTC (rev 1349)
@@ -0,0 +1,389 @@
+<?php
+session_start();
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+
+$e_id = $_REQUEST["elementID"];
+$e_target = explode(",", $_REQUEST["e_target"]);
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET;?>">
+<title>Gazetteer</title>
+<?php
+include '../include/dyn_css.php';
+?>
+<script type="text/javascript">
+
+var targetFrameArray = [];
+<?php
+echo "var e_id = '". $e_id . "';";
+for ($i = 0; $i < count($e_target); $i++) {
+	echo "targetFrameArray.push('".$e_target[$i]."');";
+}
+?>
+<!--
+// --- begin: expected element vars ---
+// var scale 
+// var numberOfResults
+// var profile = "adresse" | "alk" | "alb"
+
+if (typeof(scale) == 'undefined') {
+	var scale = 2000;
+	var e = new parent.Mb_warning("mod_gazetteerSQL: element var scale is missing.");
+}
+if (typeof(numberOfResults) == 'undefined') {
+	var numberOfResults = 0;
+	var e = new parent.Mb_warning("mod_gazetteerSQL: element var numberOfResults is missing.");
+}
+if (typeof(tooManyResultsString) == 'undefined') {
+	var tooManyResultsString = "Too many results. Please specify your query.";
+	var e = new parent.Mb_warning("mod_gazetteerSQL: element var tooManyResultsString is missing.");
+}
+if (typeof(profile) == 'undefined' || (profile != "alb" && profile != "alk" && profile != "adresse")) {
+	profile = "adresse"
+	var e = new parent.Mb_exception("mod_gazetteerSQL: element var profile is missing.");
+}
+
+// --- end: expected element vars ---
+
+
+var generalPreFunctions = [];
+var generalSubFunctions = [];
+var onloadSubFunctions = [];
+var communesSubFunctions = [];
+var streetSubFunctions = [];
+var numberSubFunctions = [];
+var districtSubFunctions = [];
+var parcelSubFunctions = [];
+var ownerSubFunctions = [];
+
+registerFunction(generalPreFunctions, "disableForm();");
+registerFunction(generalSubFunctions, "enableForm();");
+if (profile == "alb") {
+	registerFunction(onloadSubFunctions, "updateCommunes();");
+	registerFunction(communesSubFunctions, "updateOwner();");
+	registerFunction(ownerSubFunctions, "updateOwner();");
+}
+else if (profile == "alk") {
+	registerFunction(onloadSubFunctions, "updateCommunes();");
+	registerFunction(communesSubFunctions, "updateDistricts();");
+	registerFunction(parcelSubFunctions, "updateParcels();");
+}
+else if (profile == "adresse") {
+	registerFunction(onloadSubFunctions, "updateCommunes();");
+	registerFunction(communesSubFunctions, "updateStreets();");
+	registerFunction(streetSubFunctions, "updateNumbers();");
+}
+
+function executeFunctions(arrayOfFunctionStrings) {
+	for (var i = 0; i < arrayOfFunctionStrings.length; i++) {
+		eval(arrayOfFunctionStrings[i]);
+	}
+}
+
+function registerFunction(functionStringArray, functionString) {
+	functionStringArray.push(functionString);
+}
+
+function disableForm() {
+	document.getElementById('selectCommune').disabled = true;
+	document.getElementById('selectStreet').disabled = true;
+	document.getElementById('selectDistrict').disabled = true;
+	document.getElementById('inputParcel1').disabled = true;
+	document.getElementById('inputParcel2').disabled = true;
+	document.getElementById('inputParcelButton').disabled = true;
+	document.getElementById('inputOwner').disabled = true;
+	document.getElementById('inputOwnerButton').disabled = true;
+	document.getElementById("divResults").innerHTML = searchImage;
+}
+
+function enableForm() {
+	document.getElementById('selectCommune').removeAttribute("disabled");
+	document.getElementById('selectStreet').removeAttribute("disabled");
+	document.getElementById('selectDistrict').removeAttribute("disabled");
+	document.getElementById('inputParcel1').removeAttribute("disabled");
+	document.getElementById('inputParcel2').removeAttribute("disabled");
+	document.getElementById('inputParcelButton').removeAttribute("disabled");
+	document.getElementById('inputOwner').removeAttribute("disabled");
+	document.getElementById('inputOwnerButton').removeAttribute("disabled");
+	document.getElementById("divResults").innerHTML = "";
+}
+
+var highlight;
+var houseLocation;
+var parcelLocation;
+var searchImage = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
+var phpUrl = "../php/mod_gazetteerSQL_server.php";
+
+parent.mb_registerInitFunctions("window.frames['"+e_id+"'].initHighlight()");
+parent.mb_registerInitFunctions("window.frames['"+e_id+"'].updateCommunes()");
+
+
+// - BEGIN -------- HIGHLIGHTING AND ZOOMING ------------------------------------------
+
+function zoomToLocation(aPoint) {
+	parent.mb_repaintScale(targetFrameArray[0], aPoint.x, aPoint.y, scale)
+}
+
+function initHighlight() {
+	var generalHighlightZIndex = 100;
+	var generalHighlightLineWidth = 3;
+	var styleObj = {"position":"absolute", "top":"0px", "left":"0px", "z-index":generalHighlightZIndex};
+	highlight = new parent.Highlight(targetFrameArray, e_id, styleObj, generalHighlightLineWidth);
+}
+
+function zoomToHouseNumber(houseNumber) {
+	zoomToLocation(houseLocation[houseNumber]);
+	removeHighlight();
+	highlightHouseNumber(houseNumber);
+}
+
+function zoomToParcel(parcelId) {
+	zoomToLocation(parcelLocation[parcelId]);
+	removeHighlight();
+	highlightParcel(parcelId);
+}
+
+function highlightHouseNumber(houseNumber) {
+	var mG = new parent.MultiGeometry(parent.geomType.point);
+	mG.addGeometry();
+	mG.get(-1).addPoint(houseLocation[houseNumber]);
+	highlight.add(mG);
+}
+
+function highlightParcel(parcelId) {
+	var mG = new parent.MultiGeometry(parent.geomType.point);
+	mG.addGeometry();
+	mG.get(-1).addPoint(parcelLocation[parcelId]);
+	highlight.add(mG);
+}
+
+function removeHighlight() {
+	highlight.clean();
+}
+
+// - END -------- HIGHLIGHTING AND ZOOMING ------------------------------------------
+
+
+
+function removeChildNodes(node) {
+	while (node.childNodes.length > 0) {
+		var childNode = node.firstChild;
+		node.removeChild(childNode);
+	}
+}
+
+function getSize(result) {
+	if (typeof(result) == "array") {
+		return result.length;
+	}
+	else if (typeof(result) == "object") {
+		var c = 0;
+		for (var attr in result) {
+			c++;
+		}
+		return c;
+	}
+	return 1;
+}
+
+function updateCommunes() {
+	executeFunctions(generalPreFunctions);
+	parent.mb_ajax_json(phpUrl, {"command":"getCommunes"}, function (json, status) {
+		executeFunctions(generalSubFunctions);
+
+		removeChildNodes(document.getElementById('selectCommune'));
+
+		for (var communeId in json.communes) {
+			if (typeof(json.communes[communeId]) != 'function') {
+				var currentNode = document.createElement("option");
+			
+				if (document.getElementById('selectCommune').childNodes.length == 0) {
+					currentNode.selected = "selected";
+				}
+				currentNode.value = communeId;
+				currentNode.innerHTML = json.communes[communeId];
+				document.getElementById('selectCommune').appendChild(currentNode);
+			}
+		}
+		executeFunctions(communesSubFunctions);
+	});
+}
+
+function updateStreets() {
+	executeFunctions(generalPreFunctions);
+	var communeId = document.getElementById('selectCommune').value;
+	
+	parent.mb_ajax_json(phpUrl, {"command":"getStreets", "communeId":communeId}, function (json, status) {
+		executeFunctions(generalSubFunctions);
+
+		removeChildNodes(document.getElementById('selectStreet'));
+
+
+		for (var streetId in json.streets) {
+			if (typeof(json.streets[streetId]) != 'function') {
+				var currentNode = document.createElement("option");
+	
+				if (document.getElementById('selectStreet').childNodes.length == 0) {
+					currentNode.selected = "selected";
+				}
+				
+				currentNode.innerHTML = json.streets[streetId];
+				document.getElementById('selectStreet').appendChild(currentNode);
+			}
+		}
+		executeFunctions(streetSubFunctions);
+	});
+}
+
+function updateDistricts() {
+	executeFunctions(generalPreFunctions);
+
+	var communeId = document.getElementById('selectCommune').value;
+	
+	parent.mb_ajax_json(phpUrl, {"command":"getDistricts", "communeId":communeId}, function (districtObject, status) {
+		executeFunctions(generalSubFunctions);
+
+		removeChildNodes(document.getElementById('selectDistrict'));
+
+		for (var districtId in districtObject.districts) {
+			if (typeof(districtObject.districts[districtId]) != 'function') {
+				var currentNode = document.createElement("option");
+	
+				currentNode.value = districtId;
+	
+				if (document.getElementById('selectDistrict').childNodes.length == 0) {
+					currentNode.selected = "selected";
+				}
+				
+				currentNode.innerHTML = districtObject.districts[districtId];
+				document.getElementById('selectDistrict').appendChild(currentNode);
+			}
+		}
+		executeFunctions(districtSubFunctions);
+	});
+}
+
+function updateNumbers() {
+	executeFunctions(generalPreFunctions);
+
+	var streetName = document.getElementById('selectStreet').value;
+	var communeId = document.getElementById('selectCommune').value;
+
+	parent.mb_ajax_json(phpUrl, {"command":"getNumbers", "communeId":communeId, "streetName":streetName, "numberOfResults":numberOfResults}, function (json, status) {
+		executeFunctions(generalSubFunctions);
+		houseLocation = {};
+		var resultString = "";
+		if (getSize(json.houseNumbers) > 0) {
+			if (json.limited === true) {
+				resultString += tooManyResultsString;
+			}
+			for (var houseNumber in json.houseNumbers) {
+				if (typeof(json.houseNumbers[houseNumber]) != 'function') {
+					houseLocation[houseNumber] = new parent.Point(json.houseNumbers[houseNumber].x, json.houseNumbers[houseNumber].y);
+					resultString += "<b style=\"cursor:pointer\" onclick=\"zoomToHouseNumber('"+houseNumber+"')\" onmouseover=\"highlightHouseNumber('"+houseNumber+"')\" onmouseout=\"removeHighlight()\">"+houseNumber+"</b>&nbsp;&nbsp; ";
+				}
+			}
+		}
+		else {
+			resultString += noResultsString;
+		}
+		document.getElementById("divResults").innerHTML = resultString;
+		executeFunctions(numberSubFunctions);
+	});
+}
+
+function updateParcels() {
+	executeFunctions(generalPreFunctions);
+	
+	var districtId = document.getElementById('selectDistrict').value;
+	var inputParcel1 = document.getElementById('inputParcel1').value;
+	var inputParcel2 = document.getElementById('inputParcel2').value;
+
+
+	parent.mb_ajax_json(phpUrl, {"command":"getLandparcelsByDistrict", "districtId":districtId, "parcelNumber1":inputParcel1, "parcelNumber2":inputParcel2, "numberOfResults":numberOfResults}, function (json, status) {
+		executeFunctions(generalSubFunctions);
+
+		parcelLocation = {};
+		var resultString = "";
+		if (getSize(json.landparcels) > 0) {
+			if (json.limited === true) {
+				resultString += tooManyResultsString;
+			}
+			resultString += "<ol>";
+			for (var parcelId in json.landparcels) {
+				if (typeof(json.landparcels[parcelId]) != 'function') {
+					parcelLocation[parcelId] = new parent.Point(json.landparcels[parcelId].x, json.landparcels[parcelId].y);
+					resultString += "<li style=\"cursor:pointer\" onclick=\"zoomToParcel('"+parcelId+"')\" onmouseover=\"highlightParcel('"+parcelId+"')\" onmouseout=\"removeHighlight()\">"+parcelId+"</li>";
+				}
+			}
+			resultString += "</ol>";
+		}
+		else {
+			resultString += noResultsString;
+		}
+		document.getElementById("divResults").innerHTML = resultString;
+		executeFunctions(numberSubFunctions);
+	});
+}
+
+function updateOwner() {
+	var ownerQueryString = document.getElementById('inputOwner').value;
+	var communeId = document.getElementById('selectCommune').value;
+
+	document.getElementById("divResults").innerHTML = "";
+	document.getElementById('selectCommune').removeAttribute("disabled");
+	document.getElementById('inputOwner').removeAttribute("disabled");
+	document.getElementById('inputOwnerButton').removeAttribute("disabled");
+	
+	if (ownerQueryString != "") {
+		executeFunctions(generalPreFunctions);
+		parent.mb_ajax_json(phpUrl, {"command":"getLandparcelsByOwner", "communeId":communeId, "ownerQueryString":ownerQueryString, "numberOfResults":numberOfResults}, function (json, status) {
+			executeFunctions(generalSubFunctions);
+
+			parcelLocation = {};
+			var resultString = "";
+			if (getSize(json.landparcels) > 0) {
+				if (json.limited === true) {
+					resultString += tooManyResultsString;
+				}
+				resultString += "<ol>";
+				for (var i=0; i < json.landparcels.length; i++) {
+					var parcelId = json.landparcels[i].landparcelId;
+					parcelLocation[parcelId] = new parent.Point(json.landparcels[i].x, json.landparcels[i].y);
+					resultString += "<li style=\"cursor:pointer\" onclick=\"zoomToParcel('"+parcelId+"')\" onmouseover=\"highlightParcel('"+parcelId+"')\" onmouseout=\"removeHighlight()\">"+json.landparcels[i].owner+ " (" + parcelId+")</li>";
+				}
+				resultString += "</ol>";
+			}
+			else {
+				resultString += noResultsString;
+			}
+			document.getElementById("divResults").innerHTML = resultString;
+			executeFunctions(numberSubFunctions);
+	
+		});
+	}
+}
+// -->
+</script>
+</head>
+<body>
+<form>
+<select class='selectCommune' id='selectCommune' onchange='executeFunctions(communesSubFunctions)'></select>
+<select class='selectStreet' id='selectStreet' onchange='executeFunctions(streetSubFunctions);' size=5 disabled></select>
+<select class='selectDistrict' id='selectDistrict' onchange='executeFunctions(districtSubFunctions);' size=5 disabled></select>
+<div id='divParcel' class='divParcel'>
+Flur: <input type='input' class='inputParcel1' id='inputParcel1' disabled></select>
+Flstz: <input type='input' class='inputParcel2' id='inputParcel2' disabled></select>
+<input type='button' id='inputParcelButton' value='?' onclick='executeFunctions(parcelSubFunctions);'>
+</div>
+<div id='divOwner' class='divOwner'>
+Eigent&uuml;mer: <input type='input' class='inputOwner' id='inputOwner' disabled></select>
+<input type='button' id='inputOwnerButton' value='?' onclick='executeFunctions(ownerSubFunctions);'>
+</div>
+</form>
+<div class='divResults' id='divResults'></div>
+</body>
+</html>
\ No newline at end of file

Added: trunk/mapbender/http/php/mod_gazetteerSQL_server.php
===================================================================
--- trunk/mapbender/http/php/mod_gazetteerSQL_server.php	                        (rev 0)
+++ trunk/mapbender/http/php/mod_gazetteerSQL_server.php	2007-05-24 10:02:47 UTC (rev 1349)
@@ -0,0 +1,188 @@
+<?php
+session_start();
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../../conf/gazetteerSQL.conf");
+
+//$connstring = " user=" . OWNER . " dbname=".SQL_SEARCH_DBNAME." host=".DBSERVER." password=".PW;	
+$con = 	pg_connect($connstring);		
+
+$command = $_GET["command"];
+$communeId = $_GET["communeId"];
+$streetName = $_GET["streetName"];
+$districtId = $_GET["districtId"];
+$parcelNumber1 = $_GET["parcelNumber1"];
+$parcelNumber2 = $_GET["parcelNumber2"];
+$ownerQueryString = $_GET["ownerQueryString"];
+$numberOfResults = $_GET["numberOfResults"];
+
+if (isLimited($numberOfResults)) {
+	$limit = $numberOfResults + 1; 
+}
+else {
+	$limit = 0;
+}
+
+$obj = array();
+
+function isLimited($numberOfResults) {
+	if (isset($numberOfResults) && $numberOfResults > 0) {
+		return true;
+	}
+	return false;
+}
+
+function isUnderLimit($counter, $numberOfResults, $max) {
+	return (!isLimited($numberOfResults) || $counter <= $max);
+}
+
+function isOverLimit($counter, $numberOfResults, $max) {
+	return (isLimited($numberOfResults) && $counter > $max);
+}
+
+if ($command == "getCommunes") {
+	$obj["communes"] = array();
+
+	$sql = "SELECT DISTINCT gkz, name FROM public.gemeinden ORDER BY name";
+	$v = array();
+	$t = array();
+	$res = db_prep_query($sql, $v, $t);
+	while($row = db_fetch_array($res)){
+		$communeId = trim($row["gkz"]);
+		$communeName = trim($row["name"]);
+		$obj["communes"][$communeId] = $communeName;
+	}
+	$obj["limited"] = false;
+}
+else if ($command == "getStreets") {
+	$obj["streets"] = array();
+
+	$sql = "SELECT DISTINCT strk_schl, str_name FROM alb.navigation WHERE gkz = $1 ORDER BY str_name";
+	$v = array($communeId);
+	$t = array("i");
+	$res = db_prep_query($sql, $v, $t);
+	while($row = db_fetch_array($res)){
+		$streetId = trim($row["strk_schl"]);
+		$streetName = trim($row["str_name"]);
+		$obj["streets"][$streetId] = $streetName;
+	}
+	$obj["limited"] = false;
+}
+else if ($command == "getNumbers") {
+	$obj["houseNumbers"] = array();
+	
+	$sql = "SELECT DISTINCT hnr, hnrzu, rw, hw FROM alb.navigation WHERE gkz = $1 AND str_name ILIKE $2 ORDER BY hnr, hnrzu";
+	$v = array($communeId, $streetName."%");
+	$t = array("i", "s");
+
+	if (isLimited($numberOfResults)) {
+		$sql .= " LIMIT $2";
+		array_push($v, $limit);
+		array_push($t, "i");
+	}
+
+	$res = db_prep_query($sql, $v, $t);
+
+	$counter = 0;
+	while($row = db_fetch_array($res)){
+		$counter++;
+		if (isUnderLimit($counter, $numberOfResults, $numberOfResults)) {
+			$houseNumber = trim($row["hnr"] . $row["hnrzu"]);
+			$x = trim(floatval($row["rw"]));
+			$y = trim(floatval($row["hw"]));
+			$obj["houseNumbers"][$houseNumber] = array("x" => $x, "y" => $y);
+		}
+	}
+	$obj["limited"] = isOverLimit($counter, $numberOfResults, $numberOfResults);
+}
+else if ($command == "getLandparcelsByOwner") {
+	$obj["landparcels"] = array();
+
+	$sql = "SELECT DISTINCT eig.e_name, flst.flst_kennz, flst.rechtsw, flst.hochw FROM alb.albflst AS flst JOIN alb.albeig AS eig ON (flst.gemschl = eig.gemschl AND flst.flur = eig.flur AND flst.flstz = eig.flstz AND flst.flstn = eig.flstn) JOIN public.gemarkungen AS gem ON (flst.gemschl = gem.gemschl) WHERE gem.gkz = $1 AND eig.e_name ILIKE $2 ORDER BY flst.flst_kennz";
+	$v = array($communeId, "%".$ownerQueryString."%");
+	$t = array("i", "s");
+
+	if (isLimited($numberOfResults)) {
+		$sql .= " LIMIT $3";
+		array_push($v, $limit);
+		array_push($t, "i");
+	}
+	$res = db_prep_query($sql, $v, $t);
+
+	$counter = 0;
+	while($row = db_fetch_array($res)){
+		$counter++;
+		if (isUnderLimit($counter, $numberOfResults, $numberOfResults)) {
+			$landparcelId = $row["flst_kennz"];
+			$x = trim(floatval($row["rechtsw"]));
+			$y = trim(floatval($row["hochw"]));
+			$owner = trim($row["e_name"]);
+			array_push($obj["landparcels"], array("landparcelId" => $landparcelId, "owner" => $owner, "x" => $x, "y" => $y));
+		}
+	}
+	$obj["limited"] = isOverLimit($counter, $numberOfResults, $numberOfResults);
+}
+else if ($command == "getLandparcelsByDistrict") {
+	$obj["landparcels"] = array();
+	$paramCounter = 0;
+
+	$sql = "SELECT DISTINCT flst_kennz, rechtsw, hochw FROM alb.albflst WHERE gemschl = $" . ++$paramCounter;
+	$v = array($districtId);
+	$t = array("i");
+	if (!empty($parcelNumber1)) {
+		$sql .= " AND flur = $" . ++$paramCounter;
+		array_push($v, $parcelNumber1);
+		array_push($t, "i");
+	}
+	if (!empty($parcelNumber2)) {
+		$sql .= " AND flstz = $" . ++$paramCounter;
+		array_push($v, $parcelNumber2);
+		array_push($t, "i");
+	}
+	$sql .= " ORDER BY flst_kennz";
+	if (isLimited($numberOfResults)) {
+		$sql .= " LIMIT $" . ++$paramCounter;
+		array_push($v, $limit);
+		array_push($t, "i");
+	}
+	$res = db_prep_query($sql, $v, $t);
+
+	$counter = 0;
+	while($row = db_fetch_array($res)){
+		$counter++;
+		if (isUnderLimit($counter, $numberOfResults, $numberOfResults)) {
+			$landparcelId = $row["flst_kennz"];
+			$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 Services_JSON();
+$output = $json->encode($obj);
+echo $output;
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list