svn commit: r777 - trunk/mapbender/http/javascripts/wfs.js
christoph at osgeo.org
christoph at osgeo.org
Fri Sep 29 04:16:06 EDT 2006
Author: christoph
Date: 2006-09-29 08:16:06+0000
New Revision: 777
Modified:
trunk/mapbender/http/javascripts/wfs.js
Log:
moved highlighting tools to mod_highlight.php
Modified: trunk/mapbender/http/javascripts/wfs.js
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/wfs.js?view=diff&rev=777&p1=trunk/mapbender/http/javascripts/wfs.js&p2=trunk/mapbender/http/javascripts/wfs.js&r1=776&r2=777
==============================================================================
--- trunk/mapbender/http/javascripts/wfs.js (original)
+++ trunk/mapbender/http/javascripts/wfs.js 2006-09-29 08:16:06+0000
@@ -1,5 +1,6 @@
<?php
require_once("mod_geometryArray.js");
+require_once("mod_highlight.js");
require_once("wfs_usemap.js");
?>
var digiFrame = "digitize";
@@ -15,23 +16,20 @@
var mb_wfs_objwin_width = 200;
var mb_wfs_objwin_height = 200;
var mb_wfs_targets = new Array("mapframe1","overview");
-var mb_wfs_minPix = 8;
var mb_wfs_maxBasePoints = 200;
-var mb_wfs_lineColor = "#ff0000";
var mb_wfs_fillColor = "#ff0000";
-var mb_wfs_diameter = 8;
var usemap = "";
var mod_usemap_radius = 10;
var mod_usemap_line_tolerance = 5;
-var canvas = new Array();
-var canvasHasDrawing = new Array();
var useCheckboxForHighlighting = true;
+var highlight = new Highlight(mb_wfs_targets);
+
if (parseInt(useUsemap) == 1) {
mb_registerSubFunctions('mod_usemap("")');
}
if (useCheckboxForHighlighting) {
- mb_registerSubFunctions('highlightGeometry()');
+ mb_registerSubFunctions('highlight.paint()');
}
/*
@@ -170,15 +168,6 @@
tmp.style.visibility = 'hidden';
}
-function mb_wz_repaint() {
- for (var i = 0 ; i < mb_wfs_targets.length ; i ++) {
- mf = mb_wfs_targets[i];
- if (canvas[mf]) {
- canvas[mf].paint();
- }
- }
-}
-
function mb_wfs_register(n,a){
var tmp = n.split("_");
var current_wfs_name = tmp[3];
@@ -260,7 +249,7 @@
if(k != -1){
str += "<tr><td><img src = '"+buttonWfs_toDigitize_src+"' title='"+buttonWfs_toDigitize_title+"' onClick = 'tab_open(digiFrame);parent.window.frames[digiFrame].appendGeometry(mb_wfs_fetch.get("+i+"))'></td><td>";
if (useCheckboxForHighlighting) {
- str += "<input type=checkbox id=highlightCheckbox" + i + " onClick='highlightGeometry()'></td><td>";
+ str += "<input type=checkbox id=highlightCheckbox" + i + " onChange='highlightGeometry(" + i + ")'></td><td>";
}
str += "<div";
if (!useCheckboxForHighlighting) {
@@ -275,26 +264,7 @@
}
str += "</table>";
mb_wfs_objwin.innerHTML = str;
- if (parseInt(useUsemap) == 1) {
- mod_usemap(wfs_name);
- }
-}
-
-function highlightGeometry() {
- mb_wfs_wzClean();
- mb_wfs_checkTag();
-
- var l = mb_wfs_fetch.count();
- for (var i = 0; i < l ; i++) {
- var id = "highlightCheckbox"+i;
- var cb = document.getElementById(id);
- if (cb) {
- if (cb.checked) {
- mb_wfs_draw(mb_wfs_fetch.get(i));
- }
- }
- }
- mb_wz_repaint();
+ if (parseInt(useUsemap) == 1) mod_usemap(wfs_name);
}
function get_wfs_conf(index) {
@@ -307,23 +277,18 @@
return wfs_conf;
}
+function highlightGeometry(i) {
+ var id = "highlightCheckbox"+i;
+ if (document.getElementById(id).checked) highlight.add(mb_wfs_fetch.get(i));
+ else highlight.del(mb_wfs_fetch.get(i));
+}
+
function mb_wfs_perform(type,m){
+
var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
- if(type=='over'){
- mb_wfs_checkTag();
- mb_wfs_draw(m);
- mb_wz_repaint();
- }
- if(type=='out'){
- if (useCheckboxForHighlighting) {
- highlightGeometry();
- }
- else {
- mb_wfs_wzClean();
- }
- }
- if(type=='click'){
- mb_wfs_checkTag();
+ if(type=='over') highlight.add(m);
+ else if(type=='out') highlight.del(m);
+ else if(type=='click') {
var tmp = m.getBBox();
var b = parseFloat(wfs_conf[m.wfs_conf]['g_buffer']);
var buffer = new Point(b,b);
@@ -331,9 +296,6 @@
var bbox_ru = tmp[1].plus(buffer);
mb_calcExtent(mb_wfs_targets[0],bbox_ll, bbox_ru);
zoom(mb_wfs_targets[0], 'true', 1.0);
- if (!useCheckboxForHighlighting) {
- mb_wfs_draw(m);
- }
}
}
@@ -343,114 +305,3 @@
}
return false;
}
-
-function mb_wfs_checkPix(frame,g){
- var tmp = g.getBBox();
- var minpix = realToMap(frame,tmp[0]);
- var maxpix = realToMap(frame,tmp[1]);
- if((maxpix.x - minpix.x < mb_wfs_minPix) && (maxpix.y - minpix.y < mb_wfs_minPix)){
- return false;
- }
- return true;
-}
-
-function mb_wfs_draw(m){
- var t = m.geomtype;
- if(t == geomTypePoint){
- for(var i=0; i<mb_wfs_targets.length; i++){
- mb_wfs_wz(mb_wfs_targets[i],geomTypePoint,m);
- }
- }
- else {
- var r = m.getCenter();
- var newMember = new MultiGeometry();
- newMember.addGeometry();
- newMember.get(-1).addPoint(r);
- if(t == geomTypeLine){
- for(var i=0; i<mb_wfs_targets.length; i++){
- var c = mb_wfs_checkPix(mb_wfs_targets[i],m);
- if(c == false){
- mb_wfs_wz(mb_wfs_targets[i],geomTypePoint,newMember);
- }
- else{
- mb_wfs_wz(mb_wfs_targets[i],geomTypeLine,m);
- }
- }
- }
- else if(t == geomTypePolygon){
- for(var i=0; i<mb_wfs_targets.length; i++){
- var c = mb_wfs_checkPix(mb_wfs_targets[i],m);
- if(c == false){
- mb_wfs_wz(mb_wfs_targets[i],geomTypePoint,newMember);
- }
- else{
- mb_wfs_wz(mb_wfs_targets[i],geomTypePolygon,m);
- }
- }
- }
- else{
- alert("unknown geomtype");
- }
- }
-
-}
-function mb_wfs_wz(mf,t,g){
- if(t==geomTypePoint){
- for(var i=0; i<g.count(); i++){
- var apos = mb_wfs_toPix(mf,g.get(i));
- canvas[mf].setColor(mb_wfs_lineColor);
- canvas[mf].drawEllipse((apos['x'][0]-mb_wfs_diameter/2),(apos['y'][0]-mb_wfs_diameter/2),mb_wfs_diameter,mb_wfs_diameter);
- }
- }
- else if(t==geomTypeLine){
- for(var i=0; i<g.count(); i++){
- var apos = mb_wfs_toPix(mf,g.get(i));
- canvas[mf].setColor(mb_wfs_lineColor);
- canvas[mf].drawPolyline(apos['x'],apos['y']);
- }
- }
- else if(t==geomTypePolygon){
- for(var i=0; i<g.count(); i++){
- var apos = mb_wfs_toPix(mf,g.get(i));
- canvas[mf].setColor(mb_wfs_lineColor);
- canvas[mf].drawPolygon(apos['x'],apos['y']);
- }
- }
-}
-
-function mb_wfs_wzClean(){
- for(var i=0; i<mb_wfs_targets.length; i++){
- var el = window.frames[mb_wfs_targets[i]].document.getElementById('mod_gaz_draw');
- if (el) el.innerHTML = "";
- canvasHasDrawing[mb_wfs_targets[i]] = false;
- }
- return true;
-}
-
-function mb_wfs_checkTag(){
- for(var i=0; i<mb_wfs_targets.length; i++){
- var isTag = (window.frames[mb_wfs_targets[i]].document.getElementById('mod_gaz_draw'))?1:0;
- if(isTag == 0){
- var draw = window.frames[mb_wfs_targets[i]].document.createElement("div");
- var tmp = window.frames[mb_wfs_targets[i]].document.getElementsByTagName("body")[0].appendChild(draw);
- tmp.setAttribute("id","mod_gaz_draw");
- tmp.setAttribute("style","position:absolute;top:0px;left:0px;width:0px;height:0px;z-index:100");
- }
- canvas[mb_wfs_targets[i]] = new jsGraphics('mod_gaz_draw', window.frames[mb_wfs_targets[i]]);
- canvas[mb_wfs_targets[i]].setStroke(3);
- canvasHasDrawing[mb_wfs_targets[i]] = false;
- }
- return true;
-}
-
-function mb_wfs_toPix(mf,g){
- var r = new Array();
- r['x'] = new Array();
- r['y'] = new Array();
- for(var i=0; i<g.count(); i++){
- var currentV = realToMap(mf,g.get(i));
- r['x'][i] = currentV.x;
- r['y'][i] = currentV.y;
- }
- return r;
-}
\ No newline at end of file
More information about the Mapbender_commits
mailing list