Skip to content
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

Merged
merged 11 commits into from
Dec 13, 2023
Merged

Rework style #2006

merged 11 commits into from
Dec 13, 2023

Conversation

ftoromanoff
Copy link
Contributor

@ftoromanoff ftoromanoff commented Feb 14, 2023

Description

Change how itowns.Style() is used in relation with itowns.Feature.

  • remove propertie 'style' at some level to keep to the miminum:
    • 2 were kept: layer and feature
    • 2 were removed: collection and geometry.properties
  • make prioritarization of style work : layer (user) > feature (data) and this for all sub properties of style.
    • currently, the layer style is not always applied over the data style. (see example 1)
    • when one properties of point, stroke or fill is given, it all needed to be given or the default value will be used even if the child properties is existing.

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:

  1. source_file_kml_raster -> adding text.color: 'red'

in master branch:
image
with that PR:
image

@ftoromanoff ftoromanoff changed the title Rework style WIP Rework style Feb 14, 2023
@ftoromanoff ftoromanoff marked this pull request as draft February 14, 2023 16:03
@ftoromanoff ftoromanoff force-pushed the reworkStyle branch 12 times, most recently from aaa8c17 to c8d3ce6 Compare February 17, 2023 17:06
@ftoromanoff ftoromanoff force-pushed the reworkStyle branch 6 times, most recently from 4fb2b18 to 25f76f0 Compare March 15, 2023 14:37
@ftoromanoff ftoromanoff changed the title WIP Rework style Rework style Mar 15, 2023
@ftoromanoff ftoromanoff force-pushed the reworkStyle branch 8 times, most recently from 8ae0ae6 to 99a9d36 Compare March 27, 2023 13:36
@ftoromanoff ftoromanoff force-pushed the reworkStyle branch 6 times, most recently from 84f71b6 to fb2895d Compare November 21, 2023 14:04
examples/source_file_gpx_3d.html Outdated Show resolved Hide resolved
examples/source_file_gpx_3d.html Outdated Show resolved Hide resolved
src/Converter/Feature2Mesh.js Show resolved Hide resolved
src/Converter/Feature2Texture.js Outdated Show resolved Hide resolved
src/Core/Style.js Outdated Show resolved Hide resolved
src/Core/Style.js Outdated Show resolved Hide resolved
src/Core/Style.js Outdated Show resolved Hide resolved
src/Layer/ColorLayer.js Outdated Show resolved Hide resolved
src/Layer/LabelLayer.js Outdated Show resolved Hide resolved
src/Layer/Layer.js Outdated Show resolved Hide resolved
@@ -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; }
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. Using value != undefined.

Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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.
Copy link
Contributor

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" ?

Copy link
Contributor Author

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.

Copy link
Contributor

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...

* 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.
Copy link
Contributor

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`)

Copy link
Contributor Author

@ftoromanoff ftoromanoff Dec 6, 2023

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';
Copy link
Contributor

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.

Copy link
Contributor Author

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).

@ftoromanoff ftoromanoff force-pushed the reworkStyle branch 3 times, most recently from 251ef1f to b9287ba Compare December 7, 2023 14:39
@ftoromanoff ftoromanoff merged commit 356e695 into iTowns:master Dec 13, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Long term
Development

Successfully merging this pull request may close these issues.

4 participants