Fixed linting errors

This commit is contained in:
Anna Shchurova
2021-08-20 21:55:05 -04:00
parent ba65896cef
commit 711ae69bb5
2 changed files with 395 additions and 392 deletions
+6 -5
View File
@@ -5,7 +5,7 @@ import CanvasInstruction from './Instruction.js';
import GeometryType from '../../geom/GeometryType.js';
import Relationship from '../../extent/Relationship.js';
import VectorContext from '../VectorContext.js';
import {asColorLike} from '../../colorlike.js';
import { asColorLike } from '../../colorlike.js';
import {
buffer,
clone,
@@ -22,7 +22,7 @@ import {
defaultMiterLimit,
defaultStrokeStyle,
} from '../canvas.js';
import {equals, reverseSubArray} from '../../array.js';
import { equals, reverseSubArray } from '../../array.js';
import {
inflateCoordinates,
inflateCoordinatesArray,
@@ -259,7 +259,7 @@ class CanvasBuilder extends VectorContext {
let flatCoordinates, builderEnd, builderEnds, builderEndss;
let offset;
switch(type) {
switch (type) {
case GeometryType.MULTI_POLYGON:
flatCoordinates =
/** @type {import("../../geom/MultiPolygon.js").default} */ (
@@ -296,7 +296,8 @@ class CanvasBuilder extends VectorContext {
builderEndss,
geometry,
hitDetectionRenderer || renderer,
inflateMultiCoordinatesArray]);
inflateMultiCoordinatesArray,
]);
break;
case GeometryType.POLYGON:
case GeometryType.MULTI_LINE_STRING:
@@ -330,7 +331,7 @@ class CanvasBuilder extends VectorContext {
builderEnds,
geometry,
hitDetectionRenderer || renderer,
inflateCoordinatesArray
inflateCoordinatesArray,
]);
break;
case GeometryType.LINE_STRING:
+153 -151
View File
@@ -6,147 +6,147 @@ import CircleStyle from './Circle.js';
import Fill from './Fill.js';
import GeometryType from '../geom/GeometryType.js';
import Stroke from './Stroke.js';
import {assert} from '../asserts.js';
import { assert } from '../asserts.js';
/**
* A function that takes an {@link module:ol/Feature} and a `{number}`
* representing the view's resolution. The function should return a
* {@link module:ol/style/Style} or an array of them. This way e.g. a
* vector layer can be styled. If the function returns `undefined`, the
* feature will not be rendered.
*
* @typedef {function(import("../Feature.js").FeatureLike, number):(Style|Array<Style>|void)} StyleFunction
*/
* A function that takes an {@link module:ol/Feature} and a `{number}`
* representing the view's resolution. The function should return a
* {@link module:ol/style/Style} or an array of them. This way e.g. a
* vector layer can be styled. If the function returns `undefined`, the
* feature will not be rendered.
*
* @typedef {function(import("../Feature.js").FeatureLike, number):(Style|Array<Style>|void)} StyleFunction
*/
/**
* A {@link Style}, an array of {@link Style}, or a {@link StyleFunction}.
* @typedef {Style|Array<Style>|StyleFunction} StyleLike
*/
* A {@link Style}, an array of {@link Style}, or a {@link StyleFunction}.
* @typedef {Style|Array<Style>|StyleFunction} StyleLike
*/
/**
* A function that takes an {@link module:ol/Feature} as argument and returns an
* {@link module:ol/geom/Geometry} that will be rendered and styled for the feature.
*
* @typedef {function(import("../Feature.js").FeatureLike):
* (import("../geom/Geometry.js").default|import("../render/Feature.js").default|undefined)} GeometryFunction
*/
* A function that takes an {@link module:ol/Feature} as argument and returns an
* {@link module:ol/geom/Geometry} that will be rendered and styled for the feature.
*
* @typedef {function(import("../Feature.js").FeatureLike):
* (import("../geom/Geometry.js").default|import("../render/Feature.js").default|undefined)} GeometryFunction
*/
/**
* Custom renderer function. Takes two arguments:
*
* 1. The pixel coordinates of the geometry in GeoJSON notation.
* 2. The {@link module:ol/render~State} of the layer renderer.
*
* @typedef {function((import("../coordinate.js").Coordinate|Array<import("../coordinate.js").Coordinate>|Array<Array<import("../coordinate.js").Coordinate>>),import("../render.js").State): void}
* RenderFunction
*/
* Custom renderer function. Takes two arguments:
*
* 1. The pixel coordinates of the geometry in GeoJSON notation.
* 2. The {@link module:ol/render~State} of the layer renderer.
*
* @typedef {function((import("../coordinate.js").Coordinate|Array<import("../coordinate.js").Coordinate>|Array<Array<import("../coordinate.js").Coordinate>>),import("../render.js").State): void}
* RenderFunction
*/
/**
* @typedef {Object} Options
* @property {string|import("../geom/Geometry.js").default|GeometryFunction} [geometry] Feature property or geometry
* or function returning a geometry to render for this style.
* @property {import("./Fill.js").default} [fill] Fill style.
* @property {import("./Image.js").default} [image] Image style.
* @property {RenderFunction} [renderer] Custom renderer. When configured, `fill`, `stroke` and `image` will be
* ignored, and the provided function will be called with each render frame for each geometry.
* @property {RenderFunction} [hitDetectionRenderer] Custom renderer for hit detection. If provided will be used
* in hit detection rendering.
* @property {import("./Stroke.js").default} [stroke] Stroke style.
* @property {import("./Text.js").default} [text] Text style.
* @property {number} [zIndex] Z index.
*/
* @typedef {Object} Options
* @property {string|import("../geom/Geometry.js").default|GeometryFunction} [geometry] Feature property or geometry
* or function returning a geometry to render for this style.
* @property {import("./Fill.js").default} [fill] Fill style.
* @property {import("./Image.js").default} [image] Image style.
* @property {RenderFunction} [renderer] Custom renderer. When configured, `fill`, `stroke` and `image` will be
* ignored, and the provided function will be called with each render frame for each geometry.
* @property {RenderFunction} [hitDetectionRenderer] Custom renderer for hit detection. If provided will be used
* in hit detection rendering.
* @property {import("./Stroke.js").default} [stroke] Stroke style.
* @property {import("./Text.js").default} [text] Text style.
* @property {number} [zIndex] Z index.
*/
/**
* @classdesc
* Container for vector feature rendering styles. Any changes made to the style
* or its children through `set*()` methods will not take effect until the
* feature or layer that uses the style is re-rendered.
*
* ## Feature styles
*
* If no style is defined, the following default style is used:
* ```js
* import {Fill, Stroke, Circle, Style} from 'ol/style';
*
* var fill = new Fill({
* color: 'rgba(255,255,255,0.4)'
* });
* var stroke = new Stroke({
* color: '#3399CC',
* width: 1.25
* });
* var styles = [
* new Style({
* image: new Circle({
* fill: fill,
* stroke: stroke,
* radius: 5
* }),
* fill: fill,
* stroke: stroke
* })
* ];
* ```
*
* A separate editing style has the following defaults:
* ```js
* import {Fill, Stroke, Circle, Style} from 'ol/style';
* import GeometryType from 'ol/geom/GeometryType';
*
* var white = [255, 255, 255, 1];
* var blue = [0, 153, 255, 1];
* var width = 3;
* styles[GeometryType.POLYGON] = [
* new Style({
* fill: new Fill({
* color: [255, 255, 255, 0.5]
* })
* })
* ];
* styles[GeometryType.MULTI_POLYGON] =
* styles[GeometryType.POLYGON];
* styles[GeometryType.LINE_STRING] = [
* new Style({
* stroke: new Stroke({
* color: white,
* width: width + 2
* })
* }),
* new Style({
* stroke: new Stroke({
* color: blue,
* width: width
* })
* })
* ];
* styles[GeometryType.MULTI_LINE_STRING] =
* styles[GeometryType.LINE_STRING];
* styles[GeometryType.POINT] = [
* new Style({
* image: new Circle({
* radius: width * 2,
* fill: new Fill({
* color: blue
* }),
* stroke: new Stroke({
* color: white,
* width: width / 2
* })
* }),
* zIndex: Infinity
* })
* ];
* styles[GeometryType.MULTI_POINT] =
* styles[GeometryType.POINT];
* styles[GeometryType.GEOMETRY_COLLECTION] =
* styles[GeometryType.POLYGON].concat(
* styles[GeometryType.LINE_STRING],
* styles[GeometryType.POINT]
* );
* ```
*
* @api
*/
* @classdesc
* Container for vector feature rendering styles. Any changes made to the style
* or its children through `set*()` methods will not take effect until the
* feature or layer that uses the style is re-rendered.
*
* ## Feature styles
*
* If no style is defined, the following default style is used:
* ```js
* import {Fill, Stroke, Circle, Style} from 'ol/style';
*
* var fill = new Fill({
* color: 'rgba(255,255,255,0.4)'
* });
* var stroke = new Stroke({
* color: '#3399CC',
* width: 1.25
* });
* var styles = [
* new Style({
* image: new Circle({
* fill: fill,
* stroke: stroke,
* radius: 5
* }),
* fill: fill,
* stroke: stroke
* })
* ];
* ```
*
* A separate editing style has the following defaults:
* ```js
* import {Fill, Stroke, Circle, Style} from 'ol/style';
* import GeometryType from 'ol/geom/GeometryType';
*
* var white = [255, 255, 255, 1];
* var blue = [0, 153, 255, 1];
* var width = 3;
* styles[GeometryType.POLYGON] = [
* new Style({
* fill: new Fill({
* color: [255, 255, 255, 0.5]
* })
* })
* ];
* styles[GeometryType.MULTI_POLYGON] =
* styles[GeometryType.POLYGON];
* styles[GeometryType.LINE_STRING] = [
* new Style({
* stroke: new Stroke({
* color: white,
* width: width + 2
* })
* }),
* new Style({
* stroke: new Stroke({
* color: blue,
* width: width
* })
* })
* ];
* styles[GeometryType.MULTI_LINE_STRING] =
* styles[GeometryType.LINE_STRING];
* styles[GeometryType.POINT] = [
* new Style({
* image: new Circle({
* radius: width * 2,
* fill: new Fill({
* color: blue
* }),
* stroke: new Stroke({
* color: white,
* width: width / 2
* })
* }),
* zIndex: Infinity
* })
* ];
* styles[GeometryType.MULTI_POINT] =
* styles[GeometryType.POINT];
* styles[GeometryType.GEOMETRY_COLLECTION] =
* styles[GeometryType.POLYGON].concat(
* styles[GeometryType.LINE_STRING],
* styles[GeometryType.POINT]
* );
* ```
*
* @api
*/
class Style {
/**
* @param {Options} [opt_options] Style options.
@@ -192,7 +192,10 @@ class Style {
* @private
* @type {RenderFunction|null}
*/
this.hitDetectionRenderer_ = options.hitDetectionRenderer !== undefined ? options.hitDetectionRenderer : null;
this.hitDetectionRenderer_ =
options.hitDetectionRenderer !== undefined
? options.hitDetectionRenderer
: null;
/**
* @private
@@ -256,7 +259,6 @@ class Style {
this.renderer_ = renderer;
}
/**
* Sets a custom renderer function for this style used
* in hit detection.
@@ -418,13 +420,13 @@ class Style {
}
/**
* Convert the provided object into a style function. Functions passed through
* unchanged. Arrays of Style or single style objects wrapped in a
* new style function.
* @param {StyleFunction|Array<Style>|Style} obj
* A style function, a single style, or an array of styles.
* @return {StyleFunction} A style function.
*/
* Convert the provided object into a style function. Functions passed through
* unchanged. Arrays of Style or single style objects wrapped in a
* new style function.
* @param {StyleFunction|Array<Style>|Style} obj
* A style function, a single style, or an array of styles.
* @return {StyleFunction} A style function.
*/
export function toFunction(obj) {
let styleFunction;
@@ -450,15 +452,15 @@ export function toFunction(obj) {
}
/**
* @type {Array<Style>}
*/
* @type {Array<Style>}
*/
let defaultStyles = null;
/**
* @param {import("../Feature.js").FeatureLike} feature Feature.
* @param {number} resolution Resolution.
* @return {Array<Style>} Style.
*/
* @param {import("../Feature.js").FeatureLike} feature Feature.
* @param {number} resolution Resolution.
* @return {Array<Style>} Style.
*/
export function createDefaultStyle(feature, resolution) {
// We don't use an immediately-invoked function
// and a closure so we don't get an error at script evaluation time in
@@ -489,9 +491,9 @@ export function createDefaultStyle(feature, resolution) {
}
/**
* Default styles for editing features.
* @return {Object<import("../geom/GeometryType.js").default, Array<Style>>} Styles
*/
* Default styles for editing features.
* @return {Object<import("../geom/GeometryType.js").default, Array<Style>>} Styles
*/
export function createEditingStyle() {
/** @type {Object<import("../geom/GeometryType.js").default, Array<Style>>} */
const styles = {};
@@ -552,10 +554,10 @@ export function createEditingStyle() {
}
/**
* Function that is called with a feature and returns its default geometry.
* @param {import("../Feature.js").FeatureLike} feature Feature to get the geometry for.
* @return {import("../geom/Geometry.js").default|import("../render/Feature.js").default|undefined} Geometry to render.
*/
* Function that is called with a feature and returns its default geometry.
* @param {import("../Feature.js").FeatureLike} feature Feature to get the geometry for.
* @return {import("../geom/Geometry.js").default|import("../render/Feature.js").default|undefined} Geometry to render.
*/
function defaultGeometryFunction(feature) {
return feature.getGeometry();
}