Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'urn:ogc:def:crs:', ''
).replace('8.8.1:', '')
const from = epsg[crs]
//const to = proj4.default.defs('EPSG:4326', '+proj=longlat +datum=WGS84 +no_defs');
const to = '+proj=longlat +datum=WGS84 +over'
//console.log(`${geojson.type} ${JSON.stringify(geojson)}`)
if (geojson.type === 'Polygon') {
geojson = {
type: 'Polygon',
coordinates: [geojson.coordinates[0].map((c) => proj4.default(from, to, c))]
}
} else if (geojson.type === 'Point') {
geojson = {
type: 'Point',
coordinates: proj4.default(from, to, geojson.coordinates)
}
} else {
throw Error('cannot process non Point or Polygon geometries')
}
if (kinks(geojson).features.length > 0) {
throw Error('self-intersecting polygon')
}
return geojson
}
function getRectangleFromLayer(thisLayerJson) {
var extent = thisLayerJson.extent;
if (
defined(extent) &&
extent.spatialReference &&
extent.spatialReference.wkid
) {
var wkid = "EPSG:" + extent.spatialReference.wkid;
if (!defined(proj4definitions[wkid])) {
return undefined;
}
var source = new proj4.Proj(proj4definitions[wkid]);
var dest = new proj4.Proj("EPSG:4326");
var p = proj4(source, dest, [extent.xmin, extent.ymin]);
var west = p[0];
var south = p[1];
p = proj4(source, dest, [extent.xmax, extent.ymax]);
var east = p[0];
var north = p[1];
return Rectangle.fromDegrees(west, south, east, north);
}
return undefined;
}
function TransCoord(x, y) {
if(proj4) {
var p = proj4.default(EPSG4326, [parseFloat(x), parseFloat(y)]);
return {x: p[0], y: p[1]};
}
}
extent.spatialReference.wkid
) {
var wkid = "EPSG:" + extent.spatialReference.wkid;
if (!defined(proj4definitions[wkid])) {
return undefined;
}
var source = new proj4.Proj(proj4definitions[wkid]);
var dest = new proj4.Proj("EPSG:4326");
var p = proj4(source, dest, [extent.xmin, extent.ymin]);
var west = p[0];
var south = p[1];
p = proj4(source, dest, [extent.xmax, extent.ymax]);
var east = p[0];
var north = p[1];
return Rectangle.fromDegrees(west, south, east, north);
}
return undefined;
}
reprojectPoint: function(coordinates, sourceCode, destCode) {
var source = new proj4.Proj(Proj4Definitions[sourceCode]);
var dest = new proj4.Proj(Proj4Definitions[destCode]);
return proj4(source, dest, coordinates);
},