Fixed tests & linting
This commit is contained in:
@@ -7,7 +7,7 @@ export {default as Collection} from './Collection.js';
|
||||
export {default as Disposable} from './Disposable.js';
|
||||
export {default as Feature} from './Feature.js';
|
||||
export {default as Geolocation} from './Geolocation.js';
|
||||
export {default as Graticule} from './Graticule.js';
|
||||
export {default as Graticule} from './layer/Graticule.js';
|
||||
export {default as Image} from './Image.js';
|
||||
export {default as ImageBase} from './ImageBase.js';
|
||||
export {default as ImageCanvas} from './ImageCanvas.js';
|
||||
|
||||
@@ -3,27 +3,27 @@
|
||||
*/
|
||||
import VectorLayer from './Vector.js';
|
||||
import {assign} from '../obj.js';
|
||||
import {degreesToStringHDMS} from "../coordinate";
|
||||
import Text from "../style/Text";
|
||||
import Fill from "../style/Fill";
|
||||
import Stroke from "../style/Stroke";
|
||||
import {degreesToStringHDMS} from '../coordinate';
|
||||
import Text from '../style/Text';
|
||||
import Fill from '../style/Fill';
|
||||
import Stroke from '../style/Stroke';
|
||||
import LineString from '../geom/LineString.js';
|
||||
import VectorSource from "../source/Vector";
|
||||
import VectorSource from '../source/Vector';
|
||||
import {
|
||||
equivalent as equivalentProjection,
|
||||
get as getProjection,
|
||||
getTransform,
|
||||
transformExtent
|
||||
} from "../proj";
|
||||
import {getCenter, intersects, equals, getIntersection, isEmpty} from '../extent'
|
||||
import {clamp} from "../math";
|
||||
import Style from "../style/Style";
|
||||
import Feature from "../Feature";
|
||||
import {bbox} from "../loadingstrategy";
|
||||
import {meridian, parallel} from "../geom/flat/geodesic";
|
||||
import GeometryLayout from "../geom/GeometryLayout";
|
||||
import Point from "../geom/Point";
|
||||
import Collection from "../Collection";
|
||||
} from '../proj';
|
||||
import {getCenter, intersects, equals, getIntersection, isEmpty} from '../extent';
|
||||
import {clamp} from '../math';
|
||||
import Style from '../style/Style';
|
||||
import Feature from '../Feature';
|
||||
import {bbox} from '../loadingstrategy';
|
||||
import {meridian, parallel} from '../geom/flat/geodesic';
|
||||
import GeometryLayout from '../geom/GeometryLayout';
|
||||
import Point from '../geom/Point';
|
||||
import Collection from '../Collection';
|
||||
|
||||
|
||||
/**
|
||||
@@ -313,16 +313,17 @@ class Graticule extends VectorLayer {
|
||||
options.latLabelPosition;
|
||||
|
||||
/**
|
||||
* @type {Object.<string,function(Feature):Style>}
|
||||
* @type {Object.<string,Style>}
|
||||
* @private
|
||||
*/
|
||||
this.lonLabelStyleCache_ = {};
|
||||
|
||||
/**
|
||||
* @type {function(Feature):Style}
|
||||
* @private
|
||||
* @param {import("../Feature").default} feature Feature
|
||||
* @return {Style} style
|
||||
*/
|
||||
this.lonLabelStyle_ = function (feature) {
|
||||
this.lonLabelStyle_ = function(feature) {
|
||||
const label = feature.get('graticule_label');
|
||||
if (!this.lonLabelStyleCache_[label]) {
|
||||
this.lonLabelStyleCache_[label] = new Style({
|
||||
@@ -345,16 +346,17 @@ class Graticule extends VectorLayer {
|
||||
}.bind(this);
|
||||
|
||||
/**
|
||||
* @type {Object.<string,function(Feature):Style>}
|
||||
* @type {Object.<string,Style>}
|
||||
* @private
|
||||
*/
|
||||
this.latLabelStyleCache_ = {};
|
||||
|
||||
/**
|
||||
* @type {function(Feature):Style}
|
||||
* @private
|
||||
* @param {import("../Feature").default} feature Feature
|
||||
* @return {Style} style
|
||||
*/
|
||||
this.latLabelStyle_ = function (feature) {
|
||||
this.latLabelStyle_ = function(feature) {
|
||||
const label = feature.get('graticule_label');
|
||||
if (!this.latLabelStyleCache_[label]) {
|
||||
this.latLabelStyleCache_[label] = new Style({
|
||||
@@ -430,6 +432,9 @@ class Graticule extends VectorLayer {
|
||||
|
||||
/**
|
||||
* Update geometries in the source based on current view
|
||||
* @param {import("../extent").Extent} extent Extent
|
||||
* @param {number} resolution Resolution
|
||||
* @param {import("../proj/Projection.js").default} projection Projection
|
||||
*/
|
||||
loaderFunction(extent, resolution, projection) {
|
||||
const source = /** @type import("../source/Vector").default} */ (this.getSource());
|
||||
@@ -439,7 +444,7 @@ class Graticule extends VectorLayer {
|
||||
const renderExtent = getIntersection(layerExtent, extent, this.tmpExtent_);
|
||||
|
||||
// we should not keep track of loaded extents
|
||||
setTimeout(function () {
|
||||
setTimeout(function() {
|
||||
source.removeLoadedExtent(extent);
|
||||
}, 0);
|
||||
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import Graticule from '../../../src/ol/Graticule.js';
|
||||
import Graticule from '../../../src/ol/layer/Graticule.js';
|
||||
import Map from '../../../src/ol/Map.js';
|
||||
import {get as getProjection} from '../../../src/ol/proj.js';
|
||||
import Stroke from '../../../src/ol/style/Stroke.js';
|
||||
import Text from '../../../src/ol/style/Text.js';
|
||||
import Feature from '../../../src/ol/Feature';
|
||||
|
||||
describe('ol.Graticule', function() {
|
||||
describe('ol.layer.Graticule', function() {
|
||||
let graticule;
|
||||
|
||||
function createGraticule() {
|
||||
graticule = new Graticule({
|
||||
map: new Map({})
|
||||
graticule = new Graticule();
|
||||
new Map({
|
||||
layers: [graticule]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,9 +33,11 @@ describe('ol.Graticule', function() {
|
||||
|
||||
it('creates a graticule with labels', function() {
|
||||
graticule = new Graticule({
|
||||
map: new Map({}),
|
||||
showLabels: true
|
||||
});
|
||||
new Map({
|
||||
layers: [graticule]
|
||||
});
|
||||
const extent = [-25614353.926475704, -7827151.696402049,
|
||||
25614353.926475704, 7827151.696402049];
|
||||
const projection = getProjection('EPSG:3857');
|
||||
@@ -75,6 +79,7 @@ describe('ol.Graticule', function() {
|
||||
it('can be configured with label options', function() {
|
||||
const latLabelStyle = new Text();
|
||||
const lonLabelStyle = new Text();
|
||||
const feature = new Feature();
|
||||
graticule = new Graticule({
|
||||
map: new Map({}),
|
||||
showLabels: true,
|
||||
@@ -98,15 +103,14 @@ describe('ol.Graticule', function() {
|
||||
graticule.createGraticule_(extent, [0, 0], resolution, squaredTolerance);
|
||||
expect(graticule.meridiansLabels_[0].text).to.be('lon: 0');
|
||||
expect(graticule.parallelsLabels_[0].text).to.be('lat: 0');
|
||||
expect(graticule.lonLabelStyle_).to.eql(lonLabelStyle);
|
||||
expect(graticule.latLabelStyle_).to.eql(latLabelStyle);
|
||||
expect(graticule.lonLabelStyle_(feature).getText()).to.eql(lonLabelStyle);
|
||||
expect(graticule.latLabelStyle_(feature).getText()).to.eql(latLabelStyle);
|
||||
expect(graticule.lonLabelPosition_).to.be(0.9);
|
||||
expect(graticule.latLabelPosition_).to.be(0.1);
|
||||
});
|
||||
|
||||
it('can be configured with interval limits', function() {
|
||||
graticule = new Graticule({
|
||||
map: new Map({}),
|
||||
showLabels: true,
|
||||
lonLabelFormatter: function(lon) {
|
||||
return lon.toString();
|
||||
@@ -116,6 +120,9 @@ describe('ol.Graticule', function() {
|
||||
},
|
||||
intervals: [10]
|
||||
});
|
||||
new Map({
|
||||
layers: [graticule]
|
||||
});
|
||||
const extent = [-25614353.926475704, -7827151.696402049,
|
||||
25614353.926475704, 7827151.696402049];
|
||||
const projection = getProjection('EPSG:3857');
|
||||
|
||||
Reference in New Issue
Block a user