// Constants for database table names
const DB_TABLE_CITY_SECTIONS = 'city_sections';
- // Constants for database column names
- const DB_COLUMN_SECTION_ID = 'city_section_id';
- const DB_COLUMN_CITY_ID = 'city_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';
+ const DB_COLUMN_LOT_ID = 'lot_id';
+
+ // Section and sub type (e.g. residential, hut)
+ const DB_COLUMN_SECTION_TYPE = 'section_type';
+ const DB_COLUMN_SECTION_SUB_TYPE = 'section_sub_type';
+
+ // X-Y-Z position
+ const DB_COLUMN_SECTION_POSITION_X = 'section_position_x';
+ const DB_COLUMN_SECTION_POSITION_Y = 'section_position_y';
+ const DB_COLUMN_SECTION_POSITION_Z = 'section_position_z';
+
+ // Connected neigbouring sections
+ const DB_COLUMN_SECTION_NEIGHBOUR_WEST_ID = 'section_neighbour_west_id';
+ const DB_COLUMN_SECTION_NEIGHBOUR_EAST_ID = 'section_neighbour_east_id';
+ const DB_COLUMN_SECTION_NEIGHBOUR_NORTH_ID = 'section_neighbour_north_id';
+ const DB_COLUMN_SECTION_NEIGHBOUR_SOUTH_ID = 'section_neighbour_south_id';
+ const DB_COLUMN_SECTION_NEIGHBOUR_UP_ID = 'section_neighbour_up_id';
+ const DB_COLUMN_SECTION_NEIGHBOUR_DOWN_ID = 'section_neighbour_down_id';
+
+ // Other settings:
+ // Reserved section (see documentation)
+ const DB_COLUMN_SECTION_RESERVED = 'section_reserved';
/**
* Protected constructor
// Return the instance
return $wrapperInstance;
}
+
+ /**
+ * Checks if the given city id is found in sections table
+ *
+ * @param $cityId City id to check
+ * @return $isFound Whether the city id is found
+ */
+ public function ifCityHasSections ($cityId) {
+ // Get search instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Search for 'city_id'
+ $searchInstance->addCriteria(self::DB_COLUMN_CITY_ID, $cityId);
+
+ /*
+ * Only one entry is enough to find, else this query could run very\
+ * long on large maps.
+ */
+ $searchInstance->setLimit(1);
+
+ // Execute it on database instance
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+ // Check if there is one entry
+ $isFound = ($resultInstance->next() == 1);
+
+ // Return result
+ return $isFound;
+ }
+
+ /**
+ * Expands the sections table with initial data for given city id
+ *
+ * @param $cityId City id to check
+ * @return void
+ */
+ public function doInitialCityExpansion ($cityId) {
+ // Make sure this city has no sections
+ assert(!$this->ifCityHasSections($cityId));
+
+ // @TODO Unfinished
+ $this->partialStub('cityId=' . $cityId . ' - UNFINISHED!');
+ }
}
// [EOF]