mirror of
https://github.com/visgl/react-map-gl.git
synced 2025-12-08 20:16:02 +00:00
51 lines
2.1 KiB
JavaScript
51 lines
2.1 KiB
JavaScript
// Copyright (c) 2015 Uber Technologies, Inc.
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
// THE SOFTWARE.
|
|
|
|
// NOTE: Transform is not a public API so we should be careful to always lock
|
|
// down mapbox-gl to a specific major, minor, and patch version.
|
|
import Transform from 'mapbox-gl/js/geo/transform';
|
|
export {Transform as default};
|
|
|
|
import {Point} from 'mapbox-gl';
|
|
|
|
export function mod(value, divisor) {
|
|
const modulus = value % divisor;
|
|
return modulus < 0 ? divisor + modulus : modulus;
|
|
}
|
|
|
|
export function unprojectFromTransform(transform, point) {
|
|
return transform.pointLocation(Point.convert(point));
|
|
}
|
|
|
|
export function cloneTransform(original) {
|
|
const transform = new Transform(original._minZoom, original._maxZoom);
|
|
transform.latRange = original.latRange;
|
|
transform.width = original.width;
|
|
transform.height = original.height;
|
|
transform.zoom = original.zoom;
|
|
transform.center = original.center;
|
|
transform.angle = original.angle;
|
|
transform.altitude = original.altitude;
|
|
transform.pitch = original.pitch;
|
|
transform.bearing = original.bearing;
|
|
transform.altitude = original.altitude;
|
|
return transform;
|
|
}
|