npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ol-proj-ch

v1.0.4

Published

china's gcj02 for openlayers

Downloads

21

Readme

China's Projection for OpenLayers

Author: wkgreat
TS NPM version CI

Projection Supported

| Projection | code | Description | | :----: | :---- | :---- | | GCJ02 | 'GCJ02','GCJ:02','ZH:MARS' | 国测局02坐标系,火星坐标系 | | BD09 | 'BD09','BD09','baidu' | 百度坐标系 |

Introduction

GCJ02 is a coordinate systems often used in China. Strictly speaking, it is a confidential algorithm for encrypting geopoints. After processing by GCJ02 algorithm, the point defined in WGS84 will be deviated on web map visually. This module defines the GCJ02 as a Projection of openlayers, likewise EPSG:4326 and EPSG:3857

💡From version 1.0.3 also support typescript.

Install:

npm install ol-proj-ch

Import:

by import olpjch, the olpjch is defined as a container for all supported projections in this module.
by import {xxx} from 'ol-proj-ch', import the pertinent projection you want.

import olpjch from 'ol-proj-ch'

/* GCJ02 */
const GCJ02 = olpjch.GCJ02
const code = GCJ02.CODE
//...

/* BD09 */
const BD09 = olpjch.BD09
const code = BD09.CODE

//or import GCJ02, BD09 or others
import {GCJ02} from 'ol-proj-ch'
import {BD09} from 'ol-proj-ch'
const code1 = GCJ02.CODE    //the code of GCJ02
const code2 = BD09.CODE     //the code of BD09

Usage:

💡 here use GCJ02 to make exmaples.

  • transform a coordinate from gcj02 to wgs84(EPSG:4326)
import {GCJ02} from 'ol-proj-ch'
import {transform} from 'ol/proj'
const coords = [117.0,32.0];
const newCoords = transform(coords, GCJ02.CODE, "EPSG:4326");

likewise, use transform([coords, "EPSG:4326", GCJ02.CODE) from wgs84 to gcj02

  • transform a coordinate from gcj02 to EPSG:3857
import {GCJ02} from 'ol-proj-ch'
import {transform} from 'ol/proj'
const coords = [117.0,32.0];
const newCoords = transform(coords, GCJ02.CODE, "EPSG:3857");

likewise, use transform([coords, "EPSG:3857", GCJ02.CODE) from EPSG:3827 to gcj02

  • eg: create feature from geojson data of GCJ02
import {GCJ02} from 'ol-proj-ch'
import {GeoJSON} from "ol/format";

//geojson data pretend coordinates are in GCJ02
const data = {
   "type": "Feature",
   "geometry": {
      "type": "Point",
      "coordinates": [125.6, 10.1]
   },
   "properties": {
      "name": "Dinagat Islands"
   }
};

const format = new GeoJSON();
let feature = format.readFeature(data, {
   dataProjection: GCJ02.CODE,
   featureProjection: "EPSG:3857"
});
//... then add feature to layer and then add to map
  • eg: visulaize vector data from wkt with gcj02 data projection
import {GCJ02} from 'ol-proj-ch'
import WKT from "ol/format/WKT";

//WKT data
const data = `POINT (125.6 10.1)`;

const format = new WKT();
let feature = format.readFeature(data, {
   dataProjection: GCJ02.CODE,
   featureProjection: "EPSG:3857"
});
//... then add feature to layer and then add to map