Merge branch 'master' of github.com:openlayers/ol3
This commit is contained in:
11
main.json
11
main.json
@@ -1,7 +1,10 @@
|
||||
{
|
||||
"id": "ol",
|
||||
|
||||
"inputs": "src/ol.js",
|
||||
"inputs": [
|
||||
"src/ol.js",
|
||||
"src/ol.export.js"
|
||||
],
|
||||
"paths": [
|
||||
"src"
|
||||
],
|
||||
@@ -20,9 +23,9 @@
|
||||
"pretty-print": true,
|
||||
"debug": true,
|
||||
|
||||
"experimental-compiler-options": {
|
||||
"generateExports": true
|
||||
},
|
||||
// "experimental-compiler-options": {
|
||||
// "generateExports": true
|
||||
// },
|
||||
|
||||
"checks": {
|
||||
// acceptable values are "ERROR", "WARNING", and "OFF"
|
||||
|
||||
@@ -10,3 +10,17 @@ ol.geom.geometry = function(){
|
||||
var g = new ol.geom.Geometry();
|
||||
return g;
|
||||
};
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @param {ol.Bounds=} opt_arg new Bounds.
|
||||
* @return {ol.geom.Geometry|ol.Bounds|undefined} either a Geometry (when used as
|
||||
* setter) or a Bounds/undefined (if used as getter).
|
||||
*/
|
||||
ol.geom.Geometry.prototype.bounds = function(opt_arg) {
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
return this.setBounds(opt_arg);
|
||||
} else {
|
||||
return this.getBounds();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
goog.require("ol.loc");
|
||||
goog.require("ol.feature");
|
||||
goog.require("ol.projection");
|
||||
goog.require('ol.bounds');
|
||||
goog.require("ol.map");
|
||||
goog.require("ol.layer.xyz");
|
||||
goog.require("ol.layer.osm");
|
||||
goog.require("ol");
|
||||
|
||||
// ol.map
|
||||
goog.exportSymbol('ol.map', ol.map );
|
||||
goog.exportSymbol('ol.Map', ol.Map );
|
||||
goog.exportProperty( ol.Map.prototype, 'renderTo', ol.Map.prototype.renderTo );
|
||||
goog.exportProperty( ol.Map.prototype, 'center', ol.Map.prototype.center );
|
||||
goog.exportProperty( ol.Map.prototype, 'projection', ol.Map.prototype.projection );
|
||||
goog.exportProperty( ol.Map.prototype, 'userProjection', ol.Map.prototype.userProjection );
|
||||
@@ -18,7 +13,6 @@ goog.exportProperty( ol.Map.prototype, 'resolutions', ol.Map.prototype.resolutio
|
||||
goog.exportProperty( ol.Map.prototype, 'layers', ol.Map.prototype.layers );
|
||||
goog.exportProperty( ol.Map.prototype, 'controls', ol.Map.prototype.controls );
|
||||
goog.exportProperty( ol.Map.prototype, 'maxExtent', ol.Map.prototype.maxExtent );
|
||||
goog.exportProperty( ol.Map.prototype, 'maxRes', ol.Map.prototype.maxRes );
|
||||
goog.exportProperty( ol.Map.prototype, 'destroy', ol.Map.prototype.destroy );
|
||||
|
||||
// ol.loc
|
||||
@@ -46,6 +40,14 @@ goog.exportProperty( ol.Bounds.prototype, 'minY', ol.Bounds.prototype.minY );
|
||||
goog.exportProperty( ol.Bounds.prototype, 'maxX', ol.Bounds.prototype.maxX );
|
||||
goog.exportProperty( ol.Bounds.prototype, 'maxY', ol.Bounds.prototype.maxY );
|
||||
|
||||
// ol.layer.xyz
|
||||
goog.exportSymbol('ol.layer.xyz', ol.layer.xyz);
|
||||
goog.exportSymbol('ol.layer.XYZ', ol.layer.XYZ);
|
||||
|
||||
// ol.layer.osm
|
||||
goog.exportSymbol('ol.layer.osm', ol.layer.osm);
|
||||
goog.exportSymbol('ol.layer.OSM', ol.layer.OSM);
|
||||
|
||||
// ol.feature
|
||||
goog.exportSymbol('ol.feature', ol.feature);
|
||||
goog.exportSymbol('ol.Feature', ol.Feature);
|
||||
@@ -53,10 +55,27 @@ goog.exportProperty(ol.Feature.prototype, 'set', ol.Feature.prototype.set);
|
||||
goog.exportProperty(ol.Feature.prototype, 'get', ol.Feature.prototype.get);
|
||||
goog.exportProperty(ol.Feature.prototype, 'geometry', ol.Feature.prototype.geometry);
|
||||
|
||||
// ol.geometry
|
||||
goog.exportSymbol('ol.geom.geometry', ol.geom.geometry);
|
||||
goog.exportSymbol('ol.geom.Geometry', ol.geom.Geometry);
|
||||
goog.exportProperty(ol.geom.Geometry.prototype, 'bounds', ol.geom.Geometry.prototype.bounds);
|
||||
|
||||
// ol.geom.collection
|
||||
goog.exportSymbol('ol.geom.collection', ol.geom.collection);
|
||||
goog.exportSymbol('ol.geom.Collection', ol.geom.Collection);
|
||||
goog.exportProperty(ol.geom.Collection.prototype, 'components', ol.geom.Collection.prototype.components);
|
||||
goog.exportProperty(ol.geom.Collection.prototype, 'add', ol.geom.Collection.prototype.add);
|
||||
goog.exportProperty(ol.geom.Collection.prototype, 'addAll', ol.geom.Collection.prototype.addAll);
|
||||
goog.exportProperty(ol.geom.Collection.prototype, 'remove', ol.geom.Collection.prototype.remove);
|
||||
|
||||
// ol.geom.point
|
||||
goog.exportSymbol('ol.geom.point', ol.geom.point);
|
||||
goog.exportSymbol('ol.geom.Point', ol.geom.Point);
|
||||
goog.exportProperty(ol.geom.Point.prototype, 'x', ol.geom.Point.prototype.x);
|
||||
goog.exportProperty(ol.geom.Point.prototype, 'y', ol.geom.Point.prototype.y);
|
||||
goog.exportPropertz(ol.geom.Point.prototzpe, 'z', ol.geom.Point.prototzpe.z);
|
||||
goog.exportProperty(ol.geom.Point.prototype, 'z', ol.geom.Point.prototype.z);
|
||||
goog.exportProperty(ol.geom.Point.prototype, 'projection', ol.geom.Point.prototype.projection);
|
||||
|
||||
// LOOKUP FOR DYNMICALLY REGISTERED CONTROLS DOES NOT RUN WELL NOW IN THE ADVANCED MODE
|
||||
// HACK TO PUSH COMPILER TO NOT STRIP THE NAVIGATION CONTROL. TO BE FIXED.
|
||||
ol.control.addControl('navigation', ol.control.Navigation);
|
||||
|
||||
@@ -17,10 +17,6 @@ ol.geom.Geometry = function() {
|
||||
this.bounds_ = undefined;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Bounds|undefined} The ol.Bounds.
|
||||
*/
|
||||
@@ -36,17 +32,3 @@ ol.geom.Geometry.prototype.setBounds = function(bounds) {
|
||||
this.bounds_ = bounds;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @param {ol.Bounds=} opt_arg new Bounds.
|
||||
* @return {ol.geom.Geometry|ol.Bounds|undefined} either a Geometry (when used as
|
||||
* setter) or a Bounds/undefined (if used as getter).
|
||||
*/
|
||||
ol.geom.Geometry.prototype.bounds = function(opt_arg){
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
return this.setBounds(opt_arg);
|
||||
} else {
|
||||
return this.getBounds();
|
||||
}
|
||||
};
|
||||
@@ -29,12 +29,12 @@
|
||||
hostResult = hostRegex.exec(l.href),
|
||||
modeResult = modeRegex.exec(l.href),
|
||||
host = (hostResult && hostResult[1])
|
||||
? hostResult[1]
|
||||
? decodeURIComponent(hostResult[1])
|
||||
: (l.host)
|
||||
? l.host + ':9810'
|
||||
: 'localhost:9810',
|
||||
mode = (modeResult && modeResult[1])
|
||||
? modeResult[1]
|
||||
? decodeURIComponent(modeResult[1])
|
||||
: 'SIMPLE',
|
||||
|
||||
// Create the script tag which includes the derived variables from above
|
||||
@@ -89,6 +89,7 @@
|
||||
<script type="text/javascript" src="spec/ol/layer/XYZ.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/Feature.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/renderer/WebGL.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/renderer/TileLayerRenderer.test.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
describe("ol.geom.point", function() {
|
||||
describe("ol.geom.point", function() {
|
||||
var pNoArgs,
|
||||
pNoZ_arr,
|
||||
pWithZ_arr,
|
||||
@@ -7,7 +7,7 @@ describe("ol.geom.point", function() {
|
||||
pWithZ_obj,
|
||||
p_obj,
|
||||
proj = "EPSG:4326";
|
||||
|
||||
|
||||
var instances = {
|
||||
"no arguments passed": ol.geom.point(),
|
||||
"one argument <Array[x,y]> passed": ol.geom.point([21, 4]),
|
||||
@@ -17,7 +17,7 @@ describe("ol.geom.point", function() {
|
||||
"one argument <Object{x,y,z}> passed": ol.geom.point({x: 21, y: 4, z: 8}),
|
||||
"one argument <Object{x,y,z,projection}> passed": ol.geom.point({x: 21, y: 4, z: 8, projection: proj})
|
||||
};
|
||||
|
||||
|
||||
beforeEach(function() {
|
||||
proj = ol.projection("EPSG:4326");
|
||||
instances = {
|
||||
@@ -37,7 +37,7 @@ describe("ol.geom.point", function() {
|
||||
pWithZ_obj = instances["one argument <Object{x,y,z}> passed"];
|
||||
p_obj = instances["one argument <Object{x,y,z,projection}> passed"];
|
||||
});
|
||||
|
||||
|
||||
afterEach(function() {
|
||||
pNoArgs = null;
|
||||
pNoZ_arr = pWithZ_arr = p_arr = null;
|
||||
@@ -52,111 +52,118 @@ describe("ol.geom.point", function() {
|
||||
"one argument <Object{x,y,z,projection}> passed": ol.geom.point({x: 21, y: 4, z: 8, projection: proj})
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
for (instancesDesc in instances) {
|
||||
if (instances.hasOwnProperty(instancesDesc)) {
|
||||
var instance = instances[instancesDesc];
|
||||
|
||||
it("constructs instances (" + instancesDesc + ")", function() {
|
||||
expect(instance).toEqual(jasmine.any(ol.geom.Point));
|
||||
});
|
||||
|
||||
it("constructs instances of ol.geom.Geometry (" + instancesDesc + ")", function() {
|
||||
expect(instance).toEqual(jasmine.any(ol.geom.Geometry));
|
||||
});
|
||||
|
||||
it("has coordinate getter/setter methods (" + instancesDesc + ")", function() {
|
||||
expect(instance.x).not.toBeUndefined();
|
||||
expect(instance.y).not.toBeUndefined();
|
||||
expect(instance.z).not.toBeUndefined();
|
||||
|
||||
// always a number
|
||||
expect( !isNaN( instance.x() ) ).toBe(true);
|
||||
// setter returns self
|
||||
expect(instance.x(47)).toBeA(ol.geom.Point);
|
||||
// getter returns correct number
|
||||
expect(instance.x()).toBe(47);
|
||||
|
||||
// always a number
|
||||
expect( !isNaN( instance.y() ) ).toBe(true);
|
||||
// setter returns self
|
||||
expect(instance.y(74)).toBeA(ol.geom.Point);
|
||||
// getter returns correct number
|
||||
expect(instance.y()).toBe(74);
|
||||
|
||||
// always number or undefined
|
||||
expect(instance.z() === undefined || !isNaN(instance.z()) ).toBe(true);
|
||||
// setter returns self
|
||||
expect(instance.z(0.074)).toBeA(ol.geom.Point);
|
||||
// getter returns correct number
|
||||
expect(instance.z()).toBe(0.074);
|
||||
|
||||
});
|
||||
|
||||
it("has projection getter/setter methods (" + instancesDesc + ")", function() {
|
||||
expect(instance.projection).not.toBeUndefined();
|
||||
|
||||
var getRes = instance.projection();
|
||||
expect(getRes === null || getRes instanceof ol.Projection).toBe(true);
|
||||
|
||||
var setRes = instance.projection("EPSG:12345");
|
||||
expect(setRes instanceof ol.geom.Point).toBe(true);
|
||||
|
||||
getRes = instance.projection();
|
||||
expect(getRes).toBeA(ol.Projection);
|
||||
expect(getRes.code()).toEqual("EPSG:12345");
|
||||
|
||||
describe("instantiate with " + instancesDesc, function() {
|
||||
|
||||
it("constructs instances", function() {
|
||||
expect(instance).toEqual(jasmine.any(ol.geom.Point));
|
||||
});
|
||||
|
||||
it("constructs instances of ol.geom.Geometry", function() {
|
||||
expect(instance).toEqual(jasmine.any(ol.geom.Geometry));
|
||||
});
|
||||
|
||||
it("has coordinate getter/setter methods", function() {
|
||||
expect(instance.x).not.toBeUndefined();
|
||||
expect(instance.y).not.toBeUndefined();
|
||||
expect(instance.z).not.toBeUndefined();
|
||||
|
||||
// always a number
|
||||
expect( !isNaN( instance.x() ) ).toBe(true);
|
||||
// setter returns self
|
||||
expect(instance.x(47)).toBeA(ol.geom.Point);
|
||||
// getter returns correct number
|
||||
expect(instance.x()).toBe(47);
|
||||
|
||||
// always a number
|
||||
expect( !isNaN( instance.y() ) ).toBe(true);
|
||||
// setter returns self
|
||||
expect(instance.y(74)).toBeA(ol.geom.Point);
|
||||
// getter returns correct number
|
||||
expect(instance.y()).toBe(74);
|
||||
|
||||
// always number or undefined
|
||||
expect(instance.z() === undefined || !isNaN(instance.z()) ).toBe(true);
|
||||
// setter returns self
|
||||
expect(instance.z(0.074)).toBeA(ol.geom.Point);
|
||||
// getter returns correct number
|
||||
expect(instance.z()).toBe(0.074);
|
||||
|
||||
});
|
||||
|
||||
it("has projection getter/setter methods", function() {
|
||||
expect(instance.projection).not.toBeUndefined();
|
||||
|
||||
var getRes = instance.projection();
|
||||
expect(getRes === null || getRes instanceof ol.Projection).toBe(true);
|
||||
|
||||
var setRes = instance.projection("EPSG:12345");
|
||||
expect(setRes instanceof ol.geom.Point).toBe(true);
|
||||
|
||||
getRes = instance.projection();
|
||||
expect(getRes).toBeA(ol.Projection);
|
||||
expect(getRes.code()).toEqual("EPSG:12345");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
it("has functional getters (no arguments passed)", function(){
|
||||
expect(pNoArgs.x()).toBe(0);
|
||||
expect(pNoArgs.y()).toBe(0);
|
||||
expect(pNoArgs.z()).toBeUndefined();
|
||||
expect(pNoArgs.projection()).toBeNull();
|
||||
});
|
||||
|
||||
it("has functional getters (one argument <Array[x,y]> passed)", function(){
|
||||
expect(pNoZ_arr.x()).toBe(21);
|
||||
expect(pNoZ_arr.y()).toBe(4);
|
||||
expect(pNoZ_arr.z()).toBeUndefined();
|
||||
expect(pNoZ_arr.projection()).toBeNull();
|
||||
});
|
||||
|
||||
it("has functional getters (one argument <Array[x,y,z]> passed)", function(){
|
||||
expect(pWithZ_arr.x()).toBe(21);
|
||||
expect(pWithZ_arr.y()).toBe(4);
|
||||
expect(pWithZ_arr.z()).toBe(8);
|
||||
expect(pWithZ_arr.projection()).toBeNull();
|
||||
});
|
||||
|
||||
it("has functional getters (one argument <Array[x,y,z,projection]> passed)", function(){
|
||||
expect(p_arr.x()).toBe(21);
|
||||
expect(p_arr.y()).toBe(4);
|
||||
expect(p_arr.z()).toBe(8);
|
||||
expect(p_arr.projection()).not.toBeNull();
|
||||
expect(p_arr.projection()).toBeA(ol.Projection);
|
||||
});
|
||||
|
||||
it("has functional getters (one argument <Object{x,y}> passed)", function(){
|
||||
expect(pNoZ_obj.x()).toBe(21);
|
||||
expect(pNoZ_obj.y()).toBe(4);
|
||||
expect(pNoZ_obj.z()).toBeUndefined();
|
||||
expect(pNoZ_obj.projection()).toBeNull();
|
||||
});
|
||||
|
||||
it("has functional getters (one argument <Object{x,y,z}> passed)", function(){
|
||||
expect(pWithZ_obj.x()).toBe(21);
|
||||
expect(pWithZ_obj.y()).toBe(4);
|
||||
expect(pWithZ_obj.z()).toBe(8);
|
||||
expect(pWithZ_obj.projection()).toBeNull();
|
||||
});
|
||||
|
||||
it("has functional getters (one argument <Object{x,y,z,projection}> passed)", function(){
|
||||
expect(p_obj.x()).toBe(21);
|
||||
expect(p_obj.y()).toBe(4);
|
||||
expect(p_obj.z()).toBe(8);
|
||||
expect(p_obj.projection()).not.toBeNull();
|
||||
expect(p_obj.projection()).toEqual(jasmine.any(ol.Projection));
|
||||
|
||||
describe('the getters are functional', function(){
|
||||
it("works when no arguments passed", function(){
|
||||
expect(pNoArgs.x()).toBe(0);
|
||||
expect(pNoArgs.y()).toBe(0);
|
||||
expect(pNoArgs.z()).toBeUndefined();
|
||||
expect(pNoArgs.projection()).toBeNull();
|
||||
});
|
||||
|
||||
it("works when one argument <Array[x,y]> passed", function(){
|
||||
expect(pNoZ_arr.x()).toBe(21);
|
||||
expect(pNoZ_arr.y()).toBe(4);
|
||||
expect(pNoZ_arr.z()).toBeUndefined();
|
||||
expect(pNoZ_arr.projection()).toBeNull();
|
||||
});
|
||||
|
||||
it("works when one argument <Array[x,y,z]> passed", function(){
|
||||
expect(pWithZ_arr.x()).toBe(21);
|
||||
expect(pWithZ_arr.y()).toBe(4);
|
||||
expect(pWithZ_arr.z()).toBe(8);
|
||||
expect(pWithZ_arr.projection()).toBeNull();
|
||||
});
|
||||
|
||||
it("works when one argument <Array[x,y,z,projection]> passed", function(){
|
||||
expect(p_arr.x()).toBe(21);
|
||||
expect(p_arr.y()).toBe(4);
|
||||
expect(p_arr.z()).toBe(8);
|
||||
expect(p_arr.projection()).not.toBeNull();
|
||||
expect(p_arr.projection()).toBeA(ol.Projection);
|
||||
});
|
||||
|
||||
it("works when one argument <Object{x,y}> passed", function(){
|
||||
expect(pNoZ_obj.x()).toBe(21);
|
||||
expect(pNoZ_obj.y()).toBe(4);
|
||||
expect(pNoZ_obj.z()).toBeUndefined();
|
||||
expect(pNoZ_obj.projection()).toBeNull();
|
||||
});
|
||||
|
||||
it("works when one argument <Object{x,y,z}> passed", function(){
|
||||
expect(pWithZ_obj.x()).toBe(21);
|
||||
expect(pWithZ_obj.y()).toBe(4);
|
||||
expect(pWithZ_obj.z()).toBe(8);
|
||||
expect(pWithZ_obj.projection()).toBeNull();
|
||||
});
|
||||
|
||||
it("works when one argument <Object{x,y,z,projection}> passed", function(){
|
||||
expect(p_obj.x()).toBe(21);
|
||||
expect(p_obj.y()).toBe(4);
|
||||
expect(p_obj.z()).toBe(8);
|
||||
expect(p_obj.projection()).not.toBeNull();
|
||||
expect(p_obj.projection()).toEqual(jasmine.any(ol.Projection));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
describe("ol.geom.Point", function() {
|
||||
describe("ol.geom.Point", function() {
|
||||
var p2Args,
|
||||
p3Args,
|
||||
p4Args,
|
||||
proj = "EPSG:4326";
|
||||
|
||||
|
||||
var instances = {
|
||||
"two arguments <x>,<y> passed": new ol.geom.Point(21, 4),
|
||||
"three arguments <x>,<y>,<z> passed": new ol.geom.Point(21, 4, 8),
|
||||
"four arguments <x>,<y>,<z>,<projection> passed": new ol.geom.Point(21, 4, 8, proj)
|
||||
};
|
||||
|
||||
|
||||
beforeEach(function() {
|
||||
proj = ol.projection("EPSG:4326");
|
||||
instances = {
|
||||
@@ -21,7 +21,7 @@ describe("ol.geom.Point", function() {
|
||||
p3Args = instances['three arguments <x>,<y>,<z> passed'];
|
||||
p4Args = instances['four arguments <x>,<y>,<z>,<projection> passed'];
|
||||
});
|
||||
|
||||
|
||||
afterEach(function() {
|
||||
p2Args = p3Args = p4Args = null;
|
||||
instances = {
|
||||
@@ -30,94 +30,97 @@ describe("ol.geom.Point", function() {
|
||||
"four arguments <x>,<y>,<z>,<projection> passed": new ol.geom.Point(21, 4, 8, proj)
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
for (instancesDesc in instances) {
|
||||
if (instances.hasOwnProperty(instancesDesc)) {
|
||||
var instance = instances[instancesDesc];
|
||||
|
||||
it("constructs instances (" + instancesDesc + ")", function() {
|
||||
expect(instance).toEqual(jasmine.any(ol.geom.Point));
|
||||
|
||||
describe("instantiate with " + instancesDesc, function() {
|
||||
|
||||
it("constructs instances", function() {
|
||||
expect(instance).toEqual(jasmine.any(ol.geom.Point));
|
||||
});
|
||||
|
||||
it("constructs instances of ol.geom.Geometry", function() {
|
||||
expect(instance).toEqual(jasmine.any(ol.geom.Geometry));
|
||||
});
|
||||
|
||||
it("has the coordinate accessor methods", function() {
|
||||
expect(instance.getX).not.toBeUndefined();
|
||||
expect(instance.getY).not.toBeUndefined();
|
||||
expect(instance.getZ).not.toBeUndefined();
|
||||
expect(instance.setX).not.toBeUndefined();
|
||||
expect(instance.setY).not.toBeUndefined();
|
||||
expect(instance.setZ).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("has the projection accessor methods", function() {
|
||||
expect(instance.getProjection).not.toBeUndefined();
|
||||
expect(instance.setProjection).not.toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("constructs instances of ol.geom.Geometry (" + instancesDesc + ")", function() {
|
||||
expect(instance).toEqual(jasmine.any(ol.geom.Geometry));
|
||||
});
|
||||
|
||||
it("has the coordinate accessor methods (" + instancesDesc + ")", function() {
|
||||
expect(instance.getX).not.toBeUndefined();
|
||||
expect(instance.getY).not.toBeUndefined();
|
||||
expect(instance.getZ).not.toBeUndefined();
|
||||
expect(instance.setX).not.toBeUndefined();
|
||||
expect(instance.setY).not.toBeUndefined();
|
||||
expect(instance.setZ).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("has the projection accessor methods (" + instancesDesc + ")", function() {
|
||||
expect(instance.getProjection).not.toBeUndefined();
|
||||
expect(instance.setProjection).not.toBeUndefined();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
it("has functional getters (two arguments <x>,<y> passed)", function(){
|
||||
|
||||
expect(p2Args.getX()).toBe(21);
|
||||
expect(p2Args.getY()).toBe(4);
|
||||
expect(p2Args.getZ()).toBeUndefined();
|
||||
expect(p2Args.getProjection()).toBeNull();
|
||||
describe('the getters are functional', function(){
|
||||
it("works when two arguments <x>,<y> passed", function(){
|
||||
|
||||
expect(p2Args.getX()).toBe(21);
|
||||
expect(p2Args.getY()).toBe(4);
|
||||
expect(p2Args.getZ()).toBeUndefined();
|
||||
expect(p2Args.getProjection()).toBeNull();
|
||||
});
|
||||
|
||||
it("works when three arguments <x>,<y>,<z> passed", function(){
|
||||
expect(p3Args.getX()).toBe(21);
|
||||
expect(p3Args.getY()).toBe(4);
|
||||
expect(p3Args.getZ()).not.toBeUndefined();
|
||||
expect(p3Args.getZ()).toBe(8);
|
||||
expect(p3Args.getProjection()).toBeNull();
|
||||
});
|
||||
|
||||
it("works when four arguments <x>,<y>,<z>,<projection> passed", function(){
|
||||
expect(p4Args.getX()).toBe(21);
|
||||
expect(p4Args.getY()).toBe(4);
|
||||
expect(p4Args.getZ()).toBe(8);
|
||||
expect(p4Args.getProjection()).not.toBeNull();
|
||||
expect(p4Args.getProjection()).toBeA(ol.Projection);
|
||||
});
|
||||
});
|
||||
|
||||
it("has functional getters (three arguments <x>,<y>,<z> passed)", function(){
|
||||
expect(p3Args.getX()).toBe(21);
|
||||
expect(p3Args.getY()).toBe(4);
|
||||
expect(p3Args.getZ()).not.toBeUndefined();
|
||||
expect(p3Args.getZ()).toBe(8);
|
||||
expect(p3Args.getProjection()).toBeNull();
|
||||
});
|
||||
|
||||
it("has functional getters (four arguments <x>,<y>,<z>,<projection> passed)", function(){
|
||||
expect(p4Args.getX()).toBe(21);
|
||||
expect(p4Args.getY()).toBe(4);
|
||||
expect(p4Args.getZ()).toBe(8);
|
||||
expect(p4Args.getProjection()).not.toBeNull();
|
||||
expect(p4Args.getProjection()).toBeA(ol.Projection);
|
||||
});
|
||||
|
||||
it("can be transformed", function(){
|
||||
// save for later comparison
|
||||
var old = {
|
||||
x: p4Args.getX().toFixed(3),
|
||||
y: p4Args.getY().toFixed(3)
|
||||
};
|
||||
// with code only
|
||||
var transformedPoint = p4Args.transform("EPSG:3857");
|
||||
|
||||
// is it still an instance of ol.geom.Point?
|
||||
expect(transformedPoint).toBeA(ol.geom.Point);
|
||||
// coordinates OK?
|
||||
expect(transformedPoint.getX().toFixed(3)).toBe("2337709.306");
|
||||
expect(transformedPoint.getY().toFixed(3)).toBe("445640.110");
|
||||
|
||||
// with an ol.Projection
|
||||
var retransformedPoint = transformedPoint.transform(new ol.Projection("EPSG:4326"));
|
||||
expect(retransformedPoint).toBeA(ol.geom.Point);
|
||||
|
||||
// coordinates shopulkd be the originally configured
|
||||
expect(retransformedPoint.getX().toFixed(3)).toBe(old.x);
|
||||
expect(retransformedPoint.getY().toFixed(3)).toBe(old.y);
|
||||
});
|
||||
|
||||
it("throws an exception when you try to transform without a source projection", function(){
|
||||
|
||||
expect(function() {
|
||||
p2Args.transform("EPSG:3857");
|
||||
}).toThrow();
|
||||
|
||||
expect(function() {
|
||||
p3Args.transform("EPSG:3857");
|
||||
}).toThrow();
|
||||
|
||||
|
||||
describe("transformation is functional", function(){
|
||||
it("can be transformed", function(){
|
||||
// save for later comparison
|
||||
var old = {
|
||||
x: p4Args.getX().toFixed(3),
|
||||
y: p4Args.getY().toFixed(3)
|
||||
};
|
||||
// with code only
|
||||
var transformedPoint = p4Args.transform("EPSG:3857");
|
||||
|
||||
// is it still an instance of ol.geom.Point?
|
||||
expect(transformedPoint).toBeA(ol.geom.Point);
|
||||
// coordinates OK?
|
||||
expect(transformedPoint.getX().toFixed(3)).toBe("2337709.306");
|
||||
expect(transformedPoint.getY().toFixed(3)).toBe("445640.110");
|
||||
|
||||
// with an ol.Projection
|
||||
var retransformedPoint = transformedPoint.transform(new ol.Projection("EPSG:4326"));
|
||||
expect(retransformedPoint).toBeA(ol.geom.Point);
|
||||
|
||||
// coordinates shopulkd be the originally configured
|
||||
expect(retransformedPoint.getX().toFixed(3)).toBe(old.x);
|
||||
expect(retransformedPoint.getY().toFixed(3)).toBe(old.y);
|
||||
});
|
||||
|
||||
it("throws an exception when you try to transform without a source projection", function(){
|
||||
expect(function() {
|
||||
p2Args.transform("EPSG:3857");
|
||||
}).toThrow();
|
||||
|
||||
expect(function() {
|
||||
p3Args.transform("EPSG:3857");
|
||||
}).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user