1- import { nonEarthCRS } from '../../../src/leaflet/core/NonEarthCRS' ;
2- import { nonProjection } from '../../../src/leaflet/core/NonEarthCRS' ;
1+ import { nonEarthCRS } from '../../../src/leaflet/core/NonEarthCRS' ;
2+ import { nonProjection } from '../../../src/leaflet/core/NonEarthCRS' ;
33
44describe ( 'leaflet_NonEarthCRS' , ( ) => {
55 it ( 'initialize' , ( ) => {
@@ -29,7 +29,7 @@ describe('leaflet_NonEarthCRS', () => {
2929
3030 it ( 'CRS_initialize' , ( ) => {
3131 var options = {
32- origin : { x : 30 , y : 50 } ,
32+ origin : { x : 30 , y : 50 } ,
3333 bounds : L . bounds ( [ - 180 , - 90 ] , [ 180 , 90 ] ) ,
3434 resolutions : [ 1000 , 100000 ]
3535 } ;
@@ -46,40 +46,33 @@ describe('leaflet_NonEarthCRS', () => {
4646
4747 it ( 'CRS_scale' , ( ) => {
4848 var options = {
49- origin : { x : 30 , y : 50 } ,
49+ origin : { x : 30 , y : 50 } ,
5050 bounds : L . bounds ( [ - 180 , - 90 ] , [ 180 , 90 ] ) ,
51- resolutions : [ 100 , 100000 ]
51+ resolutions : [ 1 , 0.5 ]
5252 } ;
5353 var nonEarthCRSObject = nonEarthCRS ( options ) ;
54- var scale1 = nonEarthCRSObject . scale ( 0 ) ;
55- expect ( scale1 ) . toEqual ( 0.01 ) ;
54+ expect ( nonEarthCRSObject . scale ( 0 ) ) . toEqual ( 1 ) ;
55+ expect ( nonEarthCRSObject . scale ( 1 ) ) . toEqual ( 2 ) ;
56+ expect ( nonEarthCRSObject . scale ( 0.5 ) ) . toBeCloseTo ( 1.414 , 0.001 ) ;
5657 nonEarthCRSObject . resolutions = [ ] ;
57- var scale2 = nonEarthCRSObject . scale ( 1 ) ;
58- expect ( scale2 ) . not . toBeNaN ( ) ;
58+ expect ( nonEarthCRSObject . scale ( 1 ) ) . toBeCloseTo ( 1.422 , 0.001 ) ;
5959 } ) ;
6060
6161 it ( 'CRS_zoom' , ( ) => {
6262 var options1 = {
63- origin : { x : 30 , y : 50 } ,
63+ origin : { x : 30 , y : 50 } ,
6464 bounds : L . bounds ( [ - 180 , - 90 ] , [ 180 , 90 ] ) ,
65- resolutions : [ 100 , 100000 ]
65+ resolutions : [ 1 , 0.5 ]
6666 } ;
6767 var nonEarthCRS1 = nonEarthCRS ( options1 ) ;
68- var zoom1 = nonEarthCRS1 . zoom ( 0.1 ) ;
69- expect ( zoom1 ) . toEqual ( - 1 ) ;
70-
71- var options2 = {
72- origin : { x : 30 , y : 50 } ,
73- bounds : L . bounds ( [ - 180 , - 90 ] , [ 180 , 90 ] ) ,
74- resolutions : [ 100 , 100000 ]
75- } ;
76- var nonEarthCRS2 = nonEarthCRS ( options2 ) ;
77- var zoom2 = nonEarthCRS2 . zoom ( 0.01 ) ;
78- expect ( zoom2 ) . toEqual ( 0 ) ;
68+ expect ( nonEarthCRS1 . zoom ( 0.1 ) ) . toBeLessThan ( 0 ) ;
69+ expect ( nonEarthCRS1 . zoom ( 1 ) ) . toEqual ( 0 ) ;
70+ expect ( nonEarthCRS1 . zoom ( 2 ) ) . toEqual ( 1 ) ;
71+ expect ( nonEarthCRS1 . zoom ( 1.5 ) ) . toBeCloseTo ( 0.5849 , 0.0001 ) ;
7972
8073 var options3 = {
81- origin : { x : 30 , y : 50 } ,
82- bounds : L . bounds ( [ - 128 , - 90 ] , [ 128 , 90 ] ) ,
74+ origin : { x : 30 , y : 50 } ,
75+ bounds : L . bounds ( [ - 128 , - 90 ] , [ 128 , 90 ] )
8376 } ;
8477 var nonEarthCRS3 = nonEarthCRS ( options3 ) ;
8578 var zoom3 = nonEarthCRS3 . zoom ( 16 ) ;
@@ -90,12 +83,12 @@ describe('leaflet_NonEarthCRS', () => {
9083 var latlng1 = L . latLng ( 50.5 , 30.5 ) ;
9184 var latlng2 = L . latLng ( 40 , 60.5 ) ;
9285 var options = {
93- origin : { x : 30 , y : 50 } ,
86+ origin : { x : 30 , y : 50 } ,
9487 bounds : L . bounds ( [ - 180 , - 90 ] , [ 180 , 90 ] ) ,
9588 resolutions : [ 100 , 100000 ]
9689 } ;
9790 var nonEarthCRSObject = nonEarthCRS ( options ) ;
9891 var distance = nonEarthCRSObject . distance ( latlng1 , latlng2 ) ;
9992 expect ( distance ) . not . toBeNaN ( ) ;
10093 } ) ;
101- } ) ;
94+ } ) ;
0 commit comments