Skip to content

Commit

Permalink
Map points are back, other bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepwinter committed Mar 12, 2012
1 parent e6fbbd4 commit 1227da8
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 17 deletions.
1 change: 0 additions & 1 deletion Wildflowers of Detroit Iphone/AppDelegate.m
Expand Up @@ -65,7 +65,6 @@ - (void) initializeAppDelegateAndLaunch {

[self.window makeKeyAndVisible];

[RHLocation instance];

[self performSelectorInBackground:@selector(initializeInBackground) withObject:nil];

Expand Down
2 changes: 2 additions & 0 deletions Wildflowers of Detroit Iphone/CameraViewController.m
Expand Up @@ -77,6 +77,8 @@ - (void)viewDidLoad

- (void)viewDidAppear:(BOOL)animated {

[RHLocation instance];

if([RHSettings useCamera]) {
[self showImagePickerView];
}
Expand Down
43 changes: 31 additions & 12 deletions Wildflowers of Detroit Iphone/MapCouchbaseDataModel.m
Expand Up @@ -70,6 +70,25 @@ - (id) init {
// NSLog(@"%@", @"Calling did start block");
// didStartBlock();

//Compile views
CouchDesignDocument* design = [database designDocumentWithName: @"design"];
NSAssert(design, @"Couldn't find design document");
design.language = kCouchLanguageJavaScript;
[design defineViewNamed: @"detailDocuments"
map: @"function(doc) { emit([doc._id, doc.created_at], [doc._id, doc.reporter, doc.comment, doc.medium, doc.created_at] );}"];

[design defineViewNamed: @"deviceUserGalleryDocuments"
map: @"function(doc) { emit(doc.deviceuser_identifier,{'id':doc._id, 'thumb':doc.thumb, 'medium':doc.medium, 'latitude':doc.latitude, 'longitude':doc.longitude, 'reporter':doc.reporter, 'comment':doc.comment, 'created_at':doc.created_at} );}"];

design.language = kCouchLanguageJavaScript;
[design defineViewNamed: @"galleryDocuments"
map: @"function(doc) { emit([doc.created_at],{'id':doc._id, 'thumb':doc.thumb, 'medium':doc.medium, 'latitude':doc.latitude, 'longitude':doc.longitude, 'reporter':doc.reporter, 'comment':doc.comment, 'created_at':doc.created_at, 'deviceuser_identifier':doc.deviceuser_identifier } );}"];

design.language = kCouchLanguageJavaScript;
[design defineViewNamed: @"detailDocuments"
map: @"function(doc) { emit([doc._id, doc.created_at], [doc._id, doc.reporter, doc.comment, doc.medium, doc.created_at] );}"];
[design saveChanges];

//TODO: Reorganize to use a block
[(AppDelegate *) [[UIApplication sharedApplication] delegate] doneStartingUp];

Expand Down Expand Up @@ -104,6 +123,7 @@ -(void) test {
[op start];
}

/*
- (void) initializeQuery{
NSInteger count = [self.database getDocumentCount];
Expand All @@ -130,10 +150,11 @@ - (void) initializeQuery{
// Create a query sorted by descending date, i.e. newest items first:
// self.query = [[design queryViewNamed: @"all"] asLiveQuery];
//CouchLiveQuery* query = [[design queryViewNamed: @"byDate"] //asLiveQuery];
self.query = [design queryViewNamed: @"all"]; //asLiveQuery];
/* self.query = [design queryViewNamed: @"all"]; //asLiveQuery];
query.descending = YES;
[query start];
}
*/


+ (NSData *) getDocumentThumbnailData: (NSString *) key {
Expand Down Expand Up @@ -178,6 +199,10 @@ - (NSArray *) runQuery: (CouchQuery *) query {
return data;

}
/*
TODO: !!!!!!!!! This code WILL NOT SCALE. Saving of full vs. thumb images needs to be implemented
according to our plan. This is simply to get something running..
*/

+ (NSArray *) readAttachments: (NSArray *) r {

Expand Down Expand Up @@ -209,13 +234,12 @@ + (NSArray *) getUserGalleryDocumentsWithStartKey: (NSString *) startKey
CouchDatabase * database = [self.instance database];
CouchDesignDocument* design = [database designDocumentWithName: @"design"];
NSAssert(design, @"Couldn't find design document");
design.language = kCouchLanguageJavaScript;
[design defineViewNamed: @"deviceUserGalleryDocuments"
// design.language = kCouchLanguageJavaScript;
/* [design defineViewNamed: @"deviceUserGalleryDocuments"
map: @"function(doc) { emit([doc.deviceuser_identifier, Date.parse(doc.created_at)],{'id':doc._id, 'thumb':doc.thumb, 'medium':doc.medium, 'latitude':doc.latitude, 'longitude':doc.longitude, 'reporter':doc.reporter, 'comment':doc.comment, 'created_at':doc.created_at} );}"];

*/
NSLog(@"Running query without sorting");
[design defineViewNamed: @"deviceUserGalleryDocuments"
map: @"function(doc) { emit(doc.deviceuser_identifier,{'id':doc._id, 'thumb':doc.thumb, 'medium':doc.medium, 'latitude':doc.latitude, 'longitude':doc.longitude, 'reporter':doc.reporter, 'comment':doc.comment, 'created_at':doc.created_at} );}"];



CouchQuery * query = [design queryViewNamed: @"deviceUserGalleryDocuments"]; //asLiveQuery];
Expand Down Expand Up @@ -256,9 +280,6 @@ + (NSArray *) getGalleryDocumentsWithStartKey: (NSString *) startKey andLimit: (
CouchDatabase * database = [self.instance database];
CouchDesignDocument* design = [database designDocumentWithName: @"design"];
NSAssert(design, @"Couldn't find design document");
design.language = kCouchLanguageJavaScript;
[design defineViewNamed: @"galleryDocuments"
map: @"function(doc) { emit([doc.created_at],{'id':doc._id, 'thumb':doc.thumb, 'medium':doc.medium, 'latitude':doc.latitude, 'longitude':doc.longitude, 'reporter':doc.reporter, 'comment':doc.comment, 'created_at':doc.created_at, 'deviceuser_identifier':doc.deviceuser_identifier } );}"];

// NSArray * r = [ (MapCouchbaseDataModel * ) self.instance getView:@"galleryDocuments"];

Expand All @@ -274,9 +295,7 @@ + (NSArray *) getDetailDocumentsWithStartKey: (NSString *) startKey andLimit: (N

CouchDesignDocument* design = [database designDocumentWithName: @"design"];
NSAssert(design, @"Couldn't find design document");
design.language = kCouchLanguageJavaScript;
[design defineViewNamed: @"detailDocuments"
map: @"function(doc) { emit([doc._id, doc.created_at], [doc._id, doc.reporter, doc.comment, doc.medium, doc.created_at] );}"];

[design saveChanges];

// NSArray * r = [ (MapCouchbaseDataModel * ) self.instance getView:@"detailDocuments" ];
Expand Down
2 changes: 2 additions & 0 deletions Wildflowers of Detroit Iphone/MapViewController.h
Expand Up @@ -67,6 +67,8 @@

@property(strong, nonatomic) IBOutlet TimelineVisualizationView * visualization;
@property(strong, nonatomic) IBOutlet UILabel * galleryHeading2;
@property(strong, nonatomic) IBOutlet UILabel * myDataHeadingGallery;


//detailView
@property(strong, nonatomic) IBOutlet UILabel * detailDate;
Expand Down
9 changes: 7 additions & 2 deletions Wildflowers of Detroit Iphone/MapViewController.m
Expand Up @@ -75,6 +75,7 @@ @implementation MapViewController
@synthesize mapShowing;
@synthesize heading2;
@synthesize galleryHeading2;
@synthesize myDataHeadingGallery;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
Expand Down Expand Up @@ -135,6 +136,7 @@ - (void)viewDidLoad
} else {
mapShowing = TRUE;
self.heading2.hidden = TRUE;
self.myDataHeadingGallery.hidden = TRUE;
}
}

Expand Down Expand Up @@ -238,7 +240,10 @@ - (void) addAnnotations {
CLLocationCoordinate2D coordinate;
coordinate.latitude = [ (NSString*) [document objectForKey:@"latitude"] floatValue];
coordinate.longitude = [ (NSString*) [document objectForKey:@"longitude"] floatValue];

if(coordinate.latitude == 0 && coordinate.longitude==0){
continue;
}
NSLog(@"%f %f", coordinate.latitude, coordinate.longitude );
RhusMapAnnotation * rhusMapAnnotation = (RhusMapAnnotation *) [RhusMapAnnotation
mapAnnotationWithCoordinate: coordinate
title: [document getDateString]
Expand All @@ -260,7 +265,7 @@ - (void)viewWillAppear:(BOOL)animated {
//TODO: Obviously both of these shouldn't be called
[self setupGalleryScrollView];

if(launchInGalleryMode && firstView) {
if(launchInGalleryMode) {
[UIView beginAnimations:nil context:NULL];
[fullscreenTransitionDelegate subviewRequestingFullscreen];
[UIView commitAnimations];
Expand Down
52 changes: 50 additions & 2 deletions Wildflowers of Detroit Iphone/MapViewController.xib
Expand Up @@ -436,6 +436,7 @@
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="180854801"/>
<bool key="IBUIOpaque">NO</bool>
<int key="IBUIContentMode">10</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
Expand Down Expand Up @@ -475,6 +476,28 @@
<reference key="IBUIFontDescription" ref="961295082"/>
<reference key="IBUIFont" ref="948734034"/>
</object>
<object class="IBUILabel" id="692469735">
<reference key="NSNextResponder" ref="490449960"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 14}, {68, 22}}</string>
<reference key="NSSuperview" ref="490449960"/>
<reference key="NSWindow"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">My Data</string>
<object class="NSColor" key="IBUITextColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC44NDY0NDM0NzQzIDAuNDE1Nzg1MjUzIDAuMjI4OTcyNDQ5OQA</bytes>
</object>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
<float key="IBUIMinimumFontSize">10</float>
<reference key="IBUIFontDescription" ref="961295082"/>
<reference key="IBUIFont" ref="948734034"/>
</object>
</array>
<string key="NSFrameSize">{480, 320}</string>
<reference key="NSSuperview"/>
Expand Down Expand Up @@ -599,6 +622,7 @@
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="306372015"/>
<bool key="IBUIOpaque">NO</bool>
<int key="IBUIContentMode">4</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
Expand Down Expand Up @@ -809,14 +833,15 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="785330322">
<nil key="NSNextResponder"/>
<reference key="NSNextResponder"/>
<int key="NSvFlags">292</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUIButton" id="1053242681">
<reference key="NSNextResponder" ref="785330322"/>
<int key="NSvFlags">292</int>
<string key="NSFrameSize">{480, 320}</string>
<reference key="NSSuperview" ref="785330322"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="742826326"/>
<reference key="IBUIBackgroundColor" ref="816853549"/>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -838,11 +863,14 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{424, 0}, {58, 320}}</string>
<reference key="NSSuperview" ref="785330322"/>
<reference key="NSWindow"/>
<reference key="IBUIBackgroundColor" ref="816853549"/>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</array>
<string key="NSFrameSize">{480, 320}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1053242681"/>
<reference key="IBUIBackgroundColor" ref="143657789"/>
<object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
Expand Down Expand Up @@ -990,6 +1018,14 @@
</object>
<int key="connectionID">103</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">myDataHeadingGallery</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="692469735"/>
</object>
<int key="connectionID">105</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
Expand Down Expand Up @@ -1106,6 +1142,7 @@
<reference ref="940329440"/>
<reference ref="642578738"/>
<reference ref="846218631"/>
<reference ref="692469735"/>
</array>
<reference key="parent" ref="0"/>
<string key="objectName">Timeline View</string>
Expand Down Expand Up @@ -1369,6 +1406,11 @@
<reference key="object" ref="435343376"/>
<reference key="parent" ref="412910088"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">104</int>
<reference key="object" ref="692469735"/>
<reference key="parent" ref="490449960"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
Expand All @@ -1378,6 +1420,7 @@
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="101.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="104.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="11.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="17.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="18.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
Expand Down Expand Up @@ -1435,7 +1478,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">103</int>
<int key="maxID">105</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down Expand Up @@ -1507,6 +1550,7 @@
<string key="infoView">UIView</string>
<string key="location">UILabel</string>
<string key="mapView">MKMapView</string>
<string key="myDataHeadingGallery">UILabel</string>
<string key="overlayView">UIView</string>
<string key="reporter">UILabel</string>
<string key="timelineControlsView">UIView</string>
Expand Down Expand Up @@ -1556,6 +1600,10 @@
<string key="name">mapView</string>
<string key="candidateClassName">MKMapView</string>
</object>
<object class="IBToOneOutletInfo" key="myDataHeadingGallery">
<string key="name">myDataHeadingGallery</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="overlayView">
<string key="name">overlayView</string>
<string key="candidateClassName">UIView</string>
Expand Down
4 changes: 4 additions & 0 deletions Wildflowers of Detroit.xcodeproj/project.pbxproj
Expand Up @@ -429,6 +429,8 @@
F4F2857D150DB751009A24C9 /* shutter.png in Resources */ = {isa = PBXBuildFile; fileRef = F4F2857A150DADBC009A24C9 /* shutter.png */; };
F4F2857E150DB751009A24C9 /* shutter.png in Resources */ = {isa = PBXBuildFile; fileRef = F4F2857A150DADBC009A24C9 /* shutter.png */; };
F4F2859E150DEA3A009A24C9 /* mapDeviceUserPoint.png in Resources */ = {isa = PBXBuildFile; fileRef = F4F2859D150DEA3A009A24C9 /* mapDeviceUserPoint.png */; };
F4F2F42F150E0968003969F9 /* mapDeviceUserPoint.png in Resources */ = {isa = PBXBuildFile; fileRef = F4F2859D150DEA3A009A24C9 /* mapDeviceUserPoint.png */; };
F4F2F431150E0968003969F9 /* mapDeviceUserPoint.png in Resources */ = {isa = PBXBuildFile; fileRef = F4F2859D150DEA3A009A24C9 /* mapDeviceUserPoint.png */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -1275,6 +1277,7 @@
F422E2E8150C331A009317E5 /* StoreIcon.png in Resources */,
A6428BE5150CAF4800CC0D03 /* LoadingViewController.xib in Resources */,
F4F2857D150DB751009A24C9 /* shutter.png in Resources */,
F4F2F42F150E0968003969F9 /* mapDeviceUserPoint.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1457,6 +1460,7 @@
F422E2EE150C331F009317E5 /* Loadingx2.png in Resources */,
A6428BE6150CAF4800CC0D03 /* LoadingViewController.xib in Resources */,
F4F2857E150DB751009A24C9 /* shutter.png in Resources */,
F4F2F431150E0968003969F9 /* mapDeviceUserPoint.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 1227da8

Please sign in to comment.