Commits

Jonathan Blocksom committed 59fc336

Updates for height tracking

  • Participants
  • Parent commits c22fa13

Comments (0)

Files changed (2)

File pARk/ARView.m

 	[self sendSubviewToBack:captureView];
 	
 	// Initialize projection matrix	
-	createProjectionMatrix(projectionTransform, 60.0f*DEGREES_TO_RADIANS, self.bounds.size.width*1.0f / self.bounds.size.height, 0.25f, 1000.0f);
+	createProjectionMatrix(projectionTransform, 60.0f*DEGREES_TO_RADIANS, 
+                           self.bounds.size.width*1.0f / self.bounds.size.height, 
+                           0.25f, 1000.0f);
 }
 
 - (void)startCameraPreview
 	[locationManager release];
 	locationManager = [[CLLocationManager alloc] init];
 	locationManager.delegate = self;
-	locationManager.distanceFilter = 100.0;
+	locationManager.distanceFilter = 1.0;
 	[locationManager startUpdatingLocation];
 }
 
 	int i = 0;
 	
 	double myX, myY, myZ;
-	latLonToEcef(location.coordinate.latitude, location.coordinate.longitude, 0.0, &myX, &myY, &myZ);
+	latLonToEcef(location.coordinate.latitude, location.coordinate.longitude, location.altitude, &myX, &myY, &myZ);
 
 	// Array of NSData instances, each of which contains a struct with the distance to a POI and the
 	// POI's index into placesOfInterest
 	for (PlaceOfInterest *poi in [[self placesOfInterest] objectEnumerator]) {
 		double poiX, poiY, poiZ, e, n, u;
 		
-		latLonToEcef(poi.location.coordinate.latitude, poi.location.coordinate.longitude, 0.0, &poiX, &poiY, &poiZ);
+		latLonToEcef(poi.location.coordinate.latitude, poi.location.coordinate.longitude, poi.location.altitude, &poiX, &poiY, &poiZ);
 		ecefToEnu(location.coordinate.latitude, location.coordinate.longitude, myX, myY, myZ, poiX, poiY, poiZ, &e, &n, &u);
 		
 		placesOfInterestCoordinates[i][0] = (float)n;
 		placesOfInterestCoordinates[i][1]= -(float)e;
-		placesOfInterestCoordinates[i][2] = 0.0f;
+		placesOfInterestCoordinates[i][2] = (float)u;
 		placesOfInterestCoordinates[i][3] = 1.0f;
 		
 		// Add struct containing distance and index to orderedDistances
 		DistanceAndIndex distanceAndIndex;
-		distanceAndIndex.distance = sqrtf(n*n + e*e);
+		distanceAndIndex.distance = sqrtf(n*n + e*e + u*u);
 		distanceAndIndex.index = i;
 		[orderedDistances insertObject:[NSData dataWithBytes:&distanceAndIndex length:sizeof(distanceAndIndex)] atIndex:i++];
 	}
 {
 	[location release];
 	location = [newLocation retain];
+    NSLog(@"Location: %f %f %f", newLocation.coordinate.latitude, newLocation.coordinate.longitude, newLocation.altitude);
 	if (placesOfInterest != nil) {
 		[self updatePlacesOfInterestCoordinates];
 	}	

File pARk/pARkViewController.m

 	ARView *arView = (ARView *)self.view;
 	
 	// Create array of hard-coded places-of-interest, in this case some famous parks
-    const char *poiNames[] = {"Central Park NY",
+    const char *poiNames[] = {
+                              "Central Park NY",
                               "Golden Gate Park SF",
-                              "Balboa Park SD",
-                              "Hyde Park UK",
-                              "Mont Royal QC",
-                              "Retiro Park ES"};
+                              "Big Nerd Classroom",
+                              "Zipline Tower",
+    };
 	
     CLLocationCoordinate2D poiCoords[] = {{40.7711329, -73.9741874},
                                           {37.7690400, -122.4835193},
-                                          {32.7343822, -117.1441227},
-                                          {51.5068670, -0.1708030},
-                                          {45.5126399, -73.6802448},
-                                          {40.4152519, -3.6887466}};
+                                          {33.531694, -84.921774},
+                                          {33.532351, -84.922028},
+    };
+    
+    double poiAltitudes[] = { 0.0f, 0.0f, 260.0f, 240.0f };
                                           
     int numPois = sizeof(poiCoords) / sizeof(CLLocationCoordinate2D);	
 		
 		label.text = [NSString stringWithCString:poiNames[i] encoding:NSASCIIStringEncoding];		
 		CGSize size = [label.text sizeWithFont:label.font];
 		label.bounds = CGRectMake(0.0f, 0.0f, size.width, size.height);
-				
-		PlaceOfInterest *poi = [PlaceOfInterest placeOfInterestWithView:label at:[[[CLLocation alloc] initWithLatitude:poiCoords[i].latitude longitude:poiCoords[i].longitude] autorelease]];
+
+        CLLocationCoordinate2D loc = CLLocationCoordinate2DMake(poiCoords[i].latitude, poiCoords[i].longitude);
+//		PlaceOfInterest *poi = [PlaceOfInterest placeOfInterestWithView:label at:[[[CLLocation alloc] initWithLatitude:poiCoords[i].latitude 
+//                                                                                                             longitude:poiCoords[i].longitude] autorelease]];
+        CLLocation *locWithAltitude = [[[CLLocation alloc] initWithCoordinate:loc
+                                                                    altitude:poiAltitudes[i]
+                                                          horizontalAccuracy:0 
+                                                            verticalAccuracy:0
+                                                                   timestamp:[[NSDate alloc] init]] autorelease];
+		PlaceOfInterest *poi = 
+            [PlaceOfInterest placeOfInterestWithView:label 
+                                                  at:locWithAltitude];
+
 		[placesOfInterest insertObject:poi atIndex:i];
-	}	
+	}
 	[arView setPlacesOfInterest:placesOfInterest];	
 }