//
//  Immeuble.m
//  Agence
//
//  Created by Olivier Savard on 11-01-21.
//  Copyright 2011 OSInfo Informatique. All rights reserved.
//

#import "Immeuble.h"


@implementation Immeuble
@synthesize immeubleID;
@synthesize type;
@synthesize style;
@synthesize adresse;
@synthesize distance;
@synthesize prix;
@synthesize latitude;
@synthesize longitude;
@synthesize coordinate;

#pragma mark NSCoding
-(void)setCoordinate:(CLLocationCoordinate2D)newCoordinate {
	newCoordinate.latitude = self.latitude;
	newCoordinate.longitude = self.longitude;
	coordinate = newCoordinate;
}

-(NSString *)title {
	return self.style;
}

-(NSString *)subtitle {
	
	return ([NSString stringWithFormat:@"%.0f km" ,distance]);
	
	/*
	if(rue)
		[ret appendString:rue];
	if(rue && (ville || province || codePostal))
		[ret appendString:@", "];
	if (ville)
		[ret appendString:ville];
	if (ville && province)
		[ret appendString:@", "];
	if (province)
		[ret appendString:province];
	if (codePostal){
		[ret appendString:@", "];
		[ret appendString:codePostal];
	}*/
	
	
}



-(void)encodeWithCoder:(NSCoder *)aCoder {
	[aCoder encodeInt:immeubleID forKey:kFieldID];
	[aCoder encodeInt:type		forKey:kFieldType];
	[aCoder encodeObject:style		forKey:kFieldStyle];
	[aCoder encodeObject:adresse	forKey:kFieldAdresse];
	[aCoder encodeInt:distance	forKey:kFieldDistance];
	[aCoder encodeInt:prix		forKey:kFieldPrix];
}

-(id)initWithCoder:(NSCoder *)aDecoder {
	if (self = [super init]) {
		self.immeubleID = [aDecoder decodeIntForKey:kFieldID];
		self.type = [aDecoder decodeIntForKey:kFieldType];
		self.style = [aDecoder decodeObjectForKey:kFieldStyle];
		self.adresse = [aDecoder decodeObjectForKey:kFieldAdresse];
		self.distance = [aDecoder decodeIntForKey:kFieldDistance];
		self.prix = [aDecoder decodeIntForKey:kFieldPrix];
	}
	return self;
}
	

-(void)dealloc{
	style.release;
	adresse.release;
	[super dealloc];
}

@end
