Use proj4.defs instead of proj4.Proj, to conform with the proj4js API
This commit is contained in:
@@ -8,15 +8,15 @@ goog.require('ol.proj');
|
|||||||
goog.require('ol.source.TileWMS');
|
goog.require('ol.source.TileWMS');
|
||||||
|
|
||||||
|
|
||||||
var proj4Proj = new proj4.Proj('EPSG:21781');
|
var proj4Def = proj4.defs['EPSG:21781'];
|
||||||
var projection = ol.proj.addProjection({
|
var projection = ol.proj.addProjection({
|
||||||
code: 'EPSG:21781',
|
code: 'EPSG:21781',
|
||||||
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864],
|
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864],
|
||||||
units: proj4Proj.units
|
units: proj4Def.units
|
||||||
});
|
});
|
||||||
// The transform is needed for the ScaleLine control. Otherwise this example
|
// The transform is needed for the ScaleLine control. Otherwise this example
|
||||||
// would also work without proj4js.
|
// would also work without proj4js.
|
||||||
ol.proj.addCoordinateTransforms('EPSG:4326', projection, proj4(proj4Proj));
|
ol.proj.addCoordinateTransforms('EPSG:4326', projection, proj4('EPSG:21781'));
|
||||||
|
|
||||||
var extent = [420000, 30000, 900000, 350000];
|
var extent = [420000, 30000, 900000, 350000];
|
||||||
var layers = [
|
var layers = [
|
||||||
|
|||||||
+3
-27
@@ -11,32 +11,8 @@ var proj4 = function() {};
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object.<string, string>}
|
* @typedef {Object.<string, Object.<{axis: string,
|
||||||
|
* units: string,
|
||||||
|
* to_meter: number}>>}
|
||||||
*/
|
*/
|
||||||
proj4.defs;
|
proj4.defs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {Object|string} proj
|
|
||||||
*/
|
|
||||||
proj4.Proj = function(proj) {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
proj4.Proj.prototype.axis;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
proj4.Proj.prototype.units;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
proj4.Proj.prototype.to_meter;
|
|
||||||
|
|||||||
+7
-10
@@ -485,34 +485,31 @@ ol.proj.get = function(projectionLike) {
|
|||||||
var projections = ol.proj.projections_;
|
var projections = ol.proj.projections_;
|
||||||
projection = projections[code];
|
projection = projections[code];
|
||||||
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
|
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
|
||||||
var proj4jsProj;
|
|
||||||
var def = proj4.defs[code];
|
var def = proj4.defs[code];
|
||||||
if (goog.isDef(def)) {
|
if (goog.isDef(def)) {
|
||||||
proj4jsProj = new proj4.Proj(code);
|
var units = def.units;
|
||||||
var units = proj4jsProj.units;
|
|
||||||
if (!goog.isDef(units)) {
|
if (!goog.isDef(units)) {
|
||||||
if (goog.isDef(proj4jsProj.to_meter)) {
|
if (goog.isDef(def.to_meter)) {
|
||||||
units = proj4jsProj.to_meter.toString();
|
units = def.to_meter.toString();
|
||||||
ol.proj.METERS_PER_UNIT[units] = proj4jsProj.to_meter;
|
ol.proj.METERS_PER_UNIT[units] = def.to_meter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
projection = new ol.proj.Projection({
|
projection = new ol.proj.Projection({
|
||||||
code: code,
|
code: code,
|
||||||
units: units,
|
units: units,
|
||||||
axisOrientation: proj4jsProj.axis
|
axisOrientation: def.axis
|
||||||
});
|
});
|
||||||
ol.proj.addProjection(projection);
|
ol.proj.addProjection(projection);
|
||||||
var currentCode, currentDef, currentProj, currentProj4jsProj;
|
var currentCode, currentDef, currentProj;
|
||||||
for (currentCode in projections) {
|
for (currentCode in projections) {
|
||||||
currentDef = proj4.defs[currentCode];
|
currentDef = proj4.defs[currentCode];
|
||||||
if (goog.isDef(currentDef)) {
|
if (goog.isDef(currentDef)) {
|
||||||
currentProj4jsProj = new proj4.Proj(currentCode);
|
|
||||||
currentProj = ol.proj.get(currentCode);
|
currentProj = ol.proj.get(currentCode);
|
||||||
if (currentDef === def) {
|
if (currentDef === def) {
|
||||||
ol.proj.addEquivalentProjections([currentProj, projection]);
|
ol.proj.addEquivalentProjections([currentProj, projection]);
|
||||||
} else {
|
} else {
|
||||||
ol.proj.addCoordinateTransforms(currentProj, projection,
|
ol.proj.addCoordinateTransforms(currentProj, projection,
|
||||||
proj4(currentProj4jsProj, proj4jsProj));
|
proj4(currentCode, code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ describe('ol.format.WFS', function() {
|
|||||||
|
|
||||||
var features, feature;
|
var features, feature;
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
proj4.defs['urn:x-ogc:def:crs:EPSG:4326'] = proj4.defs('EPSG:4326');
|
proj4.defs['urn:x-ogc:def:crs:EPSG:4326'] = proj4.defs['EPSG:4326'];
|
||||||
afterLoadText('spec/ol/format/wfs/topp-states-wfs.xml', function(xml) {
|
afterLoadText('spec/ol/format/wfs/topp-states-wfs.xml', function(xml) {
|
||||||
try {
|
try {
|
||||||
var config = {
|
var config = {
|
||||||
|
|||||||
Reference in New Issue
Block a user