/*!
 * Two house numbers are considered to be equal if
 * * country, city, postcode, suburb, street, housenumber, name, and shop equal
 * * or housenumber, street, name, and shop equal, and country, city, and postcode do not differ (ignoring empty values),
 *    and lat/lon difference is less than DISTANCE_THRESHOLD
 */
bool HouseNumber::isSameAddress(HouseNumber const& rhs) const {
	if(getName().toLower()!=rhs.getName().toLower() ||
	   getShop().toLower()!=rhs.getShop().toLower() ||
	   getNumber().toLower()!=rhs.getNumber().toLower() ||
	   getStreet().toLower()!=rhs.getStreet().toLower() ||
	   getNumber()=="" || getStreet()=="") {
		return false;
	}
	
	if(getPostcode().toLower()==rhs.getPostcode().toLower() && getPostcode()!="" &&
	   getCity().toLower()==rhs.getCity().toLower() && getCity()!="" &&
	   getSuburb().toLower()==rhs.getSuburb().toLower() &&
	   getCountry().toLower()==rhs.getCountry().toLower() && getCountry()!="") {
		return true;
	}
	
	// consider two house numbers with similar address information and little distance to each other to be equal
	if(myAbs(getLat()-rhs.getLat())>DISTANCE_THRESHOLD ||
	   myAbs(getLon()-rhs.getLon())>DISTANCE_THRESHOLD)
		return false;
	if(getPostcode()!="" && rhs.getPostcode()!="" && getPostcode().toLower()!=rhs.getPostcode().toLower())
		return false;
	if(getCity()!="" && rhs.getCity()!="" && getCity().toLower()!=rhs.getCity().toLower())
		return false;
	if(getSuburb()!="" && rhs.getSuburb()!="" && getSuburb()!=rhs.getSuburb())
		return false;
	if(getCountry()!="" && rhs.getCountry()!="" && getCountry().toLower()!=rhs.getCountry().toLower())
		return false;
	return true;
}
/*!
 * compares QString("%1%2%3%4")
 *  .arg(number_).arg(street_).arg(id_).arg(isWay_).toLower()
 * thus, the house numbers are sorted by address, id, and type (used for treeIncomplete)
 */
bool HouseNumber::isLessThanNode(HouseNumber const& rhs) const {
	if(getNumber().toLower()!=rhs.getNumber().toLower())
		return getNumber().toLower()<rhs.getNumber().toLower();
	if(getStreet().toLower()!=rhs.getStreet().toLower())
		return getStreet().toLower()<rhs.getStreet().toLower();
	if(getId()!=rhs.getId())
		return getId()<rhs.getId();
	return getIsWay()<rhs.getIsWay();
}
Example #3
0
QString Address::toCsv() const
{
    QString res;
    if(!isEmpty())
    {
        res += "\""+ QString::number(getStreetId()) + "\";\"";
        res += QString::number(getBuildId()) + "\";\"";
        res += getRawAddress().join(';') + "\";\"";
        res += getTypeOfFSubjInString() + "\";\"";
        res += getFsubj() + "\";\"";
        res += getDistrict() + "\";\"";
        res += getTypeOfCity1() + "\";\"";
        res += getCity1() + "\";\"";
        res += getTypeOfCity2() + "\";\"";
        res += getCity2() + "\";\"";
        res += getTypeOfStreet() + "\";\"";
        res += getStreet() + "\";\"";
        res += getAdditional() + "\";\"";
        res += getBuild() + "\";\"";
        res += getKorp() + "\";\"";
        res += getLitera() + "\";\"";
        res += QString(isCorrect()?"1":"0") + "\"";
    }
    else
    {
        res += "Is empty\n";
    }
    return res;
}
Example #4
0
QString Address::toInsertSqlQuery() const
{
    QString strF =
          "INSERT INTO  %1 (BUILD_ID, BUILD, STREET_ID, STREET, "
          "TYPE_OF_STREET, KORP, LITERA, CORRECT, CITY1, "
          "TYPE_OF_CITY1, TYPE_OF_CITY2, CITY2, FSUBJ, DISTRICT, "
          "ADDITIONAL, RAW, TYPE_OF_FSUBJ) "
          "VALUES('%2', '%3', '%4', '%5', '%6', "
          "'%7', '%8', '%9', '%10', '%11', '%12', '%13', "
          "'%14', '%15', '%16', '%17', '%18'); ";

    QString str =
            strF
            .arg(TableName)
            .arg(QString::number(getBuildId()))
            .arg(getBuild())
            .arg(QString::number(getStreetId()))
            .arg(getStreet())
            .arg(getTypeOfStreet())
            .arg(getKorp())
            .arg(getLitera())
            .arg(QString(isCorrect()?"1":"0"))
            .arg(getCity1())
            .arg(getTypeOfCity1())
            .arg(getTypeOfCity2())
            .arg(getCity2())
            .arg(getFsubj())
            .arg(getDistrict())
            .arg(getAdditional())
            .arg(getRawAddress().join("\";\"").insert(0,'\"').append('\"'))
            .arg(getTypeOfFSubjInString());
    return str;
}
/*!
 * compares QString("%1%2%3%4%5%6%7")
 *  .arg(number_).arg(street_).arg(postcode_).arg(city_).arg(suburb_).arg(country_).arg(name_).arg(shop_).toLower()
 * thus, the house numbers are sorted by address (used for treeHousenumbers)
 * @note the address information must be complete
 */
bool HouseNumber::isLessThanAddress(HouseNumber const& rhs) const {
	if(getNumber().toLower()!=rhs.getNumber().toLower())
		return getNumber().toLower()<rhs.getNumber().toLower();
	if(getStreet().toLower()!=rhs.getStreet().toLower())
		return getStreet().toLower()<rhs.getStreet().toLower();
	if(getPostcode().toLower()!=rhs.getPostcode().toLower())
		return getPostcode().toLower()<rhs.getPostcode().toLower();
	if(getCity().toLower()!=rhs.getCity().toLower())
		return getCity().toLower()<rhs.getCity().toLower();
	if(getSuburb().toLower()!=rhs.getSuburb().toLower())
		return getSuburb().toLower()<rhs.getSuburb().toLower();
	if(getCountry().toLower()!=rhs.getCountry().toLower())
		return getCountry().toLower()<rhs.getCountry().toLower();
	if(getName().toLower()!=rhs.getName().toLower())
		return getName().toLower()<rhs.getName().toLower();
	return getShop().toLower()<rhs.getShop().toLower();
}
Example #6
0
void modifyClient(Client *pClients) {
    unsigned long id;
    int pos, modifyOpt, addressOpt;
    bool valId = false;
    
    do {
        printf(MSG_ID);
        scanf("%lu", &id);
        if(id > ID_MINIMUM && id < ID_MAXIMUM){
            valId = true;
        } else {
            printf(MSG_ID_ERROR, NEWLINE);
        }
    } while(valId == false);
    pos = verifyClientToModify(pClients, id);
    if(pos != EOF) {
        ModifyMenu();
        limparBufferEntradaDados();
        scanf("%d", &modifyOpt);
        if(modifyOpt == 1){
            getName(pClients, pos);
        } else if(modifyOpt == 2) {
            AddressModifyMenu();
            scanf("%d", &addressOpt);
            limparBufferEntradaDados();
            if(addressOpt == 1) {
                getStreet(pClients, pos);
            } else if(addressOpt == 2) {
                getNumber(pClients, pos);
            } else if(addressOpt == 3) {
                getPostalCode(pClients, pos);
            } else if(addressOpt == 4) {
                getCity(pClients, pos);
            } else {
                printf(MSG_MENU_ERROR, NEWLINE);
            }
        } else if(modifyOpt == 3) {
            getPhone(pClients, pos);
        } else if(modifyOpt == 4) {
            getBirthday(pClients, pos);
        } else if(modifyOpt == 5) {
            getSignupDate(pClients, pos);
        } else {
            printf(MSG_MENU_ERROR, NEWLINE);
        }
        saveClientFile(pClients);
    } else {
        printf(MSG_ID_DOESNT_EXIST_ERROR, NEWLINE);
    }
}
Example #7
0
bool Address::isEmpty() const
{
    return (getRawAddress().isEmpty() &&
            getStreet().isEmpty() &&
            getBuild().isEmpty() &&
            getKorp().isEmpty() &&
            getAdditional().isEmpty() &&
            getCity1().isEmpty() &&
            getDistrict().isEmpty() &&
            getLitera().isEmpty() &&
            getTypeOfCity1().isEmpty() &&
            getTypeOfCity2().isEmpty() &&
            getTypeOfStreet().isEmpty() &&
            getFsubj().isEmpty());
}
Example #8
0
void addClient(Client *pClients) {
    int pos;
    
    pos = verifyIfPosEmpty(pClients);
    if(pos == EOF) {
        printf(MSG_CLIENTS_FULL_ERROR);
    } else {
        getId(pClients, pos);
        getName(pClients, pos);
        getStreet(pClients, pos);
        getNumber(pClients, pos);
        getPostalCode(pClients, pos);
        getCity(pClients, pos);
        getPhone(pClients, pos);
        getBirthday(pClients, pos);
        getSignupDate(pClients, pos);
        // TODO: SORT CLIENTS IN ORDER
        printf(MSG_CLIENT_ADDED);
    }
}
Example #9
0
QString Address::toDebug() const
{
    QString res;
    res +="*** Address: ***\n";
    res += "StreetID: " + QString::number(getStreetId()) + "\n";
    res += "BuildID: " + QString::number(getBuildId()) + "\n";
    res += "Type of Federal Subj: " + getTypeOfFSubjInString() + "\n";
    res += "Federal subj: " + getFsubj() + "\n";
    res += "District: " + getDistrict() + "\n";
    res += "Type of City1: " + getTypeOfCity1() + "\n";
    res += "City1: " + getCity1() + "\n";
    res += "Type of City2: " + getTypeOfCity2() + "\n";
    res += "City2: " + getCity2() + "\n";
    res += "Type of Street: " + getTypeOfStreet() + "\n";
    res += "Street: " + getStreet() + "\n";
    res += "Additional: " + getAdditional() + "\n";
    res += "Build: " + getBuild() + "\n";
    res += "Korpus: " + getKorp() + "\n";
    res += "Litera: " + getLitera() + "\n";
    res += "Correct: " + QString(isCorrect()?"1":"0") + "\n";
    return res;
}