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

Add roll angle to stylesheet #858

Merged
merged 7 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### ✨ Features and improvements

* Added `roll` property to stylesheet ([#850](https://github.com/maplibre/maplibre-style-spec/issues/850))
- _...Add new stuff here..._

### 🐞 Bug fixes
Expand Down
19 changes: 19 additions & 0 deletions src/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,25 @@ describe('diff', () => {
]);
});

test('set roll to undefined', () => {
expect(diffStyles({
roll: 1
} as StyleSpecification, {
} as StyleSpecification)).toEqual([
{command: 'setRoll', args: [undefined]}
]);
});

test('set roll', () => {
NathanMOlson marked this conversation as resolved.
Show resolved Hide resolved
expect(diffStyles({
roll: 0
} as StyleSpecification, {
roll: 1
} as StyleSpecification)).toEqual([
{command: 'setRoll', args: [1]}
]);
});

test('no changes in light', () => {
expect(diffStyles({
light: {
Expand Down
4 changes: 4 additions & 0 deletions src/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type DiffOperationsMap = {
'setZoom': [number];
'setBearing': [number];
'setPitch': [number];
'setRoll': [number];
'setSprite': [SpriteSpecification];
'setGlyphs': [string];
'setTransition': [TransitionSpecification];
Expand Down Expand Up @@ -287,6 +288,9 @@ function diffStyles(before: StyleSpecification, after: StyleSpecification): Diff
if (!isEqual(before.pitch, after.pitch)) {
commands.push({command: 'setPitch', args: [after.pitch]});
}
if (!isEqual(before.roll, after.roll)) {
commands.push({command: 'setRoll', args: [after.roll]});
}
if (!isEqual(before.sprite, after.sprite)) {
commands.push({command: 'setSprite', args: [after.sprite]});
}
Expand Down
14 changes: 14 additions & 0 deletions src/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@
"doc": "Default pitch, in degrees. Zero is perpendicular to the surface, for a look straight down at the map, while a greater value like 60 looks ahead towards the horizon. The style pitch will be used only if the map has not been positioned by other means (e.g. map options or user interaction).",
"example": 50
},
"roll": {
"type": "number",
"default": 0,
"units": "degrees",
"doc": "Default roll, in degrees. The roll angle is measured counterclockwise about the camera boresight. The style roll will be used only if the map has not been positioned by other means (e.g. map options or user interaction).",
"example": 45,
"sdk-support": {
"basic functionality": {
"js": "5.0.0",
"android": "wontfix",
NathanMOlson marked this conversation as resolved.
Show resolved Hide resolved
"ios": "wontfix"
}
}
},
"light": {
"type": "light",
"doc": "The global light source.",
Expand Down
6 changes: 6 additions & 0 deletions test/integration/style-spec/tests/roll.input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": 8,
"roll": "45",
"sources": {},
"layers": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"message": "roll: number expected, string found",
"line": 3
}
]
6 changes: 6 additions & 0 deletions test/integration/style-spec/tests/roll.output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"message": "roll: number expected, string found",
"line": 3
}
]