Skip to content

Commit

Permalink
review 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Nov 10, 2023
1 parent 2d8a651 commit b9e6705
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/Core/Style.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,22 @@ function defineStyleProperty(style, category, name, value, defaultValue) {
* type of feature and what is needed (fill, stroke or draw a point, etc.) as well as where to get its
* properties and its coordinates (for base_altitude).
*
* @property {Coordinates} worldCoord @private Coordinates of the FeatureGeometry in world system.
* @property {Coordinates} localCoordinates @private Are the coordinates systeme origin local or global.
* @property {boolean} isProjected @private Are the coordinates already been projected.
* @property {FeatureGeometry} geometry @private
* @property {Object} globals Style type (fill, stroke, point, text and or icon) to consider. As
* well as the zoom.
* @property {Object} collection The FeatureCollection on which the FeatureGeomatry is attached
* @property {Coordinates} coordinates The coordinates (in world crs) of the last vertice set with
* @property {Object} globals Style type (fill, stroke, point, text and or icon) to consider it also
* contains the current zoom.
* @property {Object} collection The FeatureCollection to which the FeatureGeometry is attached
* @property {Coordinates} coordinates The coordinates (in world space) of the last vertice (x, y, z) set with
* setLocalCoordinatesFromArray().
* private properties:
* @property {Coordinates} worldCoord @private Coordinates object to store coordinates in world space.
* @property {Coordinates} localCoordinates @private Coordinates object to store coordinates in local space.
* @property {boolean} worldCoordsComputed @private Have the world coordinates already been computed
* from the local coordinates?
* @property {FeatureGeometry} geometry @private The FeatureGeometry to compute the style.
*/
export class StyleContext {
#worldCoord = new Coordinates('EPSG:4326', 0, 0, 0);
#localCoordinates = new Coordinates('EPSG:4326', 0, 0, 0);
#isProjected = true;
#worldCoordsComputed = true;
#geometry = {};
/**
* @constructor
Expand All @@ -199,7 +201,7 @@ export class StyleContext {
}

setLocalCoordinatesFromArray(vertices, offset) {
this.#isProjected = false;
this.#worldCoordsComputed = false;
return this.#localCoordinates.setFromArray(vertices, offset);
}

Expand All @@ -208,8 +210,8 @@ export class StyleContext {
}

get coordinates() {
if (!this.#isProjected) {
this.#isProjected = true;
if (!this.#worldCoordsComputed) {
this.#worldCoordsComputed = true;
this.#worldCoord.copy(this.#localCoordinates).applyMatrix4(this.collection.matrixWorld);
if (this.#localCoordinates.crs == 'EPSG:4978') {
return this.#worldCoord.as('EPSG:4326', this.#worldCoord);
Expand Down

0 comments on commit b9e6705

Please sign in to comment.