Utilities for map projections.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

index.test.ts 2.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // import * as fc from 'fast-check';
  2. import { describe, it, expect } from 'vitest';
  3. import * as orbisCore from '../src';
  4. describe('orbis-core', () => {
  5. describe('projectPoint', () => {
  6. it('throws error for invalid coordinates', () => {
  7. expect(() => orbisCore.projectPoint([-181, 90], ['Equirectangular'])).toThrowError(RangeError);
  8. expect(() => orbisCore.projectPoint([181, 90], ['Equirectangular'])).toThrowError(RangeError);
  9. expect(() => orbisCore.projectPoint([-180, 91], ['Equirectangular'])).toThrowError(RangeError);
  10. expect(() => orbisCore.projectPoint([-180, -91], ['Equirectangular'])).toThrowError(RangeError);
  11. });
  12. it('returns identity for equirectangular', () => {
  13. // fc.assert(
  14. // fc.property(
  15. // fc.tuple(
  16. // fc.float().filter((c) => -180 <= c && c <= 180),
  17. // fc.float().filter((c) => -180 <= c && c <= 180),
  18. // ),
  19. // (coords) => {
  20. // expect(orbisCore.project(coords, 'Equirectangular')).toEqual(coords);
  21. // },
  22. // ),
  23. // );
  24. [
  25. [0, 0] as [number, number],
  26. [45, 45] as [number, number],
  27. [90, 90] as [number, number],
  28. ]
  29. .forEach((coords) => {
  30. expect(orbisCore.projectPoint(coords, ['Equirectangular'])).toEqual(coords);
  31. });
  32. });
  33. it('returns coords for other projections', () => {
  34. // fc.assert(
  35. // fc.property(
  36. // fc.tuple(
  37. // fc.float().filter((c) => -180 <= c && c <= 180),
  38. // fc.float().filter((c) => -180 <= c && c <= 180),
  39. // ),
  40. // (coords) => {
  41. // expect(orbisCore.project(coords, 'Equirectangular')).toEqual(coords);
  42. // },
  43. // ),
  44. // );
  45. [
  46. [0, 0] as [number, number],
  47. [45, 45] as [number, number],
  48. [90, 90] as [number, number],
  49. ]
  50. .forEach((coords) => {
  51. expect(orbisCore.projectPoint(coords, ['Mercator'])).toEqual([
  52. expect.any(Number),
  53. expect.any(Number),
  54. ]);
  55. });
  56. });
  57. });
  58. });