final project of EC504
Jiaqi Zhang, Wenqiang Yang
- super fast pre-processing and querying with K-d tree
- always gives the accurate K nearest reference points
- calculates distances correctly, the results are consistent with http://www.movable-type.co.uk/scripts/latlong.html
- easy to use GUI and CLI
- clone the repository by
git clone https://github.com/wq-yang/Nearest-Province-Finder.git
, and go to directoryNearest-Province-Finder
- run command
make
to compile - You may need to run
ulimit -s unlimited
so that you can load the whole data to stack memory. - run CLI with the input file as its first argument
./cli NationalFile_StateProvinceDecimalLatLong.txt
- Follow the instruction and have fun!
-
To run the GUI, first make sure that
node
andnpm
is all set on your computer. If not, please refer to https://nodejs.org/en/download/current/. You may need to set $PATH variable, likeexport PATH=~/node-v17.2.0-linux-x64/bin:$PATH
.- go to directory
gui
- Run
npm i
to install necessary libraries - Run
npm start &
. If it runs successfully, you can visitlocalhost:8080
in your browser and will see the map.
- go to directory
-
To make the nearest place finder working, we need to start a backend server.
- Go to
services
. If you are atgui
right now, runcd ../services
- compile server.cpp by
g++ -std=c++11 -o server -pthread
- run
./server ../NationalFile_StateProvinceDecimalLatLong.txt &
. If no error message promps, the server starts successfully.
- Go to
-
Now you can visit
localhost:8080
and enjoy fast finding K nearest points! (You may need to zoom in if the nearest points are close to each other)
some important files
-
findKNearst.h: defines how to read file, and main structure of K-d tree
-
cli.cpp: deals with cli interface
-
gui/src/index.ts: gui implementation
-
services/server.cpp: server with RESTful API dealing with nearest point querying
Big thanks to https://github.com/yhirose/cpp-httplib and https://github.com/googlemaps/js-samples. They make the GUI development (and the backend services development) much easier.
Our implementation of K-d tree referred to https://oi-wiki.org/ds/kdt/ (Chinese).