Skip to content

Commit

Permalink
Compare projections by code
Browse files Browse the repository at this point in the history
  • Loading branch information
mschulz-716 committed May 4, 2022
1 parent 3f2825d commit ff6bffe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/olcs/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ exports.olGeometryCloneTo4326 = function(geometry, projection) {

const proj4326 = getProjection('EPSG:4326');
const proj = getProjection(projection);
if (proj !== proj4326) {
if (proj.getCode() !== proj4326.getCode()) {
const properties = geometry.getProperties();
geometry = geometry.clone();
geometry.transform(proj, proj4326);
Expand Down Expand Up @@ -753,8 +753,8 @@ exports.normalizeView = function(view, angle = 0) {
* @returns {boolean} Whether it's managed by Cesium.
*/
exports.isCesiumProjection = function(projection) {
const is3857 = projection === getProjection('EPSG:3857');
const is4326 = projection === getProjection('EPSG:4326');
const is3857 = projection.getCode() === 'EPSG:3857';
const is4326 = projection.getCode() === 'EPSG:4326';
return is3857 || is4326;
};

Expand Down
5 changes: 2 additions & 3 deletions src/olcs/core/OLImageryProvider.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* @module olcs.core.OLImageryProvider
*/
import {get as getProjection} from 'ol/proj.js';
import olcsUtil from '../util.js';
import {Tile as TileSource} from 'ol/source.js';
import {attributionsFunctionToCredits} from '../core.js';
Expand Down Expand Up @@ -124,11 +123,11 @@ class OLImageryProvider /* should not extend Cesium.ImageryProvider */ {
});
}

if (this.projection_ == getProjection('EPSG:4326')) {
if (this.projection_.getCode() === 'EPSG:4326') {
// Cesium zoom level 0 is OpenLayers zoom level 1 for layer in EPSG:4326 with a single tile on level 0
this.shouldRequestNextLevel = options.numberOfLevelZeroTilesX === 1 && options.numberOfLevelZeroTilesY === 1;
this.tilingScheme_ = new Cesium.GeographicTilingScheme(options);
} else if (this.projection_ == getProjection('EPSG:3857')) {
} else if (this.projection_.getCode() === 'EPSG:3857') {
this.shouldRequestNextLevel = false;
this.tilingScheme_ = new Cesium.WebMercatorTilingScheme(options);
} else {
Expand Down

0 comments on commit ff6bffe

Please sign in to comment.