예제 #1
0
QJsonObject JsonSaver::saveCity(const City& city)
{
    QJsonObject res;
    res.insert("name", QString::fromStdString(city.name()));

    QJsonArray buildings;
    int i = 0;
    for(const auto& b : city.buildings())
        buildings.insert(i++, saveBuilding(b));
    res.insert("buildings", buildings);

    res.insert("size", saveSizeU(city.map().size()));

    QJsonArray roads;
    i = 0;
    for(std::size_t x = 0; x < city.map().width(); x++)
        for(std::size_t y = 0; y < city.map().height(); y++)
            if(city.map().squareType({x, y}) == Map::SquareType::Road)
            {
                roads.insert(i++, savePointU({x, y}));
            }

    res.insert("roads", roads);

    return res;
}
예제 #2
0
bool City::operator <(const City &_city)const{

	if(m_name < _city.name())
		return true;
	if (m_name>_city.name())
		return false;
	if (m_country_id < _city.country_id())
		return true;
	if (m_country_id>_city.country_id())
		return false;
	if (GeoGraphyUtils::less_than(longitude(), _city.longitude()))
		return true;
	if (GeoGraphyUtils::greater_than(longitude(), _city.longitude()))
		return false;
	if (GeoGraphyUtils::less_than(latitude(), _city.latitude()))
		return true;
	if (GeoGraphyUtils::greater_than(latitude(), _city.latitude()))
		return false;
	return false;

}