Skip to content

Commit

Permalink
Accurate projection naming
Browse files Browse the repository at this point in the history
  • Loading branch information
birkskyum committed Nov 2, 2024
1 parent 248b4f5 commit 211f7a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions src/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"type": "projection",
"doc": "The projection configuration. **Note:** this definition is still experimental and is under development in maplibre-gl-js.",
"example": {
"type": "globe"
"type": "web-mercator"
}
},
"terrain": {
Expand Down Expand Up @@ -4538,7 +4538,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 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-to-web-mercator projection."
}
},
"terrain": {
Expand Down Expand Up @@ -4572,13 +4572,16 @@
"type": {
"type": "enum",
"doc": "The projection type.",
"default": "mercator",
"default": "web-mercator",
"values": {
"mercator": {
"doc": "The Mercator projection."
"web-mercator": {
"doc": "Web Mercator projection."
},
"globe": {
"doc": "The globe projection."
"doc": "\"Static Globe\". Spherical projection."
},
"globe-to-web-mercator": {
"doc": "\"Adaptive Globe\". Transition from a Spherical projection to a Web Mercator projection on zoom."
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/validate/validate_projection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ 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], 1 found');
expect(errors[0].message).toBe('type: expected one of [web-mercator, globe, globe-to-web-mercator], 1 found');
});

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

Check failure on line 33 in src/validate/validate_projection.test.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Type '"spherical-to-web-mercator"' is not assignable to type '"web-mercator" | "globe" | "globe-to-web-mercator"'.
expect(errors).toHaveLength(0);

Check failure on line 34 in src/validate/validate_projection.test.ts

View workflow job for this annotation

GitHub Actions / Unit and Integration Tests

Validate projection › Should pass if everything is according to spec

expect(received).toHaveLength(expected) Expected length: 0 Received length: 1 Received array: [{"message": "type: expected one of [web-mercator, globe, globe-to-web-mercator], \"spherical-to-web-mercator\" found"}] at Object.<anonymous> (src/validate/validate_projection.test.ts:34:24)
errors = validateProjection({validateSpec, value: {type: 'mercator'}, styleSpec: v8, style: {} as any});
errors = validateProjection({validateSpec, value: {type: 'web-mercator'}, styleSpec: v8, style: {} as any});
expect(errors).toHaveLength(0);
});
});

0 comments on commit 211f7a7

Please sign in to comment.