mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Refactored and update Location Geocoding (#9359)
- Fix location so it is a regular database relation (this allows multiple devices to be accurately linked to one location and saves api calls) - Parse coordinates from the location more consistently - Add settings to webui - ~~Used [PHP Geocoder](http://geocoder-php.org/), which has lots of backends and is well tested. (also includes reverse and geoip)~~ - Google Maps, Bing, Mapquest, and OpenStreetMap supported initially. - Default to OpenStreetMap, which doesn't require a key. They will liberally hand out bans if you exceed 1 query per second though. - All other Geocoding APIs require an API key. (Google requires a credit card on file, but seems to be the most accurate) - Update all (I think) sql queries to handle the new structure - Remove final vestiges of override_sysLocation as a device attribute - Update existing device groups and rules in DB - Tested all APIs with good/bad location, no/bad/good key, and no connection. - Cannot fix advanced queries that use location This blocks #8868 DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926` After you are done testing, you can remove the changes with `./scripts/github-remove`. If there are schema changes, you can ask on discord how to revert.
This commit is contained in:
committed by
Neil Lathwood
parent
eadf27cbcc
commit
3e35ee0e7d
@@ -36,10 +36,11 @@ if (isset($config['branding']) && is_array($config['branding'])) {
|
||||
}
|
||||
}
|
||||
|
||||
$where = '';
|
||||
$param = [];
|
||||
if (is_numeric($_GET['device']) && isset($_GET['device'])) {
|
||||
$where = 'WHERE device_id = '.mres($_GET['device']);
|
||||
} else {
|
||||
$where = '';
|
||||
$where = '&& device_id = ?';
|
||||
$param[] = $_GET['device'];
|
||||
}
|
||||
|
||||
// FIXME this shit probably needs tidied up.
|
||||
@@ -57,7 +58,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
||||
} else {
|
||||
$loc_count = 1;
|
||||
|
||||
foreach (dbFetch("SELECT * from devices ".$where) as $device) {
|
||||
foreach (dbFetch("SELECT *, locations.location from devices,locations WHERE devices.location_id = locations.id ".$where, $param) as $device) {
|
||||
if ($device) {
|
||||
$links = dbFetch("SELECT * from ports AS I, links AS L WHERE I.device_id = ? AND L.local_port_id = I.port_id ORDER BY L.remote_hostname", array($device['device_id']));
|
||||
if (count($links)) {
|
||||
|
Reference in New Issue
Block a user