1
|
/*
|
2
|
Author: Mike Adair mike.adairATccrs.nrcan.gc.ca
|
3
|
Author: Cameron Shorter cameronATshorter.net
|
4
|
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
5
|
|
6
|
$Id$
|
7
|
*/
|
8
|
// Ensure this object's dependancies are loaded.
|
9
|
mapbuilder.loadScript(baseDir+"/widget/GmlRenderer.js");
|
10
|
|
11
|
/**
|
12
|
* Render an Area Of Interest (AOI) Box over a map.
|
13
|
* This widget extends GmlRenderer and uses GmlRenderer.xsl to build the HTML box.
|
14
|
* @constructor
|
15
|
* @base GmlRenderer
|
16
|
* @param widgetNode The widget's XML object node from the configuration document.
|
17
|
* @param model The model object that this widget belongs to.
|
18
|
*/
|
19
|
function AoiBox2(widgetNode, model) {
|
20
|
// Inherit the GmlRenderer functions and parameters
|
21
|
var base = new GmlRenderer(widgetNode, model);
|
22
|
for (sProperty in base) {
|
23
|
this[sProperty] = base[sProperty];
|
24
|
}
|
25
|
|
26
|
/** Use the GmlRenderer stylesheet. */
|
27
|
this.stylesheet=new XslProcessor(baseDir+"/widget/GmlRenderer.xsl");
|
28
|
|
29
|
/**
|
30
|
* Build Gml Envelope from AOI and set XSL params.
|
31
|
* @param objRef Pointer to this object.
|
32
|
*/
|
33
|
this.prePaint = function(objRef) {
|
34
|
objRef.stylesheet.setParameter("width", objRef.targetModel.getWindowWidth() );
|
35
|
objRef.stylesheet.setParameter("height", objRef.targetModel.getWindowHeight() );
|
36
|
bBox=objRef.targetModel.getBoundingBox();
|
37
|
objRef.stylesheet.setParameter("bBoxMinX", bBox[0]);
|
38
|
objRef.stylesheet.setParameter("bBoxMinY", bBox[1]);
|
39
|
objRef.stylesheet.setParameter("bBoxMaxX", bBox[2]);
|
40
|
objRef.stylesheet.setParameter("bBoxMaxY", bBox[3]);
|
41
|
objRef.stylesheet.setParameter("color", "#FF0000");
|
42
|
objRef.stylesheet.setParameter("crossSize", "15");
|
43
|
objRef.stylesheet.setParameter("lineWidth", "1");
|
44
|
|
45
|
aoiBox = objRef.model.getParam("aoi");
|
46
|
gml='<?xml version="1.0" encoding="utf-8" standalone="no"?>';
|
47
|
if (aoiBox) {
|
48
|
ul = objRef.model.extent.getPL(aoiBox[0]);
|
49
|
lr = objRef.model.extent.getPL(aoiBox[1]);
|
50
|
gml=gml+'<Aoi version="1.0.0" xmlns:gml="http://www.opengis.net/gml">';
|
51
|
gml=gml+'<gml:Envelope>';
|
52
|
gml=gml+'<gml:coord>';
|
53
|
gml=gml+'<gml:X>'+aoiBox[0][0]+'</gml:X>';
|
54
|
gml=gml+'<gml:Y>'+aoiBox[0][1]+'</gml:Y>';
|
55
|
gml=gml+'</gml:coord>';
|
56
|
gml=gml+'<gml:coord>';
|
57
|
gml=gml+'<gml:X>'+aoiBox[1][0]+'</gml:X>';
|
58
|
gml=gml+'<gml:Y>'+aoiBox[1][1]+'</gml:Y>';
|
59
|
gml=gml+'</gml:coord>';
|
60
|
gml=gml+'</gml:Envelope>';
|
61
|
gml=gml+'</Aoi>';
|
62
|
} else {
|
63
|
gml=gml+"<null/>";
|
64
|
}
|
65
|
|
66
|
objRef.resultDoc = Sarissa.getDomDocument();
|
67
|
objRef.resultDoc.loadXML(gml);
|
68
|
}
|
69
|
|
70
|
/**
|
71
|
* Called when the AoiChanged.
|
72
|
* @param objRef This object.
|
73
|
*/
|
74
|
this.aoiListener = function(objRef) {
|
75
|
objRef.paint(objRef);
|
76
|
}
|
77
|
model.addListener("aoi",this.aoiListener, this);
|
78
|
}
|