· 7 years ago · Nov 22, 2018, 10:58 AM
1Create a repo on github or bitbucket, please name it "apitest"
2
3​use any language, but you have to use postgresql
4Database setup : (NOTE: Enable geolocation features in Postgresql with extensions : cube and earthdistance.
5Use the specific data types to create latitude and longitude
6
7--------Interview Stage 1--------
8create a new table in postgres and load this CSV that denotes the mapping between pincode and lat/long (https://github.com/sanand0/pincode/blob/master/data/IN.csv).
9Create Two APIs in Django : Get,Post.
10Post : Post lat,lng of any location with pin code+address+city and you can add new pin code in db. This api will be /post_location. Remember to check if pin code
11already exists or if there are existing latitude+longitude THAT ARE CLOSE ENOUGH TO BE THE SAME (dont assume that they will exactly be the same.)
12
13Write testcases (using the test framework in your language. please use a test framework, do NOT just write functions and call it tests).
14Test different situations of adding data.
15
16--------Interview Stage 2--------
17Get : There are two GET apis. Given a location, fetch all the nearby pin codes within a radius. For example, I can ask - give me all points within 5km radius
18of (45.12, 71.12) . To do this you will need to do mathematical computation of radius. there are two ways to do this:
19You can use postgres "earthdistance" to compute all points in 5km radius. This api will be /get_using_postgres
20Implement the mathematical computation yourself. this api will be /get_using_self
21
22Write testcases (using the test framework in your language. please use a test framework, do NOT just write functions and call it tests). Test results between /get_using_postgres and /get_using_self.
23
24--------Interview Stage 3--------
25a Geojson is a json file which defines shapes of locations - for example the shape of delhi, gurgaon, etc. This geojson is used to define delhi and its areas. https://gist.github.com/ramsingla/6202001?short_path=7d9a995
26you can check it out by going to http://geojson.io and pasting the raw json on the right side (on tab marked JSON).
27You will then parse this json, and load the boundaries latitude and longitude (geometry -> coordinates) into postgresql in a new table. you can use any structure,
28but remember that one place will have lots of lat/long (because it marks the boundaries).
29Write a new API : given a latitude/longitude, it will tell you which place it falls within.
30
31Write testcases.