Update to use the documented Proj4js 2.2.x API

This commit is contained in:
Andreas Hocevar
2014-07-08 22:33:21 +02:00
parent a22d7e4d22
commit 90c745006d
8 changed files with 12 additions and 11 deletions

View File

@@ -44,7 +44,7 @@
</div> </div>
<script src="jquery.min.js" type="text/javascript"></script> <script src="jquery.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.1.4/proj4.js" type="text/javascript"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js" type="text/javascript"></script>
<script src="http://epsg.io/21781.js" type="text/javascript"></script> <script src="http://epsg.io/21781.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script> <script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=wms-custom-proj" type="text/javascript"></script> <script src="loader.js?id=wms-custom-proj" type="text/javascript"></script>

View File

@@ -15,7 +15,7 @@ var projection = ol.proj.addProjection({
// projection's validity extent can be found at http://epsg.io/. // projection's validity extent can be found at http://epsg.io/.
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864], extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864],
// Use data from proj4js to configure the projection's units. // Use data from proj4js to configure the projection's units.
units: proj4.defs['EPSG:21781'].units units: proj4.defs('EPSG:21781').units
}); });
// Proj4js provides transform functions between its configured projections. // Proj4js provides transform functions between its configured projections.
// The transform is needed for the ScaleLine control. Otherwise this example // The transform is needed for the ScaleLine control. Otherwise this example

View File

@@ -45,7 +45,7 @@
</div> </div>
<script src="jquery.min.js" type="text/javascript"></script> <script src="jquery.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.1.4/proj4.js" type="text/javascript"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js" type="text/javascript"></script>
<script src="http://epsg.io/21781.js" type="text/javascript"></script> <script src="http://epsg.io/21781.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script> <script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=wms-image-custom-proj" type="text/javascript"></script> <script src="loader.js?id=wms-image-custom-proj" type="text/javascript"></script>

View File

@@ -11,8 +11,9 @@ var proj4 = function() {};
/** /**
* @typedef {Object.<string, Object.<{axis: string, * @param {string} name
* units: string, * @param {(string|Object)=} opt_def
* @return {undefined|Object.<string, Object.<{axis: string, units: string,
* to_meter: number}>>} * to_meter: number}>>}
*/ */
proj4.defs; proj4.defs = function(name, opt_def) {};

View File

@@ -31,7 +31,7 @@
"mocha-phantomjs": "~3.5.0", "mocha-phantomjs": "~3.5.0",
"nomnom": "~1.6.2", "nomnom": "~1.6.2",
"phantomjs": "~1.9.7-5", "phantomjs": "~1.9.7-5",
"proj4": "~2.1.4", "proj4": "~2.2.1",
"sinon": "~1.10.2", "sinon": "~1.10.2",
"temp": "~0.7.0", "temp": "~0.7.0",
"walk": "~2.3.3" "walk": "~2.3.3"

View File

@@ -479,7 +479,7 @@ ol.proj.get = function(projectionLike) {
projection = projections[code]; projection = projections[code];
if (ol.ENABLE_PROJ4JS && !goog.isDef(projection) && if (ol.ENABLE_PROJ4JS && !goog.isDef(projection) &&
goog.isFunction(proj4)) { goog.isFunction(proj4)) {
var def = proj4.defs[code]; var def = proj4.defs(code);
if (goog.isDef(def)) { if (goog.isDef(def)) {
var units = def.units; var units = def.units;
if (!goog.isDef(units)) { if (!goog.isDef(units)) {
@@ -496,7 +496,7 @@ ol.proj.get = function(projectionLike) {
ol.proj.addProjection(projection); ol.proj.addProjection(projection);
var currentCode, currentDef, currentProj; 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)) {
currentProj = ol.proj.get(currentCode); currentProj = ol.proj.get(currentCode);
if (currentDef === def) { if (currentDef === def) {

View File

@@ -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 = {

View File

@@ -141,7 +141,7 @@ describe('ol.proj', function() {
it('caches the new Proj4js projections given their srsCode', function() { it('caches the new Proj4js projections given their srsCode', function() {
var code = 'urn:ogc:def:crs:EPSG:21781'; var code = 'urn:ogc:def:crs:EPSG:21781';
var srsCode = 'EPSG:21781'; var srsCode = 'EPSG:21781';
proj4.defs[code] = proj4.defs[srsCode]; proj4.defs(code, proj4.defs(srsCode));
var proj = ol.proj.get(code); var proj = ol.proj.get(code);
var proj2 = ol.proj.get(srsCode); var proj2 = ol.proj.get(srsCode);
expect(ol.proj.equivalent(proj2, proj)).to.be(true); expect(ol.proj.equivalent(proj2, proj)).to.be(true);