A universal, cross-platform location simulator written in 100% safe Rust.
Instantly spoof device coordinates, altitude, accuracy, speed, and heading across Windows, Linux, macOS, Android emulators, iOS simulators, and headless browsers.
Features • Installation • Quick Start • Usage Guide • Docs • CI/CD Testing
Testing location-dependent applications is notoriously fragmented:
- Browsers require Chrome DevTools Protocol (
Emulation.setGeolocationOverride) or manual sensor panels. - Android emulators require
adb emu geo fixor telnet commands with custom parameter ordering. - iOS simulators require
xcrun simctl location booted set. - Desktop operating systems require registry overrides, GeoClue static configs, or NMEA-0183 serial feeds.
- CI/CD test suites require deterministic JSON payloads without third-party rate limits.
locsim solves this with a single command.
Whether you provide a place name ("Tokyo Station"), coordinates (35.6812, 139.7671), or a saved bookmark (locsim use home), locsim resolves the position, validates all coordinates and telemetry bounds, and simultaneously broadcasts the simulated state to your operating system, connected mobile emulators, browser test harnesses, and developer test scripts.
┌──────────────────────────┐
│ locsim CLI / CI Test │
└────────────┬─────────────┘
│
▼
┌───────────────────────────────────────────────┐
│ Location Core │
│ - Lat / Lon Validation (-90..90, -180..180) │
│ - Altitude, Accuracy, Speed, Heading │
│ - In-Memory & Disk Cached Geocoding │
└───────────────────────┬───────────────────────┘
│
┌──────────────────┬───────────────┼───────────────┬──────────────────┐
▼ ▼ ▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌───────────┐ ┌─────────────┐ ┌──────────────┐
│ Windows │ │ Linux │ │ macOS │ │ Android │ │ Chromium │
│ WinRT / HKCU │ │ GeoClue2 & │ │ Xcode │ │ ADB Bridge │ │ CDP Sensors │
│ & Sensor HW │ │ gpsd NMEA │ │ simctl │ │ emu geo fix │ │ & Playwright │
└──────────────┘ └──────────────┘ └───────────┘ └─────────────┘ └──────────────┘
- Natural Language Geocoding: Resolve any address or point of interest with OpenStreetMap Nominatim, LocationIQ, Mapbox, OpenCage, or Google Maps.
- First-Class Reverse Geocoding: Convert coordinates into human-readable street addresses instantly via
--reverse/-r. - Extended Real-World Telemetry: Full simulation of altitude (meters), horizontal accuracy (meters), ground speed (m/s), and heading (0.0°–360.0° bearing).
- Mobile Emulator Bridges:
- Android ADB: Automatically detects running AVDs and dispatches
adb emu geo fixandcmd location set-location. Target individual devices with--android-device. - iOS Simulator: Automatic synchronization via
xcrun simctl location booted set.
- Android ADB: Automatically detects running AVDs and dispatches
- Named Location Profiles / Bookmarks: Save, list, apply, and delete frequently used testing spots (
locsim save home,locsim use work). - Reset with IP Geolocation: Instantly clear all mock states and detect genuine physical location via public IP lookup (
locsim reset). - Browser & Automation Exports: Automatically updates Chrome DevTools Protocol (
cdp_geolocation.json), GPX 1.1 tracks (simulated_location.gpx), and shell environment scripts (locsim_env.sh/locsim_env.ps1). - Shell Auto-Completions: First-class shell completions for PowerShell, Bash, Zsh, Fish, and Elvish.
- Modern TOML Configuration: Global defaults in
~/.config/locsim/config.tomlwith per-project.locsimrcoverrides. - Zero Unsafe Code: 100% safe Rust, thread-safe parallel test execution, and comprehensive error handling.
cargo install locsimgit clone https://github.com/itznan/locsim.git
cd locsim
cargo build --releaseThe compiled binary will be located in:
target/release/locsim(Linux / macOS)target/release/locsim.exe(Windows)
# 1. Search any location by name and apply (with auto-confirm -y)
locsim "Empire State Building, New York" -y
# 2. View active simulation status, diagnostics, and exports
locsim --show
# 3. Save as a bookmark for rapid testing
locsim save nyc
# 4. Jump anywhere else, then switch back instantly
locsim "Tokyo Tower" -y
locsim use nyc
# 5. Clear simulation and detect your real physical IP location
locsim resetSimply run locsim without arguments to launch an interactive search session:
$ locsim
╔══════════════════════════════════════╗
║ Location Simulator ║
╚══════════════════════════════════════╝
Enter a location:
> Eiffel Tower, Paris, France
Searching location...
✓ Location found
Location : Eiffel Tower
Address : 5, Avenue Anatole France, Quartier du Gros-Caillou, Paris, 75007, France
Latitude : 48.858370
Longitude: 2.294481
Set this as simulated location? [Y/n] > y
✓ Simulated location successfully applied!
Provider: Windows Location Provider (WinRT / Sensor Driver Overrides / DevTools)
OS Mechanism: WinRT Sensor Testing Overrides & Developer State
Generated integration files:
• ~/.config/locsim/current_location.json
• ~/.config/locsim/simulated_location.gpx
• ~/.config/locsim/cdp_geolocation.json
• ~/.config/locsim/locsim_env.ps1
# Search with interactive confirmation
locsim "Sydney Opera House"
# Search and automatically accept confirmation (-y / --yes)
locsim "Berlin Hauptbahnhof" -yTranslate GPS coordinates back into a human-readable street address:
# Lookup coordinates and display address
locsim -r 37.7749 -122.4194
# Lookup coordinates and apply immediately to OS & emulators
locsim -r 37.7749 -122.4194 -yDirectly set coordinates with strict boundary verification:
locsim --lat 22.3688 --lon 70.8022 -ySimulate realistic vehicular movement, flight, drone telemetry, or low-accuracy GPS drift:
locsim "Golden Gate Bridge" \
--altitude 67.5 \
--accuracy 5.0 \
--speed 18.5 \
--heading 350.0 \
-y| Parameter | Unit | Description | Validation |
|---|---|---|---|
--altitude |
Meters | Altitude above sea level | Finite float |
--accuracy |
Meters | Horizontal GPS accuracy radius | Must be >= 0.0 |
--speed |
m/s | Ground velocity (meters per second) | Must be >= 0.0 |
--heading |
Degrees | Bearing clockwise from True North | 0.0° to 360.0° |
Never re-type coordinates or queries you test repeatedly:
# Save current location as a bookmark
locsim save office
# Geocode and save a spot in one step
locsim save cafe "Blue Bottle Coffee, San Francisco"
# List all saved bookmarks
locsim list
# or
locsim --bookmarks
# Apply a saved bookmark
locsim use office
# or
locsim -u office
# Delete a bookmark
locsim delete cafelocsim automatically identifies online Android Virtual Devices via adb and broadcasts fixes:
# Broadcast to all connected Android emulators
locsim "Times Square, New York" -y
# Target a specific emulator instance
locsim "Times Square, New York" --android-device emulator-5554 -yOn macOS, locsim synchronizes booted simulators via xcrun simctl location booted set <lat> <lon>.
Switch between free and commercial providers on the fly:
# OpenStreetMap Nominatim (default, no API key needed)
locsim "Brandenburg Gate" --provider nominatim
# Mapbox Places API
locsim "Central Park" --provider mapbox --api-key pk.your_token
# LocationIQ API
locsim "Big Ben" --provider locationiq --api-key your_locationiq_key
# OpenCage Data API
locsim "Colosseum" --provider opencage --api-key your_opencage_key
# Google Maps Geocoding API
locsim "Taj Mahal" --provider google --api-key AIzaSy...Generate high-performance autocompletion scripts:
# PowerShell (add to your $PROFILE)
locsim completions powershell | Out-String | Invoke-Expression
# Bash (add to ~/.bashrc)
eval "$(locsim completions bash)"
# Zsh (add to ~/.zshrc)
eval "$(locsim completions zsh)"
# Fish
locsim completions fish | sourceInspect the active simulation state across every integration layer:
locsim --show══════════════════════════════════════
Simulated Location Status
══════════════════════════════════════
Status : ACTIVE SIMULATION
Location : Marwadi University
Address : Rajkot - Morbi Highway, Rajkot Taluka, Gujarat, India - 360003
Latitude : 22.367601
Longitude: 70.797092
Altitude : 50.00 m
Accuracy : 10.00 m
Speed : 5.50 m/s
Heading : 180.00°
OS & Platform Integration:
Platform : Windows
Provider : Windows Location Provider (WinRT / Sensor Driver Overrides / DevTools)
Geocoder : nominatim
Mechanism : WinRT Sensor Testing Overrides & Developer State
Elevated : No (Standard user)
Artifacts & Exports:
• ~/.config/locsim/current_location.json [EXISTS]
• ~/.config/locsim/simulated_location.gpx [EXISTS]
• ~/.config/locsim/cdp_geolocation.json [EXISTS]
• ~/.config/locsim/locsim_env.ps1 [EXISTS]
Mobile Emulator Status:
ADB : Available (Android Debug Bridge version 1.0.41)
Emulator : emulator-5554 [ONLINE]
Clear all simulation overrides, restore defaults, and verify your genuine physical location using IP geolocation:
locsim reset✓ Simulated location successfully cleared.
Reset overrides and cleaned up local mock artifacts.
Detecting real physical location via IP Geolocation...
══════════════════════════════════════
Real Physical Location (IP)
══════════════════════════════════════
Public IP : 203.0.113.42
Location : Rajkot, Gujarat, India
Coordinates: 22.303890, 70.802160
ISP / Org : Reliance Jio Infocomm Ltd
Device is now reporting its genuine network location.
For visual terminal management:
locsim -iLocation Simulator Menu:
1. Search for a location
2. Enter coordinates manually
3. Show current simulated location
4. Clear simulated location
5. Saved location bookmarks (List / Use / Save)
6. Reset to real physical location
7. Exit
Select an option [1-7] >
locsim supports configuration files with the following precedence:
- CLI Flags (
--provider,--api-key) - Environment Variables (
LOCSIM_PROVIDER,LOCSIM_API_KEY) - Project Override (
./.locsimrcor./.locsim.toml) - Global Defaults (
~/.config/locsim/config.tomlor%APPDATA%\locsim\locsim\config\config.toml)
# Default geocoder provider: nominatim | locationiq | mapbox | opencage | google
provider = "nominatim"
# API Key for commercial geocoders (optional for Nominatim)
# api_key = "pk.your_api_key_or_token"
cache_enabled = true
timeout_seconds = 10
user_agent = "locsim/0.1.0 (https://github.com/itznan/locsim; universal-location-simulator)"| Variable | Description | Default |
|---|---|---|
LOCSIM_PROVIDER |
Geocoder backend (nominatim, locationiq, mapbox, opencage, google) |
nominatim |
LOCSIM_API_KEY |
API Key applied to the active provider | None |
MAPBOX_ACCESS_TOKEN |
Fallback API key for Mapbox Places | None |
LOCATIONIQ_API_KEY |
Fallback API key for LocationIQ | None |
OPENCAGE_API_KEY |
Fallback API key for OpenCage | None |
GOOGLE_MAPS_API_KEY |
Fallback API key for Google Maps | None |
LOCSIM_CACHE_ENABLED |
Set to false or 0 to bypass local disk cache |
true |
LOCSIM_TIMEOUT |
Request timeout in seconds | 10 |
LOCSIM_DATA_DIR |
Custom directory for mock artifacts and caches | OS default |
locsim exports cdp_geolocation.json containing exact Chrome DevTools Protocol parameters:
// Playwright test example
import { test, expect } from '@playwright/test';
import * as fs from 'fs';
test('verify location-dependent pricing', async ({ browser }) => {
const cdp = JSON.parse(fs.readFileSync('.locsim/cdp_geolocation.json', 'utf-8'));
const context = await browser.newContext({
geolocation: { latitude: cdp.latitude, longitude: cdp.longitude, accuracy: cdp.accuracy },
permissions: ['geolocation'],
});
const page = await context.newPage();
await page.goto('https://example.com/checkout');
await expect(page.locator('#currency')).toHaveText('USD');
});name: Location-Dependent Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install --path .
- name: Set Simulated Position
run: |
locsim "London, UK" -y
source ~/.config/locsim/locsim_env.sh
npm testFor advanced architecture, developer integrations, and provider guides, explore the dedicated documentation suite:
- Architecture & Internals — Trait design, memory caching, telemetry validation, and platform dispatcher mechanics.
- Geocoding Providers Guide — Comprehensive guide on configuring Nominatim, LocationIQ, Mapbox, OpenCage, and Google Maps.
- Mobile Emulator Guide — Step-by-step setup for Android Virtual Devices (AVD), multi-device ADB targeting, and iOS Simulators.
- Continuous Integration Guide — Playwright, Puppeteer, Selenium, Python
pytest, and GitHub Actions workflow recipes. - Configuration Reference — Complete TOML schema, environment variable hierarchy, and export file paths.
When testing location-aware applications, it is essential to understand that different technologies resolve location using different mechanisms:
- CLI & Developer Test Suites: Read
current_location.jsonor sourcelocsim_env.ps1/locsim_env.sh. Fully supported. - OS-Level Location Services:
- Windows: Updates
HKCU\Software\Locsim. If run as Administrator, updates the documented Windows Sensor Platform override key (HKLM\...\Sensor\Overrides\{BFA794E4-F964-4F53-B00F-CEDD57E4457E}). - Linux: Generates
geoclue-static.conffororg.freedesktop.GeoClue2and NMEA-0183 ($GPRMC,$GPGGA) feeds forgpsd/gpsfake. - macOS: Executes
xcrun simctl location booted set <lat> <lon>for running iOS simulators.
- Windows: Updates
- Browser Geolocation: Desktop browsers rely on Wi-Fi positioning services (e.g. Google Location Services). To test browsers, use the exported
cdp_geolocation.jsonwith Chrome DevTools Sensors or Playwright/Puppeteer. - IP-Based Geolocation (GeoIP): Server-side GeoIP lookups (MaxMind, Cloudflare headers) resolve the public IP of your network connection. GPS mock tools cannot alter network routing IP geolocation.
We welcome issues, feedback, and pull requests!
# Clone the repository
git clone https://github.com/itznan/locsim.git
cd locsim
# Run the full unit and integration test suite
cargo test
# Run linter checks
cargo clippy --all-targets -- -D warningsDual-licensed under either:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.