Giter Site home page Giter Site logo

gisshare2015 / geoproject Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 254 KB

图形坐标转换工具

Home Page: http://www.gisshare.com

License: MIT License

JavaScript 16.17% HTML 8.29% Vue 75.55%
bd09 bd09ll bd09mc esrijson fitting gcj02 geojson gis project shapefile smap topojson webmc wgs84 wkb wkt gisshare coordinate-transforms

geoproject's Introduction

GeoProject

GeoProject:是一个基于GISShare能力实现的图形坐标转换工具网站项目,为第三方提供便捷图形数据坐标转换/纠偏及显示服务。

网页址
http://www.gisshare.com/GeoProject/index.html
image

项目开发应用
如果您的项目也需要用到坐标转换/纠偏也可以调用该组件。
1.引入GISSHare.SMap前端包;(gisshare-smap:仅含图形数据部分较小;gisshare-smap-all:包含图形和可视化较大。)

npm install @gisshare/gisshare-smap  

2.在项目主入口文件引入即可;(引入后GISShare命名空间就会挂在window下,编码时直接调用即可。)

import { GISShare } from '@gisshare/gisshare-smap-all'

3.具体的转化&纠偏代码实现,及API文档;(加密坐标与非加密坐标之间的拟合转换存在误差,误差范围在±1米左右。)

var pPoint;
//
// 【坐标变换】WGS84-WebMercator互转
//
pPoint = new GISShare.SMap.Geometry.Point(117, 31);
//WGS84 转 WebMercator
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984, //当前空间参考
                                        GISShare.SMap.SpatialReference.ProjectedCoordinateSystemStyle.eWGS_1984_Web_Mercator_Auxiliary_Sphere//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//WebMercator 转 WGS84
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.ProjectedCoordinateSystemStyle.eWGS_1984_Web_Mercator_Auxiliary_Sphere, //当前空间参考
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//
// 【坐标加解密】GCJ02(国测局相关)
//
pPoint = new GISShare.SMap.Geometry.Point(117, 31);
//WGS84 转 GCJ02
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984, //当前空间参考
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_GCJ02//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//GCJ02 转 WGS84
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_GCJ02, //当前空间参考
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//
// 【坐标加解密】BD09(百度相关)
//
pPoint = new GISShare.SMap.Geometry.Point(117, 31);
//WGS84 转 BD09LL
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984, //当前空间参考
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_BD09LL//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//BD09LL 转 WGS84
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_BD09LL, //当前空间参考
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//
pPoint = new GISShare.SMap.Geometry.Point(117, 31);
//GCJ02 转 BD09LL
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_GCJ02, //当前空间参考
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_BD09LL//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//BD09LL 转 GCJ02
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_BD09LL, //当前空间参考
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_GCJ02//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//
pPoint = new GISShare.SMap.Geometry.Point(117, 31);
//WGS84 转 BD09MC
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984, //当前空间参考
                                        GISShare.SMap.SpatialReference.ProjectedCoordinateSystemStyle.eWGS_1984_Web_Mercator_Auxiliary_Sphere_BD09MC//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//BD09MC 转 WGS84
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.ProjectedCoordinateSystemStyle.eWGS_1984_Web_Mercator_Auxiliary_Sphere_BD09MC, //当前空间参考
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//
pPoint = new GISShare.SMap.Geometry.Point(117, 31);
//GCJ02 转 BD09MC
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_GCJ02, //当前空间参考
                                        GISShare.SMap.SpatialReference.ProjectedCoordinateSystemStyle.eWGS_1984_Web_Mercator_Auxiliary_Sphere_BD09MC//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//BD09MC 转 GCJ02
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.ProjectedCoordinateSystemStyle.eWGS_1984_Web_Mercator_Auxiliary_Sphere_BD09MC, //当前空间参考
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_GCJ02//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//
pPoint = new GISShare.SMap.Geometry.Point(117, 31);
//BD09LL 转 BD09MC
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_BD09LL, //当前空间参考
                                        GISShare.SMap.SpatialReference.ProjectedCoordinateSystemStyle.eWGS_1984_Web_Mercator_Auxiliary_Sphere_BD09MC//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());
//BD09MC 转 BD09LL
GISShare.SMap.Fitting.FittingHelper.Fit(pPoint, //目标点
                                        GISShare.SMap.SpatialReference.ProjectedCoordinateSystemStyle.eWGS_1984_Web_Mercator_Auxiliary_Sphere_BD09MC, //当前空间参考
                                        GISShare.SMap.SpatialReference.GeographicCoordinateSystemStyle.eGCS_WGS_1984_BD09LL//目标空间参考
                                        );
console.log(pPoint.getX() + "," + pPoint.getY());

(注:
GISShare.SMap库包是一个提供GIS能力的多语言SDK(1.DotNet-C#-WinFrom和WPF;2.Java-Android;3.JS)。
支持:
1.几何数据的定义与计算(如:点、线、面、多点、多线、多面、圆、直线、三阶贝塞尔、圆弧、椭圆弧等);
2.空间参考的定义与转换(支持:Proj4、WKT等);
3.加密坐标的拟合转化(如:火星坐标GCJ02、百度坐标BD09LL/BD09MC);
4.图形数据计算(如:线条打断&分割&截取&切线&法线等、长度计算、面积计算、拓扑关系判断等);
5.图形数据的读取转换(如:WKT、WKB、GeoJson、EsriJson、TopoJson、ShapeFile等);
6.地图的可视化展现(如:WMS、WMTS、聚合、热力图等)。
);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.