Normalize OSM geometry to 1x1 coordinate system

I'm extracting a couple of geometries with overpass turbo and need to "normalize" their shape from lat-lon to [[0-1][0-1]] coordinates.

The first thing I've tried is probably pretty wrong: get highest & smallest lat-lon values in the geometry and remap them to 0-1. This is the JS code:

function (geometry) {
let biggestLat = geometry;
let biggestLong = geometry;

for (let i = 0; i < geometry.length; i++) {
if (biggestLat < geometry[i]) {
biggestLat = geometry[i];
}

if (biggestLong < geometry[i]) {
biggestLong = geometry[i];
}
}

let smallestLat = geometry;
let smallestLong = geometry;

for (let i = 0; i < geometry.length; i++) {
if (smallestLat > geometry[i]) {
smallestLat = geometry[i];
}

if (smallestLong > geometry[i]) {
smallestLong = geometry[i];
}
}

let coordinatesArray = [];

for (let i = 0; i < geometry.length; i++) {

let lat = this.map_range(geometry[i], smallestLat, biggestLat, 0, 1);
let lon = this.map_range(geometry[i], smallestLong, biggestLong, 0, 1);
coordinatesArray.push([lat, lon]);

}

return coordinatesArray
}

And the result is obviously pretty off: I've been reading about the different projection methods and that I need to decide for one, but I don't really understand which I should use in this case. Mercator seems to be wrong?

To summarize my aim: I want to scale any Geometry i get from osm to the same size in a x,y coordinate system. Can anyone explain me how to do it correctly or what framework to use to do the calculation? I've been using turf.js in other projects.

So actually, what I missed, is to reverse the mercator projection. Then everything was fine:

function mercator (longitude, latitude) {
var radius = 6378137;
var max = 85.0511287798;
var radians = Math.PI / 180;
var point = {};

point.x = radius * longitude * radians;
point.y = Math.max(Math.min(max, latitude), -max) * radians;
point.y = radius * Math.log(Math.tan((Math.PI / 4) + (point.y / 2)));

return point;
}

I also messed up the long lat order + taking the relation of the bounding box of the shape into account:

function normalizeGeometry(geometry) {
let biggestLong = geometry;
let biggestLat = geometry;

for (let i = 0; i < geometry.length; i++) {
if (biggestLong < geometry[i]) {
biggestLong = geometry[i];
}
if (biggestLat < geometry[i]) {
biggestLat = geometry[i];
}
}

let smallestLong = geometry;
let smallestLat = geometry;

for (let i = 0; i < geometry.length; i++) {
if (smallestLat > geometry[i]) {
smallestLat = geometry[i];
}

if (smallestLong > geometry[i]) {
smallestLong = geometry[i];
}
}

// calculate Ratio
let width = biggestLong - smallestLong;
let height = biggestLat - smallestLat;
let ratio;

let smallestLatRemap = 0;
let biggestLatRemap = 1;
let smallestLonRemap = 0;
let biggestLonRemap = 1;

if (width > height) { // landscape
ratio = height / width;
let shift = 1 - ratio;
smallestLatRemap += shift / 2;
biggestLatRemap -= shift / 2;
} else if (width < height) { // portrait
ratio = width / height;
let shift = 1 - ratio;
smallestLonRemap += shift / 2;
biggestLonRemap -= shift / 2;
} else { // square ratio
}

let coordinatesArray = [];

for (let i = 0; i < geometry.length; i++) {
let lon = this.map_range(geometry[i], smallestLong, biggestLong, smallestLonRemap, biggestLonRemap);
let lat = this.map_range(geometry[i], smallestLat, biggestLat, biggestLatRemap, smallestLatRemap);
coordinatesArray.push([lon, lat]);
}

return coordinatesArray
}