Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
shtyr-maxim committed Oct 25, 2023
1 parent 2799af2 commit 6d01f4c
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- BUGS: Please use this template -->
<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/@mappable-world/mappable-spherical-mercator-projection -->
<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/mappable-web-mercator-projection -->

**@mappable-world/mappable-spherical-mercator-projection Version:** xxxxx
**@mappable-world/mappable-web-mercator-projection Version:** xxxxx

**Browser:** <!-- Chrome/IE/Safary/FF -->
**OS:** <!-- Windows/Mac/Linux -->
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# @mappable-world/mappable-spherical-mercator-projection package
# @mappable-world/mappable-web-mercator-projection package

---

Mappable JS API package

[![npm version](https://badge.fury.io/js/@mappable-world%2Fmappable-spherical-mercator-projection.svg)](https://badge.fury.io/js/@mappable-world%2Fmappable-spherical-mercator-projection)
[![npm](https://img.shields.io/npm/dm/@mappable-world/mappable-spherical-mercator-projection.svg)](https://www.npmjs.com/package/@mappable-world/mappable-spherical-mercator-projection)
[![npm version](https://badge.fury.io/js/@mappable-world%2Fmappable-web-mercator-projection.svg)](https://badge.fury.io/js/@mappable-world%2Fmappable-web-mercator-projection)
[![npm](https://img.shields.io/npm/dm/@mappable-world/mappable-web-mercator-projection.svg)](https://www.npmjs.com/package/@mappable-world/mappable-web-mercator-projection)
[![Build Status](https://github.com/mappable-world/mappable-cartesian-projection/workflows/Run%20tests/badge.svg)](https://github.com/mappable-world/mappable-cartesian-projection/actions/workflows/tests.yml)

## How use
Expand All @@ -20,7 +20,7 @@ to use Mappable JS Module you need to add your module loading handler to JS API

```js
mappable.import.loaders.unshift(async (pkg) => {
if (!pkg.includes('@mappable-world/mappable-spherical-mercator-projection')) {
if (!pkg.includes('@mappable-world/mappable-web-mercator-projection')) {
return;
}

Expand All @@ -38,5 +38,5 @@ mappable.import.loaders.unshift(async (pkg) => {
and in your final code just use `mappable.import`

```js
const pkg = await mappable.import('@mappable-world/mappable-spherical-mercator-projection')
const pkg = await mappable.import('@mappable-world/mappable-web-mercator-projection')
```
2 changes: 1 addition & 1 deletion example/common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mappable.import.loaders.unshift(async (pkg) => {
if (!pkg.includes('@mappable-world/mappable-spherical-mercator-projection')) {
if (!pkg.includes('@mappable-world/mappable-web-mercator-projection')) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions example/react.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>React example @mappable-world/mappable-spherical-mercator-projection</title>
<title>React example @mappable-world/mappable-web-mercator-projection</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script>
Expand All @@ -25,8 +25,8 @@
const {MMapZoomControl} = reactify.module(await mappable.import('@mappable-world/mappable-controls@0.0.1'));
const {MMapDefaultMarker} = reactify.module(await mappable.import('@mappable-world/mappable-markers@0.0.1'));

const {SphericalMercator} = await mappable.import('@mappable-world/mappable-spherical-mercator-projection');
const projection = new SphericalMercator();
const {WebMercator} = await mappable.import('@mappable-world/mappable-web-mercator-projection');
const projection = new WebMercator();

ReactDOM.render(
<React.StrictMode>
Expand Down
6 changes: 3 additions & 3 deletions example/vanilla.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Vanila example @mappable-world/mappable-spherical-mercator-projection</title>
<title>Vanila example @mappable-world/mappable-web-mercator-projection</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<script src="https://js.api.mappable.world/3.0/?apikey=%APIKEY%&lang=en_US"></script>
Expand All @@ -17,8 +17,8 @@
const {MMapZoomControl} = await mappable.import('@mappable-world/mappable-controls@0.0.1');
const {MMapDefaultMarker} = await mappable.import('@mappable-world/mappable-markers@0.0.1');

const {SphericalMercator} = await mappable.import('@mappable-world/mappable-spherical-mercator-projection');
const projection = new SphericalMercator();
const {WebMercator} = await mappable.import('@mappable-world/mappable-web-mercator-projection');
const projection = new WebMercator();

const map = new MMap(document.getElementById('app'), {
location: LOCATION,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "0.0.1-beta.2",
"name": "@mappable-world/mappable-spherical-mercator-projection",
"description": "Mappable Maps JS API 3.0 example @mappable-world/mappable-spherical-mercator-projection",
"name": "@mappable-world/mappable-web-mercator-projection",
"description": "Mappable Maps JS API 3.0 example @mappable-world/mappable-web-mercator-projection",
"types": "./dist/types/index.d.ts",
"main": "./dist/esm/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './spherical-mercator';
export * from './web-mercator';
14 changes: 7 additions & 7 deletions src/spherical-mercator.test.ts → src/web-mercator.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type {LngLat} from '@mappable-world/mappable-types';
import * as turf from '@turf/projection';
import {restrict, cycleRestrict, RAD_TO_DEG} from './utils';
import {SphericalMercator} from './spherical-mercator';
import {WebMercator} from './web-mercator';

describe('sphericalMercator transformations', () => {
describe('webMercator transformations', () => {
const WORLD_TO_METRIC = 6378137.0 * Math.PI;
const sphericalMercator = new SphericalMercator();
const webMercator = new WebMercator();

const maxLat = Math.atan(Math.sinh(Math.PI)) * RAD_TO_DEG;
const lngWorld = [
Expand Down Expand Up @@ -40,7 +40,7 @@ describe('sphericalMercator transformations', () => {
it('check toWorldCoordinates', () => {
lngWorld.map(([lng, worldX]) => {
latWorld.map(([lat, worldY]) => {
const world = sphericalMercator.toWorldCoordinates([lng, lat]);
const world = webMercator.toWorldCoordinates([lng, lat]);
expect(world.x).toBeCloseTo(worldX, 9);
expect(world.y).toBeCloseTo(worldY, 9);

Expand All @@ -54,7 +54,7 @@ describe('sphericalMercator transformations', () => {
it('check fromWorldCoordinates', () => {
lngWorld.map(([lng, worldX]) => {
latWorld.map(([lat, worldY]) => {
const lngLat = sphericalMercator.fromWorldCoordinates({x: worldX, y: worldY});
const lngLat = webMercator.fromWorldCoordinates({x: worldX, y: worldY});
expect(lngLat[0]).toBeCloseTo(cycleRestrict(lng, -180, 180), 9);
expect(lngLat[1]).toBeCloseTo(restrict(lat, -maxLat, maxLat), 9);

Expand All @@ -70,8 +70,8 @@ describe('sphericalMercator transformations', () => {
for (let lat = -100; lat < 100; lat++) {
const lngLat: LngLat = [cycleRestrict(lng, -180, 180), restrict(lat, -maxLat, maxLat)];

const world = sphericalMercator.toWorldCoordinates(lngLat);
const lngLatAfter = sphericalMercator.fromWorldCoordinates(world);
const world = webMercator.toWorldCoordinates(lngLat);
const lngLatAfter = webMercator.fromWorldCoordinates(world);
expect(lngLat[0]).toBeCloseTo(lngLatAfter[0], 9);
expect(lngLat[1]).toBeCloseTo(lngLatAfter[1], 9);
}
Expand Down
10 changes: 5 additions & 5 deletions src/spherical-mercator.ts → src/web-mercator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import {cycleRestrict, restrict, DEG_TO_RAD, RAD_TO_DEG} from './utils'
/**
* @class Mercator projection onto a sphere.
* Used by many mapping services, in particular OpenStreetMap.
* @name projection.sphericalMercator
* @name projection.webMercator
* @augments Projection
* @static
* @example
* ```js
* const {MMap, MMapTileDataSource, MMapLayer} = mappable;
* const {SphericalMercator} = await mappable.import('@mappable-world/mappable-spherical-mercator-projection');
* const {WebMercator} = await mappable.import('@mappable-world/mappable-web-mercator-projection');
*
* // Create a map in the spherical Mercator projection
* // Create a map in the web Mercator projection
* const map = new MMap(document.getElementById('map_id'), {
* // ...
* projection: new SphericalMercator()
* projection: new WebMercator()
* });
*
* // Add osm tiles
Expand All @@ -38,7 +38,7 @@ import {cycleRestrict, restrict, DEG_TO_RAD, RAD_TO_DEG} from './utils'
* ```
*/

export class SphericalMercator implements Projection {
export class WebMercator implements Projection {
private _maxLatitudeRad = Math.atan(Math.sinh(Math.PI));

toWorldCoordinates(coords: LngLat): WorldCoordinates {
Expand Down

0 comments on commit 6d01f4c

Please sign in to comment.