Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Jalencas committed Feb 18, 2010
0 parents commit 4a96305
Show file tree
Hide file tree
Showing 9 changed files with 378 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -crlf -diff -merge
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# xcode noise
*.mode1v3
*.pbxuser
*.perspective
*.perspectivev3
*.pyc
*~.nib/
build/*

# Textmate - if you build your xcode projects with it
*.tm_build_errors

# old skool
.svn

# osx noise
.DS_Store
profile
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2010 Victor Jalencas

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
So what is it?
==============

whereami is a simple command-line utility that outputs your geographical coordinates, as determined by Core Location, which uses nearby WiFi networks with known positions to pinpoint your position. It outputs them to the standard output in an easy to parse format, in good UNIX fashion.


Requirements
============

wherami only works in versions of Mac OS X 10.6 (Snow Leopard) or greater, as it makes use of the Core Location framework.


TODO
====

* Write a proper man page. There is a template generated by Xcode but I won't commit it just yet
* Add more options for output of additional data, like altitude, precision or course, and also for input of minimum precision
* Write a Makefile so that Xcode is not needed
* Handle errors gracefully. I just need to implement the proper delegate method


LICENSE
=======

This code is released under the MIT license. Check the file LICENSE for details.
21 changes: 21 additions & 0 deletions VJWhereAmI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// VJWhereAmI.h
// whereami
//
// Created by Victor Jalencas on 17/02/10.
// Copyright 2010 Victor Jalencas All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <CoreLocation/CoreLocation.h>

@interface VJWhereAmI : NSObject <CLLocationManagerDelegate> {

CLLocationManager * manager;
BOOL locationObtained;

}
- (void) printLocation;


@end
36 changes: 36 additions & 0 deletions VJWhereAmI.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// VJWhereAmI.m
// whereami
//
// Created by Victor Jalencas on 17/02/10.
// Copyright 2010 Victor Jalencas All rights reserved.
//

#import "VJWhereAmI.h"


@implementation VJWhereAmI

- (void) printLocation {
manager = [[CLLocationManager alloc] init];
locationObtained = NO;
[manager setDelegate:self];



[manager startUpdatingLocation];

while (!locationObtained) {
CFRunLoopRun();
}
[manager release];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
printf("%s\n",[[NSString stringWithFormat:@"%f,%f", newLocation.coordinate.latitude, newLocation.coordinate.longitude] UTF8String]);
locationObtained = YES;
CFRunLoopStop(CFRunLoopGetCurrent());
}


@end
13 changes: 13 additions & 0 deletions whereami.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#import <Cocoa/Cocoa.h>
#import "VJWhereAmI.h"

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

VJWhereAmI* main = [[VJWhereAmI alloc] init];
[main printLocation];
[main release];

[pool drain];
return 0;
}
235 changes: 235 additions & 0 deletions whereami.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objects = {

/* Begin PBXBuildFile section */
577A353F112D24EB00A9D832 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 577A353E112D24EB00A9D832 /* Foundation.framework */; };
57863D80112C25240066128A /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57863D7F112C25240066128A /* CoreLocation.framework */; };
57863D89112C264E0066128A /* VJWhereAmI.m in Sources */ = {isa = PBXBuildFile; fileRef = 57863D88112C264E0066128A /* VJWhereAmI.m */; };
8DD76F9A0486AA7600D96B5E /* whereami.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* whereami.m */; settings = {ATTRIBUTES = (); }; };
8DD76F9F0486AA7600D96B5E /* whereami.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859EA3029092ED04C91782 /* whereami.1 */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
8DD76F9E0486AA7600D96B5E /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 8;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
8DD76F9F0486AA7600D96B5E /* whereami.1 in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
08FB7796FE84155DC02AAC07 /* whereami.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = whereami.m; sourceTree = "<group>"; };
32A70AAB03705E1F00C91783 /* whereami_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = whereami_Prefix.pch; sourceTree = "<group>"; };
577A3420112C628A00A9D832 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
577A343F112C675400A9D832 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
577A353E112D24EB00A9D832 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
57863D7F112C25240066128A /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
57863D87112C264E0066128A /* VJWhereAmI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VJWhereAmI.h; sourceTree = "<group>"; };
57863D88112C264E0066128A /* VJWhereAmI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VJWhereAmI.m; sourceTree = "<group>"; };
8DD76FA10486AA7600D96B5E /* whereami */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = whereami; sourceTree = BUILT_PRODUCTS_DIR; };
C6859EA3029092ED04C91782 /* whereami.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = whereami.1; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
8DD76F9B0486AA7600D96B5E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
57863D80112C25240066128A /* CoreLocation.framework in Frameworks */,
577A353F112D24EB00A9D832 /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
08FB7794FE84155DC02AAC07 /* whereami */ = {
isa = PBXGroup;
children = (
08FB7795FE84155DC02AAC07 /* Source */,
C6859EA2029092E104C91782 /* Documentation */,
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */,
1AB674ADFE9D54B511CA2CBB /* Products */,
);
name = whereami;
sourceTree = "<group>";
};
08FB7795FE84155DC02AAC07 /* Source */ = {
isa = PBXGroup;
children = (
32A70AAB03705E1F00C91783 /* whereami_Prefix.pch */,
08FB7796FE84155DC02AAC07 /* whereami.m */,
57863D87112C264E0066128A /* VJWhereAmI.h */,
57863D88112C264E0066128A /* VJWhereAmI.m */,
);
name = Source;
sourceTree = "<group>";
};
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = {
isa = PBXGroup;
children = (
57863D7F112C25240066128A /* CoreLocation.framework */,
577A353E112D24EB00A9D832 /* Foundation.framework */,
);
name = "External Frameworks and Libraries";
sourceTree = "<group>";
};
1AB674ADFE9D54B511CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
8DD76FA10486AA7600D96B5E /* whereami */,
);
name = Products;
sourceTree = "<group>";
};
C6859EA2029092E104C91782 /* Documentation */ = {
isa = PBXGroup;
children = (
C6859EA3029092ED04C91782 /* whereami.1 */,
577A3420112C628A00A9D832 /* LICENSE */,
577A343F112C675400A9D832 /* README.md */,
);
name = Documentation;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
8DD76F960486AA7600D96B5E /* whereami */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "whereami" */;
buildPhases = (
8DD76F990486AA7600D96B5E /* Sources */,
8DD76F9B0486AA7600D96B5E /* Frameworks */,
8DD76F9E0486AA7600D96B5E /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = whereami;
productInstallPath = "$(HOME)/bin";
productName = whereami;
productReference = 8DD76FA10486AA7600D96B5E /* whereami */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "whereami" */;
compatibilityVersion = "Xcode 3.1";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* whereami */;
projectDirPath = "";
projectRoot = "";
targets = (
8DD76F960486AA7600D96B5E /* whereami */,
);
};
/* End PBXProject section */

/* Begin PBXSourcesBuildPhase section */
8DD76F990486AA7600D96B5E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8DD76F9A0486AA7600D96B5E /* whereami.m in Sources */,
57863D89112C264E0066128A /* VJWhereAmI.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin XCBuildConfiguration section */
1DEB927508733DD40010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = whereami_Prefix.pch;
INSTALL_PATH = /usr/local/bin;
PRODUCT_NAME = whereami;
};
name = Debug;
};
1DEB927608733DD40010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = whereami_Prefix.pch;
INSTALL_PATH = /usr/local/bin;
PRODUCT_NAME = whereami;
};
name = Release;
};
1DEB927908733DD40010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
SDKROOT = macosx10.6;
};
name = Debug;
};
1DEB927A08733DD40010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = macosx10.6;
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "whereami" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB927508733DD40010E9CD /* Debug */,
1DEB927608733DD40010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "whereami" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB927908733DD40010E9CD /* Debug */,
1DEB927A08733DD40010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
}
7 changes: 7 additions & 0 deletions whereami_Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'whereami' target in the 'whereami' project.
//

#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif

0 comments on commit 4a96305

Please sign in to comment.