# TODO - add geo fences (2 regions) - add parameter to zip resulting tiles, 50 mb max - implement api to download tile - lat, lon and zoom level - implement parallel tiles fetching from google maps # High level description We need to implement a service which will have the following high level functionality: 1. Download map tiles with from google maps for specific area which is defined by: - Zoom level (default - maximum zoom in google maps) - Lattitude (center of square) - Longitude (center of square) - Size of the square in meters, minimum 100 meters, maximum 1000 meters 2. Store downloaded tiles and its metadata - We should store tiles "as is" just like google maps returns them in folder /tiles (which will be mounted to the docker container where the service is running) - We should store metadata in Postgres database in table "tiles". We should store the following information: -- Unique UUID -- Zoom level -- Lattitude (center of square) -- Longitude (center of square) -- Tile size in meters (per google maps data) -- Tile size in pixels -- Composite key - it should be a combination of Lattitude, Longitude and Tile size in meters for fast lookups or search -- Image type -- Maps version (google maps can update maps over time) -- File path relative to the folder where tiles are stored 3. Request maps for certain region We should have API endpoint POST /api/satellite/request which will do the following: - Request map tiles for the region defined by -- Unique ID (region UUID) -- Lattitude (center of square) -- Longitude (center of square) -- Size of the square in meters, minimum 100 meters, maximum 10000 meters - Use previously stored tiles and metadata, if tiles are missing it should download them (see above) - When all tiles are ready, it should create a file region_{id}_ready.csv in folder /ready (which will be mounted to the docker container where the service is running) -- The file should have comma separated data with coordinates and filenames from /tiles folder covering the region -- Rows sequence should represent tiles from top left corner to bottom right corner of the region -- Create file region_{id}_summary.txt where write a summary of how many tiles were downloaded, how many we reused from cache, time taken and othe usefull summary information - API endpoint GET /api/satellite/region/{id} should return path to file region_{id}_ready.csv when all tiles are ready and the file is created, otherwise it should return response indicating that download is in progress. 4. Plan route, split it into overlapping regions We should have API endpoint POST /api/satellite/route which will do the following: - Create a route on the map defined by an array of points where the first point is "start" and the last point is "end" of the route - for each node in the route the service should calculate coordinates of intermediate points such as: -- If the distance between node start and node end is less than 200 meters, no intermediate points needed -- If the distance between node start and node end is more than 200 meters, the service should create intermediate points on the same line as the line defined by node start and node end -- Intermidiate points should have equal distance between each other and node start and node end but not more than 200 meters -- Each point and intermediate point on the route will define a center of a region on maps - We should store routes in the database, each route should have unique ID - We should have API endpoint GET /api/satellite/route/{id} which will return information of the route including intermidiate points The service will be running in docker container, we also need to run postgres database also in docker container. I also want to use integration tests as a separate app running as a console app in a separate docker container. We would need two docker compose files: - docker-compose.svc.yml - will run the service and its dependencies - docker-compose.tests.yml - will run the integration tests, the service and its dependencies We have legacy code which already implements downloading tiles using google map, you can use it for reference. But don't directly copy code as we might have different structure and different requirements. You might find there api key for google maps, feel free to use it. Legacy code is here: ../dev/annotator/Azaion.Common/Services/SatelliteDownloader.cs