Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
///////////////////////////////////
// Named Projections
///////////////////////////////////
proj4.defs('WGS84', epsg['4326'])
proj4.defs([
['EPSG:4326', epsg['4326']],
['EPSG:4269', epsg['4269']]
])
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326'))
///////////////////////////////////
// Utils
///////////////////////////////////
// WGS84
proj4.WGS84
// Proj
proj4.Proj('WGS84')
// toPoint
proj4.toPoint([1, 2])
proj4.toPoint([1, 2, 3])
proj4.toPoint([1, 2, 3, 4])
// Point
// WARNING: Deprecated in v3
proj4.Point([1, 2, 3, 4])
transform.vincentyDistance = function (pt1, pt2, gcs, baseGcs, ellipsoid, maxIterations) {
baseGcs = baseGcs || 'EPSG:4326';
ellipsoid = ellipsoid || proj4.WGS84;
maxIterations = maxIterations || 100;
gcs = gcs || baseGcs;
if (gcs !== baseGcs) {
var pts = transform.transformCoordinates(gcs, baseGcs, [pt1, pt2]);
pt1 = pts[0];
pt2 = pts[1];
}
var a = ellipsoid.a,
b = ellipsoid.b || ellipsoid.a * (1.0 - (ellipsoid.f || 1.0 / ellipsoid.rf)),
f = ellipsoid.f || (ellipsoid.rf ? 1.0 / ellipsoid.rf : 1.0 - b / a),
// baseGcs must be in degrees or this will be wrong
phi1 = pt1.y * Math.PI / 180,
phi2 = pt2.y * Math.PI / 180,
L = (((pt2.x - pt1.x) % 360 + 360) % 360) * Math.PI / 180,
U1 = Math.atan((1 - f) * Math.tan(phi1)), // reduced latitude
U2 = Math.atan((1 - f) * Math.tan(phi2)),
// for Guadeloupe, Saint-Barthélemy, Saint-Martin, Martinique
proj4.defs["EPSG:32620"] = "+proj=utm +zone=20 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ";
var UTM20 = proj4.defs["EPSG:32620"];
var projectorUTM20 = proj4(UTM20, proj4.WGS84);
// for Guyane
proj4.defs["EPSG:2972"] = "+proj=utm +zone=22 +ellps=GRS80 +towgs84=2,2,-2,0,0,0,0 +units=m +no_defs ";
var UTM22 = proj4.defs["EPSG:2972"];
var projectorUTM22 = proj4(UTM22, proj4.WGS84);
// for Réunion
proj4.defs["EPSG:2975"] = "+proj=utm +zone=40 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ";
var UTM40 = proj4.defs["EPSG:2975"];
var projectorUTM40 = proj4(UTM40, proj4.WGS84);
var output = fs.createWriteStream("data/iris.json");
output.write('{"type": "FeatureCollection", "features": [\n');
var shapefiles = [];
(new Promise(function (resolve, reject) {
glob("data/**/*.shp", {}, function (err, files) {
if (err) {
reject(err);
} else {
resolve(files);
}
});
"use strict";
require("es6-shim");
var fs = require("fs");
var glob = require("glob");
var shapefile = require('shapefile');
var Map = require('es6-map');
var proj4 = require('proj4');
// Metropolitan France
proj4.defs["EPSG:2154"] = "+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
var epsg2154 = proj4.defs['EPSG:2154'];
var projector = proj4(epsg2154, proj4.WGS84);
// for Guadeloupe, Saint-Barthélemy, Saint-Martin, Martinique
proj4.defs["EPSG:32620"] = "+proj=utm +zone=20 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ";
var UTM20 = proj4.defs["EPSG:32620"];
var projectorUTM20 = proj4(UTM20, proj4.WGS84);
// for Guyane
proj4.defs["EPSG:2972"] = "+proj=utm +zone=22 +ellps=GRS80 +towgs84=2,2,-2,0,0,0,0 +units=m +no_defs ";
var UTM22 = proj4.defs["EPSG:2972"];
var projectorUTM22 = proj4(UTM22, proj4.WGS84);
// for Réunion
proj4.defs["EPSG:2975"] = "+proj=utm +zone=40 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ";
var UTM40 = proj4.defs["EPSG:2975"];
var projectorUTM40 = proj4(UTM40, proj4.WGS84);
initialize: function() {
this.projections = {
'EPSG:4326': proj4.WGS84
};
},
import * as THREE from 'three';
import proj4 from 'proj4';
import Coordinates from 'Core/Geographic/Coordinates';
export const ellipsoidSizes = new THREE.Vector3(
proj4.WGS84.a,
proj4.WGS84.a,
proj4.WGS84.b);
const normal = new THREE.Vector3();
class Ellipsoid {
constructor(size = ellipsoidSizes) {
this.size = new THREE.Vector3();
this._radiiSquared = new THREE.Vector3();
this._invRadiiSquared = new THREE.Vector3();
this.setSize(size);
}
geodeticSurfaceNormal(cartesian, target = new THREE.Vector3()) {
return cartesian.toVector3(target).multiply(this._invRadiiSquared).normalize();
}
show: function(latlng) {
var el = L.DomUtil.get(this._el),
lnglat = [latlng.lng, latlng.lat],
pname,
proj,
transform,
c,
li;
el.innerHTML = '';
for (pname in this._projs.projections) {
proj = this._projs.projections[pname];
transform = proj4(proj4.WGS84, proj);
c = transform.forward(lnglat);
c = c.map(this._formatCoordinateValue);
li = L.DomUtil.create('li');
li.innerHTML = '<strong>' + pname + '</strong>: ' + c[0] + ' ' + c[1];
el.appendChild(li)
}
},
import * as THREE from 'three';
import proj4 from 'proj4';
import Coordinates from 'Core/Geographic/Coordinates';
export const ellipsoidSizes = new THREE.Vector3(
proj4.WGS84.a,
proj4.WGS84.a,
proj4.WGS84.b);
const normal = new THREE.Vector3();
class Ellipsoid {
constructor(size = ellipsoidSizes) {
this.size = new THREE.Vector3();
this._radiiSquared = new THREE.Vector3();
this._invRadiiSquared = new THREE.Vector3();
this.setSize(size);
}
geodeticSurfaceNormal(cartesian, target = new THREE.Vector3()) {
return cartesian.toVector3(target).multiply(this._invRadiiSquared).normalize();
isObject: function (value) {
var type = typeof value;
return value !== null && value !== undefined && (type === 'object' || type === 'function');
},
///////////////////////////////////////////////////////////////////////////
/*
* Utility member properties.
*/
///////////////////////////////////////////////////////////////////////////
/**
* Radius of the earth in meters, from the equatorial radius of SRID 4326.
* @memberof geo.util
*/
radiusEarth: proj4.WGS84.a
};
module.exports = util;