<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -26,7 +26,6 @@
 #import &quot;SDTideFactory.h&quot;
 #import &quot;SDTide.h&quot;
 #import &quot;SDTideEvent.h&quot;
-#import &quot;SDStationOffset.h&quot;
 #import &quot;RootViewController.h&quot;
 
 @interface MainViewController (PrivateMethods)
@@ -85,13 +84,7 @@
 	[date setText: [formatter stringFromDate:[sdTide startTime]]];
 	[formatter release];
 	
-	SDStationOffset *offset = [[sdTide tideStation] stationOffset];
-	if (offset != nil) {
-		[locationLabel setText:[offset shortRefStationName]];	
-		[correctionLabel setText:[NSString stringWithFormat:@&quot;Events corrected for %@&quot;, [sdTide shortLocationName]]];
-	} else {
-		[locationLabel setText:[sdTide shortLocationName]];
-	}
+	[locationLabel setText:[sdTide shortLocationName]];
 	
 	int minutesSinceMidnight = [self currentTimeInMinutes:sdTide];
 	if (minutesSinceMidnight &gt; 0) {
@@ -99,6 +92,12 @@
 	} else {
 		[presentHeight setText:@&quot;&quot;];
 	}
+	
+	if ([[sdTide events] count] &gt; 4) {
+		// there shouldn't be more than 4 tide events in a day -- 2 high, 2 low
+		[correctionLabel setText:@&quot;Too many events predicted&quot;];
+		return nil;
+	}
 	 
 	int index = 0;
 	for (SDTideEvent *event in [sdTide events]) {</diff>
      <filename>Classes/Controllers/MainViewController.m</filename>
    </modified>
    <modified>
      <diff>@@ -50,6 +50,7 @@
 - (NSData *)applicationDataFromFile:(NSString *)fileName;
 - (void)replaceSubview:(UIView *)oldView withSubview:(UIView *)newView transition:(NSString *)transition direction:(NSString *)direction duration:(NSTimeInterval)duration;
 -(void)refreshLocationTable;
+-(void)setDefaultLocation;
 @end
 
 static NSUInteger kNumberOfPages = 5;
@@ -76,19 +77,31 @@ static NSUInteger kNumberOfPages = 5;
 
 - (void)viewDidLoad {
 	NSString *lastLocation = [self lastLocation];
+	
 	if (lastLocation) {
 		[self setLocation:lastLocation];
 		self.tideStation = [SDTideFactory tideStationWithName:lastLocation];
+		if (self.tideStation.name == nil) {
+			NSString *message = [NSString stringWithFormat:@&quot;%@ is no longer a supported location. Please choose another location.&quot;,lastLocation];
+			UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@&quot;Sorry&quot; message:message delegate:nil cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil];
+			[alert show];
+			[alert release];
+			[self setDefaultLocation];
+		}
 	} else {
-		NSString *defaultLocation = @&quot;La Jolla, Scripps Pier, California&quot;;
-		[self setLocation:defaultLocation];
-		self.tideStation = [SDTideFactory tideStationWithName:defaultLocation];
+		[self setDefaultLocation];
 	}
 	self.currentCalendar = [NSCalendar currentCalendar];
 	
 	[self createMainViews];
 }
 
+- (void)setDefaultLocation {
+	NSString *defaultLocation = @&quot;La Jolla, Scripps Pier, California&quot;;
+	[self setLocation:defaultLocation];
+	self.tideStation = [SDTideFactory tideStationWithName:defaultLocation];
+}
+
 - (void)createMainViews {
 	NSMutableArray *controllers = [[NSMutableArray alloc] init];
     for (unsigned i = 0; i &lt; kNumberOfPages; i++) {
@@ -347,12 +360,20 @@ static NSUInteger kNumberOfPages = 5;
 	[nameDescriptor release];
 	
 	[self stopWaitIndicator];
+	
 	if (flipsideViewController) {
 		[self refreshLocationTable];
 	} else {
 		[self loadFlipsideViewController];
 	}
-	[self toggleView];
+	
+	if ([locations count] &gt; 0) {
+		[self toggleView];
+	} else {
+		UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@&quot;Sorry&quot; message:@&quot;There are no tide stations in your area. You may select a location manually by pressing the globe icon.&quot; delegate:nil cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil];
+		[alert show];
+		[alert release];
+	}
 }
 
 -(IBAction)chooseFromAllTideStations {
@@ -762,6 +783,15 @@ static NSUInteger kNumberOfPages = 5;
 		[manager stopUpdatingLocation];
 	}
 	
+#if TARGET_IPHONE_SIMULATOR
+	[newLocation release];
+	//newLocation = [[CLLocation alloc] initWithLatitude:48.4500 longitude:-123.3000]; // victoria, bc
+	//newLocation = [[CLLocation alloc] initWithLatitude:-33.867707 longitude: 151.225777]; sydney, aus
+	//newLocation = [[CLLocation alloc] initWithLatitude:-36.846581 longitude: 174.77809]; // aukland, nz
+	//newLocation = [[CLLocation alloc] initWithLatitude:35.570922 longitude:140.331673]; // chiba, jp
+	newLocation = [[CLLocation alloc] initWithLatitude:41.855242 longitude:-87.618713]; // chicago, il
+#endif
+	
     if (signbit(newLocation.horizontalAccuracy)) {
         // Negative accuracy means an invalid or unavailable measurement
 		UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@&quot;Sorry&quot; message:@&quot;Unable to determine your location at this time.&quot; delegate:nil cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil];</diff>
      <filename>Classes/Controllers/RootViewController.m</filename>
    </modified>
    <modified>
      <diff>@@ -24,12 +24,10 @@
 #import &quot;SDTide.h&quot;
 #import &quot;SDTideInterval.h&quot;
 #import &quot;SDTideEvent.h&quot;
-#import &quot;SDStationOffset.h&quot;
 
 @interface SDTide(PrivateMethods)
 -(int)findPreviousInterval:(int) minutesFromMidnight;
 -(int)findNearestInterval:(int) minutesFromMidnight;
--(void)applyEventCorrections;
 @end
 
 @implementation SDTide
@@ -48,38 +46,10 @@
     intervals = [tideIntervals retain];
     events = [tideEvents retain];
 	self.tideStation = station;
-	
-	if (tideStation.stationOffset != nil) {
-		[self applyEventCorrections];
-	}
     
     return self;
 }
 
--(void)applyEventCorrections
-{
-	SDStationOffset *offset = [[self tideStation] stationOffset];
-	for (SDTideEvent *event in events) {
-		NSDate *time = [event eventTime];
-		switch ([event eventType]) {
-			case SDTideStateHightTide: 
-				// add high minutes to event time
-				[event setEventTime:[time addTimeInterval: [offset highTideMinutesOffset] * 60]];
-				// multiply high by correction factor
-				float correctedHi = [event eventHeight] * [offset highTideHeightCorrection];
-				[event setEventHeight:correctedHi];
-				break;
-			case SDTideStateLowTide: 
-				// add low min to event time
-				[event setEventTime: [time addTimeInterval: [offset lowTideMinutesOffset] * 60]];
-				// multiply low by correction factor
-				float correctedLo = [event eventHeight] * [offset lowTideHeightCorrection];
-				[event setEventHeight:correctedLo];
-				break;
-		}
-	}
-}
-
 -(NSString*)shortLocationName {
 	NSString *name = [tideStation name];
 	NSArray *parts = [name componentsSeparatedByString:@&quot;,&quot;];</diff>
      <filename>Classes/Model/SDTide.m</filename>
    </modified>
    <modified>
      <diff>@@ -24,7 +24,6 @@
 #import &quot;SDTideFactory.h&quot;
 #include &quot;everythi.h&quot;
 #import &quot;SDTideStation.h&quot;
-#import &quot;SDStationOffset.h&quot;
 
 @interface SDTideFactory (PrivateMethods)
 +(void)mapTideStation:(SDTideStation*)station fromResultSet:(FMResultSet*)rs;
@@ -40,12 +39,7 @@
     char cEnd[30];
     time_t stoptime = 0;
     
-	NSString *stationName = nil;
-	if (station.stationOffset) {
-		stationName = station.stationOffset.referenceStationName;
-	} else {
-		stationName = station.name;
-	}
+	NSString *stationName = station.name;
 
     //strcpy(location,[stationName cStringUsingEncoding:NSISOLatin2StringEncoding]);
 	strcpy(location, [stationName cStringUsingEncoding:NSISOLatin1StringEncoding]);
@@ -214,7 +208,7 @@
         NSLog(@&quot;Could not open db.&quot;);
     }
 	
-	FMResultSet *rs = [db executeQuery:@&quot;select s.name, s.unit, s.lat, s.long, s.disp_name, s.disp_state, o.high_minutes, o.low_minutes, o.high_const, o.low_const, rs.name as ref_station_name from station s left outer join station_offset o on s.offset_id = o.offset_id left outer join station rs on o.ref_station_id = rs.id&quot;];
+	FMResultSet *rs = [db executeQuery:@&quot;select s.name, s.unit, s.lat, s.long, s.disp_name, s.disp_state from station s&quot;];
 
 	if ([db hadError]) {
 		NSLog(@&quot;Err %d: %@&quot;, [db lastErrorCode], [db lastErrorMessage]);
@@ -247,7 +241,7 @@
         NSLog(@&quot;Could not open db.&quot;);
     }
 	
-	FMResultSet *rs = [db executeQuery:@&quot;select s.name, s.unit, s.lat, s.long, s.disp_name, s.disp_state, o.high_minutes, o.low_minutes, o.high_const, o.low_const, rs.name as ref_station_name from station s left outer join station_offset o on s.offset_id = o.offset_id left outer join station rs on o.ref_station_id = rs.id where s.lat between ? and ? and s.long between ? and ?&quot;,
+	FMResultSet *rs = [db executeQuery:@&quot;select s.name, s.unit, s.lat, s.long, s.disp_name, s.disp_state from station s where s.lat between ? and ? and s.long between ? and ?&quot;,
 		 minLatitude, 
 		 maxLatitude, 
 		 minLongitude,
@@ -276,7 +270,7 @@
         NSLog(@&quot;Could not open db.&quot;);
     }
 	
-	FMResultSet *rs = [db executeQuery:@&quot;select s.name, s.unit, s.lat, s.long, s.disp_name, s.disp_state, o.high_minutes, o.low_minutes, o.high_const, o.low_const, rs.name as ref_station_name from station s left outer join station_offset o on s.offset_id = o.offset_id left outer join station rs on o.ref_station_id = rs.id where s.name =  ?&quot;, name];
+	FMResultSet *rs = [db executeQuery:@&quot;select s.name, s.unit, s.lat, s.long, s.disp_name, s.disp_state from station s where s.name =  ?&quot;, name];
 	
 	[rs next];
 	
@@ -297,19 +291,6 @@
 	station.displayName = [rs stringForColumn:@&quot;disp_name&quot;];
 	station.displayState = [rs stringForColumn:@&quot;disp_state&quot;];
 	station.units = [rs stringForColumn:@&quot;unit&quot;];
-	
-	NSString* refStationName = [rs stringForColumn:@&quot;ref_station_name&quot;];
-
-	if (refStationName != nil) {
-		int hiMinutes = [rs intForColumn:@&quot;high_minutes&quot;];
-		int loMinutes = [rs intForColumn:@&quot;low_minutes&quot;];
-		float highCorrection = [rs doubleForColumn:@&quot;high_const&quot;];
-		float lowCorrection = [rs doubleForColumn:@&quot;low_const&quot;];
-		
-		SDStationOffset *offset = [[SDStationOffset alloc] initWithStation:refStationName deltaHighMinutes:hiMinutes deltaLow:loMinutes highCorrection:highCorrection lowCorrection:lowCorrection];
-		station.stationOffset = offset;
-		[offset release];
-	}
 }
 
 @end</diff>
      <filename>Classes/Model/SDTideFactory.m</filename>
    </modified>
    <modified>
      <diff>@@ -21,8 +21,6 @@
    along with ShralpTide.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 */
 
-@class SDStationOffset;
-
 @interface SDTideStation : NSObject {
 	NSString *name;
 	NSNumber *latitude;
@@ -31,10 +29,8 @@
 	NSString *units;
 	NSString *displayName;
 	NSString *displayState;
-	SDStationOffset *stationOffset;
 }
 
 @property (retain, readwrite) NSString *name, *units, *displayName, *displayState;
 @property (retain, readwrite) NSNumber *distance, *latitude, *longitude;
-@property (retain, readwrite) SDStationOffset *stationOffset;
 @end</diff>
      <filename>Classes/Model/SDTideStation.h</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,6 @@
 @synthesize longitude;
 @synthesize displayName;
 @synthesize displayState;
-@synthesize stationOffset;
 
 -(void)dealloc {
 	[name release];
@@ -42,7 +41,6 @@
 	[longitude release];
 	[displayName release];
 	[displayState release];
-	[stationOffset release];
 	[super dealloc];
 }
 </diff>
      <filename>Classes/Model/SDTideStation.m</filename>
    </modified>
    <modified>
      <diff>@@ -21,7 +21,7 @@
 	&lt;key&gt;CFBundleSignature&lt;/key&gt;
 	&lt;string&gt;????&lt;/string&gt;
 	&lt;key&gt;CFBundleVersion&lt;/key&gt;
-	&lt;string&gt;1.1.0&lt;/string&gt;
+	&lt;string&gt;1.1.1&lt;/string&gt;
 	&lt;key&gt;LSRequiresIPhoneOS&lt;/key&gt;
 	&lt;true/&gt;
 	&lt;key&gt;NSMainNibFile&lt;/key&gt;</diff>
      <filename>Info.plist</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>Resources/tidestations.sqlite</filename>
    </modified>
    <modified>
      <diff>@@ -37,7 +37,6 @@
 		DC8ED80C0F0D8C3B009EAF2F /* Decreasing.png in Resources */ = {isa = PBXBuildFile; fileRef = DC8ED8080F0D8C3B009EAF2F /* Decreasing.png */; };
 		DC8ED80D0F0D8C3B009EAF2F /* Increasing.png in Resources */ = {isa = PBXBuildFile; fileRef = DC8ED8090F0D8C3B009EAF2F /* Increasing.png */; };
 		DC8EDBB20F107814009EAF2F /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = DC8EDBB10F107814009EAF2F /* Default.png */; };
-		DC9B14A90F524BED006B89FD /* SDStationOffset.m in Sources */ = {isa = PBXBuildFile; fileRef = DC9B14A80F524BED006B89FD /* SDStationOffset.m */; };
 		DCA935600EDF722B0050113B /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCA9355F0EDF722B0050113B /* CoreLocation.framework */; };
 		DCA9379B0EE1B3910050113B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCA9379A0EE1B3910050113B /* CoreGraphics.framework */; };
 		DCC7EB6A0F20622800E6904E /* CONTRIBUTORS.txt in Resources */ = {isa = PBXBuildFile; fileRef = DCC7EB670F20622800E6904E /* CONTRIBUTORS.txt */; };
@@ -107,8 +106,6 @@
 		DC8ED8080F0D8C3B009EAF2F /* Decreasing.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Decreasing.png; path = Resources/Decreasing.png; sourceTree = &quot;&lt;group&gt;&quot;; };
 		DC8ED8090F0D8C3B009EAF2F /* Increasing.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Increasing.png; path = Resources/Increasing.png; sourceTree = &quot;&lt;group&gt;&quot;; };
 		DC8EDBB10F107814009EAF2F /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = Resources/Default.png; sourceTree = &quot;&lt;group&gt;&quot;; };
-		DC9B14A70F524BED006B89FD /* SDStationOffset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDStationOffset.h; path = Classes/Model/SDStationOffset.h; sourceTree = &quot;&lt;group&gt;&quot;; };
-		DC9B14A80F524BED006B89FD /* SDStationOffset.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDStationOffset.m; path = Classes/Model/SDStationOffset.m; sourceTree = &quot;&lt;group&gt;&quot;; };
 		DCA9355F0EDF722B0050113B /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
 		DCA9379A0EE1B3910050113B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
 		DCC7EB670F20622800E6904E /* CONTRIBUTORS.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CONTRIBUTORS.txt; path = FMDB/CONTRIBUTORS.txt; sourceTree = &quot;&lt;group&gt;&quot;; };
@@ -320,8 +317,6 @@
 				DCFD59460E39A93D00B7B1B8 /* SDTideEvent.m */,
 				DC328D100EE30652004F45C4 /* SDTideStation.h */,
 				DC328D110EE30652004F45C4 /* SDTideStation.m */,
-				DC9B14A70F524BED006B89FD /* SDStationOffset.h */,
-				DC9B14A80F524BED006B89FD /* SDStationOffset.m */,
 			);
 			name = objctidelib;
 			sourceTree = &quot;&lt;group&gt;&quot;;
@@ -427,7 +422,6 @@
 				DC328D120EE30652004F45C4 /* SDTideStation.m in Sources */,
 				DCE897DB0EEE3CAE00BF2357 /* CursorView.m in Sources */,
 				DCCAD90E0F1DBC4600141002 /* FMResultSet.m in Sources */,
-				DC9B14A90F524BED006B89FD /* SDStationOffset.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -438,7 +432,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
-				&quot;CODE_SIGN_IDENTITY[sdk=iphoneos*]&quot; = &quot;iPhone Developer: Michael Parlee&quot;;
+				&quot;CODE_SIGN_IDENTITY[sdk=iphoneos*]&quot; = &quot;iPhone Distribution: Michael Parlee&quot;;
 				COPY_PHASE_STRIP = NO;
 				FRAMEWORK_SEARCH_PATHS = (
 					&quot;$(inherited)&quot;,
@@ -459,7 +453,7 @@
 				);
 				OTHER_LDFLAGS = &quot;-lsqlite3&quot;;
 				PRODUCT_NAME = ShralpTide;
-				&quot;PROVISIONING_PROFILE[sdk=iphoneos*]&quot; = &quot;D465FCAA-FFB5-44A7-A0B4-A979106139DB&quot;;
+				&quot;PROVISIONING_PROFILE[sdk=iphoneos*]&quot; = &quot;093283FB-ACFE-4306-A72E-10A3B958AF82&quot;;
 				SDKROOT = iphoneos2.2;
 				STRIP_INSTALLED_PRODUCT = NO;
 				WARNING_CFLAGS = &quot;-Wl,-M&quot;;</diff>
      <filename>ShralpTide.xcodeproj/project.pbxproj</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>Classes/Model/SDStationOffset.h</filename>
    </removed>
    <removed>
      <filename>Classes/Model/SDStationOffset.m</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>839fa261c785c869fa18631f7c4bb8c10c313513</id>
    </parent>
  </parents>
  <author>
    <name>Michael Parlee</name>
    <email>shralpmeister@me.com</email>
  </author>
  <url>http://github.com/shralpmeister/shralptide/commit/e21d33b8c209080ef628ec09d9cda41ee25f7fc4</url>
  <id>e21d33b8c209080ef628ec09d9cda41ee25f7fc4</id>
  <committed-date>2009-03-28T20:33:01-07:00</committed-date>
  <authored-date>2009-03-28T20:33:01-07:00</authored-date>
  <message>Removes currents and station offsets, handles last saved location not found and shows warning if more than four tide events returned instead of crashing. </message>
  <tree>c4207418ee69a07414a457f302b1f740d6635a3e</tree>
  <committer>
    <name>Michael Parlee</name>
    <email>shralpmeister@me.com</email>
  </committer>
</commit>
