-
Notifications
You must be signed in to change notification settings - Fork 227
Protobuf changes #472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Protobuf changes #472
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ | |
|
|
||
| /* eslint-disable camelcase */ | ||
| import {CompositeLayer} from '@deck.gl/core'; | ||
| import {ScatterplotLayer, PathLayer, PolygonLayer, TextLayer} from '@deck.gl/layers'; | ||
| import {ScatterplotLayer, PathLayer, PolygonLayer, TextLayer, BitmapLayer} from '@deck.gl/layers'; | ||
| import PointCloudLayer from './point-cloud-layer/point-cloud-layer'; | ||
| // TODO/ib - Uncomment to enable binary/flat polygon arrays | ||
| // import PathLayer from './binary-path-layer/binary-path-layer'; | ||
|
|
@@ -30,6 +30,16 @@ import {XVIZObject} from '@xviz/parser'; | |
|
|
||
| import deepExtend from 'lodash.merge'; | ||
|
|
||
| const XVIZ_PRIMITIVE_TYPES = { | ||
| circle: 'circle', | ||
| image: 'image', | ||
| point: 'point', | ||
| polygon: 'polygon', | ||
| polyline: 'polyline', | ||
| stadium: 'stadium', | ||
| text: 'text' | ||
| }; | ||
|
|
||
| const XVIZ_TO_LAYER_TYPE = { | ||
| // V1 | ||
| points2d: 'scatterplot', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets not change the existing style unless there is some reason. When in rome ... |
||
|
|
@@ -46,7 +56,8 @@ const XVIZ_TO_LAYER_TYPE = { | |
| polyline: 'path', | ||
| polygon: 'polygon', | ||
| text: 'text', | ||
| stadium: 'stadium' | ||
| stadium: 'stadium', | ||
| image: 'image' | ||
| }; | ||
|
|
||
| const STYLE_TO_LAYER_PROP = { | ||
|
|
@@ -59,9 +70,9 @@ const STYLE_TO_LAYER_PROP = { | |
| filled: 'filled', | ||
| stroke_width_min_pixels: 'lineWidthMinPixels', | ||
| stroke_width_max_pixels: 'lineWidthMaxPixels', | ||
| stroke_width: 'getLineWidth', | ||
| stroke_color: 'getLineColor', | ||
| fill_color: 'getFillColor' | ||
| strokeWidth: 'getLineWidth', | ||
| strokeColor: 'getLineColor', | ||
| fillColor: 'getFillColor' | ||
| }, | ||
| pointcloud: { | ||
| opacity: 'opacity', | ||
|
|
@@ -74,34 +85,34 @@ const STYLE_TO_LAYER_PROP = { | |
| opacity: 'opacity', | ||
| stroke_width_min_pixels: 'widthMinPixels', | ||
| stroke_width_max_pixels: 'widthMaxPixels', | ||
| stroke_color: 'getColor', | ||
| stroke_width: 'getWidth' | ||
| strokeColor: 'getColor', | ||
| strokeWidth: 'getWidth' | ||
| }, | ||
| stadium: { | ||
| opacity: 'opacity', | ||
| radius_min_pixels: 'widthMinPixels', | ||
| radius_max_pixels: 'widthMaxPixels', | ||
| fill_color: 'getColor', | ||
| fillColor: 'getColor', | ||
| radius: 'getWidth' | ||
| }, | ||
| polygon: { | ||
| opacity: 'opacity', | ||
| stroked: 'stroked', | ||
| filled: 'filled', | ||
| extruded: 'extruded', | ||
| stroke_color: 'getLineColor', | ||
| stroke_width: 'getLineWidth', | ||
| strokeColor: 'getLineColor', | ||
| strokeWidth: 'getLineWidth', | ||
| stroke_width_min_pixels: 'lineWidthMinPixels', | ||
| stroke_width_max_pixels: 'lineWidthMaxPixels', | ||
| fill_color: 'getFillColor', | ||
| fillColor: 'getFillColor', | ||
| height: 'getElevation' | ||
| }, | ||
| text: { | ||
| opacity: 'opacity', | ||
| fill_color: 'getColor', | ||
| fillColor: 'getColor', | ||
| font_family: 'fontFamily', | ||
| font_weight: 'fontWeight', | ||
| text_size: 'getSize', | ||
| textSize: 'getSize', | ||
| text_rotation: 'getAngle', | ||
| text_anchor: 'getTextAnchor', | ||
| text_baseline: 'getAlignmentBaseline' | ||
|
|
@@ -130,15 +141,22 @@ const getStylesheetProperty = (context, propertyName, objectState) => | |
| // to be inline, stylesheet, then default. | ||
| // | ||
| /* eslint-disable complexity */ | ||
| function getProperty(context, propertyName, f = EMPTY_OBJECT) { | ||
| function getProperty( | ||
| context, | ||
| propertyName, | ||
| f = EMPTY_OBJECT, | ||
| primitiveType = null | ||
| ) { | ||
| let objectState = f; | ||
|
|
||
| // Handle XVIZ v1 color override where our semantic color mapping | ||
| // differs from current OCS colors. In XVIZ v2 we should be aligned. | ||
| if (context.useSemanticColor) { | ||
| switch (propertyName) { | ||
| case 'stroke_color': | ||
| case 'strokeColor': | ||
| case 'fill_color': | ||
| case 'fillColor': | ||
| objectState = XVIZObject.get(f.id) || f; | ||
| break; | ||
|
|
||
|
|
@@ -154,9 +172,12 @@ function getProperty(context, propertyName, f = EMPTY_OBJECT) { | |
| switch (propertyName) { | ||
| case 'stroke_color': | ||
| case 'fill_color': | ||
| case 'strokeColor': | ||
| case 'fillColor': | ||
| altPropertyName = 'color'; | ||
| break; | ||
| case 'stroke_width': | ||
| case 'strokeWidth': | ||
| altPropertyName = 'thickness'; | ||
| break; | ||
| case 'radius': | ||
|
|
@@ -190,25 +211,47 @@ function getProperty(context, propertyName, f = EMPTY_OBJECT) { | |
|
|
||
| // 3. Property from default style | ||
| if (property === null) { | ||
| property = context.style.getPropertyDefault(propertyName); | ||
| property = context.style.getPropertyDefault(propertyName, primitiveType); | ||
| } | ||
|
|
||
| if (propertyName === 'text_anchor' || propertyName === 'text_baseline') { | ||
| if ( | ||
| property && | ||
| (propertyName === 'text_anchor' || propertyName === 'text_baseline') | ||
| ) { | ||
| // These XVIZ enumerations map to Deck.gl as lowercase strings | ||
| property = property.toLowerCase(); | ||
| } | ||
| if ( | ||
| property && | ||
| (propertyName === 'textAnchor' || propertyName === 'textBaseline') | ||
| ) { | ||
| // These XVIZ enumerations map to Deck.gl as lowercase strings | ||
| const lcProp = property.toLowerCase(); | ||
| property = `${lcProp.substring(0, 4)}_${lcProp.substring(4)}`; | ||
| } | ||
|
|
||
| return property; | ||
| } | ||
| /* eslint-enable complexity */ | ||
|
|
||
| export default class XVIZLayer extends CompositeLayer { | ||
| _getProperty(propertyName) { | ||
| return getProperty(this.props, propertyName); | ||
| return getProperty( | ||
| this.props, | ||
| propertyName, | ||
| {}, | ||
| this._getLayerType(this.props.data) | ||
| ); | ||
| } | ||
|
|
||
| _getPropertyAccessor(propertyName) { | ||
| return f => getProperty(this.props, propertyName, f); | ||
| return f => | ||
| getProperty( | ||
| this.props, | ||
| propertyName, | ||
| f, | ||
| this._getLayerType(this.props.data) | ||
| ); | ||
| } | ||
|
|
||
| // These props are persistent unless data type and stylesheet change | ||
|
|
@@ -331,7 +374,10 @@ export default class XVIZLayer extends CompositeLayer { | |
| length: data[0].points.length / 3, | ||
| attributes: { | ||
| getPosition: data[0].points, | ||
| getColor: data[0].colors | ||
| getColor: { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fixing the difference between rgb and rgba? We should make sure we have a test for this
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, I will add some tests |
||
| value: data[0].colors, | ||
| size: data[0].points.length === data[0].colors.length ? 3 : 4 | ||
| } | ||
| } | ||
| }, | ||
| vehicleRelativeTransform: this.props.vehicleRelativeTransform, | ||
|
|
@@ -353,6 +399,7 @@ export default class XVIZLayer extends CompositeLayer { | |
| }) | ||
| ); | ||
|
|
||
| // TODO (mauricio): also figure out wht a box appears on top of the stadium | ||
| case 'stadium': | ||
| return new PathLayer( | ||
| forwardProps, | ||
|
|
@@ -378,6 +425,7 @@ export default class XVIZLayer extends CompositeLayer { | |
| data, | ||
| lightSettings, | ||
| wireframe: layerProps.stroked, | ||
| extruded: layerProps.stroked, //TODO: check for height instead | ||
| getPolygon: f => f.vertices, | ||
| updateTriggers: deepExtend(updateTriggers, { | ||
| getLineColor: {useSemanticColor: this.props.useSemanticColor}, | ||
|
|
@@ -400,6 +448,21 @@ export default class XVIZLayer extends CompositeLayer { | |
| }) | ||
| ); | ||
|
|
||
| case XVIZ_PRIMITIVE_TYPES.image: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this constant buy us? The rest of the code is just using a string. Just curious if i'm missing something. |
||
| // TODO (mauricio): images stream is being filtered out, figure out why | ||
| return new BitmapLayer( | ||
| forwardProps, | ||
| layerProps, | ||
| this.getSubLayerProps({ | ||
| id: XVIZ_PRIMITIVE_TYPES.image, | ||
| image: URL.createObjectURL( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. URL is not defined. |
||
| // TODO (mauricio): adjust this once we can send mime type from the backend | ||
| new Blob([data[0].data], { type: 'image/png' }) | ||
| ), | ||
| bounds: [-1, -1, 1, 1] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add comment on this. We need to get the actual width changes added to xviz. |
||
| }) | ||
| ); | ||
|
|
||
| default: | ||
| return null; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be using fixed versions. Why is this necessary. Is there a patch version that is required? Otherwise ^ should cover this already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I partially agree with you, unfortunately dependencies among the whole viz.gl packages are complex and having fuzzy versions leads to tons of conflicts. Some of them can be solved with resolutions, but a lot of them cannot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we've made it this far? Do we have a concise statement of the problem? This does not seem to be a streetscape.gl issue, but an application issue. So the solution should be placed there, not in streetscape.gl