From 100874762064377af73292f8415bcb3ddd5ae262 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 27 Aug 2015 02:29:18 +0200 Subject: [PATCH] Calculation of total sections added + debug message enabled + entry id added. Signed-off-by: Roland Haeder --- .../class_CityDistrictsDatabaseWrapper.php | 2 +- .../lots/class_CityLotsDatabaseWrapper.php | 2 +- .../class_CitySectionsDatabaseWrapper.php | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/application/city/classes/database/frontend/city_entities/districts/class_CityDistrictsDatabaseWrapper.php b/application/city/classes/database/frontend/city_entities/districts/class_CityDistrictsDatabaseWrapper.php index 67ea7c4..fa319ff 100644 --- a/application/city/classes/database/frontend/city_entities/districts/class_CityDistrictsDatabaseWrapper.php +++ b/application/city/classes/database/frontend/city_entities/districts/class_CityDistrictsDatabaseWrapper.php @@ -69,7 +69,7 @@ class CityDistrictsDatabaseWrapper extends BaseDatabaseWrapper implements CityDi $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId); /* - * Only one entry is enough to find, else this query could run very\ + * Only one entry is enough to find, else this query could run very * long on large maps. */ $searchInstance->setLimit(1); diff --git a/application/city/classes/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php b/application/city/classes/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php index 7e4bfd5..a6dff78 100644 --- a/application/city/classes/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php +++ b/application/city/classes/database/frontend/city_entities/lots/class_CityLotsDatabaseWrapper.php @@ -70,7 +70,7 @@ class CityLotsDatabaseWrapper extends BaseDatabaseWrapper implements CityLotsWra $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId); /* - * Only one entry is enough to find, else this query could run very\ + * Only one entry is enough to find, else this query could run very * long on large maps. */ $searchInstance->setLimit(1); diff --git a/application/city/classes/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php b/application/city/classes/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php index 0dc6003..b8b57e5 100644 --- a/application/city/classes/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php +++ b/application/city/classes/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php @@ -33,6 +33,9 @@ class CitySectionsDatabaseWrapper extends BaseDatabaseWrapper implements CitySec // Constants for database table names const DB_TABLE_CITY_SECTIONS = 'city_sections'; + // Entry id + const DB_COLUMN_ENTRY_ID = 'entry_id'; + // Section id, an referenced city id and lot id const DB_COLUMN_SECTION_ID = 'city_section_id'; const DB_COLUMN_CITY_ID = 'city_id'; @@ -160,8 +163,11 @@ class CitySectionsDatabaseWrapper extends BaseDatabaseWrapper implements CitySec $maxUp = $this->getConfigInstance()->getConfigEntry('city_max_initial_up_expansion'); $maxDown = $this->getConfigInstance()->getConfigEntry('city_max_initial_down_expansion'); - // Extremely huge debug message: - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: radius=' . $radius . ',maxUp=' . $maxUp . ',maxDown=' . $maxDown); + // Calculate total sections + $totalSections = (($radius + 1) * ($radius + 1) * $maxUp * ($maxDown + 1)); + + // Debug message: + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: radius=' . $radius . ',maxUp=' . $maxUp . ',maxDown=' . $maxDown . ',totalSections=' . $totalSections); // Get data set instance $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_CITY_SECTIONS)); @@ -186,6 +192,9 @@ class CitySectionsDatabaseWrapper extends BaseDatabaseWrapper implements CitySec // Set primary key to 'city_id'/'section_id' $dataSetInstance->setPrimaryKeyCombined(array(self::DB_COLUMN_CITY_ID, self::DB_COLUMN_SECTION_ID)); + // Entry id for counting each entry + $dataSetInstance->setUniqueKey(self::DB_COLUMN_ENTRY_ID); + // Add "zero point" $this->queryInsertDataSet($dataSetInstance); @@ -193,7 +202,7 @@ class CitySectionsDatabaseWrapper extends BaseDatabaseWrapper implements CitySec $sections = array(); // Output message to ask for user's patience ... - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: Writing ' . (($radius + 1) * ($radius + 1) * $maxUp * ($maxDown + 1)) . ' sections for city ' . $cityId . ' ... (this may takes some time)'); + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: Writing ' . $totalSections . ' sections for city ' . $cityId . ' ... (this may takes some time)'); // Expand half of it to north/south (north=positive, south=negative) for ($north = 1; $north < round($radius / 2); $north++) { @@ -251,7 +260,7 @@ class CitySectionsDatabaseWrapper extends BaseDatabaseWrapper implements CitySec } // END - foreach // Thank you for waiting! :-) - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: ' . (($radius + 1) * ($radius + 1) * $maxUp * ($maxDown + 1)) . ' sections has been written for city ' . $cityId . '.'); + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: A total of ' . $totalSections . ' sections has been written for city id ' . $cityId . '.'); } } -- 2.39.5