Skip to content

Commit

Permalink
Merge branch '2.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
elemoine committed May 16, 2012
2 parents e2c9662 + 24b1fa1 commit 985233c
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 27 deletions.
12 changes: 6 additions & 6 deletions lib/OpenLayers/Format/GPX.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, {
this.externalProjection);
}
if (geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
var wpt = this.buildWptNode(feature);
var wpt = this.buildWptNode(geometry);
this.appendAttributesNode(wpt, feature);
return wpt;
} else {
var trkNode = this.createElementNSPlus("gpx:trk");
Expand Down Expand Up @@ -348,16 +349,15 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, {
* Builds a wpt node given a point
*
* Parameters:
* feature - {<OpenLayers.Feature.Vector>}
* geometry - {<OpenLayers.Geometry.Point>}
*
* Returns:
* {DOMElement} A wpt node
*/
buildWptNode: function(feature) {
buildWptNode: function(geometry) {
var node = this.createElementNSPlus("gpx:wpt");
node.setAttribute("lon", feature.geometry.x);
node.setAttribute("lat", feature.geometry.y);
this.appendAttributesNode(node, feature);
node.setAttribute("lon", geometry.x);
node.setAttribute("lat", geometry.y);
return node;
},

Expand Down
3 changes: 2 additions & 1 deletion lib/OpenLayers/Layer/Bing.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
new OpenLayers.Projection("EPSG:4326")
);
var providers = res.imageryProviders,
zoom = this.serverResolutions.indexOf(this.getServerResolution()),
zoom = OpenLayers.Util.indexOf(this.serverResolutions,
this.getServerResolution()),
copyrights = "", provider, i, ii, j, jj, bbox, coverage;
for (i=0,ii=providers.length; i<ii; ++i) {
provider = providers[i];
Expand Down
4 changes: 3 additions & 1 deletion lib/OpenLayers/Renderer/SVG.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
* {DOMElement} The specific render engine's root element
*/
createRenderRoot: function() {
return this.nodeFactory(this.container.id + "_svgRoot", "svg");
var svg = this.nodeFactory(this.container.id + "_svgRoot", "svg");
svg.style.position = "absolute";
return svg;
},

/**
Expand Down
15 changes: 3 additions & 12 deletions lib/OpenLayers/Strategy/BBOX.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,11 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
if(activated) {
this.layer.events.on({
"moveend": this.update,
scope: this
});
this.layer.events.on({
"refresh": this.update,
"visibilitychanged": this.update,
scope: this
});
if(this.layer.visibility === true && this.layer.inRange === true) {
this.update();
} else {
this.layer.events.on({
"visibilitychanged": this.update,
scope: this
});
}
this.update();
}
return activated;
},
Expand Down Expand Up @@ -134,7 +125,7 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
update: function(options) {
var mapBounds = this.getMapBounds();
if (mapBounds !== null && ((options && options.force) ||
this.invalidBounds(mapBounds))) {
(this.layer.visibility && this.layer.calculateInRange() && this.invalidBounds(mapBounds)))) {
this.calculateBounds(mapBounds);
this.resolution = this.layer.map.getResolution();
this.triggerRead(options);
Expand Down
2 changes: 2 additions & 0 deletions notes/2.12.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ Corresponding issues/pull requests:

The `gpxns` API property has been removed. The GPX namespace is now defined in the `namespaces` property but is not intended to be overriden.

GPX also now has a basic write function.

Corresponding issues/pull requests:

* https://github.com/openlayers/openlayers/pull/221
Expand Down
65 changes: 59 additions & 6 deletions tests/Format/GPX.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,48 @@
"default external projection is EPSG:4326");
}
function test_Format_GPX_read(t) {
t.plan(4);
t.plan(7);
var expected,
P = OpenLayers.Geometry.Point,
LS = OpenLayers.Geometry.LineString;
var f = new OpenLayers.Format.GPX();
var features = f.read(gpx_data);
t.eq(features.length, 3, "Number of features read is correct");
t.eq(features[2].geometry.toString(), "POINT(-0.1853562259 51.3697845627)", "waypoint feature correctly created");
t.eq(features[0].geometry.toString(), "LINESTRING(-0.1721292044 51.3768216433,-0.1649230916 51.370833767,-0.1736741378 51.3644368725,-0.166259525 51.3576354272)", "track feature correctly created");
t.eq(features[1].geometry.toString(), "LINESTRING(-0.1829991904 51.3761803674,-0.1758887005 51.3697894659,-0.1833202965 51.3639790884,-0.1751119509 51.3567607069)", "route feature correctly created");
expected = new P(-0.1853562259, 51.3697845627);
t.geom_eq(features[2].geometry, expected, "waypoint feature correctly created");
expected = new LS([
new P(-0.1721292044, 51.3768216433),
new P(-0.1649230916, 51.370833767),
new P(-0.1736741378, 51.3644368725),
new P(-0.166259525, 51.3576354272)
]);
t.geom_eq(features[0].geometry, expected, "track feature correctly created");
expected = new LS([
new P(-0.1829991904, 51.3761803674),
new P(-0.1758887005, 51.3697894659),
new P(-0.1833202965, 51.3639790884),
new P(-0.1751119509, 51.3567607069)
]);
t.geom_eq(features[1].geometry, expected, "route feature correctly created");

f.internalProjection = new OpenLayers.Projection("EPSG:3857");
features = f.read(gpx_data);
expected = new P(-20633.760679678744, 6686966.841929403);
t.geom_eq(features[2].geometry, expected, "transformed waypoint feature correctly created");
expected = new LS([
new P(-19161.33538179203, 6688221.743275255),
new P(-18359.1545744088, 6687153.931130851),
new P(-19333.316581165607, 6686013.33343931),
new P(-18507.925659955214, 6684800.777090962)
]);
t.geom_eq(features[0].geometry, expected, "transformed track feature correctly created");
expected = new LS([
new P(-20371.3766880736, 6688107.378491073),
new P(-19579.84057322507, 6686967.716235109),
new P(-20407.12205561124, 6685931.714395953),
new P(-19493.373203291227, 6684644.845706556)
]);
t.geom_eq(features[1].geometry, expected, "transformed route feature correctly created");
}
function test_format_GPX_read_attributes(t) {
t.plan(2);
Expand All @@ -35,7 +70,7 @@
t.eq(features[2].attributes['sym'], "Flag", "CDATA attribute node read correctly.");
}
function test_Format_GPX_serialize_points(t) {
t.plan(1);
t.plan(2);

var parser = new OpenLayers.Format.GPX();

Expand All @@ -47,9 +82,19 @@
];
var data = parser.write(features);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wpt lon="-111.04" lat="45.68"><name>foo</name><desc>bar</desc></wpt><wpt lon="-112.04" lat="45.68"><name>foo</name><desc>bar</desc></wpt></gpx>', 'GPX serializes points correctly');

parser.internalProjection = new OpenLayers.Projection("EPSG:3857");
point = new OpenLayers.Geometry.Point(-12367595.42541111, 5621521.485409545);
point2 = new OpenLayers.Geometry.Point(-12472235.746742222, 5621521.485409545);
features = [
new OpenLayers.Feature.Vector(point, {name: 'foo', description: 'bar'}),
new OpenLayers.Feature.Vector(point2, {name: 'foo', description: 'bar'})
];
data = parser.write(features);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wpt lon="-111.1" lat="45"><name>foo</name><desc>bar</desc></wpt><wpt lon="-112.04" lat="45"><name>foo</name><desc>bar</desc></wpt></gpx>', 'GPX serializes transformed points correctly');
}
function test_Format_GPX_serialize_line(t) {
t.plan(1);
t.plan(2);

var parser = new OpenLayers.Format.GPX();

Expand All @@ -59,6 +104,14 @@
var f = new OpenLayers.Feature.Vector(line, {name: 'foo', description: 'bar'});
var data = parser.write(f);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.04" lat="45.68"/><trkpt lon="-112.04" lat="45.68"/></trkseg></trk></gpx>', 'GPX serializes line correctly');

parser.internalProjection = new OpenLayers.Projection("EPSG:3857");
point = new OpenLayers.Geometry.Point(-12367595.42541111, 5621521.485409545);
point2 = new OpenLayers.Geometry.Point(-12472235.746742222, 5621521.485409545);
line = new OpenLayers.Geometry.LineString([point, point2]);
f = new OpenLayers.Feature.Vector(line, {name: 'foo', description: 'bar'});
data = parser.write(f);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.1" lat="45"/><trkpt lon="-112.04" lat="45"/></trkseg></trk></gpx>', 'GPX serializes transformed line correctly');
}
function test_Format_GPX_serialize_lines(t) {
t.plan(1);
Expand Down
7 changes: 6 additions & 1 deletion tests/Strategy/BBOX.html
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@

// Test fix for Ticket #3142
function test_layerLoadedAfterBeingAdded(t) {
t.plan(2);
t.plan(3);

var dummy = new OpenLayers.Layer(null, {isBaseLayer: true});

Expand Down Expand Up @@ -341,6 +341,11 @@
// test that the strategy bounds were set
t.ok(map.getExtent().equals(strategy.bounds), "[set center] bounds set to map extent");
t.eq(layerOutOfRange.strategies[0].bounds, null, "Data not requested if layer is out of range");

layerOutOfRange.setVisibility(false);
layerOutOfRange.setVisibility(true);
t.eq(layerOutOfRange.strategies[0].bounds, null, "Data not requested if layer is out of range when switching visibility");

map.destroy();
}

Expand Down

0 comments on commit 985233c

Please sign in to comment.