Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
zmiao committed Feb 27, 2020
1 parent cbc231a commit b422b32
Show file tree
Hide file tree
Showing 19 changed files with 28 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/data/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type Context from '../gl/context';
import type {FeatureStates} from '../source/source_state';
import type {ImagePosition} from '../render/image_atlas';
import type {CanonicalTileID} from '../source/tile_id';

export type BucketParameters<Layer: TypedStyleLayer> = {
index: number,
layers: Array<Layer>,
Expand Down
1 change: 1 addition & 0 deletions src/data/bucket/circle_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import loadGeometry from '../load_geometry';
import EXTENT from '../extent';
import {register} from '../../util/web_worker_transfer';
import EvaluationParameters from '../../style/evaluation_parameters';

import type {CanonicalTileID} from '../../source/tile_id';
import type {
Bucket,
Expand Down
1 change: 1 addition & 0 deletions src/data/bucket/fill_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {register} from '../../util/web_worker_transfer';
import {hasPattern, addPatternDependencies} from './pattern_bucket_features';
import loadGeometry from '../load_geometry';
import EvaluationParameters from '../../style/evaluation_parameters';

import type {CanonicalTileID} from '../../source/tile_id';
import type {
Bucket,
Expand Down
1 change: 1 addition & 0 deletions src/data/bucket/fill_extrusion_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {register} from '../../util/web_worker_transfer';
import {hasPattern, addPatternDependencies} from './pattern_bucket_features';
import loadGeometry from '../load_geometry';
import EvaluationParameters from '../../style/evaluation_parameters';

import type {CanonicalTileID} from '../../source/tile_id';
import type {
Bucket,
Expand Down
1 change: 1 addition & 0 deletions src/data/bucket/line_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {register} from '../../util/web_worker_transfer';
import {hasPattern, addPatternDependencies} from './pattern_bucket_features';
import loadGeometry from '../load_geometry';
import EvaluationParameters from '../../style/evaluation_parameters';

import type {CanonicalTileID} from '../../source/tile_id';
import type {
Bucket,
Expand Down
1 change: 1 addition & 0 deletions src/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import EvaluationParameters from '../../style/evaluation_parameters';
import Formatted from '../../style-spec/expression/types/formatted';
import ResolvedImage from '../../style-spec/expression/types/resolved_image';
import {plugin as globalRTLTextPlugin, getRTLTextPluginStatus} from '../../source/rtl_text_plugin';

import type {CanonicalTileID} from '../../source/tile_id';
import type {
Bucket,
Expand Down
3 changes: 1 addition & 2 deletions src/data/feature_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ class FeatureIndex {
const sourceLayerName = this.sourceLayerCoder.decode(sourceLayerIndex);
const sourceLayer = this.vtLayers[sourceLayerName];
const feature = sourceLayer.feature(featureIndex);
const evaluationFeature = {type: feature.type, id: ('id' in feature ? feature.id : null), properties: feature.properties};
if (!filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature))
if (!filter(new EvaluationParameters(this.tileID.overscaledZ), feature))
return;

const id = this.getId(feature, sourceLayerName);
Expand Down
3 changes: 2 additions & 1 deletion src/data/program_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {register} from '../util/web_worker_transfer';
import {PossiblyEvaluatedPropertyValue} from '../style/properties';
import {StructArrayLayout1f4, StructArrayLayout2f8, StructArrayLayout4f16, PatternLayoutArray} from './array_types';
import {clamp} from '../util/util';

import loadGeometry from './load_geometry';
import type {CanonicalTileID} from '../source/tile_id';
import EvaluationParameters from '../style/evaluation_parameters';
import FeaturePositionMap from './feature_position_map';
import {
Expand All @@ -19,6 +19,7 @@ import {
type UniformLocations
} from '../render/uniform_binding';

import type {CanonicalTileID} from '../source/tile_id';
import type Context from '../gl/context';
import type {TypedStyleLayer} from '../style/style_layer/typed_style_layer';
import type {CrossfadeParameters} from '../style/evaluation_parameters';
Expand Down
1 change: 1 addition & 0 deletions src/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import browser from '../util/browser';
import EvaluationParameters from '../style/evaluation_parameters';
import SourceFeatureState from '../source/source_state';
import {lazyLoadRTLTextPlugin} from './rtl_text_plugin';

const CLOCK_SKEW_RETRY_TIMEOUT = 30000;

import type {Bucket} from '../data/bucket';
Expand Down
3 changes: 3 additions & 0 deletions src/source/worker_tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type {
WorkerTileCallback,
} from '../source/worker_source';
import type {PromoteIdSpecification} from '../style-spec/types';

class WorkerTile {
tileID: OverscaledTileID;
uid: string;
Expand Down Expand Up @@ -65,6 +66,7 @@ class WorkerTile {
parse(data: VectorTile, layerIndex: StyleLayerIndex, availableImages: Array<string>, actor: Actor, callback: WorkerTileCallback) {
this.status = 'parsing';
this.data = data;

this.collisionBoxArray = new CollisionBoxArray();
const sourceLayerCoder = new DictionaryCoder(Object.keys(data.layers).sort());

Expand Down Expand Up @@ -121,6 +123,7 @@ class WorkerTile {
sourceLayerIndex,
sourceID: this.source
});

bucket.populate(features, options, this.tileID.canonical);
featureIndex.bucketLayerIDs.push(family.map((l) => l.id));
}
Expand Down
4 changes: 2 additions & 2 deletions src/style-spec/expression/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import type {CanonicalTileID} from '../../source/tile_id';
export type Feature = {
+type: 1 | 2 | 3 | 'Unknown' | 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon',
+id?: any,
+properties: {[string]: any},
+patterns?: {[string]: {"min": string, "mid": string, "max": string}},
+properties: {[_: string]: any},
+patterns?: {[_: string]: {"min": string, "mid": string, "max": string}},
+geometry?: Array<Array<Point>>
};

Expand Down
1 change: 0 additions & 1 deletion src/style-spec/expression/parsing_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class ParsingContext {
}

const Expr = this.registry[op];

if (Expr) {
let parsed = Expr.parse(expr, this);
if (!parsed) return null;
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -3459,7 +3459,7 @@
"group": "Decision",
"sdk-support": {
"basic functionality": {
"js": "1.6.0"
"js": "1.9.0"
}
}
},
Expand Down
17 changes: 6 additions & 11 deletions src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,8 @@ class Style extends Evented {
}

/**
* Apply queued style updates in a batch and recalculate zoom-dependent paint properties.
*
* @param parameters
*/
* Apply queued style updates in a batch and recalculate zoom-dependent paint properties.
*/
update(parameters: EvaluationParameters) {
if (!this._loaded) {
return;
Expand Down Expand Up @@ -621,13 +619,10 @@ class Style extends Evented {
}

/**
* Add a layer to the map style. The layer will be inserted before the layer with
ID `before`, or appended if `before` is omitted.
*
* @param layerObject
* @param {string} [before] ID of an existing layer to insert before
* @param options
*/
* Add a layer to the map style. The layer will be inserted before the layer with
* ID `before`, or appended if `before` is omitted.
* @param {string} [before] ID of an existing layer to insert before
*/
addLayer(layerObject: LayerSpecification | CustomLayerInterface, before?: string, options: StyleSetterOptions = {}) {
this._checkLoaded();

Expand Down
5 changes: 2 additions & 3 deletions src/style/style_layer/circle_style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type Transform from '../../geo/transform';
import type {Bucket, BucketParameters} from '../../data/bucket';
import type {LayoutProps, PaintProps} from './circle_style_layer_properties';
import type {LayerSpecification} from '../../style-spec/types';
import loadGeometry from '../../data/load_geometry';

class CircleStyleLayer extends StyleLayer {
_unevaluatedLayout: Layout<LayoutProps>;
layout: PossiblyEvaluated<LayoutProps>;
Expand All @@ -40,7 +40,7 @@ class CircleStyleLayer extends StyleLayer {
}

queryIntersectsFeature(queryGeometry: Array<Point>,
vFeature: VectorTileFeature,
feature: VectorTileFeature,
featureState: FeatureState,
geometry: Array<Array<Point>>,
zoom: number,
Expand All @@ -51,7 +51,6 @@ class CircleStyleLayer extends StyleLayer {
this.paint.get('circle-translate'),
this.paint.get('circle-translate-anchor'),
transform.angle, pixelsToTileUnits);
const feature = {type: vFeature.type, properties: vFeature.properties, geometry: loadGeometry(vFeature)};
const radius = this.paint.get('circle-radius').evaluate(feature, featureState);
const stroke = this.paint.get('circle-stroke-width').evaluate(feature, featureState);
const size = radius + stroke;
Expand Down
4 changes: 1 addition & 3 deletions src/style/style_layer/fill_extrusion_style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import type {BucketParameters} from '../../data/bucket';
import type {PaintProps} from './fill_extrusion_style_layer_properties';
import type Transform from '../../geo/transform';
import type {LayerSpecification} from '../../style-spec/types';
import loadGeometry from '../../data/load_geometry';

class FillExtrusionStyleLayer extends StyleLayer {
_transitionablePaint: Transitionable<PaintProps>;
Expand All @@ -39,7 +38,7 @@ class FillExtrusionStyleLayer extends StyleLayer {
}

queryIntersectsFeature(queryGeometry: Array<Point>,
vfeature: VectorTileFeature,
feature: VectorTileFeature,
featureState: FeatureState,
geometry: Array<Array<Point>>,
zoom: number,
Expand All @@ -51,7 +50,6 @@ class FillExtrusionStyleLayer extends StyleLayer {
this.paint.get('fill-extrusion-translate'),
this.paint.get('fill-extrusion-translate-anchor'),
transform.angle, pixelsToTileUnits);
const feature = {type: vfeature.type, properties: vfeature.properties, geometry: loadGeometry(vfeature)};
const height = this.paint.get('fill-extrusion-height').evaluate(feature, featureState);
const base = this.paint.get('fill-extrusion-base').evaluate(feature, featureState);

Expand Down
4 changes: 1 addition & 3 deletions src/style/style_layer/line_style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import type {LayoutProps, PaintProps} from './line_style_layer_properties';
import type Transform from '../../geo/transform';
import type Texture from '../../render/texture';
import type {LayerSpecification} from '../../style-spec/types';
import loadGeometry from '../../data/load_geometry';

class LineFloorwidthProperty extends DataDrivenProperty<number> {
useIntegerZoom: true;
Expand Down Expand Up @@ -91,7 +90,7 @@ class LineStyleLayer extends StyleLayer {
}

queryIntersectsFeature(queryGeometry: Array<Point>,
vfeature: VectorTileFeature,
feature: VectorTileFeature,
featureState: FeatureState,
geometry: Array<Array<Point>>,
zoom: number,
Expand All @@ -101,7 +100,6 @@ class LineStyleLayer extends StyleLayer {
this.paint.get('line-translate'),
this.paint.get('line-translate-anchor'),
transform.angle, pixelsToTileUnits);
const feature = {type: vfeature.type, properties: vfeature.properties, geometry: loadGeometry(vfeature)};
const halfWidth = pixelsToTileUnits / 2 * getLineWidth(
this.paint.get('line-width').evaluate(feature, featureState),
this.paint.get('line-gap-width').evaluate(feature, featureState));
Expand Down
1 change: 1 addition & 0 deletions src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ class Map extends Camera {
PerformanceUtils.mark(PerformanceMarkers.create);

options = extend({}, defaultOptions, options);

if (options.minZoom != null && options.maxZoom != null && options.minZoom > options.maxZoom) {
throw new Error(`maxZoom must be greater than or equal to minZoom`);
}
Expand Down
1 change: 1 addition & 0 deletions src/util/web_worker_transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ register('Color', Color);
register('Error', Error);
register('ResolvedImage', ResolvedImage);
register('StylePropertyFunction', StylePropertyFunction);

register('StyleExpression', StyleExpression, {omit: ['_evaluator']});

register('ZoomDependentExpression', ZoomDependentExpression);
Expand Down

0 comments on commit b422b32

Please sign in to comment.