Skip to content

Commit

Permalink
fix inspire grid latitude fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Karagappa authored and Karagappa committed Aug 28, 2024
1 parent 3b29c91 commit 74f844b
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions frontend/src/components/InspireGridComponents/inspire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export function getGrid(bounds: [[number, number], [number, number]], level: num
const scalingFactorLong = 2 * latitudeSpacing[level] / 3600; // BS is in Zone 2

const latMin: number = bounds[0][0];
const latMax: number = bounds[1][0];
const lonMin: number = bounds[0][1];
const latMax: number = bounds[1][0];
const lonMax: number = bounds[1][1];

const latMinNew: number = latMin - latMin % scalingFactorLat;
Expand All @@ -22,11 +22,14 @@ export function getGrid(bounds: [[number, number], [number, number]], level: num
};
}


function latitudeCoordinates(latMin: number, latMax: number, lonMin: number, lonMax: number, level: number) {
const linesLat = [];
const latSpacing = latitudeSpacing[level] / 3600;

for (let lat = latMin; lat <= (latMax + latSpacing); lat += latSpacing) {
for (let lat = latMin; lat <= (latMax + latitudeSpacing[level] / 3600); lat += latitudeSpacing[level] / 3600) {
const { factor } = getLongitudinalFactorAndZone(lat);
const latSpacing = (factor * latitudeSpacing[level]) / 3600;

const latLine: Array<[number, number]> = [];
const lonRange = range(lonMin, lonMax, latSpacing);

Expand All @@ -41,16 +44,15 @@ function latitudeCoordinates(latMin: number, latMax: number, lonMin: number, lon

function longitudeCoordinates(latMin: number, latMax: number, lonMin: number, lonMax: number, level: number) {
const linesLong = [];
const lonSpacing = (latitudeSpacing[level]) / 3600;

for (let lat = latMin; lat <= latMax + latitudeSpacing[level] / 3600; lat += latitudeSpacing[level] / 3600) {
const { factor } = getLongitudinalFactorAndZone(lat);
const lonIncrement = (factor * latitudeSpacing[level]) / 3600;
for (let lat = latMin; lat <= latMax + lonSpacing; lat += lonSpacing) {

const lonRange = range(lonMin, lonMax, lonIncrement);
const lonRange = range(lonMin, lonMax, lonSpacing);
for (let lon of lonRange) {
linesLong.push([
[lon, lat],
[lon, lat + lonIncrement],
[lon, lat + lonSpacing],
]);
}
}
Expand Down Expand Up @@ -124,18 +126,4 @@ export function cellBoundsFromId(cellIdentifier: string): Array<Array<number>> |
return null;
}

function getResolutionFromZoom(input: number): number {
const inputStart = 14;
const inputEnd = 18;
const outputStart = 10;
const outputEnd = 14;

if (input < inputStart || input > inputEnd) {
throw new Error("Input value out of range");
}


const output = Math.round(outputStart + ((input - inputStart) * (outputEnd - outputStart)) / (inputEnd - inputStart));
return output;
}

0 comments on commit 74f844b

Please sign in to comment.