Skip to content

Commit

Permalink
new project structure (no changes in the code)
Browse files Browse the repository at this point in the history
  • Loading branch information
Obkircher Jakob committed Dec 16, 2010
1 parent 6deec1e commit 52d2656
Show file tree
Hide file tree
Showing 68 changed files with 4,005 additions and 0 deletions.
Binary file added Classes/data/.DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions Classes/data/DataHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2010- Peer internet solutions
*
* This file is part of mixare.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>
*/



@interface DataHandler : NSObject {

}

@end
24 changes: 24 additions & 0 deletions Classes/data/DataHandler.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2010- Peer internet solutions
*
* This file is part of mixare.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>
*/
#import "DataHandler.h"


@implementation DataHandler

@end
30 changes: 30 additions & 0 deletions Classes/data/DataSource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright (C) 2010- Peer internet solutions
*
* This file is part of mixare.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/> */

#import <Foundation/Foundation.h>
#define WIKI_BASE_URL @"http://ws.geonames.org/findNearbyWikipediaJSON"
#define TWITTER_BASE_URL @"http://search.twitter.com/search.json"
#define BUZZ_BASE_URL @"https://www.googleapis.com/buzz/v1/activities/search?alt=json&max-results=20"
#define OSM_BASE_URL @"http://osmxapi.hypercube.telascience.org/api/0.6/node[railway=station]"
typedef enum {WIKIPEDIA, BUZZ, TWITTER, OWNURL,OSM} DATASOURCE;

@interface DataSource : NSObject {


}
+(NSString *) createRequestURLFromDataSource: (NSString*) source Lat: (float) lat Lon: (float) lon Alt: (float) alt radius: (float) rad Lang: (NSString *) lang;
@end
38 changes: 38 additions & 0 deletions Classes/data/DataSource.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Copyright (C) 2010- Peer internet solutions
*
* This file is part of mixare.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/> */

#import "DataSource.h"


@implementation DataSource
+(NSString *) createRequestURLFromDataSource: (NSString*) source Lat: (float) lat Lon: (float) lon Alt: (float) alt radius: (float) rad Lang: (NSString *) lang{
NSString * ret;
if([source isEqualToString: @"WIKIPEDIA"] ){
ret = [NSString stringWithFormat:@"%@?lat=%f&lng=%f&radius=%f&maxRows=50&lang=%@",WIKI_BASE_URL,lat,lon,rad,lang];
}else if ([source isEqualToString: @"BUZZ"]){
ret = [NSString stringWithFormat:@"%@&lat=%f&lon=%f&radius=%f",BUZZ_BASE_URL,lat,lon,rad*1000];
}else if ([source isEqualToString: @"TWITTER"]){
ret = [NSString stringWithFormat:@"%@?geocode=%f,%f,%fkm",TWITTER_BASE_URL,lat,lon,rad];
return ret;
}else if ([source isEqualToString: @"OSM"]){
//ret=@"";
}else if ([source isEqualToString: @"OWNURL"]){

}
return ret;
}
@end
31 changes: 31 additions & 0 deletions Classes/data/JsonHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2010- Peer internet solutions
*
* This file is part of mixare.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>
*/

#import "JSON.h"
@interface JsonHandler : NSObject {
SBJsonParser * parser;
}
-(NSMutableArray*)processWikipediaJSONData: (NSString*) jsonData;
-(NSMutableArray*)processMixareJSONData: (NSString*) jsonData;
-(NSMutableArray*)processTwitterJSONData: (NSString*) jsonData;
-(NSMutableArray*)processBuzzJSONData: (NSString*) jsonData;
-(NSMutableArray*)processGooglePlacesData: (NSString*) jsonData;

@end

111 changes: 111 additions & 0 deletions Classes/data/JsonHandler.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Copyright (C) 2010- Peer internet solutions
*
* This file is part of mixare.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>
*/

#import "JsonHandler.h"
static NSString *kTitleKey = @"title";
static NSString *kLatKey = @"lat";
static NSString *kLonKey = @"lon";
static NSString *kAltKey = @"alt";
static NSString *kSummaryKey = @"sum";
static NSString *kUrlKey = @"url";
static NSString *kUserKey = @"user";
static NSString *kSourceKey = @"source";
static NSString *kReferenceKey = @"reference";

@implementation JsonHandler

-(NSMutableArray*)processWikipediaJSONData: (NSString*) jsonData{
NSDictionary* data = [jsonData JSONValue];
NSMutableArray* ret = [[NSMutableArray alloc]init];
NSArray* geonames = [data objectForKey:@"geonames"];
for(NSDictionary *geoname in geonames){
//NSLog(@"Title: %@", [geoname objectForKey:@"title"]);
//[ret addObject:[geoname objectForKey:@"title"]];

[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:[geoname objectForKey:@"title"],kTitleKey, [geoname objectForKey:@"summary"],kSummaryKey,[NSString stringWithFormat:@"http://%@",[geoname objectForKey:@"wikipediaUrl"]],kUrlKey,[geoname objectForKey:@"lng"],kLonKey,[geoname objectForKey:@"lat"],kLatKey,[geoname objectForKey:@"elevation"],kAltKey, @"WIKIPEDIA",kSourceKey, nil]];
}
return ret;
}
-(NSMutableArray*)processMixareJSONData: (NSString*) jsonData{
if(! [jsonData isEqualToString:@""]){
NSDictionary* data = [jsonData JSONValue];
NSMutableArray* ret = [[NSMutableArray alloc]init];
NSArray* geonames = [data objectForKey:@"results"];
for(NSDictionary *geoname in geonames){
[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:[geoname objectForKey:@"title"],kTitleKey, [geoname objectForKey:@"webpage"],kUrlKey,[geoname objectForKey:@"lng"],kLonKey,[geoname objectForKey:@"lat"],kLatKey,[geoname objectForKey:@"elevation"],kAltKey,@"MIXARE",kSourceKey, nil]];
}
return ret;
}else return nil;
}

-(NSMutableArray*)processTwitterJSONData: (NSString*) jsonData{
NSDictionary * data = [jsonData JSONValue];
NSMutableArray* ret = [[NSMutableArray alloc]init];
NSArray* tweets = [data objectForKey:@"results"];
float height = 8000.0;
for(NSDictionary *tweet in tweets){
[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:[tweet objectForKey:@"from_user"],kUserKey,[tweet objectForKey:@"text"],kTitleKey,[NSString stringWithFormat:@"http://twitter.com/%@",[tweet objectForKey:@"from_user"]],kUrlKey, @"TWITTER",kSourceKey,[NSString stringWithFormat:@"%f",height],kAltKey,nil]];
height += 1000;
}
return ret;
}

-(NSMutableArray*)processGooglePlacesData: (NSString*) jsonData{
NSDictionary* data = [jsonData JSONValue];
NSMutableArray * ret = [[NSMutableArray alloc]init];
NSArray * googlePlaces = [data objectForKey:@"results"];
for(NSDictionary *place in googlePlaces){
[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:[place objectForKey:@"name"],kTitleKey,[place objectForKey:@"reference"],kReferenceKey, nil]];
}
return ret;
}

-(NSMutableArray*)processBuzzJSONData: (NSString*) jsonData{
if(jsonData != nil){
NSDictionary * data = [jsonData JSONValue];
NSMutableArray* ret = [[NSMutableArray alloc]init];
NSDictionary* msgs = [data objectForKey:@"data"];
NSArray* items = [msgs objectForKey:@"items"];
float height = 8000.0;
for(NSDictionary *msg in items){
NSArray * splittedGeoCode = [[msg objectForKey:@"geocode"] componentsSeparatedByString:@" "];

NSString* lat = [splittedGeoCode objectAtIndex:0];
NSString* lng = [splittedGeoCode objectAtIndex:1];
NSLog(@"%@:%@",lat,lng);
NSDictionary * links = [msg objectForKey:@"links"];
NSArray * alternate = [links objectForKey:@"alternate"];
NSDictionary *href=[alternate objectAtIndex:0];
NSString * link = [href objectForKey:@"href"];
NSString * title = [msg objectForKey:@"title"];
NSArray * words = [title componentsSeparatedByString:@" "];
NSMutableString * finalText = [[NSMutableString alloc]init];
for(int i=0;i <[words count]; i++){
[finalText appendFormat:@" %@",[words objectAtIndex:i]];
if(i % 3 ==0 && i !=0){
[finalText appendString: @"\n"];
}
}
height += 1000;
[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:lat,kLatKey,lng,kLonKey,title,kTitleKey, link,kUrlKey,@"BUZZ",kSourceKey,[NSString stringWithFormat:@"%f",height],kAltKey, nil]];
}
return ret;
}return nil;
}
@end
26 changes: 26 additions & 0 deletions Classes/data/XMLHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2010- Peer internet solutions
*
* This file is part of mixare.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>
*/



@interface XMLHandler : NSObject {

}

@end
25 changes: 25 additions & 0 deletions Classes/data/XMLHandler.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2010- Peer internet solutions
*
* This file is part of mixare.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>
*/

#import "XMLHandler.h"


@implementation XMLHandler

@end
58 changes: 58 additions & 0 deletions Classes/data/json/JSON.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright (C) 2009-2010 Stig Brautaset. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**
@mainpage A strict JSON parser and generator for Objective-C
JSON (JavaScript Object Notation) is a lightweight data-interchange
format. This framework provides two apis for parsing and generating
JSON. One standard object-based and a higher level api consisting of
categories added to existing Objective-C classes.
This framework does its best to be as strict as possible, both in what it accepts and what it generates. For example, it does not support trailing commas in arrays or objects. Nor does it support embedded comments, or anything else not in the JSON specification. This is considered a feature.
@section Links
@li <a href="http://stig.github.com/json-framework">Project home page</a>.
@li Online version of the <a href="http://stig.github.com/json-framework/api">API documentation</a>.
*/


// This setting of 1 is best if you copy the source into your project.
// The build transforms the 1 to a 0 when building the framework and static lib.



#import "SBJsonParser.h"
#import "SBJsonWriter.h"
#import "NSObject+SBJSON.h"
#import "NSString+SBJSON.h"


Loading

0 comments on commit 52d2656

Please sign in to comment.