-
Notifications
You must be signed in to change notification settings - Fork 302
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
Rework style #2006
Rework style #2006
Conversation
aaa8c17
to
c8d3ce6
Compare
4fb2b18
to
25f76f0
Compare
8ae0ae6
to
99a9d36
Compare
99a9d36
to
c54fedd
Compare
84f71b6
to
fb2895d
Compare
src/Core/Style.js
Outdated
@@ -138,10 +138,10 @@ function defineStyleProperty(style, category, parameter, userValue, defaultValue | |||
{ | |||
enumerable: true, | |||
get: () => { | |||
if (property) { return property; } | |||
if (userValue) { return readExpression(userValue, style.context); } | |||
if (property !== undefined) { return property; } |
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.
you have to check for null
too
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.
done. Using value != undefined.
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.
Seems to work for null
and undefined
but are you sure it won't be true
in any other case? I haven't found many documentation about it and it is more generally done with property !== undefined && property !== null
(even if it is more verbose)
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 got the information on internet https://codedamn.com/news/javascript/check-if-undefined-null and checked it with https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Operators/Inequality.
src/Core/Style.js
Outdated
@@ -895,6 +895,13 @@ class Style { | |||
} | |||
} | |||
} | |||
// VectorTileSet: by default minZoom = 0 and maxZoom = 24 | |||
// https://docs.mapbox.com/style-spec/reference/layers/#maxzoom and #minzoom | |||
// Should be move to layer properties, when (if) VectorTile will be considered as multiLayer. |
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.
what do you mean by "multilayer" ?
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.
A VectorTileSource send for each tile data on several 'layer' (building, road etc for instance), thus the use of the propertiy filter (that should be move to layer in my opinion). So one Layer with a VectorTileSource will have data on several vectorTile 'layer' that can have diferent 'layer' properties (style, zoom max and min etc). That why i fell like this kind of source is more a multiLayer that a real Layer.
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.
Ok I understand what you mean, there is itowns layer concept and mapbox layer concept; can you precise your comment then or open an issue please? Otherwise I'm afraid that we won't understand this comment in a few month...
c7d80eb
to
65003a9
Compare
src/Core/Style.js
Outdated
* and zoom of a Style instance. | ||
* When the getter of a categorie.parameter is called, the purpose is to send, in that order, the value set by the user 'userValue' | ||
* (if available), or the value read from the data 'dataValue' or the default value 'defaultValue' (if set). In case we | ||
* need to overpass all we can set a value using the setter. |
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 propose to update the comment a bit:
Defines a new style property and its getter and setter for a given parameter in a given category (one of fill, stroke, point, text, icon or zoom).
The getter is in charge of returning the right style value from the following ones if they are defined (in that specific order):
* the value set by the user (`userValue`)
* the value read from the data source (`dataValue`)
* the default fallback value (`defaultValue`)
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.
Thanks for that proposal that is indeed clearer that mine. I used it to update the documentation.
src/Main.js
Outdated
@@ -39,7 +39,7 @@ export { CAMERA_TYPE } from 'Renderer/Camera'; | |||
|
|||
// Internal itowns format | |||
export { default as Feature, FeatureCollection, FeatureGeometry, FEATURE_TYPES } from 'Core/Feature'; | |||
export { default as Style } from 'Core/Style'; | |||
// export { default as Style } from 'Core/Style'; |
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.
why do you need this change ? I think it is out of scope of this PR and we should uncomment it for now.
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.
Indeed. It's not in the scope of the PR and was just a test to see if it can be removed safely in the futur (with the actual modification).
251ef1f
to
b9287ba
Compare
…mContext(ctx) for hierarchization of style properties
b9287ba
to
74f364e
Compare
Description
Change how itowns.Style() is used in relation with itowns.Feature.
Additional changes :
The instanciation of itowns.style is now only done on converter and not anymore on Source nor during the Feature generation:
For that we currently create an object style, to store all properties used later on for the instanciation of itowns.Style().
A slight change in base_altitude has been made, to be able to use a function for feature.style.
All references to parent Style had been removed.
Merge Style.symbolStylefromContext() with Style.drawingStylefromContext()
Examples:
in master branch:
with that PR: