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 2 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 2 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 2 months ago
I updated the description above to reflect this approach...
Qdev 2 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.