2.2 KiB
2.2 KiB
Search Algorithm Strategies
1. Zoom Level Calibration
Objective: Determine the optimal zoom level to maximize the number of unique locations found for a given keyword and location.
Strategy
-
Input:
- Keyword (e.g., "carpenters")
- Location (e.g., "Barcelona, Spain")
- Zoom Range (e.g., 12-18)
-
Process:
- Iterate through the defined range of zoom levels.
- For each zoom level:
- Perform a Google Maps search using the
googleMapsfunction. - Store the results in a JSON file using the
--dstoption (e.g.,./tmp/search/test-zoomlevel-<zoom>.json). - Count the total number of valid results returned.
- Perform a Google Maps search using the
- Maintain a record of (Zoom Level -> Result Count).
-
Output:
- The zoom level that yielded the maximum number of results.
-
Notes:
- This process assumes that for a fixed point, the "best" zoom captures the most relevant density without being too broad (losing small entities) or too narrow (missing context).
- Overlaps/Duplicates should be handled by the underlying search function or post-processing if multi-point scanning is used later.
2. Area Scanning (Grid Search)
Objective: Scan a larger, defined area (e.g., "Madrid" or "Spain") using the optimal zoom level to ensure comprehensive coverage.
Strategy (Planning)
-
Input:
- Target Area Boundaries (Polygon/Box).
- Calibrated Zoom Level (from Step 1).
- List of Provinces/Towns (if segmenting by admin regions).
-
Grid Generation:
- Determine the lat/long delta that corresponds to the calibrated zoom level's viewport size.
- Create a grid of search coordinates covering the Target Area.
-
Execution & State Management:
- This is a long-running task.
- State Store: Maintain a persistent state (JSON/DB) tracking:
- Queue of pending coordinates.
- Completed coordinates.
- Failed coordinates.
- Process the queue sequentially or in parallel batches.
-
Aggregation:
- Combine all result files.
- Perform global deduplication (by
place_idortitle+address).