Skip to content

Commit

Permalink
Make globe a spherical projection
Browse files Browse the repository at this point in the history
Add projection expression
  • Loading branch information
birkskyum committed Nov 5, 2024
1 parent 90fdb88 commit d1cad9d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 14 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
## main

### ✨ Features and improvements
- Rename adaptive globe from `globe` to `globe-to-mercator` ([#878](https://github.com/maplibre/maplibre-style-spec/pull/878))
- Add non-adaptive `globe` ([#878](https://github.com/maplibre/maplibre-style-spec/pull/878))
- Add projection type expression syntax ([#888](https://github.com/maplibre/maplibre-style-spec/pull/888))
- _...Add new stuff here..._

### 🐞 Bug fixes
Expand Down
4 changes: 2 additions & 2 deletions src/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,10 @@ describe('diff', () => {
} as StyleSpecification,
{
projection: {
type: 'globe-to-mercator'
type: 'globe'
}
} as StyleSpecification)).toEqual([
{command: 'setProjection', args: [{type: 'globe-to-mercator'}]},
{command: 'setProjection', args: [{type: 'globe'}]},
]);
});
});
58 changes: 50 additions & 8 deletions src/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,55 @@
}
},
"projection": {
"type": "projection",
"doc": "The projection configuration. **Note:** this definition is still experimental and is under development in maplibre-gl-js.",
"example": {
"type": "globe-to-mercator"
"type": {
"type": ["enum", "expression"],
"doc": "The projection type. Can be specified as a string, or as an expression for supported projection types.",
"default": "mercator",
"values": {
"mercator": {
"doc": "Web Mercator projection.",
"expression-compatible": true
},
"globe": {
"doc": "Spherical projection.",
"expression-compatible": true
},
"utm32": {
"doc": "Metric central europe.",
"expression-compatible": false
},
"albers": {
"doc": "Albers equal-area conic projection.",
"expression-compatible": true
},
"equalEarth": {
"doc": "Equal Earth projection.",
"expression-compatible": true
}
},
"expression": {
"interpolated": true,
"parameters": ["zoom"],
"validate": "return value.expressionCompatible === true"
},
"example": {
"simple": {
"projection": {
"type": "albers"
}
},
"expression": {
"projection": {
"type": [
"interpolate",
["linear"],
["zoom"],
10, "globe",
12, "mercator"
]
}
}
}
}
},
"terrain": {
Expand Down Expand Up @@ -4538,7 +4583,7 @@
]
},
"transition": true,
"doc": "How to blend the atmosphere. Where 1 is visible atmosphere and 0 is hidden. It is best to interpolate this expression when using globe-to-mercator projection."
"doc": "How to blend the atmosphere. Where 1 is visible atmosphere and 0 is hidden. It is best to interpolate this expression when using globe projection."
}
},
"terrain": {
Expand Down Expand Up @@ -4579,9 +4624,6 @@
},
"globe": {
"doc": "Spherical projection."
},
"globe-to-mercator": {
"doc": "Spherical projection with zoom transition to Web Mercator projection."
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/validate/validate_projection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ describe('Validate projection', () => {
test('Should return errors according to spec violations', () => {
const errors = validateProjection({validateSpec, value: {type: 1 as any}, styleSpec: v8, style: {} as any});
expect(errors).toHaveLength(1);
expect(errors[0].message).toBe('type: expected one of [mercator, globe, globe-to-mercator], 1 found');
expect(errors[0].message).toBe('type: expected one of [mercator, globe], 1 found');
});

test('Should pass if everything is according to spec', () => {
let errors = validateProjection({validateSpec, value: {type: 'globe-to-mercator'}, styleSpec: v8, style: {} as any});
let errors = validateProjection({validateSpec, value: {type: 'globe'}, styleSpec: v8, style: {} as any});
expect(errors).toHaveLength(0);
errors = validateProjection({validateSpec, value: {type: 'mercator'}, styleSpec: v8, style: {} as any});
expect(errors).toHaveLength(0);
Expand Down

0 comments on commit d1cad9d

Please sign in to comment.