How to use the @terrestris/ol-util/dist/MapUtil/MapUtil.getResolutionForScale function in @terrestris/ol-util

To help you get started, we’ve selected a few @terrestris/ol-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geostyler / geostyler-openlayers-parser / src / OlStyleParser.spec.ts View on Github external
.then((olStyle: OlParserStyleFct) => {
          expect(olStyle).toBeDefined();

          const scaleWithinFirst: number = scaleDenomLineCircle.rules[0].scaleDenominator.min;
          const scaleWithinSecond: number = scaleDenomLineCircle.rules[1].scaleDenominator.min;
          const scaleBeyond: number = scaleDenomLineCircle.rules[1].scaleDenominator.max;

          const resolutionWithinFirst = MapUtil.getResolutionForScale(scaleWithinFirst, 'm');
          const resolutionWithinSecond = MapUtil.getResolutionForScale(scaleWithinSecond, 'm');
          const resolutionBeyond = MapUtil.getResolutionForScale(scaleBeyond, 'm');

          const dummyFeat = new OlFeature();
          const styleWithinFirst = olStyle(dummyFeat, resolutionWithinFirst);
          const styleWithinSecond = olStyle(dummyFeat, resolutionWithinSecond);
          const styleBeyond = olStyle(dummyFeat, resolutionBeyond);

          expect(styleWithinFirst).toHaveLength(1);
          expect(styleWithinSecond).toHaveLength(1);
          expect(styleBeyond).toHaveLength(0);

          const styleFirst: OlStyle = styleWithinFirst[0];
          const expecFirst = scaleDenomLineCircle.rules[0].symbolizers[0] as LineSymbolizer;
          const olStroke = styleFirst.getStroke();
          expect(olStroke).toBeDefined();
          expect(olStroke.getColor()).toEqual(expecFirst.color);
          expect(olStroke.getWidth()).toBeCloseTo(expecFirst.width);
github geostyler / geostyler-openlayers-parser / src / OlStyleParser.spec.ts View on Github external
.then((olStyle: OlParserStyleFct) => {
          expect(olStyle).toBeDefined();

          const scaleWithinFirst: number = scaleDenomLineCircle.rules[0].scaleDenominator.min;
          const scaleWithinSecond: number = scaleDenomLineCircle.rules[1].scaleDenominator.min;
          const scaleBeyond: number = scaleDenomLineCircle.rules[1].scaleDenominator.max;

          const resolutionWithinFirst = MapUtil.getResolutionForScale(scaleWithinFirst, 'm');
          const resolutionWithinSecond = MapUtil.getResolutionForScale(scaleWithinSecond, 'm');
          const resolutionBeyond = MapUtil.getResolutionForScale(scaleBeyond, 'm');

          const dummyFeat = new OlFeature();
          const styleWithinFirst = olStyle(dummyFeat, resolutionWithinFirst);
          const styleWithinSecond = olStyle(dummyFeat, resolutionWithinSecond);
          const styleBeyond = olStyle(dummyFeat, resolutionBeyond);

          expect(styleWithinFirst).toHaveLength(1);
          expect(styleWithinSecond).toHaveLength(1);
          expect(styleBeyond).toHaveLength(0);

          const styleFirst: OlStyle = styleWithinFirst[0];
          const expecFirst = scaleDenomLineCircle.rules[0].symbolizers[0] as LineSymbolizer;
          const olStroke = styleFirst.getStroke();
          expect(olStroke).toBeDefined();
github geostyler / geostyler-openlayers-parser / src / OlStyleParser.spec.ts View on Github external
.then((olStyle: OlParserStyleFct) => {
          expect(olStyle).toBeDefined();

          const scaleOnlyFirst: number = scaleDenomLineCircleOverlap.rules[0].scaleDenominator.min;
          const scaleOverlap: number = scaleDenomLineCircleOverlap.rules[1].scaleDenominator.min;
          const scaleOnlySecond: number = scaleDenomLineCircleOverlap.rules[1].scaleDenominator.max - 1;

          const resolutionOnlyFirst = MapUtil.getResolutionForScale(scaleOnlyFirst, 'm');
          const resolutionOverlap = MapUtil.getResolutionForScale(scaleOverlap, 'm');
          const resolutionOnlySecond = MapUtil.getResolutionForScale(scaleOnlySecond, 'm');

          const dummyFeat = new OlFeature();
          const styleOnlyFirst = olStyle(dummyFeat, resolutionOnlyFirst);
          const styleOverlap = olStyle(dummyFeat, resolutionOverlap);
          const styleOnlySecond = olStyle(dummyFeat, resolutionOnlySecond);

          expect(styleOnlyFirst).toHaveLength(1);
          expect(styleOverlap).toHaveLength(2);
          expect(styleOnlySecond).toHaveLength(1);
        });
    });
github terrestris / react-geo / src / Field / ScaleCombo / ScaleCombo.tsx View on Github external
const defaultOnZoomLevelSelect = (selectedScale: string) => {
      const mapView = props.map.getView();
      const calculatedResolution = MapUtil.getResolutionForScale(
        selectedScale, mapView.getProjection().getUnits()
      );
      mapView.setResolution(calculatedResolution);
    };
github geostyler / geostyler-openlayers-parser / src / OlStyleParser.spec.ts View on Github external
.then((olStyle: OlParserStyleFct) => {
          expect(olStyle).toBeDefined();

          const withinScale: number = scaleDenomLine.rules[0].scaleDenominator.min;
          const beyondScale: number = scaleDenomLine.rules[0].scaleDenominator.max;

          const resolutionRuleOne = MapUtil.getResolutionForScale(withinScale, 'm');
          const resolutionRuleTwo = MapUtil.getResolutionForScale(beyondScale, 'm');

          const dummyFeat = new OlFeature();
          const styleWithinScale = olStyle(dummyFeat, resolutionRuleOne);
          const styleBeyondScale = olStyle(dummyFeat, resolutionRuleTwo);

          expect(styleWithinScale).toHaveLength(1);
          expect(styleBeyondScale).toHaveLength(0);
        });
    });
github geostyler / geostyler-openlayers-parser / src / OlStyleParser.spec.ts View on Github external
.then((olStyle: OlParserStyleFct) => {
          expect(olStyle).toBeDefined();

          const scaleOnlyFirst: number = scaleDenomLineCircleOverlap.rules[0].scaleDenominator.min;
          const scaleOverlap: number = scaleDenomLineCircleOverlap.rules[1].scaleDenominator.min;
          const scaleOnlySecond: number = scaleDenomLineCircleOverlap.rules[1].scaleDenominator.max - 1;

          const resolutionOnlyFirst = MapUtil.getResolutionForScale(scaleOnlyFirst, 'm');
          const resolutionOverlap = MapUtil.getResolutionForScale(scaleOverlap, 'm');
          const resolutionOnlySecond = MapUtil.getResolutionForScale(scaleOnlySecond, 'm');

          const dummyFeat = new OlFeature();
          const styleOnlyFirst = olStyle(dummyFeat, resolutionOnlyFirst);
          const styleOverlap = olStyle(dummyFeat, resolutionOverlap);
          const styleOnlySecond = olStyle(dummyFeat, resolutionOnlySecond);

          expect(styleOnlyFirst).toHaveLength(1);
          expect(styleOverlap).toHaveLength(2);
          expect(styleOnlySecond).toHaveLength(1);
        });
    });
github geostyler / geostyler-openlayers-parser / src / OlStyleParser.spec.ts View on Github external
.then((olStyle: OlParserStyleFct) => {
          expect(olStyle).toBeDefined();

          const scaleWithinFirst: number = scaleDenomLineCircle.rules[0].scaleDenominator.min;
          const scaleWithinSecond: number = scaleDenomLineCircle.rules[1].scaleDenominator.min;
          const scaleBeyond: number = scaleDenomLineCircle.rules[1].scaleDenominator.max;

          const resolutionWithinFirst = MapUtil.getResolutionForScale(scaleWithinFirst, 'm');
          const resolutionWithinSecond = MapUtil.getResolutionForScale(scaleWithinSecond, 'm');
          const resolutionBeyond = MapUtil.getResolutionForScale(scaleBeyond, 'm');

          const dummyFeat = new OlFeature();
          const styleWithinFirst = olStyle(dummyFeat, resolutionWithinFirst);
          const styleWithinSecond = olStyle(dummyFeat, resolutionWithinSecond);
          const styleBeyond = olStyle(dummyFeat, resolutionBeyond);

          expect(styleWithinFirst).toHaveLength(1);
          expect(styleWithinSecond).toHaveLength(1);
          expect(styleBeyond).toHaveLength(0);

          const styleFirst: OlStyle = styleWithinFirst[0];
          const expecFirst = scaleDenomLineCircle.rules[0].symbolizers[0] as LineSymbolizer;
          const olStroke = styleFirst.getStroke();
          expect(olStroke).toBeDefined();
          expect(olStroke.getColor()).toEqual(expecFirst.color);
github geostyler / geostyler-openlayers-parser / src / OlStyleParser.spec.ts View on Github external
.then((olStyle: OlParserStyleFct) => {
          expect(olStyle).toBeDefined();

          const withinScale: number = scaleDenomLine.rules[0].scaleDenominator.min;
          const beyondScale: number = scaleDenomLine.rules[0].scaleDenominator.max;

          const resolutionRuleOne = MapUtil.getResolutionForScale(withinScale, 'm');
          const resolutionRuleTwo = MapUtil.getResolutionForScale(beyondScale, 'm');

          const dummyFeat = new OlFeature();
          const styleWithinScale = olStyle(dummyFeat, resolutionRuleOne);
          const styleBeyondScale = olStyle(dummyFeat, resolutionRuleTwo);

          expect(styleWithinScale).toHaveLength(1);
          expect(styleBeyondScale).toHaveLength(0);
        });
    });
github geostyler / geostyler-openlayers-parser / src / OlStyleParser.spec.ts View on Github external
.then((olStyle: OlParserStyleFct) => {
          expect(olStyle).toBeDefined();

          const scaleOnlyFirst: number = scaleDenomLineCircleOverlap.rules[0].scaleDenominator.min;
          const scaleOverlap: number = scaleDenomLineCircleOverlap.rules[1].scaleDenominator.min;
          const scaleOnlySecond: number = scaleDenomLineCircleOverlap.rules[1].scaleDenominator.max - 1;

          const resolutionOnlyFirst = MapUtil.getResolutionForScale(scaleOnlyFirst, 'm');
          const resolutionOverlap = MapUtil.getResolutionForScale(scaleOverlap, 'm');
          const resolutionOnlySecond = MapUtil.getResolutionForScale(scaleOnlySecond, 'm');

          const dummyFeat = new OlFeature();
          const styleOnlyFirst = olStyle(dummyFeat, resolutionOnlyFirst);
          const styleOverlap = olStyle(dummyFeat, resolutionOverlap);
          const styleOnlySecond = olStyle(dummyFeat, resolutionOnlySecond);

          expect(styleOnlyFirst).toHaveLength(1);
          expect(styleOverlap).toHaveLength(2);
          expect(styleOnlySecond).toHaveLength(1);
        });
    });