Skip to content

Commit

Permalink
Fix for EPSG:3857 failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
kj415j45 committed Aug 8, 2023
1 parent ef0b0a9 commit e570aa8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
shuffle,
SampleType,
generateSample,
isValidEPSG3857Lat,
} from "./src/utils";
import { Command } from "commander";
import { redis } from "./src/Redis/Redis";
Expand Down Expand Up @@ -113,6 +114,9 @@ new Promise<void>(async (resolve, reject) => {

// Query B case
testPoint = data[Math.floor(Math.random() * data.length)];
while( !isValidEPSG3857Lat(testPoint.lat) ){
testPoint = data[Math.floor(Math.random() * data.length)];
}
lng = testPoint.lng;
lat = testPoint.lat;
distance = Math.random() * 100;
Expand All @@ -135,6 +139,9 @@ new Promise<void>(async (resolve, reject) => {

// Query C case
testPoint = data[Math.floor(Math.random() * data.length)];
while( !isValidEPSG3857Lat(testPoint.lat) ){
testPoint = data[Math.floor(Math.random() * data.length)];
}
lng = testPoint.lng;
lat = testPoint.lat;
distance = Math.random() * 100;
Expand Down
2 changes: 1 addition & 1 deletion src/Redis/Locations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Entity, Schema } from 'redis-om';
import { Schema } from 'redis-om';


export type Location = {
Expand Down
5 changes: 5 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ export function randomLat() {
return Math.random() * 180 - 90;
}

export function isValidEPSG3857Lat(lat: number): boolean {
const latLimit = 85.05112878;
return Math.abs(lat) < latLimit;
}

export type Longitude = number;
export type Latitude = number;

Expand Down

0 comments on commit e570aa8

Please sign in to comment.