Skip to content

Commit

Permalink
fix broken layers with pattern expressions (#8833)
Browse files Browse the repository at this point in the history
 fix #8832 broken fill pattern layers

ResolvedImage was not registered for serialization. This registers it
and fixes a couple codegen'd files so that they generate properly.
  • Loading branch information
ansis authored and ryanhamley committed Oct 9, 2019
1 parent d95de6e commit a64bfc0
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build/generate-style-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ global.flowType = function (property) {
case 'formatted':
return `Formatted`;
case 'image':
return `Image`;
return `ResolvedImage`;
case 'array':
if (property.length) {
return `[${new Array(property.length).fill(flowType({type: property.value})).join(', ')}]`;
Expand Down
1 change: 1 addition & 0 deletions src/style/style_layer/background_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type Formatted from '../../style-spec/expression/types/formatted';

import type ResolvedImage from '../../style-spec/expression/types/resolved_image';


export type PaintProps = {|
"background-color": DataConstantProperty<Color>,
"background-pattern": CrossFadedProperty<ResolvedImage>,
Expand Down
2 changes: 2 additions & 0 deletions src/style/style_layer/circle_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import type Color from '../../style-spec/util/color';

import type Formatted from '../../style-spec/expression/types/formatted';

import type ResolvedImage from '../../style-spec/expression/types/resolved_image';

export type LayoutProps = {|
"circle-sort-key": DataDrivenProperty<number>,
|};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type Formatted from '../../style-spec/expression/types/formatted';

import type ResolvedImage from '../../style-spec/expression/types/resolved_image';


export type PaintProps = {|
"fill-extrusion-opacity": DataConstantProperty<number>,
"fill-extrusion-color": DataDrivenProperty<Color>,
Expand Down
2 changes: 2 additions & 0 deletions src/style/style_layer/heatmap_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import type Color from '../../style-spec/util/color';

import type Formatted from '../../style-spec/expression/types/formatted';

import type ResolvedImage from '../../style-spec/expression/types/resolved_image';


export type PaintProps = {|
"heatmap-radius": DataDrivenProperty<number>,
Expand Down
2 changes: 2 additions & 0 deletions src/style/style_layer/hillshade_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import type Color from '../../style-spec/util/color';

import type Formatted from '../../style-spec/expression/types/formatted';

import type ResolvedImage from '../../style-spec/expression/types/resolved_image';


export type PaintProps = {|
"hillshade-illumination-direction": DataConstantProperty<number>,
Expand Down
2 changes: 2 additions & 0 deletions src/style/style_layer/layer_properties.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
import type Color from '../../style-spec/util/color';

import type Formatted from '../../style-spec/expression/types/formatted';

import type ResolvedImage from '../../style-spec/expression/types/resolved_image';
<%
const overridables = paintProperties.filter(p => p.overridable)
if (overridables.length) { -%>
Expand Down
2 changes: 2 additions & 0 deletions src/style/style_layer/raster_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import type Color from '../../style-spec/util/color';

import type Formatted from '../../style-spec/expression/types/formatted';

import type ResolvedImage from '../../style-spec/expression/types/resolved_image';


export type PaintProps = {|
"raster-opacity": DataConstantProperty<number>,
Expand Down
2 changes: 2 additions & 0 deletions src/util/web_worker_transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Color from '../style-spec/util/color';
import {StylePropertyFunction, StyleExpression, ZoomDependentExpression, ZoomConstantExpression} from '../style-spec/expression';
import CompoundExpression from '../style-spec/expression/compound_expression';
import expressions from '../style-spec/expression/definitions';
import ResolvedImage from '../style-spec/expression/types/resolved_image';
import window from './window';
const {ImageData} = window;

Expand Down Expand Up @@ -86,6 +87,7 @@ register('Grid', Grid);

register('Color', Color);
register('Error', Error);
register('ResolvedImage', ResolvedImage);

register('StylePropertyFunction', StylePropertyFunction);
register('StyleExpression', StyleExpression, {omit: ['_evaluator']});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions test/integration/render-tests/line-pattern/zoom-expression/style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"version": 8,
"metadata": {
"test": {
"height": 128,
"width": 128
}
},
"zoom": 2,
"sprite": "local://sprites/emerald",
"sources": {
"a": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"class": "trunk"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
10,
-10
],
[
-10,
-10
]
]
}
},
{
"type": "Feature",
"properties": {
"class": "path"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
-10,
0
],
[
10,
0
]
]
}
},
{
"type": "Feature",
"properties": {
"class": "street"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
-10,
10
],
[
10,
10
]
]
}
}
]
}
}
},
"layers": [
{
"id": "background",
"type": "background",
"paint": {
"background-color": "white"
}
},
{
"id": "road",
"type": "line",
"source": "a",
"paint": {
"line-width": 10,
"line-pattern": [
"step", ["zoom"],
"generic_icon",
2,
"generic_metro"
]
}
}
]
}

0 comments on commit a64bfc0

Please sign in to comment.