diff --git a/application/libraries/Geojson.php b/application/libraries/Geojson.php index 8d3890dc2..db4b87772 100644 --- a/application/libraries/Geojson.php +++ b/application/libraries/Geojson.php @@ -66,11 +66,17 @@ class Geojson { ]; private $qra; + private $geojsonFile = null; + private $geojsonData = null; - public function __construct() { + public function __construct($dxcc = null) { $CI =& get_instance(); $CI->load->library('qra'); $this->qra = $CI->qra; + if ($dxcc !== null) { + $this->geojsonFile = "assets/json/geojson/states_{$dxcc}.geojson"; + $this->geojsonData = $this->loadGeoJsonFile($geojsonFile); + } } // ============================================================================ @@ -114,14 +120,16 @@ class Geojson { return null; } - $geojsonFile = "assets/json/geojson/states_{$dxcc}.geojson"; - $geojsonData = $this->loadGeoJsonFile($geojsonFile); + if ($this->geojsonFile === null) { + $this->geojsonFile = "assets/json/geojson/states_{$dxcc}.geojson"; + $this->geojsonData = $this->loadGeoJsonFile($this->geojsonFile); + } - if ($geojsonData === null) { + if ($this->geojsonData === null) { return null; } - return $this->findFeatureContainingPoint($lat, $lng, $geojsonData); + return $this->findFeatureContainingPoint($lat, $lng, $this->geojsonData); } /** diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index 6161260dd..5052e6e50 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -1583,7 +1583,7 @@ class Logbookadvanced_model extends CI_Model { * @return array Result array with success, dxcc_name, dxcc_number, state_code, skipped */ function fixStateBatch($dxcc) { - $this->load->library('Geojson'); + $this->load->library('Geojson', $dxcc); // Get QSO data $sql = "SELECT COL_PRIMARY_KEY, COL_CALL, COL_GRIDSQUARE, COL_DXCC, COL_STATE, d.name as dxcc_name, station_profile.station_profile_name @@ -1632,8 +1632,6 @@ class Logbookadvanced_model extends CI_Model { * @return array Result array with success, dxcc_name, dxcc_number, state_code, skipped */ function fixStateDxcc($qso_id) { - $this->load->library('Geojson'); - // Get QSO data $sql = "SELECT COL_PRIMARY_KEY, COL_CALL, COL_GRIDSQUARE, COL_DXCC, COL_STATE, d.name as dxcc_name FROM " . $this->config->item('table_name') . " qsos