├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── Documentation ├── AppledocSettings.plist ├── Makefile ├── Templates │ ├── docset │ │ └── Contents │ │ │ ├── Resources │ │ │ ├── Documents │ │ │ │ └── documents-template │ │ │ ├── nodes-template.xml │ │ │ └── tokens-template.xml │ │ │ └── info-template.plist │ └── html │ │ ├── css │ │ └── styles.css │ │ ├── document-template.html │ │ ├── hierarchy-template.html │ │ ├── img │ │ ├── button_bar_background.png │ │ ├── disclosure.png │ │ ├── disclosure_open.png │ │ ├── help.png │ │ ├── hierarchy.png │ │ ├── home.png │ │ ├── logo.png │ │ └── title_background.png │ │ ├── index-template.html │ │ └── object-template.html └── appledoc ├── LICENSE.md ├── Project ├── Mac │ ├── Config │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── Shared.xcconfig │ ├── Makefile │ ├── SimpleGeo-Info.plist │ ├── SimpleGeo-Prefix.pch │ ├── SimpleGeo.xcodeproj │ │ └── project.pbxproj │ └── Tests │ │ ├── Classes │ │ ├── GHUnitTestMain.m │ │ ├── SGGeometryTest.m │ │ ├── SimpleGeoTest+Context.m │ │ ├── SimpleGeoTest+Places10.m │ │ ├── SimpleGeoTest+Places12.m │ │ ├── SimpleGeoTest+Storage.m │ │ ├── SimpleGeoTest.h │ │ └── SimpleGeoTest.m │ │ ├── RunTests.sh │ │ ├── SimpleGeoTestSettings-Example.h │ │ └── Tests-Info.plist ├── Shared │ ├── Classes │ │ ├── Client │ │ │ ├── Params │ │ │ │ ├── FactualCategories.h │ │ │ │ ├── SGCategories.h │ │ │ │ ├── SGTypes.h │ │ │ │ └── SGTypes.m │ │ │ ├── Queries │ │ │ │ ├── SGContextQuery.h │ │ │ │ ├── SGContextQuery.m │ │ │ │ ├── SGNearbyQuery.h │ │ │ │ ├── SGNearbyQuery.m │ │ │ │ ├── SGPlacesQuery.h │ │ │ │ ├── SGPlacesQuery.m │ │ │ │ ├── SGQuery.h │ │ │ │ ├── SGQuery.m │ │ │ │ ├── SGStorageQuery.h │ │ │ │ └── SGStorageQuery.m │ │ │ ├── Services │ │ │ │ ├── SimpleGeo+Context.h │ │ │ │ ├── SimpleGeo+Context.m │ │ │ │ ├── SimpleGeo+Places.h │ │ │ │ ├── SimpleGeo+Places.m │ │ │ │ ├── SimpleGeo+Storage.h │ │ │ │ └── SimpleGeo+Storage.m │ │ │ ├── SimpleGeo+Internal.h │ │ │ ├── SimpleGeo.h │ │ │ └── SimpleGeo.m │ │ ├── Model │ │ │ ├── Additions │ │ │ │ ├── NSArray+SGCollection.h │ │ │ │ ├── NSArray+SGCollection.m │ │ │ │ ├── NSDictionary+Classifier.h │ │ │ │ └── NSDictionary+Classifier.m │ │ │ ├── Addresses │ │ │ │ ├── SGAddress+Internal.h │ │ │ │ ├── SGAddress.h │ │ │ │ ├── SGAddress.m │ │ │ │ ├── SGPlacemark+Internal.h │ │ │ │ ├── SGPlacemark.h │ │ │ │ └── SGPlacemark.m │ │ │ ├── Geo Objects │ │ │ │ ├── SGFeature.h │ │ │ │ ├── SGFeature.m │ │ │ │ ├── SGGeoObject.h │ │ │ │ ├── SGGeoObject.m │ │ │ │ ├── SGPlace.h │ │ │ │ ├── SGPlace.m │ │ │ │ ├── SGStoredRecord.h │ │ │ │ └── SGStoredRecord.m │ │ │ ├── Geometries │ │ │ │ ├── SGEnvelope.h │ │ │ │ ├── SGEnvelope.m │ │ │ │ ├── SGGeometry.h │ │ │ │ ├── SGGeometry.m │ │ │ │ ├── SGMultiPolygon.h │ │ │ │ ├── SGMultiPolygon.m │ │ │ │ ├── SGPoint+Internal.h │ │ │ │ ├── SGPoint.h │ │ │ │ ├── SGPoint.m │ │ │ │ ├── SGPolygon+Internal.h │ │ │ │ ├── SGPolygon.h │ │ │ │ └── SGPolygon.m │ │ │ ├── SGContext.h │ │ │ ├── SGContext.m │ │ │ ├── SGLayer.h │ │ │ └── SGLayer.m │ │ └── Utility │ │ │ └── SGPreprocessorMacros.h │ └── Config │ │ └── Global.xcconfig └── iOS │ ├── Classes │ └── Mapkit │ │ ├── SGEnvelope+Mapkit.h │ │ ├── SGEnvelope+Mapkit.m │ │ ├── SGGeometry+Mapkit.h │ │ ├── SGGeometry+Mapkit.m │ │ ├── SGMultiPolygon+Mapkit.h │ │ ├── SGMultiPolygon+Mapkit.m │ │ ├── SGPoint+Mapkit.h │ │ ├── SGPoint+Mapkit.m │ │ ├── SGPolygon+Mapkit.h │ │ └── SGPolygon+Mapkit.m │ ├── Config │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── Shared.xcconfig │ ├── Makefile │ ├── SimpleGeo-Info.plist │ ├── SimpleGeo-Prefix.pch │ └── SimpleGeo.xcodeproj │ └── project.pbxproj ├── README.md ├── RELEASE.md └── scripts ├── deploy ├── update-dependencies ├── update-factual-categories.py └── update-sg-categories.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | *.pbxuser 3 | !default.pbxuser 4 | *.mode1v3 5 | !default.mode1v3 6 | *.mode2v3 7 | !default.mode2v3 8 | *.perspectivev3 9 | !default.perspectivev3 10 | *.xcworkspace 11 | !default.xcworkspace 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | *.tgz 16 | 17 | # OS X 18 | .DS_Store 19 | Icon? 20 | 21 | # Thumbnails 22 | ._* 23 | 24 | # Files that might appear on external disk 25 | .Spotlight-V100 26 | .Trashes 27 | 28 | # Project-specific ignores 29 | Project/Mac/Build 30 | Project/iOS/Build 31 | Project/Mac/Tests/Resources/GHUnit.framework 32 | Project/Mac/Tests/SimpleGeoTestSettings.h 33 | Documentation/html 34 | Documentation/docset 35 | Documentation/docset-installed.txt 36 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Project/Shared/Resources/SGObjCHTTP"] 2 | path = Project/Shared/Resources/SGObjCHTTP 3 | url = git@github.com:simplegeo/SGObjCHTTP.git 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## 2.2.3 - 10/27/11 4 | 5 | * Added missing API url 6 | 7 | ## 2.2.2 - 10/27/11 8 | 9 | * Bug fix: allow [[SimpleGeo alloc] initWithConsumerKey:key secret:secret] 10 | 11 | ## 2.2.1 - 10/25/11 12 | 13 | * Bug fix: added FactualCategories.h to Xcode projects 14 | 15 | ## 2.2.0 - 10/17/11 16 | 17 | * Make Places 1.2 the default 18 | * Search ASC tables endpoint 19 | * Factual categories list 20 | * Bug fix for ampersands in Places category queries 21 | 22 | ## 2.1.2 - 9/22/11 23 | 24 | * Ensure UTF8 encoded strings work for address parameters 25 | 26 | ## 2.1.1 - 9/7/11 27 | 28 | * Updated SGObjCHTTP client 29 | 30 | ## 2.1.0 - 9/7/11 31 | 32 | * Storage property querying 33 | * Removed selfLink/layerLink from models 34 | * Refactored SGAddress to use an address dictionary 35 | 36 | ## 2.0.4 - 8/30/11 37 | 38 | * 3rd-party header files were missing from the compiled frameworks 39 | 40 | ## 2.0.3 - 8/25/11 41 | 42 | * Namespaced all 3rd-party libraries 43 | * Added a deploy script 44 | 45 | ## 2.0.2 - 8/23/11 46 | 47 | * armv6 was missing from the compiled iOS static library 48 | 49 | ## 2.0.1 - 8/22/11 50 | 51 | * Fixed a bug in the bounding box query for nearby records 52 | * Wrapped all memory management methods within a pre-processor macro 53 | * No longer required to set `all_load` or `ObjC` as other linking flags 54 | 55 | ## 2.0 - 8/3/11 56 | 57 | * Complete rewrite. SGQuery object, new SGObject model, streamlined request methods, SGCallbacks with block support, and much more. 58 | 59 | ## 1.3.0 - 6/8/11 60 | 61 | * SSL support (this will be automatically enabled unless you specify `NO` in 62 | the `clientWithDelegate:consumerKey:consumerSecret:useSSL:` convenience 63 | constructor) 64 | * Deprecated `SIMPLEGEO_URL_PREFIX` in favor of `SIMPLEGEO_HOSTNAME` 65 | * Added the following Mapkit convenience methods for iOS: 66 | * `- (CLLocationCoordinate2D)coordinate` (`SGPoint`) 67 | * `- (NSArray *)overlays` (`SGGeometry`) 68 | * `- (MKPolygon *)asMKPolygon` (`SGPolygon`) 69 | * `- (NSArray *)asMKPolygons` (`SGMultiPolygon`) 70 | * Improved `SGFeature` `isEqual:` to match on feature ids. 71 | * Added `containsPoint:` to `SGPolygon` and `SGMultiPolygon` 72 | * Added `isInsidePolygon:` to `SGPoint` 73 | 74 | ## 1.2.3 - 4/30/11 75 | 76 | * Tracked down some Zombies that were causing crashes under mysterious 77 | conditions (connection failures, mostly) 78 | * Mild spring cleaning 79 | * Stripped debug symbols from library to avoid warnings when linking 80 | 81 | ## 1.2.2 - 4/8/11 82 | 83 | * Exposed missing headers 84 | * Support for `num` parameter in Places (as `count`) 85 | 86 | ## 1.2.1 - 3/11/11 87 | 88 | * Support for layer manipulation 89 | 90 | ## 1.2.0 - 3/2/11 91 | 92 | * Storage support 93 | 94 | ## 1.1.6 - 1/27/11 95 | 96 | * Categories support 97 | * Fixed some documented memory leaks 98 | 99 | ## 1.1.5 - 1/12/11 100 | 101 | * Don't call delegate methods when they're not implemented; warn instead 102 | * Moved potentially conflicting symbols in `NSString` 103 | * Refactored OAuth implementation to no longer conflict with Basic Auth 104 | * Fixed some potential memory leaks 105 | 106 | ## 1.1.4 - 1/7/11 107 | 108 | * Add a missing retain that was causing invalid pointers in `SGFeature` 109 | 110 | ## 1.1.3 - 1/4/11 111 | 112 | * Properly URL-encode strings 113 | * Always pass radius through when it's provided 114 | 115 | ## 1.1.2 - 1/1/11 116 | 117 | * More complete namespacing of `Base64Transcoder` 118 | 119 | ## 1.1.1 - 1/1/11 120 | 121 | * Support for `zoom` in SimpleGeo Features 122 | * Unicode characters are encoded properly 123 | * `Base64Transcoder` has been namespaced to avoid conflicts (usually with other 124 | libraries that use OAuth) 125 | * No need to `#import `, etc. any longer 126 | * iOS framework build 127 | 128 | ## 1.1 - 12/22/10 129 | 130 | * Support for `radius` in SimpleGeo Places 131 | * Support for address queries against SimpleGeo Context + SimpleGeo Places 132 | * Changed `didLoadContext:(NSDictionary *)for:(SGPoint *)` to 133 | `didLoadContext:(NSDictionary *)forQuery:(NSDictionary *)` in 134 | `SimpleGeoContextDelegate` 135 | * Changed `didLoadPlaces:(SGFeatureCollection *)near:(SGPoint *):matching:(NSString *):inCategory:(NSString *)` 136 | to `didLoadPlaces:(SGFeatureCollection *)forQuery:(NSDictionary *)` in 137 | `SimpleGeoPlacesDelegate` 138 | * Changed `didUpdatePlace:(NSString *)token:(NSString *)` to 139 | `didUpdatePlace:(SGFeature *)handle:(NSString *)token:(NSString *)` in 140 | `SimpleGeoPlacesDelegate` 141 | * Changed `getContext:(SGPoint *)` to `getContextForPoint:(SGPoint *)` in 142 | `SimpleGeo+Context` 143 | * `SimpleGeo` `delegate` property is now read/write 144 | 145 | ## 1.0 - 12/8/10 146 | 147 | * Initial release 148 | -------------------------------------------------------------------------------- /Documentation/AppledocSettings.plist: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | --ignore 7 | 8 | Project/Mac/Tests 9 | .* 10 | Project/Shared/Resources 11 | Project/Mac/Build 12 | Project/iOS/Build 13 | *+Private.h 14 | *+Private.m 15 | *+Internal.h 16 | *+Internal.m 17 | 18 | --project-name 19 | SimpleGeo.framework 20 | --project-company 21 | SimpleGeo 22 | --company-id 23 | com.simplegeo 24 | --output 25 | . 26 | --templates 27 | Templates 28 | --create-docset 29 | 30 | --install-docset 31 | 32 | --create-html 33 | 34 | --prefix-merged-sections 35 | 36 | --keep-intermediate-files 37 | 38 | --no-repeat-first-par 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Documentation/Makefile: -------------------------------------------------------------------------------- 1 | default: 2 | ./appledoc AppledocSettings.plist ../ 3 | -------------------------------------------------------------------------------- /Documentation/Templates/docset/Contents/Resources/Documents/documents-template: -------------------------------------------------------------------------------- 1 | This is used only as placeholder for location of Documents directory! -------------------------------------------------------------------------------- /Documentation/Templates/docset/Contents/Resources/nodes-template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{projectName}} 6 | {{indexFilename}} 7 | 8 | {{#hasClasses}} 9 | 10 | {{strings/docset/classesTitle}} 11 | {{indexFilename}} 12 | 13 | {{#classes}}{{>NodeRef}} 14 | {{/classes}} 15 | 16 | 17 | {{/hasClasses}} 18 | {{#hasCategories}} 19 | 20 | {{strings/docset/categoriesTitle}} 21 | {{indexFilename}} 22 | 23 | {{#categories}}{{>NodeRef}} 24 | {{/categories}} 25 | 26 | 27 | {{/hasCategories}} 28 | {{#hasProtocols}} 29 | 30 | {{strings/docset/protocolsTitle}} 31 | {{indexFilename}} 32 | 33 | {{#protocols}}{{>NodeRef}} 34 | {{/protocols}} 35 | 36 | 37 | {{/hasProtocols}} 38 | 39 | 40 | 41 | 42 | {{#classes}}{{>Node}} 43 | {{/classes}} 44 | {{#categories}}{{>Node}} 45 | {{/categories}} 46 | {{#protocols}}{{>Node}} 47 | {{/protocols}} 48 | 49 | 50 | 51 | Section Node 52 | 53 | {{name}} 54 | {{path}} 55 | 56 | EndSection 57 | 58 | Section NodeRef 59 | 60 | EndSection 61 | -------------------------------------------------------------------------------- /Documentation/Templates/docset/Contents/Resources/tokens-template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{#object}} 5 | 6 | {{>TokenIdentifier}} 7 | {{>Abstract}} 8 | {{>DeclaredIn}} 9 | {{>RelatedTokens}} 10 | {{#refid}}{{/refid}} 11 | 12 | {{/object}} 13 | {{#members}} 14 | 15 | {{>TokenIdentifier}} 16 | {{>Abstract}} 17 | {{>DeclaredIn}} 18 | {{>RelatedTokens}} 19 | {{>MethodDeclaration}} 20 | {{#hasParameters}} 21 | {{#parameters}} 22 | {{name}} 23 | {{>Abstract}} 24 | {{/parameters}} 25 | {{/hasParameters}} 26 | {{#returnValue}}{{>Abstract}}{{/returnValue}} 27 | {{#anchor}}{{anchor}}{{/anchor}} 28 | 29 | {{/members}} 30 | 31 | 32 | 33 | Section TokenIdentifier 34 | {{identifier}} 35 | EndSection 36 | 37 | Section DeclaredIn 38 | {{declaredin}} 39 | EndSection 40 | 41 | Section RelatedTokens 42 | {{#hasRelatedTokens}} 43 | 44 | {{#relatedTokens}}{{.}} 45 | {{/relatedTokens}} 46 | 47 | {{/hasRelatedTokens}} 48 | EndSection 49 | 50 | Section Abstract 51 | {{#abstract}}{{>GBCommentComponentsList}}{{/abstract}} 52 | EndSection 53 | 54 | Section MethodDeclaration 55 | {{#formattedComponents}}{{value}}{{/formattedComponents}} 56 | EndSection 57 | 58 | Section GBCommentComponentsList 59 | {{#components}}{{&textValue}}{{/components}} 60 | EndSection 61 | 62 | -------------------------------------------------------------------------------- /Documentation/Templates/docset/Contents/info-template.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | {{#bundleIdentifier}}CFBundleIdentifier 8 | {{bundleIdentifier}}{{/bundleIdentifier}} 9 | {{#bundleName}}CFBundleName 10 | {{bundleName}}{{/bundleName}} 11 | {{#bundleVersion}}CFBundleShortVersionString 12 | {{bundleVersion}} 13 | CFBundleVersion 14 | {{bundleVersion}}{{/bundleVersion}} 15 | {{#certificateIssuer}}DocSetCertificateIssuer 16 | {{certificateIssuer}}{{/certificateIssuer}} 17 | {{#certificateSigner}}DocSetCertificateSigner 18 | {{certificateSigner}}{{/certificateSigner}} 19 | {{#description}}DocSetDescription 20 | {{description}}{{/description}} 21 | {{#fallbackURL}}DocSetFallbackURL 22 | {{fallbackURL}}{{/fallbackURL}} 23 | {{#feedName}}DocSetFeedName 24 | {{feedName}}{{/feedName}} 25 | {{#feedURL}}DocSetFeedURL 26 | {{feedURL}}{{/feedURL}} 27 | {{#minimumXcodeVersion}}DocSetMinimumXcodeVersion 28 | {{minimumXcodeVersion}}{{/minimumXcodeVersion}} 29 | {{#platformFamily}}DocSetPlatformFamily 30 | {{platformFamily}}{{/platformFamily}} 31 | {{#publisherIdentifier}}DocSetPublisherIdentifier 32 | {{publisherIdentifier}}{{/publisherIdentifier}} 33 | {{#publisherName}}DocSetPublisherName 34 | {{publisherName}}{{/publisherName}} 35 | {{#copyrightMessage}}NSHumanReadableCopyright 36 | {{copyrightMessage}}{{/copyrightMessage}} 37 | 38 | 39 | -------------------------------------------------------------------------------- /Documentation/Templates/html/document-template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{page/title}} 5 | 6 | 7 | 8 | 9 | {{#strings/appledocData}}{{/strings/appledocData}} 10 | 11 | 12 |
13 | 14 |
15 | {{#object/comment}}{{#longDescription}}{{>GBCommentComponentsList}}{{/longDescription}}{{/object/comment}} 16 |
17 |
18 | 19 | 20 | 21 | 22 | Section GBCommentComponentsList 23 | {{#components}}{{>GBCommentComponent}}{{/components}} 24 | EndSection 25 | 26 | Section GBCommentComponent 27 | {{&htmlValue}} 28 | EndSection 29 | -------------------------------------------------------------------------------- /Documentation/Templates/html/hierarchy-template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{page/title}} 5 | 6 | 7 | {{#strings/appledocData}}{{/strings/appledocData}} 8 | 9 | 10 |
11 | 17 | 20 |
21 |
22 |
23 |
24 | {{#hasClasses}} 25 |
26 |

{{strings/hierarchyPage/classesTitle}}

27 | {{>Classes}} 28 |
29 | {{/hasClasses}} 30 | 31 | {{#hasProtocolsOrCategories}} 32 |
33 | {{#hasProtocols}} 34 |

{{strings/hierarchyPage/protocolsTitle}}

35 |
    36 | {{#protocols}} 37 |
  • {{title}}
  • 38 | {{/protocols}} 39 |
40 | {{/hasProtocols}} 41 | {{#hasCategories}} 42 |

{{strings/hierarchyPage/categoriesTitle}}

43 |
    44 | {{#categories}} 45 |
  • {{title}}
  • 46 | {{/categories}} 47 |
48 | {{/hasCategories}} 49 |
50 | {{/hasProtocolsOrCategories}} 51 |
52 | 55 | 65 |
66 |
67 | 68 | 69 | 70 | Section Classes 71 | {{#hasClasses}} 72 | 77 | {{/hasClasses}} 78 | EndSection 79 | 80 | Section Navigation 81 | Index 82 | EndSection -------------------------------------------------------------------------------- /Documentation/Templates/html/img/button_bar_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplegeo/SimpleGeo.framework/70d92d014a00df4b84e1e57ef60c3da230b8038f/Documentation/Templates/html/img/button_bar_background.png -------------------------------------------------------------------------------- /Documentation/Templates/html/img/disclosure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplegeo/SimpleGeo.framework/70d92d014a00df4b84e1e57ef60c3da230b8038f/Documentation/Templates/html/img/disclosure.png -------------------------------------------------------------------------------- /Documentation/Templates/html/img/disclosure_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplegeo/SimpleGeo.framework/70d92d014a00df4b84e1e57ef60c3da230b8038f/Documentation/Templates/html/img/disclosure_open.png -------------------------------------------------------------------------------- /Documentation/Templates/html/img/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplegeo/SimpleGeo.framework/70d92d014a00df4b84e1e57ef60c3da230b8038f/Documentation/Templates/html/img/help.png -------------------------------------------------------------------------------- /Documentation/Templates/html/img/hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplegeo/SimpleGeo.framework/70d92d014a00df4b84e1e57ef60c3da230b8038f/Documentation/Templates/html/img/hierarchy.png -------------------------------------------------------------------------------- /Documentation/Templates/html/img/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplegeo/SimpleGeo.framework/70d92d014a00df4b84e1e57ef60c3da230b8038f/Documentation/Templates/html/img/home.png -------------------------------------------------------------------------------- /Documentation/Templates/html/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplegeo/SimpleGeo.framework/70d92d014a00df4b84e1e57ef60c3da230b8038f/Documentation/Templates/html/img/logo.png -------------------------------------------------------------------------------- /Documentation/Templates/html/img/title_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplegeo/SimpleGeo.framework/70d92d014a00df4b84e1e57ef60c3da230b8038f/Documentation/Templates/html/img/title_background.png -------------------------------------------------------------------------------- /Documentation/Templates/html/index-template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{page/title}} 5 | 6 | 7 | {{#strings/appledocData}}{{/strings/appledocData}} 8 | 9 | 10 |
11 | 17 | 20 |
21 |
22 |
23 |
24 | {{#indexDescription}} 25 |
26 | {{#comment}} 27 | {{#hasLongDescription}} 28 | {{#longDescription}}{{#components}}{{&htmlValue}}{{/components}}{{/longDescription}} 29 | {{/hasLongDescription}} 30 | {{/comment}} 31 |
32 | {{/indexDescription}} 33 | 34 | {{#hasClasses}} 35 |
36 |

{{strings/indexPage/classesTitle}}

37 |
    38 | {{#classes}} 39 |
  • {{title}}
  • 40 | {{/classes}} 41 |
42 |
43 | {{/hasClasses}} 44 | 45 | {{#hasProtocolsOrCategories}} 46 |
47 | {{#hasProtocols}} 48 |

{{strings/indexPage/protocolsTitle}}

49 |
    50 | {{#protocols}} 51 |
  • {{title}}
  • 52 | {{/protocols}} 53 |
54 | {{/hasProtocols}} 55 | {{#hasCategories}} 56 |

{{strings/indexPage/categoriesTitle}}

57 |
    58 | {{#categories}} 59 |
  • {{title}}
  • 60 | {{/categories}} 61 |
62 | {{/hasCategories}} 63 |
64 | {{/hasProtocolsOrCategories}} 65 |
66 | 69 | 79 |
80 |
81 | 82 | 83 | 84 | Section Navigation 85 | Hierarchy 86 | EndSection -------------------------------------------------------------------------------- /Documentation/appledoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplegeo/SimpleGeo.framework/70d92d014a00df4b84e1e57ef60c3da230b8038f/Documentation/appledoc -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010, SimpleGeo Inc. 2 | ## All rights reserved. 3 | 4 | _Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:_ 5 | 6 | - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | - 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. 8 | - Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 9 | 10 | 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 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. 11 | -------------------------------------------------------------------------------- /Project/Mac/Config/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // Debug.xcconfig 3 | // SimpleGeo 4 | // 5 | 6 | #include "Shared.xcconfig" 7 | 8 | COPY_PHASE_STRIP = NO 9 | GCC_ENABLE_FIX_AND_CONTINUE = YES 10 | GCC_DYNAMIC_NO_PIC = NO 11 | GCC_OPTIMIZATION_LEVEL = 0 12 | -------------------------------------------------------------------------------- /Project/Mac/Config/Release.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // Release.xcconfig 3 | // SimpleGeo 4 | // 5 | 6 | #include "Shared.xcconfig" 7 | 8 | DEBUG_INFORMATION_FORMAT = dwarf-with-dsym 9 | -------------------------------------------------------------------------------- /Project/Mac/Config/Shared.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // Shared.xcconfig 3 | // SimpleGeo 4 | // 5 | 6 | #include "../../Shared/Config/Global.xcconfig" 7 | 8 | INSTALL_PATH = @executable_path/../Frameworks 9 | MACOSX_DEPLOYMENT_TARGET = 10.5 10 | INFOPLIST_FILE = SimpleGeo-Info.plist 11 | GCC_PREFIX_HEADER = SimpleGeo-Prefix.pch -------------------------------------------------------------------------------- /Project/Mac/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_TARGET=SimpleGeo 2 | TEST_TARGET=Tests 3 | SDK=macosx10.6 4 | COMMAND=xcodebuild 5 | 6 | default: 7 | $(COMMAND) -target $(BUILD_TARGET) -configuration Release -sdk $(SDK) build 8 | 9 | # If you need to clean a specific target/configuration: $(COMMAND) -target $(TARGET) -configuration DebugOrRelease -sdk $(SDK) clean 10 | clean: 11 | -rm -rf Build/ 12 | 13 | test:: 14 | GHUNIT_AUTORUN=1 GHUNIT_AUTOEXIT=1 $(COMMAND) -target $(TEST_TARGET) -configuration Debug -sdk $(SDK) build 15 | -------------------------------------------------------------------------------- /Project/Mac/SimpleGeo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.simplegeo.${PRODUCT_NAME:rfc1034Identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 2.0.1 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | ${DYLIB_CURRENT_VERSION} 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Project/Mac/SimpleGeo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SimpleGeo' target in the 'SimpleGeo' project. 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | 10 | #define SGLog NSLog -------------------------------------------------------------------------------- /Project/Mac/Tests/Classes/GHUnitTestMain.m: -------------------------------------------------------------------------------- 1 | // 2 | // GHUnitTestMain.m 3 | // GHUnit 4 | // 5 | // Created by Gabriel Handford on 2/22/09. 6 | // Copyright 2009. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | #import 33 | #import 34 | 35 | // Default exception handler 36 | void exceptionHandler(NSException *exception) { 37 | NSLog(@"%@\n%@", [exception reason], GHUStackTraceFromException(exception)); 38 | } 39 | 40 | int main(int argc, char *argv[]) { 41 | 42 | /** 43 | For debugging: 44 | Go into the "Get Info" contextual menu of your (test) executable (inside the "Executables" group in the left panel of XCode). 45 | Then go in the "Arguments" tab. You can add the following environment variables: 46 | 47 | Default: Set to: 48 | NSDebugEnabled NO "YES" 49 | NSZombieEnabled NO "YES" 50 | NSDeallocateZombies NO "YES" 51 | NSHangOnUncaughtException NO "YES" 52 | 53 | NSEnableAutoreleasePool YES "NO" 54 | NSAutoreleaseFreedObjectCheckEnabled NO "YES" 55 | NSAutoreleaseHighWaterMark 0 non-negative integer 56 | NSAutoreleaseHighWaterResolution 0 non-negative integer 57 | 58 | For info on these varaiables see NSDebug.h; http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html 59 | 60 | For malloc debugging see: http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html 61 | */ 62 | 63 | NSSetUncaughtExceptionHandler(&exceptionHandler); 64 | 65 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 66 | 67 | // Register any special test case classes 68 | //[[GHTesting sharedInstance] registerClassName:@"GHSpecialTestCase"]; 69 | 70 | int retVal = 0; 71 | // If GHUNIT_CLI is set we are using the command line interface and run the tests 72 | // Otherwise load the GUI app 73 | if (getenv("GHUNIT_CLI")) { 74 | retVal = [GHTestRunner run]; 75 | } else { 76 | // To run all tests (from ENV) 77 | GHTestApp *app = [[GHTestApp alloc] init]; 78 | // To run a different test suite: 79 | //GHTestSuite *suite = [GHTestSuite suiteWithTestFilter:@"GHSlowTest,GHAsyncTestCaseTest"]; 80 | //GHTestApp *app = [[GHTestApp alloc] initWithSuite:suite]; 81 | // Or set global: 82 | //GHUnitTest = @"GHSlowTest"; 83 | [NSApp run]; 84 | [app release]; 85 | } 86 | [pool release]; 87 | return retVal; 88 | } 89 | -------------------------------------------------------------------------------- /Project/Mac/Tests/Classes/SGGeometryTest.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGGeometryTest.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import 32 | #import "SGGeometry.h" 33 | #import "SGPoint.h" 34 | #import "SGPolygon.h" 35 | #import "SGMultiPolygon.h" 36 | #import "SGEnvelope.h" 37 | 38 | @interface SGGeometryTest : GHTestCase { } 39 | @end 40 | 41 | @implementation SGGeometryTest 42 | 43 | - (void)testGeometryForPolygonContainsPoint 44 | { 45 | SGPolygon *singlePolygon = [SGPolygon polygonWithRings: 46 | [NSArray arrayWithObjects: 47 | [NSArray arrayWithObjects: 48 | [SGPoint pointWithLat:2.0 lon:2.0], 49 | [SGPoint pointWithLat:0.0 lon:2.0], 50 | [SGPoint pointWithLat:0.0 lon:0.0], 51 | [SGPoint pointWithLat:2.0 lon:0.0], 52 | [SGPoint pointWithLat:2.0 lon:2.0], 53 | nil], 54 | [NSArray arrayWithObjects: 55 | [SGPoint pointWithLat:1.0 lon:1.0], 56 | [SGPoint pointWithLat:0.0 lon:1.0], 57 | [SGPoint pointWithLat:0.0 lon:0.0], 58 | [SGPoint pointWithLat:1.0 lon:0.0], 59 | [SGPoint pointWithLat:1.0 lon:1.0], 60 | nil], 61 | nil] 62 | ]; 63 | SGPoint *testPoint1 = [SGPoint pointWithLat:3.0 lon:3.0]; // outside 64 | SGPoint *testPoint2 = [SGPoint pointWithLat:1.5 lon:3.0]; // outside but in scope 65 | SGPoint *testPoint3 = [SGPoint pointWithLat:1.5 lon:1.5]; // inside 66 | SGPoint *testPoint4 = [SGPoint pointWithLat:0.5 lon:0.5]; // inside, but in hole 67 | BOOL contains1 = [singlePolygon containsPoint:testPoint1]; 68 | BOOL contains2 = [singlePolygon containsPoint:testPoint2]; 69 | BOOL contains3 = [singlePolygon containsPoint:testPoint3]; 70 | BOOL contains4 = [singlePolygon containsPoint:testPoint4]; 71 | GHAssertEquals(contains1, NO, nil); 72 | GHAssertEquals(contains2, NO, nil); 73 | GHAssertEquals(contains3, YES, nil); 74 | GHAssertEquals(contains4, NO, nil); 75 | } 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /Project/Mac/Tests/Classes/SimpleGeoTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleGeoTest.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import 32 | #import "SimpleGeo.h" 33 | #import "SimpleGeoTestSettings.h" 34 | 35 | @interface SimpleGeoTest : GHAsyncTestCase 36 | { 37 | SGFailureBlock failureBlock; 38 | } 39 | @property (nonatomic, readonly) SGFailureBlock failureBlock; 40 | 41 | // Test clients 42 | - (SimpleGeo *)client; 43 | - (SimpleGeo *)placesClient:(NSString *)version; 44 | 45 | // Test objects 46 | - (SGPoint *)point; 47 | - (SGPoint *)outlierPoint; 48 | - (SGEnvelope *)envelope; 49 | 50 | // Test callbacks 51 | - (SGCallback *)delegateCallbacks; 52 | 53 | // Test delegate methods 54 | - (void)requestDidSucceed:(NSObject *)response; 55 | - (void)requestDidFail:(NSError *)error; 56 | 57 | // Check Methods 58 | - (void)removeAPISpecificKeys:(NSMutableDictionary *)object; 59 | - (void)checkSGFeatureConversion:(id)response 60 | object:(SGGeoObject *)object; 61 | - (void)checkSGCollectionConversion:(id)response 62 | type:(SGCollectionType)type; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /Project/Mac/Tests/RunTests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # If we aren't running from the command line, then exit 4 | if [ "$GHUNIT_CLI" = "" ] && [ "$GHUNIT_AUTORUN" = "" ]; then 5 | exit 0 6 | fi 7 | 8 | export DYLD_ROOT_PATH="$SDKROOT" 9 | export DYLD_FRAMEWORK_PATH="$CONFIGURATION_BUILD_DIR" 10 | export IPHONE_SIMULATOR_ROOT="$SDKROOT" 11 | 12 | export MallocScribble=YES 13 | export MallocPreScribble=YES 14 | export MallocGuardEdges=YES 15 | export MallocStackLogging=YES 16 | export MallocStackLoggingNoCompact=YES 17 | 18 | export NSDebugEnabled=YES 19 | export NSZombieEnabled=YES 20 | export NSDeallocateZombies=NO 21 | export NSHangOnUncaughtException=YES 22 | export NSAutoreleaseFreedObjectCheckEnabled=YES 23 | 24 | export DYLD_FRAMEWORK_PATH="$CONFIGURATION_BUILD_DIR" 25 | RUN_CMD="$TARGET_BUILD_DIR/$EXECUTABLE_PATH -RegisterForSystemEvents" 26 | 27 | echo "Running: $RUN_CMD" 28 | $RUN_CMD 29 | RETVAL=$? 30 | 31 | if [ -n "$WRITE_JUNIT_XML" ]; then 32 | MY_TMPDIR=`/usr/bin/getconf DARWIN_USER_TEMP_DIR` 33 | RESULTS_DIR="${MY_TMPDIR}test-results" 34 | 35 | if [ -d "$RESULTS_DIR" ]; then 36 | `$CP -r "$RESULTS_DIR" "$BUILD_DIR" && rm -r "$RESULTS_DIR"` 37 | fi 38 | fi 39 | 40 | exit $RETVAL 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Project/Mac/Tests/SimpleGeoTestSettings-Example.h: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleGeoTest.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | /* AUTHENTICATION */ 32 | 33 | #define SGTestKey @"" 34 | #define SGTestSecret @"" 35 | #define SGTestApiURL @"https://api.simplegeo.com" 36 | 37 | /* REQUEST HANDLING */ 38 | 39 | #define SGTestTimeout 5.0 40 | 41 | /* LOCATIONS */ 42 | 43 | #define SGTestLatitude 37.772445 44 | #define SGTestLongitude -122.405698 45 | #define SGTestAddress @"41 Decatur Street, San Francisco, CA" 46 | #define SGTestEnvelopeNorth 37.79 47 | #define SGTestEnvelopeWest -122.42 48 | #define SGTestEnvelopeSouth 37.75 49 | #define SGTestEnvelopeEast -122.38 50 | 51 | /* NEARBY */ 52 | 53 | #define SGTestRadius 1000.0 // meters 54 | #define SGTestLimit 1 55 | 56 | /* STORAGE LAYER */ 57 | 58 | #define SGTestLayer @"com.simplegeo.testing.ios" -------------------------------------------------------------------------------- /Project/Mac/Tests/Tests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.simplegeo.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | LSMinimumSystemVersion 22 | ${MACOSX_DEPLOYMENT_TARGET} 23 | NSPrincipalClass 24 | NSApplication 25 | 26 | 27 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Params/SGTypes.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGTypes.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #pragma mark Context Filters 32 | 33 | typedef NSString * SGContextFilter; 34 | extern SGContextFilter const SGContextFilterQuery; 35 | extern SGContextFilter const SGContextFilterFeatures; 36 | extern SGContextFilter const SGContextFilterWeather; 37 | extern SGContextFilter const SGContextFilterAddress; 38 | extern SGContextFilter const SGContextFilterDemographics; 39 | extern SGContextFilter const SGContextFilterIntersections; 40 | 41 | #pragma mark Storage Property Types 42 | 43 | typedef NSString * SGStoredPropertyType; 44 | extern SGStoredPropertyType const SGStoredPropertyTypeBoolean; 45 | extern SGStoredPropertyType const SGStoredPropertyTypeNumber; 46 | extern SGStoredPropertyType const SGStoredPropertyTypeString; 47 | 48 | #pragma mark Storage Sort Orders 49 | 50 | typedef NSString * SGSortOrder; 51 | extern SGSortOrder const SGSortOrderDistance; 52 | extern SGSortOrder const SGSortOrderCreatedAscending; 53 | extern SGSortOrder const SGSortOrderCreatedDescending; 54 | extern SGSortOrder const SGSortOrderPropertyAscending; 55 | extern SGSortOrder const SGSortOrderPropertyDescending; 56 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Params/SGTypes.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGTypes.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGTypes.h" 32 | 33 | #pragma mark Context Filters 34 | 35 | SGContextFilter const SGContextFilterQuery = @"query"; 36 | SGContextFilter const SGContextFilterFeatures = @"features"; 37 | SGContextFilter const SGContextFilterWeather = @"weather"; 38 | SGContextFilter const SGContextFilterAddress = @"address"; 39 | SGContextFilter const SGContextFilterDemographics = @"demographics"; 40 | SGContextFilter const SGContextFilterIntersections = @"intersections"; 41 | 42 | #pragma mark Storage Property Types 43 | 44 | SGStoredPropertyType const SGStoredPropertyTypeBoolean = @"boolean"; 45 | SGStoredPropertyType const SGStoredPropertyTypeNumber = @"number"; 46 | SGStoredPropertyType const SGStoredPropertyTypeString = @"string"; 47 | 48 | #pragma mark Storage Sort Orders 49 | 50 | SGSortOrder const SGSortOrderDistance = @""; 51 | SGSortOrder const SGSortOrderCreatedAscending = @"created"; 52 | SGSortOrder const SGSortOrderCreatedDescending = @"-created"; 53 | SGSortOrder const SGSortOrderPropertyAscending = @"property"; 54 | SGSortOrder const SGSortOrderPropertyDescending = @"-property"; 55 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Queries/SGContextQuery.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGContextQuery.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGQuery.h" 32 | 33 | /** 34 | * An SGContextQuery object stores query information for a SimpleGeo Context API request. 35 | * To make a Context request, create an SGContextQuery object and call [SimpleGeo getContextForQuery:callback:]. 36 | * 37 | * - Specify *filters* to request only specific parts of a full Context response. 38 | * - Specify *feature categories* to limit the types of polygons returned in the response. 39 | */ 40 | @interface SGContextQuery : SGQuery 41 | { 42 | @private 43 | NSArray *featureCategories; 44 | NSArray *featureSubcategories; 45 | NSArray *filters; 46 | NSArray *acsTableIDs; 47 | } 48 | 49 | /// Feature categories to include in the Context response 50 | @property (nonatomic, retain) NSArray *featureCategories; 51 | 52 | /// Feature subcategories to include in the Context response 53 | @property (nonatomic, retain) NSArray *featureSubcategories; 54 | 55 | /// Filters for returning only part of a Context response 56 | @property (nonatomic, retain) NSArray *filters; 57 | 58 | /// ACS [demographics tables](https://simplegeo.com/docs/api-endpoints/simplegeo-context#demographics) to include in the Context response; 59 | @property (nonatomic, retain) NSArray *acsTableIDs; 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Queries/SGContextQuery.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGContextQuery.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGContextQuery.h" 32 | #import "SGPreprocessorMacros.h" 33 | 34 | @implementation SGContextQuery 35 | 36 | @synthesize featureCategories, featureSubcategories, filters, acsTableIDs; 37 | 38 | #pragma mark - 39 | #pragma mark Memory 40 | 41 | - (void)dealloc 42 | { 43 | SG_RELEASE(featureCategories); 44 | SG_RELEASE(featureSubcategories); 45 | SG_RELEASE(filters); 46 | SG_RELEASE(acsTableIDs); 47 | [super dealloc]; 48 | } 49 | 50 | @end -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Queries/SGNearbyQuery.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGNearbyQuery.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGQuery.h" 32 | 33 | /** 34 | * SGNearbyQuery serves as an abstract class for a nearby API request. 35 | * With an SGNearby query, you may: 36 | * 37 | * - Constrain results with a *radius* 38 | * - Limit the number of results with a *limit* 39 | * 40 | * @warning *Important:* You should never create an SGNearbyQuery directly, 41 | * but instead create an SGContextQuery or SGStorageQuery object (both are subclasses of SGNearbyQuery). 42 | */ 43 | @interface SGNearbyQuery : SGQuery 44 | { 45 | @private 46 | double radius; 47 | int limit; 48 | } 49 | 50 | /// Max radius to query 51 | @property (nonatomic, assign) double radius; 52 | 53 | /// Limit for the number of items returned 54 | @property (nonatomic, assign) int limit; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Queries/SGNearbyQuery.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGNearbyQuery.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGNearbyQuery.h" 32 | #import "SGTypes.h" 33 | 34 | @implementation SGNearbyQuery 35 | 36 | @synthesize radius, limit; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Queries/SGPlacesQuery.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGPlacesQuery.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGNearbyQuery.h" 32 | 33 | /** 34 | * An SGContextQuery object stores query information for a SimpleGeo Places API request. 35 | * To make a Places request, create an SGPlacesQuery object and call [SimpleGeo getPlacesForQuery:callback:]. 36 | * 37 | * - Specify a *search string* to simultaneously search place names, tags, and categories. 38 | * - Specify *categories* to constrain results to particular categories of Places. 39 | */ 40 | @interface SGPlacesQuery : SGNearbyQuery 41 | { 42 | @private 43 | NSString *searchString; 44 | NSArray *categories; 45 | } 46 | 47 | /// Seach string for query 48 | @property (nonatomic, retain) NSString *searchString; 49 | 50 | /// Categories to query 51 | @property (nonatomic, retain) NSArray *categories; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Queries/SGPlacesQuery.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGPlacesQuery.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGPlacesQuery.h" 32 | #import "SGPreprocessorMacros.h" 33 | 34 | @implementation SGPlacesQuery 35 | 36 | @synthesize searchString, categories; 37 | 38 | #pragma mark - 39 | #pragma mark Memory 40 | 41 | - (void)dealloc 42 | { 43 | SG_RELEASE(searchString); 44 | SG_RELEASE(categories); 45 | [super dealloc]; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Queries/SGQuery.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGQuery.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | @class SGPoint; 32 | @class SGEnvelope; 33 | 34 | /** 35 | * SGQuery serves as an abstract class for a complex SimpleGeo API request. 36 | * Queries may be created with a point, envelope, or address and appended with additional constraints. 37 | * 38 | * @warning *Important:* You should never create an SGQuery object directly; 39 | * rather, you should create an SGContextQuery, SGPlacesQuery, or SGStorageQuery object instead. 40 | */ 41 | @interface SGQuery : NSObject 42 | { 43 | @private 44 | SGPoint *point; 45 | NSString *address; 46 | SGEnvelope *envelope; 47 | } 48 | 49 | /// Point for a point-based API query 50 | @property (nonatomic, readonly) SGPoint *point; 51 | 52 | /// Address for an address-based API query 53 | @property (nonatomic, readonly) NSString *address; 54 | 55 | /// Envelope for a bounding box API query 56 | @property (nonatomic, readonly) SGEnvelope *envelope; 57 | 58 | #pragma mark - 59 | #pragma mark Instantiation 60 | 61 | /** 62 | * Create a non-geo search query 63 | */ 64 | + (id)query; 65 | 66 | /** 67 | * Create a point-based API query 68 | * @param point Point 69 | */ 70 | + (id)queryWithPoint:(SGPoint *)point; 71 | 72 | /** 73 | * Create an address-based API query 74 | * @param address Address 75 | */ 76 | + (id)queryWithAddress:(NSString *)address; 77 | 78 | /** 79 | * Create an a bounding box API query 80 | * @param envelope Bounding box 81 | */ 82 | + (id)queryWithEnvelope:(SGEnvelope *)envelope; 83 | 84 | /** 85 | * Construct a point-based API query 86 | * @param point Point 87 | */ 88 | - (id)initWithPoint:(SGPoint *)point; 89 | 90 | /** 91 | * Construct an address-based API query 92 | * @param address Address 93 | */ 94 | - (id)initWithAddress:(NSString *)address; 95 | 96 | /** 97 | * Construct a bounding box API query 98 | * @param envelope Bounding box 99 | */ 100 | - (id)initWithEnvelope:(SGEnvelope *)envelope; 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Queries/SGQuery.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGQuery.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGQuery.h" 32 | #import "SGPoint.h" 33 | #import "SGEnvelope.h" 34 | #import "SGPreprocessorMacros.h" 35 | 36 | @implementation SGQuery 37 | 38 | @synthesize point, address, envelope; 39 | 40 | #pragma mark - 41 | #pragma mark Instantiation 42 | 43 | + (id)query 44 | { 45 | return SG_AUTORELEASE([[self alloc] init]); 46 | } 47 | 48 | + (id)queryWithPoint:(SGPoint *)point 49 | { 50 | return SG_AUTORELEASE([[self alloc] initWithPoint:point]); 51 | } 52 | 53 | + (id)queryWithAddress:(NSString *)address 54 | { 55 | return SG_AUTORELEASE([[self alloc] initWithAddress:address]); 56 | } 57 | 58 | + (id)queryWithEnvelope:(SGEnvelope *)envelope 59 | { 60 | return SG_AUTORELEASE([[self alloc] initWithEnvelope:envelope]); 61 | } 62 | 63 | - (id)initWithPoint:(SGPoint *)aPoint 64 | { 65 | self = [self init]; 66 | if (self) { 67 | point = SG_RETAIN(aPoint); 68 | } 69 | return self; 70 | } 71 | 72 | - (id)initWithAddress:(NSString *)anAddress 73 | { 74 | self = [self init]; 75 | if (self) { 76 | address = SG_RETAIN(anAddress); 77 | } 78 | return self; 79 | } 80 | 81 | - (id)initWithEnvelope:(SGEnvelope *)anEnvelope 82 | { 83 | self = [self init]; 84 | if (self) { 85 | envelope = SG_RETAIN(anEnvelope); 86 | } 87 | return self; 88 | } 89 | 90 | #pragma mark - 91 | #pragma mark Memory 92 | 93 | - (void)dealloc { 94 | SG_RELEASE(point); 95 | SG_RELEASE(address); 96 | SG_RELEASE(envelope); 97 | [super dealloc]; 98 | } 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Services/SimpleGeo+Context.h: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleGeo+Context.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SimpleGeo.h" 32 | @class SGContextQuery; 33 | @class SGCallback; 34 | 35 | /** 36 | * Client support for Context API 37 | */ 38 | @interface SimpleGeo (Context) 39 | 40 | #pragma mark - 41 | #pragma mark Requests 42 | 43 | /** 44 | * Get Context matching an SGContextQuery 45 | * @param query Query for the request 46 | * @param callback Request callback 47 | */ 48 | - (void)getContextForQuery:(SGContextQuery *)query 49 | callback:(SGCallback *)callback; 50 | 51 | /** 52 | * Get a feature with a specific handle. 53 | * If requesting a place, please note: this method only works 54 | * for Places v1.0 (the old SimpleGeo dataset). To request a place 55 | * from the new Factual dataset, use getPlace:callback: 56 | * @param handle Feature handle 57 | * @param zoom Zoom (complexity of returned geometry) (optional) 58 | * @param callback Request callback 59 | */ 60 | - (void)getFeatureWithHandle:(NSString *)handle 61 | zoom:(NSNumber *)zoom 62 | callback:(SGCallback *)callback; 63 | 64 | /** 65 | * Get annotations attached to a feature 66 | * @param handle Feature handle 67 | * @param callback Request callback 68 | */ 69 | - (void)getAnnotationsForFeature:(NSString *)handle 70 | callback:(SGCallback *)callback; 71 | 72 | /** 73 | * Search ACS demographic tables 74 | * @param searchString Search string 75 | * @param callback Request callback 76 | */ 77 | - (void)searchDemographicsTables:(NSString *)searchString 78 | callback:(SGCallback *)callback; 79 | 80 | #pragma mark - 81 | #pragma mark Manipulations 82 | 83 | /** 84 | * Annotate a feature 85 | * @param handle Feature handle 86 | * @param annotation Annotation list 87 | * @param isPrivate Annotation privacy 88 | * @param callback Request callback 89 | */ 90 | - (void)annotateFeature:(NSString *)handle 91 | withAnnotation:(NSDictionary *)annotation 92 | isPrivate:(BOOL)isPrivate 93 | callback:(SGCallback *)callback; 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Services/SimpleGeo+Places.h: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleGeo+Places.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SimpleGeo.h" 32 | @class SGPlacesQuery; 33 | @class SGPlace; 34 | @class SGCallback; 35 | 36 | /** 37 | * Client support for Places API 38 | */ 39 | @interface SimpleGeo (Places) 40 | 41 | #pragma mark - 42 | #pragma mark Requests 43 | 44 | /** 45 | * Request a place by its ID. 46 | * Note: this method only works with Places > v1.2 (the Factual dataset). 47 | * If working with Places 1.0 (the old SimpleGeo dataset), 48 | * use getFeatureWithHandle:zoom:callback: 49 | * @param identifier Factual place ID 50 | * @param callback Request callback 51 | */ 52 | - (void)getPlace:(NSString *)identifier 53 | callback:(SGCallback *)callback; 54 | 55 | /** 56 | * Find places matching an SGPlacesQuery 57 | * @param query Request query 58 | * @param callback Request callback 59 | */ 60 | - (void)getPlacesForQuery:(SGPlacesQuery *)query 61 | callback:(SGCallback *)callback; 62 | 63 | #pragma mark - 64 | #pragma mark Manipulations 65 | 66 | /** 67 | * Add a feature to the Places database 68 | * @param place Place to add 69 | * @param callback Request callback 70 | */ 71 | - (void)addPlace:(SGPlace *)place 72 | callback:(SGCallback *)callback; 73 | 74 | /** 75 | * Update a place in the Places database 76 | * @param identifier Place ID 77 | * @param place The updated Place 78 | * @param callback Request callback 79 | */ 80 | - (void)updatePlace:(NSString *)identifier 81 | withPlace:(SGPlace *)place 82 | callback:(SGCallback *)callback; 83 | 84 | /** 85 | * Delete a place from the Places database 86 | * @param identifier Place ID 87 | * @param callback Request callback 88 | */ 89 | - (void)deletePlace:(NSString *)identifier 90 | callback:(SGCallback *)callback; 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/Services/SimpleGeo+Places.m: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleGeo+Places.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SimpleGeo+Places.h" 32 | #import "SimpleGeo+Internal.h" 33 | #import "SGPlacesQuery.h" 34 | #import "SGPlace.h" 35 | #import "SGJSONKit.h" 36 | #import "SGPreprocessorMacros.h" 37 | 38 | @implementation SimpleGeo (Places) 39 | 40 | #pragma mark - 41 | #pragma mark Requests 42 | 43 | - (void)getPlace:(NSString *)identifier 44 | callback:(SGCallback *)callback 45 | { 46 | [self sendHTTPRequest:@"GET" 47 | toFile:[NSString stringWithFormat:@"/places/%@", identifier] 48 | withParams:nil 49 | version:self.placesVersion 50 | callback:callback]; 51 | } 52 | 53 | - (void)getPlacesForQuery:(SGPlacesQuery *)query 54 | callback:(SGCallback *)callback 55 | { 56 | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; 57 | [parameters setValue:query.address forKey:@"address"]; 58 | [parameters setValue:query.searchString forKey:@"q"]; 59 | [parameters setValue:query.categories forKey:@"category"]; 60 | if (query.radius > 0.0f) { 61 | NSString *radiusString; 62 | if ([self.placesVersion isEqual:@"1.0"]) radiusString = [NSString stringWithFormat:@"%f", query.radius]; 63 | else radiusString = [NSString stringWithFormat:@"%d", (int)query.radius]; 64 | [parameters setValue:radiusString forKey:@"radius"]; 65 | } 66 | if (query.limit > 0) { 67 | [parameters setValue:[NSString stringWithFormat:@"%d", query.limit] forKey:@"limit"]; 68 | } 69 | 70 | [self sendHTTPRequest:@"GET" 71 | toFile:[NSString stringWithFormat:@"/places/%@",[self baseEndpointForQuery:query]] 72 | withParams:parameters 73 | version:self.placesVersion 74 | callback:callback]; 75 | } 76 | 77 | #pragma mark - 78 | #pragma mark Manipulations (v1.0) 79 | 80 | - (void)addPlace:(SGPlace *)place 81 | callback:(SGCallback *)callback 82 | { 83 | NSString *urlString = [NSString stringWithFormat:@"%@/%@/places", 84 | self.apiURL, self.placesVersion, nil]; 85 | 86 | [self sendHTTPRequest:@"POST" 87 | toURL:[NSURL URLWithString:urlString] 88 | withParams:[[place asGeoJSON] JSONData] 89 | callback:callback]; 90 | } 91 | 92 | - (void)updatePlace:(NSString *)identifier 93 | withPlace:(SGPlace *)place 94 | callback:(SGCallback *)callback 95 | { 96 | [self sendHTTPRequest:@"POST" 97 | toFile:[NSString stringWithFormat:@"/features/%@", identifier] 98 | withParams:[[place asGeoJSON] JSONData] 99 | version:self.placesVersion 100 | callback:callback]; 101 | } 102 | 103 | - (void)deletePlace:(NSString *)identifier 104 | callback:(SGCallback *)callback 105 | { 106 | [self sendHTTPRequest:@"DELETE" 107 | toFile:[NSString stringWithFormat:@"/features/%@", identifier] 108 | withParams:nil 109 | version:self.placesVersion 110 | callback:callback]; 111 | } 112 | 113 | @end 114 | 115 | SG_CATEGORY(SimpleGeoPlaces) 116 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/SimpleGeo+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleGeo+Internal.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | @class SimpleGeo; 32 | 33 | @interface SimpleGeo (Internal) 34 | 35 | #pragma mark - 36 | #pragma mark Request 37 | 38 | /** 39 | * Send an API request 40 | * @param type Request type 41 | * @param file Request URL 42 | * @param params Request parameters 43 | * @param version API version 44 | * @param callback Request callback 45 | */ 46 | - (void)sendHTTPRequest:(NSString *)type 47 | toFile:(NSString *)file 48 | withParams:(id)params 49 | version:(NSString *)version 50 | callback:(SGCallback *)callback; 51 | 52 | #pragma mark - 53 | #pragma mark Helpers 54 | 55 | /** 56 | * Generate the base endpoint for a query, depending 57 | * on whether it is a point, address, or envelope query 58 | * @param query Query object 59 | */ 60 | - (NSString *)baseEndpointForQuery:(SGQuery *)query; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/SimpleGeo.h: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleGeo.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | // Requests 32 | #import "SGHTTPClient.h" 33 | 34 | // Geometry 35 | #import "SGGeometry.h" 36 | #import "SGPoint.h" 37 | #import "SGEnvelope.h" 38 | #import "SGPolygon.h" 39 | #import "SGMultiPolygon.h" 40 | 41 | #if TARGET_OS_IPHONE 42 | // Mapkit Additions 43 | #import "SGGeometry+Mapkit.h" 44 | #import "SGPoint+Mapkit.h" 45 | #import "SGPolygon+Mapkit.h" 46 | #import "SGMultiPolygon+Mapkit.h" 47 | #import "SGEnvelope+Mapkit.h" 48 | #endif 49 | 50 | // Objects 51 | #import "SGAddress.h" 52 | #import "SGPlacemark.h" 53 | #import "SGContext.h" 54 | #import "SGLayer.h" 55 | 56 | // Query Objects 57 | #import "SGContextQuery.h" 58 | #import "SGPlacesQuery.h" 59 | #import "SGStorageQuery.h" 60 | 61 | // Geo Objects 62 | #import "SGGeoObject.h" 63 | #import "SGFeature.h" 64 | #import "SGPlace.h" 65 | #import "SGStoredRecord.h" 66 | 67 | // Helpers 68 | #import "SGTypes.h" 69 | #import "SGCategories.h" 70 | #import "FactualCategories.h" 71 | #import "NSArray+SGCollection.h" 72 | #import "NSDictionary+Classifier.h" 73 | 74 | /** 75 | A SimpleGeo object acts as a client for all API requests. 76 | A SimpleGeo object is created with SimpleGeo credentials (an OAuth consumer key and secret). 77 | All API requests are made by calling methods in this class. 78 | 79 | // Create the client 80 | SimpleGeo *client = [SimpleGeo clientWithConsumerKey:@"key" 81 | consumerSecret:@"secret"]; 82 | // Example request 83 | [client getContextForQuery:query callback:callback]; 84 | */ 85 | @interface SimpleGeo: SGHTTPClient 86 | { 87 | @private 88 | NSString *storageVersion; 89 | NSString *contextVersion; 90 | NSString *placesVersion; 91 | NSString *apiURL; 92 | } 93 | 94 | /// API version for SimpleGeo Storage 95 | @property (nonatomic, retain) NSString *storageVersion; 96 | 97 | /// API version for SimpleGeo Context 98 | @property (nonatomic, retain) NSString *contextVersion; 99 | 100 | /// API version for SimpleGeo Places 101 | @property (nonatomic, retain) NSString *placesVersion; 102 | 103 | /// API URL 104 | @property (nonatomic, retain) NSString *apiURL; 105 | 106 | #pragma mark - 107 | #pragma mark Instantiation 108 | 109 | /** 110 | * Create a client for making requests 111 | * @param consumerKey OAuth consumer key 112 | * @param consumerSecret OAuth consumer secret 113 | */ 114 | + (SimpleGeo *)clientWithConsumerKey:(NSString *)consumerKey 115 | consumerSecret:(NSString *)consumerSecret; 116 | 117 | #pragma mark - 118 | #pragma mark Requests 119 | 120 | /** 121 | * Get the overall list of SimpleGeo categories 122 | * @param callback Request callback 123 | */ 124 | - (void)getCategoriesWithCallback:(SGCallback *)callback; 125 | 126 | @end 127 | 128 | // Services 129 | #import "SimpleGeo+Context.h" 130 | #import "SimpleGeo+Places.h" 131 | #import "SimpleGeo+Storage.h" 132 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Client/SimpleGeo.m: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleGeo.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SimpleGeo.h" 32 | #import "SimpleGeo+Internal.h" 33 | #import "SGPreprocessorMacros.h" 34 | 35 | @implementation SimpleGeo 36 | 37 | @synthesize storageVersion, contextVersion, placesVersion, apiURL; 38 | 39 | #pragma mark - 40 | #pragma mark Instantiation 41 | 42 | - (id)initWithConsumerKey:(NSString *)key 43 | consumerSecret:(NSString *)secret 44 | { 45 | self = [super initWithConsumerKey:key consumerSecret:secret]; 46 | if (self) { 47 | apiURL = SG_RETAIN(@"https://api.simplegeo.com"); 48 | storageVersion = SG_RETAIN(@"0.1"); // Default Storage version 49 | contextVersion = SG_RETAIN(@"1.0"); // Default Context version 50 | placesVersion = SG_RETAIN(@"1.2"); // Default Places version 51 | } 52 | return self; 53 | } 54 | 55 | + (SimpleGeo *)clientWithConsumerKey:(NSString *)key 56 | consumerSecret:(NSString *)secret 57 | { 58 | return SG_AUTORELEASE([[self alloc] initWithConsumerKey:key consumerSecret:secret]); 59 | } 60 | 61 | #pragma mark - 62 | #pragma mark Requests 63 | 64 | - (void)getCategoriesWithCallback:(SGCallback *)callback 65 | { 66 | 67 | [self sendHTTPRequest:@"GET" 68 | toFile:@"/features/categories" 69 | withParams:nil 70 | version:self.contextVersion 71 | callback:callback]; 72 | } 73 | 74 | #pragma mark - 75 | #pragma mark Helpers 76 | 77 | - (NSString *)baseEndpointForQuery:(SGQuery *)query 78 | { 79 | if (query.point) return [NSString stringWithFormat:@"%f,%f", 80 | query.point.latitude, 81 | query.point.longitude]; 82 | else if (query.envelope) return [NSString stringWithFormat:@"%f,%f", 83 | [query.envelope.center latitude], 84 | [query.envelope.center longitude]]; 85 | else if (query.address) return [NSString stringWithFormat:@"address"]; 86 | else return [NSString stringWithFormat:@"search"]; 87 | } 88 | 89 | - (void)sendHTTPRequest:(NSString *)type 90 | toFile:(NSString *)file 91 | withParams:(id)params 92 | version:(NSString *)version 93 | callback:(SGCallback *)callback 94 | { 95 | NSString *urlString = [NSString stringWithFormat:@"%@/%@%@.json", 96 | self.apiURL, version, 97 | [file stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding], nil]; 98 | 99 | [self sendHTTPRequest:type 100 | toURL:[NSURL URLWithString:urlString] 101 | withParams:params 102 | callback:callback]; 103 | } 104 | 105 | #pragma mark - 106 | #pragma mark Memory 107 | 108 | - (void)dealloc 109 | { 110 | SG_RELEASE(storageVersion); 111 | SG_RELEASE(placesVersion); 112 | SG_RELEASE(contextVersion); 113 | SG_RELEASE(apiURL); 114 | [super dealloc]; 115 | } 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Additions/NSArray+SGCollection.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+SGGeoJSON.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGTypes.h" 32 | 33 | /** 34 | * This category on NSArray allows an NSArray to be created from a [GeoJSON Collection.](http://geojson.org/geojson-spec.html#feature-collection-objects) 35 | * It also allows a GeoJSON Collection to be created from an NSArray. 36 | * Call *arrayWithSGCollection:* to transform a GeoJSON Collection of 37 | * SimpleGeo places or records into an array of SGPlaces or SGStoredRecords. 38 | */ 39 | @interface NSArray (SGCollection) 40 | 41 | #pragma mark - 42 | #pragma mark SG GeoJSON Collection -> SGGeoObjects 43 | 44 | typedef enum { 45 | SGCollectionTypePoints, 46 | SGCollectionTypeObjects, 47 | SGCollectionTypeFeatures, 48 | SGCollectionTypePlaces, 49 | SGCollectionTypeRecords, 50 | SGCollectionTypeLayers, 51 | } SGCollectionType; 52 | 53 | /** 54 | * Create an array of SGGeometry or SGFeature objects from 55 | * a GeoJSON Collection returned from SimpleGeo 56 | * @param collection GeoJSON Collection 57 | * @param collectionType Collection type 58 | */ 59 | + (NSArray *)arrayWithSGCollection:(NSDictionary *)collection 60 | type:(SGCollectionType)collectionType; 61 | 62 | /** 63 | * Construct an array of SGGeometry or SGFeature objects from 64 | * a GeoJSON Collection returned from SimpleGeo 65 | * @param collection GeoJSON Collection 66 | * @param collectionType Collection type 67 | */ 68 | - (id)initWithSGCollection:(NSDictionary *)collection 69 | type:(SGCollectionType)collectionType; 70 | 71 | #pragma mark - 72 | #pragma mark SGGeoObjects -> GeoJSONCollection 73 | 74 | typedef enum { 75 | GeoJSONCollectionTypeGeometries, 76 | GeoJSONCollectionTypeFeatures, 77 | } GeoJSONCollectionType; 78 | 79 | /** 80 | * Create a GeoJSON Collection dictionary from an array 81 | * of objects that respond to *asGeoJSON* 82 | * @param collectionType Collection type 83 | */ 84 | - (NSDictionary *)asGeoJSONCollection:(GeoJSONCollectionType)collectionType; 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Additions/NSDictionary+Classifier.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+Classifier.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGCategories.h" 32 | 33 | /** 34 | * This category on NSDictionary allows you to easily create a SimpleGeo classifier - 35 | * a dictionary with *"type,"* *"category,"* and *"subcategory"* top-level keys. 36 | * More importantly, accessor methods allow for easier access to key values, 37 | * returning nil if no key exists or if the value is null. 38 | */ 39 | @interface NSDictionary (Classifier) 40 | 41 | /** 42 | * Create a dictionary that conforms to the SimpleGeo 43 | * classifier protocol for Features 44 | * @param type Feature type 45 | * @param category Feature category 46 | * @param subcategory Feature subcategory 47 | */ 48 | + (NSDictionary *)classifierWithType:(SGFeatureType)type 49 | category:(SGFeatureCategory)category 50 | subcategory:(SGFeatureSubcategory)subcategory; 51 | 52 | /** 53 | * Retreive the feature type 54 | */ 55 | - (SGFeatureType)classifierType; 56 | 57 | /** 58 | * Retreive the feature category 59 | */ 60 | - (SGFeatureCategory)classifierCategory; 61 | 62 | /** 63 | * Retreive the feature subcategory 64 | */ 65 | - (SGFeatureSubcategory)classifierSubcategory; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Additions/NSDictionary+Classifier.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+Classifier.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "NSDictionary+Classifier.h" 32 | 33 | 34 | @implementation NSDictionary (Classifier) 35 | 36 | + (NSDictionary *)classifierWithType:(SGFeatureType)type 37 | category:(SGFeatureCategory)category 38 | subcategory:(SGFeatureSubcategory)subcategory 39 | { 40 | return [NSDictionary dictionaryWithObjectsAndKeys: 41 | type, @"type", 42 | category, @"category", 43 | subcategory, @"subcategory", 44 | nil]; 45 | } 46 | 47 | - (SGFeatureType)classifierType { 48 | if ([self objectForKey:@"type"] != (id)[NSNull null]) 49 | return [self objectForKey:@"type"]; 50 | return nil; 51 | } 52 | 53 | - (SGFeatureCategory)classifierCategory { 54 | if ([self objectForKey:@"category"] != (id)[NSNull null]) 55 | return [self objectForKey:@"category"]; 56 | return nil; 57 | } 58 | 59 | - (SGFeatureSubcategory)classifierSubcategory { 60 | if ([self objectForKey:@"subcategory"] != (id)[NSNull null]) 61 | return [self objectForKey:@"subcategory"]; 62 | return nil; 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Addresses/SGAddress+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGAddress+Internal.h 3 | // SimpleGeo 4 | // 5 | // Copyright (c) 2010-2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGAddress.h" 32 | 33 | @interface SGAddress (Internal) 34 | 35 | /** 36 | * Extract address from a dictionary 37 | * @param dictionary Dictionary containing an address 38 | */ 39 | + (SGAddress *)addressStrippedFromDictionary:(NSMutableDictionary *)dictionary; 40 | 41 | @end -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Addresses/SGAddress.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGAddress.h 3 | // SimpleGeo 4 | // 5 | // Copyright (c) 2010-2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | @class SGPoint; 32 | 33 | typedef enum { 34 | SGAddressFormatUSFull, 35 | SGAddressFormatUSNormal, 36 | SGAddressFormatUSShort, 37 | } SGAddressFormat; 38 | 39 | /** 40 | * An SGAddress object stores address data. 41 | * Address data includes information such as country, state, city, and street address. 42 | * SGAddress objects are typically generated by a Context response or stored as part of an SGPlace object, 43 | * although you can also create them explicitly yourself. 44 | * 45 | * - Create an SGAddress from an NSDictionary containing standard address keys (city, province, etc). 46 | * - Generate a a formatted address string from an SGAddress using [SGAddress formattedAddress:withStreet:]. 47 | */ 48 | @interface SGAddress : NSObject 49 | { 50 | @private 51 | NSMutableDictionary *addressDictionary; 52 | } 53 | 54 | /// Address Dictionary 55 | @property (nonatomic, retain) NSMutableDictionary *addressDictionary; 56 | 57 | /// Street Address, eg. 41 Decatur St 58 | @property (nonatomic, readonly) NSString *street; 59 | 60 | /// City, eg. San Francisco 61 | @property (nonatomic, readonly) NSString *city; 62 | 63 | /// County, eg. Santa Clara 64 | @property (nonatomic, readonly) NSString *county; 65 | 66 | /// State, eg. CA 67 | @property (nonatomic, readonly) NSString *province; 68 | 69 | /// Zip code, eg. 94103 70 | @property (nonatomic, readonly) NSString *postalCode; 71 | 72 | /// Country, eg. US 73 | @property (nonatomic, readonly) NSString *country; 74 | 75 | #pragma mark - 76 | #pragma mark Instantiation 77 | 78 | /** 79 | * Create an address from a dictionary containing top-level address keys 80 | * @param dictionary Address dictionary 81 | */ 82 | + (SGAddress *)addressWithDictionary:(NSDictionary *)dictionary; 83 | 84 | /** 85 | * Construct an address from a dictionary containing top-level address keys 86 | * @param dictionary Address dictionary 87 | */ 88 | - (id)initWithDictionary:(NSDictionary *)dictionary; 89 | 90 | #pragma mark - 91 | #pragma mark Convenience 92 | 93 | /** 94 | * Formatted address string 95 | * @param addressFormat Address format 96 | * @param includeStreet Include the street address 97 | */ 98 | - (NSString *)formattedAddress:(SGAddressFormat)addressFormat 99 | withStreet:(BOOL)includeStreet; 100 | 101 | /** 102 | * Keys an inspected upon instantiation 103 | */ 104 | + (NSArray *)candidateKeys; 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Addresses/SGPlacemark+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGPlacemark+Internal.h 3 | // SimpleGeo 4 | // 5 | // Copyright (c) 2010-2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGPlacemark.h" 32 | 33 | @interface SGPlacemark (Internal) 34 | 35 | - (id)initWithGeoJSON:(NSDictionary *)geoJSONDictionary; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Addresses/SGPlacemark.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGPlacemark.h 3 | // SimpleGeo 4 | // 5 | // Copyright (c) 2010-2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGAddress.h" 32 | @class SGPoint; 33 | 34 | /** 35 | * An SGPlacemark object stores *address* data for a particular *point.* 36 | * Address data includes information such as the country, state, city, and street address associated with the point. 37 | * A Placemark object is generated by a SimpleGeo Context response and represents the reverse geocode for a query. 38 | * A Placemark's *distance* property represents the distance of the Placemark point from the query point. 39 | */ 40 | @interface SGPlacemark : SGAddress 41 | { 42 | @private 43 | SGPoint *point; 44 | NSNumber *distance; 45 | } 46 | 47 | /// Address location 48 | @property (nonatomic, readonly) SGPoint *point; 49 | 50 | /// Distance from query point 51 | @property (nonatomic, readonly) NSNumber *distance; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Addresses/SGPlacemark.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGPlacemark.m 3 | // SimpleGeo 4 | // 5 | // Copyright (c) 2010-2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGPlacemark.h" 32 | #import "SGPoint.h" 33 | 34 | #import "SGPreprocessorMacros.h" 35 | 36 | @implementation SGPlacemark 37 | 38 | @synthesize point, distance; 39 | 40 | - (id)initWithGeoJSON:(NSDictionary *)geoJSONDictionary 41 | { 42 | self = [super initWithDictionary:[geoJSONDictionary objectForKey:@"properties"]]; 43 | if (self) { 44 | point = [[SGPoint alloc] initWithGeoJSON:[geoJSONDictionary objectForKey:@"geometry"]]; 45 | distance = SG_RETAIN([[geoJSONDictionary objectForKey:@"properties"] objectForKey:@"distance"]); 46 | } 47 | return self; 48 | } 49 | 50 | - (void)dealloc 51 | { 52 | SG_RELEASE(point); 53 | SG_RELEASE(distance); 54 | [super dealloc]; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geo Objects/SGFeature.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGFeature.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGGeoObject.h" 32 | 33 | /** 34 | * An SGFeature object represents a *named* and *classified* SGGeoObject with a *unique identifier.* 35 | * In practice, SGFeatures represent SimpleGeo polygons (e.g., neighborhoods or states). 36 | */ 37 | @interface SGFeature : SGGeoObject 38 | { 39 | @private 40 | // required 41 | NSString *name; 42 | // optional 43 | NSMutableArray *classifiers; 44 | } 45 | 46 | /// Feature name 47 | @property (nonatomic, retain) NSString *name; 48 | 49 | /// Feature classifiers 50 | @property (nonatomic, retain, setter = setMutableClassifiers:) NSMutableArray *classifiers; 51 | 52 | #pragma mark - 53 | #pragma mark Convenience 54 | 55 | /** 56 | * Set classifiers from an immutable array of 57 | * classifier dictionaries 58 | * @param classifiers Classifiers 59 | */ 60 | - (void)setClassifiers:(NSArray *)classifiers; 61 | 62 | #pragma mark - 63 | #pragma mark Instantiation 64 | 65 | /** 66 | * Create an SGFeature from a dictionary that 67 | * abides by the GeoJSON Feature specification 68 | * @param geoJSONFeature Feature dictionary 69 | */ 70 | + (SGFeature *)featureWithGeoJSON:(NSDictionary *)geoJSONFeature; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geo Objects/SGFeature.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGFeature.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGFeature.h" 32 | 33 | #import "SGPreprocessorMacros.h" 34 | 35 | @implementation SGFeature 36 | 37 | @synthesize name, classifiers; 38 | 39 | #pragma mark - 40 | #pragma mark Instantiation 41 | 42 | + (SGFeature *)featureWithGeoJSON:(NSDictionary *)geoJSONFeature 43 | { 44 | return SG_AUTORELEASE([[SGFeature alloc] initWithGeoJSON:geoJSONFeature]); 45 | } 46 | 47 | - (id)initWithGeoJSON:(NSDictionary *)geoJSONFeature 48 | { 49 | self = [super initWithGeoJSON:geoJSONFeature]; 50 | if (self) { 51 | // name 52 | name = SG_RETAIN([self.properties objectForKey:@"name"]); 53 | [self.properties removeObjectForKey:@"name"]; 54 | // classifiers 55 | NSArray *someClassifiers = [self.properties objectForKey:@"classifiers"]; 56 | if (someClassifiers && [someClassifiers count] > 0) 57 | [self setClassifiers:[self.properties objectForKey:@"classifiers"]]; 58 | [self.properties removeObjectForKey:@"classifiers"]; 59 | } 60 | return self; 61 | } 62 | 63 | #pragma mark - 64 | #pragma mark Convenience 65 | 66 | - (void)setClassifiers:(NSArray *)someClassifiers 67 | { 68 | [self setMutableClassifiers:[NSMutableArray arrayWithArray:someClassifiers]]; 69 | } 70 | 71 | - (void)setMutableClassifiers:(NSMutableArray *)someClassifiers 72 | { 73 | SG_RELEASE(classifiers); 74 | classifiers = SG_RETAIN(someClassifiers); 75 | } 76 | 77 | - (NSDictionary *)asGeoJSON 78 | { 79 | NSMutableDictionary *dictionary = (NSMutableDictionary *)[super asGeoJSON]; 80 | [[dictionary objectForKey:@"properties"] setValue:name forKey:@"name"]; // name 81 | [[dictionary objectForKey:@"properties"] setValue:classifiers forKey:@"classifiers"]; // classifiers 82 | return dictionary; 83 | } 84 | 85 | #pragma mark - 86 | #pragma mark Memory 87 | 88 | - (void)dealloc 89 | { 90 | SG_RELEASE(name); 91 | SG_RELEASE(classifiers); 92 | [super dealloc]; 93 | } 94 | 95 | @end -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geo Objects/SGGeoObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGGeoObject.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGGeometry.h" 32 | 33 | /** 34 | * An SGGeoObject represents a basic geo object. 35 | * SGGeoObjects store a geometry (SGPoint, SGPolygon, SGMultiPolygon, or SGEnvelope) and a property dictionary. 36 | * An example of a very basic geo object is an intersection. 37 | */ 38 | @interface SGGeoObject : NSObject 39 | { 40 | @private 41 | // required 42 | SGGeometry *geometry; 43 | // optional 44 | NSString *identifier; 45 | NSMutableDictionary *properties; 46 | // from request 47 | NSNumber *distance; 48 | } 49 | 50 | /// Object geometry 51 | @property (nonatomic, readonly) SGGeometry *geometry; 52 | 53 | /// Object ID 54 | @property (nonatomic, retain) NSString *identifier; 55 | 56 | /// Object properties 57 | @property (nonatomic, retain, setter = setMutableProperties:) NSMutableDictionary *properties; 58 | 59 | /// Distance (in meters) from the query point. 60 | /// Valid for SGGeoObjects with point geometry 61 | /// Only present if the Object originated from a nearby request 62 | @property (nonatomic, readonly) NSNumber *distance; 63 | 64 | #pragma mark - 65 | #pragma mark Instantiation 66 | 67 | /** 68 | * Construct an SGGeoObject with a geometry 69 | * @param geometry Object geometry 70 | */ 71 | - (id)initWithGeometry:(SGGeometry *)geometry; 72 | 73 | /** 74 | * Construct an SGGeoObject from a dictionary that 75 | * abides by the GeoJSON Feature specification 76 | * @param geoJSONFeature Feature dictionary 77 | */ 78 | - (id)initWithGeoJSON:(NSDictionary *)geoJSONFeature; 79 | 80 | #pragma mark - 81 | #pragma mark Convenience 82 | 83 | /** 84 | * Set properties from an immutable properties dictionary 85 | * @param properties Feature properties 86 | */ 87 | - (void)setProperties:(NSDictionary *)properties; 88 | 89 | /** 90 | * Dictionary representation of the SGGeoObject that 91 | * conforms to the geoJSON Feature specification 92 | */ 93 | - (NSDictionary *)asGeoJSON; 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geo Objects/SGGeoObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGGeoObject.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGGeoObject.h" 32 | #import "SGGeometry.h" 33 | 34 | #import "SGPreprocessorMacros.h" 35 | 36 | @implementation SGGeoObject 37 | 38 | @synthesize identifier, geometry, properties, distance; 39 | 40 | #pragma mark - 41 | #pragma mark Instantiation 42 | 43 | - (id)initWithGeometry:(SGGeometry *)aGeometry 44 | { 45 | self = [super init]; 46 | if (self) { 47 | geometry = SG_RETAIN(aGeometry); 48 | } 49 | return self; 50 | } 51 | 52 | 53 | - (id)initWithGeoJSON:(NSDictionary *)geoJSONFeature 54 | { 55 | self = [super init]; 56 | if (self) { 57 | geometry = [[SGGeometry alloc] initWithGeoJSON:[geoJSONFeature objectForKey:@"geometry"]]; 58 | identifier = [[geoJSONFeature objectForKey:@"id"] retain]; 59 | [self setProperties:[geoJSONFeature objectForKey:@"properties"]]; 60 | // distance 61 | distance = SG_RETAIN([geoJSONFeature objectForKey:@"distance"]); 62 | if (!distance) { 63 | distance = SG_RETAIN([properties objectForKey:@"distance"]); 64 | [properties removeObjectForKey:@"distance"]; 65 | } 66 | } 67 | return self; 68 | } 69 | 70 | #pragma mark - 71 | #pragma mark Convenience 72 | 73 | - (void)setProperties:(NSDictionary *)someProperties 74 | { 75 | [self setMutableProperties:[NSMutableDictionary dictionaryWithDictionary:someProperties]]; 76 | } 77 | 78 | - (void)setMutableProperties:(NSMutableDictionary *)someProperties 79 | { 80 | SG_RELEASE(properties); 81 | properties = SG_RETAIN(someProperties); 82 | } 83 | 84 | - (NSDictionary *)asGeoJSON 85 | { 86 | NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; 87 | [dictionary setObject:@"Feature" forKey:@"type"]; 88 | [dictionary setValue:[geometry asGeoJSON] forKey:@"geometry"]; 89 | [dictionary setValue:identifier forKey:@"id"]; 90 | [dictionary setValue:[NSMutableDictionary dictionaryWithDictionary:properties] forKey:@"properties"]; 91 | return dictionary; 92 | } 93 | 94 | - (NSString *)description 95 | { 96 | return [[self asGeoJSON] description]; 97 | } 98 | 99 | #pragma mark - 100 | #pragma mark Comparison 101 | 102 | - (BOOL)isEqual:(id)object 103 | { 104 | if (object == self) return YES; 105 | if (!object || ![object isKindOfClass:[self class]]) return NO; 106 | return [identifier isEqual:[object identifier]]; 107 | } 108 | 109 | - (NSUInteger)hash 110 | { 111 | return [identifier hash]; 112 | } 113 | 114 | #pragma mark - 115 | #pragma mark Memory 116 | 117 | - (void)dealloc 118 | { 119 | SG_RELEASE(geometry); 120 | SG_RELEASE(identifier); 121 | SG_RELEASE(properties); 122 | SG_RELEASE(distance); 123 | [super dealloc]; 124 | } 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geo Objects/SGPlace.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGPlace.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGFeature.h" 32 | @class SGPoint; 33 | @class SGAddress; 34 | 35 | /** 36 | * An SGPlace object represents a place in the SimpleGeo Places database. 37 | * Places are SGFeatures with an associated *address* and *tag array.* 38 | * SGPlace objects usually originate from a SimpleGeo Places API request, 39 | * although you can also create them explicitly yourself if you would like to add a private Place to the database. 40 | */ 41 | @interface SGPlace : SGFeature 42 | { 43 | @private 44 | SGAddress *address; 45 | NSMutableArray *tags; 46 | NSMutableArray *categories; 47 | BOOL isPrivate; 48 | } 49 | 50 | /// Place location 51 | @property (nonatomic, readonly) SGPoint *point; 52 | 53 | /// Place address 54 | @property (nonatomic, readonly) SGAddress *address; 55 | 56 | /// Place tags 57 | @property (nonatomic, retain, setter = setMutableTags:) NSMutableArray *tags; 58 | 59 | /// Place categories (v1.2+) 60 | @property (nonatomic, retain, setter = setMutableCategories:) NSMutableArray *categories; 61 | 62 | /// Place visibility 63 | @property (nonatomic, assign) BOOL isPrivate; 64 | 65 | #pragma mark - 66 | #pragma mark Instantiation 67 | 68 | /** 69 | * Create an SGPlace with a name, and location 70 | * @param name Place name 71 | * @param point Place location 72 | */ 73 | + (SGPlace *)placeWithName:(NSString *)name 74 | point:(SGPoint *)point; 75 | 76 | /** 77 | * Construct an SGPlace from a dictionary that 78 | * abides by the GeoJSON Feature specification. 79 | * Note: geoJSON Feature must contain a "name" 80 | * key and value in the property dictionary 81 | * @param geoJSONFeature Feature dictionary 82 | */ 83 | + (SGPlace *)placeWithGeoJSON:(NSDictionary *)geoJSONFeature; 84 | 85 | /** 86 | * Construct an SGPlace with a name and location 87 | * @param name Place name 88 | * @param point Place location 89 | */ 90 | - (id)initWithName:(NSString *)name 91 | point:(SGPoint *)point; 92 | 93 | #pragma mark - 94 | #pragma mark Convenience 95 | 96 | /** 97 | * Set tags 98 | * @param tags Place tags 99 | */ 100 | - (void)setTags:(NSArray *)tags; 101 | 102 | /** 103 | * Set categories 104 | * @param categories Place categories 105 | */ 106 | - (void)setCategories:(NSArray *)categories; 107 | 108 | @end -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geo Objects/SGStoredRecord.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGStoredRecord.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGGeoObject.h" 32 | @class SGPoint; 33 | 34 | /** 35 | * An SGStoredRecord object represents a record in a SimpleGeo Storage layer. 36 | * Like any SGGeoObject, a SGStoredRecord object stores a geometry (specifically, a point) and a properties dictionary. 37 | * A SGStoredRecord object also stores the name of its associated layer and a creation date. 38 | * If the SGStoredRecord originated from an API query response, it will also store a distance value (its distance from the query point). 39 | */ 40 | @interface SGStoredRecord : SGGeoObject 41 | { 42 | @private 43 | // required 44 | NSString *layer; 45 | // optional 46 | NSDate *created; 47 | } 48 | 49 | /// Record location 50 | @property (nonatomic, readonly) SGPoint *point; 51 | 52 | /// Layer name 53 | @property (nonatomic, retain) NSString *layer; 54 | 55 | /// Record timestamp 56 | @property (nonatomic, retain) NSDate *created; 57 | 58 | #pragma mark - 59 | #pragma mark Instantiation 60 | 61 | /** 62 | * Create an SGStoredRecord with an ID, point, and layer 63 | * @param identifier Record ID 64 | * @param point Record location 65 | * @param layerName Record layer 66 | */ 67 | + (SGStoredRecord *)recordWithID:(NSString *)identifier 68 | point:(SGPoint *)point 69 | layer:(NSString *)layerName; 70 | 71 | /** 72 | * Create an SGStoredRecord from a dictionary that 73 | * abides by the GeoJSON Feature specification. 74 | * Note: geoJSON Feature must contain a "layer" 75 | * key and value in the property dictionary 76 | * @param geoJSONFeature Feature dictionary 77 | */ 78 | + (SGStoredRecord *)recordWithGeoJSON:(NSDictionary *)geoJSONFeature; 79 | 80 | /** 81 | * Construct an SGStoredRecord with an ID, point, and layer 82 | * @param identifier Record ID 83 | * @param point Record location 84 | * @param layerName Record layer 85 | */ 86 | - (id)initWithID:(NSString *)identifier 87 | point:(SGPoint *)point 88 | layer:(NSString *)layerName; 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geo Objects/SGStoredRecord.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGStoredRecord.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGStoredRecord.h" 32 | #import "SGPoint.h" 33 | 34 | #import "SGPreprocessorMacros.h" 35 | 36 | @implementation SGStoredRecord 37 | 38 | @synthesize layer, created; 39 | 40 | #pragma mark - 41 | #pragma mark Instantiation 42 | 43 | + (SGStoredRecord *)recordWithID:(NSString *)identifier 44 | point:(SGPoint *)point 45 | layer:(NSString *)layerName 46 | { 47 | return SG_AUTORELEASE([[SGStoredRecord alloc] initWithID:identifier 48 | point:point 49 | layer:layerName]); 50 | } 51 | 52 | + (SGStoredRecord *)recordWithGeoJSON:(NSDictionary *)geoJSONFeature 53 | { 54 | return SG_AUTORELEASE([[SGStoredRecord alloc] initWithGeoJSON:geoJSONFeature]); 55 | } 56 | 57 | - (id)initWithID:(NSString *)anIdentifier 58 | point:(SGPoint *)point 59 | layer:(NSString *)layerName 60 | { 61 | self = [super initWithGeometry:point]; 62 | if (self) { 63 | [self setIdentifier:anIdentifier]; 64 | layer = SG_RETAIN(layerName); 65 | } 66 | return self; 67 | } 68 | 69 | - (id)initWithGeoJSON:(NSDictionary *)geoJSONFeature 70 | { 71 | self = [super initWithGeoJSON:geoJSONFeature]; 72 | if (self) { 73 | // layer 74 | layer = SG_RETAIN([self.properties objectForKey:@"layer"]); 75 | [self.properties removeObjectForKey:@"layer"]; 76 | // created 77 | NSNumber *epoch = [geoJSONFeature objectForKey:@"created"]; 78 | if (epoch) created = [[NSDate alloc] initWithTimeIntervalSince1970:[epoch intValue]]; 79 | } 80 | return self; 81 | } 82 | 83 | #pragma mark - 84 | #pragma mark Convenience 85 | 86 | - (SGPoint *)point 87 | { 88 | return (SGPoint *)self.geometry; 89 | } 90 | 91 | - (NSDictionary *)asGeoJSON 92 | { 93 | NSMutableDictionary *dictionary = (NSMutableDictionary *)[super asGeoJSON]; 94 | [[dictionary objectForKey:@"properties"] setValue:layer forKey:@"layer"]; // layer 95 | if (created) [dictionary setValue:[NSNumber numberWithDouble:[created timeIntervalSince1970]] forKey:@"created"]; // created 96 | return dictionary; 97 | } 98 | 99 | #pragma mark - 100 | #pragma mark Comparison 101 | 102 | - (BOOL)isEqual:(id)object 103 | { 104 | if (object == self) return YES; 105 | if (!object || ![object isKindOfClass:[self class]]) return NO; 106 | return ([super isEqual:object] && 107 | [layer isEqual:[object layer]]); 108 | } 109 | 110 | - (NSUInteger)hash 111 | { 112 | return [super hash] + [layer hash]; 113 | } 114 | 115 | #pragma mark - 116 | #pragma mark Memory 117 | 118 | - (void)dealloc 119 | { 120 | SG_RELEASE(layer); 121 | SG_RELEASE(created); 122 | [super dealloc]; 123 | } 124 | 125 | @end 126 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geometries/SGEnvelope.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGEnvelope.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGGeometry.h" 32 | @class SGPoint; 33 | 34 | /** 35 | * An SGEnvelope object represents a geometric envelope, or bounding box. 36 | * Envelopes may be used to create a Context or Storage query. 37 | * An Envelope may also be useful when displaying results on a map since it can represent a map's visible bounds. 38 | */ 39 | @interface SGEnvelope : SGGeometry 40 | { 41 | @private 42 | double north; 43 | double west; 44 | double south; 45 | double east; 46 | } 47 | 48 | /// Northern latitude (top coordinate) 49 | @property (nonatomic, assign) double north; 50 | 51 | /// Southern latitude (bottom coordinate) 52 | @property (nonatomic, assign) double south; 53 | 54 | /// Western longitude (left coordinate) 55 | @property (nonatomic, assign) double west; 56 | 57 | /// Eastern longitude (right coordinate) 58 | @property (nonatomic, assign) double east; 59 | 60 | /// Center coordinate 61 | @property (nonatomic, readonly) SGPoint *center; 62 | 63 | #pragma mark - 64 | #pragma mark Instantiation 65 | 66 | /** 67 | * Create a bounding box from edge coordinates 68 | * @param northernLat Northern latitude 69 | * @param westernLon Western longitude 70 | * @param southernLat Southern latitude 71 | * @param easternLon Eastern longitude 72 | */ 73 | + (SGEnvelope *)envelopeWithNorth:(double)northernLat 74 | west:(double)westernLon 75 | south:(double)southernLat 76 | east:(double)easternLon; 77 | 78 | /** 79 | * Construct a bounding box from edge coordinates 80 | * @param northernLat Northern latitude 81 | * @param westernLon Western longitude 82 | * @param southernLat Southern latitude 83 | * @param easternLon Eastern longitude 84 | */ 85 | - (id)initWithWithNorth:(double)northernLat 86 | west:(double)westernLon 87 | south:(double)southernLat 88 | east:(double)easternLon; 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geometries/SGGeometry.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGGeometry.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | @class SGPoint; 32 | @class SGEnvelope; 33 | 34 | /** 35 | * SGGeometry serves as an abstract class for a geometry. 36 | * Every SGGeometry object can be created from, and transformed into, a [GeoJSON geometry dictionary.](http://geojson.org/geojson-spec.html#geometry-objects) 37 | */ 38 | @interface SGGeometry : NSObject 39 | 40 | #pragma mark - 41 | #pragma mark GeoJSON -> SGGeometry 42 | 43 | /** 44 | * Create an appropriate SGGeometry object from 45 | * a valid GeoJSON Geometry dictionary 46 | * @param geoJSONGeometry GeoJSON Geometry dictionary 47 | */ 48 | + (SGGeometry *)geometryWithGeoJSON:(NSDictionary *)geoJSONGeometry; 49 | 50 | /** 51 | * Construct an appropriate SGGeometry object from 52 | * a valid GeoJSON Geometry dictionary 53 | * @param geoJSONGeometry GeoJSON Geometry dictionary 54 | */ 55 | - (id)initWithGeoJSON:(NSDictionary *)geoJSONGeometry; 56 | 57 | #pragma mark - 58 | #pragma mark SGGeometry -> GeoJSON 59 | 60 | /** 61 | * SGGeometry object as a GeoJSON Geometry dictionary 62 | */ 63 | - (NSDictionary *)asGeoJSON; 64 | 65 | @end 66 | 67 | #pragma mark - 68 | #pragma mark Region Geometry Protocol 69 | 70 | /** 71 | * (Multi)Polygon geometry protocol 72 | */ 73 | @protocol SGRegionGeometry 74 | 75 | - (SGEnvelope *)envelope; 76 | 77 | /** 78 | * Determine if a given point lies within the bounds of the polygon 79 | * @param point Point to check 80 | */ 81 | - (BOOL)containsPoint:(SGPoint *)point; 82 | 83 | @end -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geometries/SGGeometry.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGGeometry.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGGeometry.h" 32 | #import "SGPoint.h" 33 | #import "SGEnvelope.h" 34 | #import "SGPolygon.h" 35 | #import "SGMultiPolygon.h" 36 | 37 | #import "SGPreprocessorMacros.h" 38 | 39 | @implementation SGGeometry 40 | 41 | #pragma mark - 42 | #pragma mark GeoJSON -> SGGeometry 43 | 44 | + (SGGeometry *)geometryWithGeoJSON:(NSDictionary *)geoJSONGeometry 45 | { 46 | return SG_AUTORELEASE([[SGGeometry alloc] initWithGeoJSON:geoJSONGeometry]); 47 | } 48 | 49 | - (id)initWithGeoJSON:(NSDictionary *)geoJSONGeometry 50 | { 51 | NSString *type = [geoJSONGeometry objectForKey:@"type"]; 52 | if ([type isEqual:@"Point"]) return [[SGPoint alloc] initWithGeoJSON:geoJSONGeometry]; 53 | else if ([type isEqual:@"Polygon"]) return [[SGPolygon alloc] initWithGeoJSON:geoJSONGeometry]; 54 | else if ([type isEqual:@"MultiPolygon"]) return [[SGMultiPolygon alloc] initWithGeoJSON:geoJSONGeometry]; 55 | else if ([geoJSONGeometry objectForKey:@"bbox"]) return [[SGEnvelope alloc] initWithGeoJSON:geoJSONGeometry]; 56 | return nil; 57 | } 58 | 59 | #pragma mark - 60 | #pragma mark SGGeometry -> GeoJSON 61 | 62 | - (NSDictionary *)asGeoJSON 63 | { 64 | // subclasses must implement 65 | return nil; 66 | } 67 | 68 | @end -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geometries/SGMultiPolygon.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGMultiPolygon.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGGeometry.h" 32 | 33 | @class SGPoint; 34 | @class SGEnvelope; 35 | 36 | /** 37 | * An SGMultiPolygon object stores information about a multi-polygon — an array of SGPolygons representing a single feature. 38 | * 39 | * A good example of a multi-polygon is the state of Hawaii, a single feature composed of many polygons. 40 | */ 41 | @interface SGMultiPolygon : SGGeometry 42 | { 43 | @private 44 | NSArray *polygons; 45 | } 46 | 47 | /// Polygons that define this multi-polygon 48 | @property (nonatomic, retain) NSArray *polygons; 49 | 50 | /// Bounding box for the multi-polygon 51 | @property (nonatomic, readonly) SGEnvelope *envelope; 52 | 53 | #pragma mark - 54 | #pragma mark Instantiation 55 | 56 | /** 57 | * Create a multi-polygon from a set of Polygons 58 | * @param polygons Polygons 59 | */ 60 | + (SGMultiPolygon *)multiPolygonWithPolygons:(NSArray *)polygons; 61 | 62 | /** 63 | * Construct a multi-polygon from a set of Polygons 64 | * @param polygons Polygons 65 | */ 66 | - (id)initWithPolygons:(NSArray *)polygons; 67 | 68 | @end -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geometries/SGPoint+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGPoint+Internal.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGPoint.h" 32 | 33 | @interface SGPoint (Private) 34 | 35 | /** 36 | * Create a point from an array of coordinates [lon, lat] 37 | * @param point Point array 38 | */ 39 | + (SGPoint *)pointWithArray:(NSArray *)point; 40 | 41 | /** 42 | * Construct a point from an array of coordinates [lon, lat] 43 | * @param point Point array 44 | */ 45 | - (id)initWithArray:(NSArray *)point; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geometries/SGPoint.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGPoint.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGGeometry.h" 32 | #import "SGPolygon.h" 33 | #import "SGMultiPolygon.h" 34 | 35 | /** 36 | * An SGPoint object stores information about a geometric coordinate. 37 | * In addition to latitude and longitude, an SGPoint object may store an associated date 38 | * if it originates from a SimpleGeo Storage _record history request._ 39 | */ 40 | @interface SGPoint : SGGeometry 41 | { 42 | @private 43 | double latitude; 44 | double longitude; 45 | NSDate *created; 46 | } 47 | 48 | /// Latitude (y coordinate) 49 | @property (nonatomic, assign) double latitude; 50 | 51 | /// Longitude (x coordinate) 52 | @property (nonatomic, assign) double longitude; 53 | 54 | /// Date created 55 | @property (nonatomic, retain) NSDate *created; 56 | 57 | #pragma mark - 58 | #pragma mark Instantiation 59 | 60 | /** 61 | * Create a point from a pair of coordinates 62 | * @param latitude Latitude 63 | * @param longitude Longitude 64 | */ 65 | + (SGPoint *)pointWithLat:(double)latitude 66 | lon:(double)longitude; 67 | 68 | /** 69 | * Construct a point from a pair of coordinates 70 | * @param latitude Latitude 71 | * @param longitude Longitude 72 | */ 73 | - (id)initWithLat:(double)latitude 74 | lon:(double)longitude; 75 | 76 | @end -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geometries/SGPolygon+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGPolygon+Internal.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGPolygon.h" 32 | 33 | @interface SGPolygon (Private) 34 | 35 | /** 36 | * Create a polygon from an array of coordinates 37 | * @param polygon Polygon array 38 | */ 39 | + (SGPolygon *)polygonWithArray:(NSArray *)polygon; 40 | 41 | /** 42 | * Create a polygon from an array of coordinates 43 | * @param polygon Polygon array 44 | */ 45 | - (id)initWithArray:(NSArray *)polygon; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/Geometries/SGPolygon.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGPolygon.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGGeometry.h" 32 | 33 | @class SGPoint; 34 | @class SGEnvelope; 35 | 36 | /** 37 | * An SGPolygon object stores information about a polygon. 38 | * Point information is stored in an array of *rings.* 39 | * The first ring of points represents the polygon's *boundary.* 40 | * Additional rings contain information about *holes* in the polygon. 41 | */ 42 | @interface SGPolygon : SGGeometry 43 | { 44 | @private 45 | NSArray *rings; 46 | } 47 | 48 | /// LinearRings that define this polygon 49 | @property (nonatomic, retain) NSArray *rings; 50 | 51 | /// Bounding box for the polygon 52 | @property (nonatomic, readonly) SGEnvelope *envelope; 53 | 54 | #pragma mark - 55 | #pragma mark Instantiation 56 | 57 | /** 58 | * Create a polygon from a set of LinearRings of SGPoints 59 | * @param rings LinearRings 60 | */ 61 | + (SGPolygon *)polygonWithRings:(NSArray *)rings; 62 | 63 | /** 64 | * Create a polygon from a boundary ring and 65 | * and array of hole rings of SGPoints 66 | * @param boundary Boundary ring 67 | * @param holes Hole rings 68 | */ 69 | + (SGPolygon *)polygonWithBoundary:(NSArray *)boundary 70 | holes:(NSArray *)holes; 71 | 72 | /** 73 | * Construct a polygon from a set of LinearRings 74 | * @param rings LinearRings 75 | */ 76 | - (id)initWithRings:(NSArray *)rings; 77 | 78 | /** 79 | * Construct a polygon from a boundary ring and 80 | * and array of hole rings 81 | * @param boundary Boundary ring 82 | * @param holes Hole rings 83 | */ 84 | - (id)initWithBoundary:(NSArray *)boundary 85 | holes:(NSArray *)holes; 86 | 87 | #pragma mark - 88 | #pragma mark Convenience 89 | 90 | /** 91 | * Boundary ring 92 | */ 93 | - (NSArray *)boundary; 94 | 95 | /** 96 | * Array of hole rings 97 | */ 98 | - (NSArray *)holes; 99 | 100 | @end -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/SGContext.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+SGContext.h 3 | // SimpleGeo 4 | // 5 | // Copyright (c) 2010-2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | @class SGPlacemark; 32 | 33 | /** 34 | * An SGContext object stores information from a SimpleGeo Context response. 35 | * Context information includes a nearest address, a collection of feature polygons, 36 | * weather and demographic information, as well as nearby intersections. 37 | * To create an SGContext object from a Context response, call [SGContext contextWithDictionary:]. 38 | * This will transform the response dictionary into an SContext object, which generates SG model objects where appropriate. 39 | * E.g., an SGPlacemark object will be created to hold the response address. 40 | */ 41 | @interface SGContext : NSObject 42 | { 43 | @private 44 | NSDate *timestamp; 45 | NSDictionary *query; 46 | SGPlacemark *address; 47 | NSArray *features; 48 | NSDictionary *demographics; 49 | NSArray *intersections; 50 | NSDictionary *weather; 51 | } 52 | 53 | /// Timestamp for the Context request 54 | @property (nonatomic, readonly) NSDate *timestamp; 55 | 56 | /// Submitted query 57 | @property (nonatomic, readonly) NSDictionary *query; 58 | 59 | /// Nearest address 60 | @property (nonatomic, readonly) SGPlacemark *address; 61 | 62 | /// Feature polygons 63 | @property (nonatomic, readonly) NSArray *features; 64 | 65 | /// Demographics information 66 | @property (nonatomic, readonly) NSDictionary *demographics; 67 | 68 | /// Nearest intersections 69 | @property (nonatomic, readonly) NSArray *intersections; 70 | 71 | /// Local weather 72 | @property (nonatomic, readonly) NSDictionary *weather; 73 | 74 | /** 75 | * Create an SGContext object from a SimpleGeo Context response 76 | * @param dictionary Context response dictionary 77 | */ 78 | + (SGContext *)contextWithDictionary:(NSDictionary *)dictionary; 79 | 80 | /** 81 | * Construct an SGContext object from a SimpleGeo Context response 82 | * @param dictionary Context response dictionary 83 | */ 84 | - (id)initWithDictionary:(NSDictionary *)dictionary; 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Model/SGLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGLayer.h 3 | // SimpleGeo 4 | // 5 | // Copyright (c) 2010-2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | /** 32 | * An SGLayer object represents a SimpleGeo Storage layer. 33 | * Storage layers hold SGStoredRecord objects. 34 | * Each Storage layer has a unique *name*. 35 | * SGLayer objects also store information about when the later was *created* and last *updated.* 36 | * An array of *callback URLs* may be attached to a layer; 37 | * these URLs are notified every time a record is added or updated. 38 | */ 39 | @interface SGLayer : NSObject 40 | { 41 | @private 42 | NSString *name; 43 | NSString *title; 44 | NSString *description; 45 | NSMutableArray *callbackURLs; 46 | // from API request 47 | BOOL isPublic; 48 | NSDate *created; 49 | NSDate *updated; 50 | } 51 | 52 | /// Layer name 53 | @property (nonatomic, readonly) NSString *name; 54 | 55 | /// Layer title 56 | @property (nonatomic, retain) NSString *title; 57 | 58 | /// Layer description 59 | @property (nonatomic, retain) NSString *description; 60 | 61 | /// Callback URLs for the layer 62 | @property (nonatomic, retain) NSArray *callbackURLs; 63 | 64 | /// Privacy of the layer 65 | @property (nonatomic, readonly) BOOL isPublic; 66 | 67 | /// Date the layer was created 68 | @property (nonatomic, readonly) NSDate *created; 69 | 70 | /// Date the layer was last updated 71 | @property (nonatomic, readonly) NSDate *updated; 72 | 73 | #pragma mark - 74 | #pragma mark Instantiation 75 | 76 | /** 77 | * Create an SGLayer 78 | * @param name Layer name 79 | * @param title Layer title 80 | * @param description Layer description 81 | * @param callbackURLs Callback URLs for the layer 82 | */ 83 | + (SGLayer *)layerWithName:(NSString *)name 84 | title:(NSString *)title 85 | description:(NSString *)description 86 | callbackURLs:(NSArray *)callbackURLs; 87 | 88 | /** 89 | * Construct an SGLayer 90 | * @param name Layer name 91 | * @param title Layer title 92 | * @param description Layer description 93 | * @param callbackURLs Callback URLs for the layer 94 | */ 95 | - (id)initWithName:(NSString *)name 96 | title:(NSString *)title 97 | description:(NSString *)description 98 | callbackURLs:(NSArray *)callbackURLs; 99 | 100 | /** 101 | * Create an SGLayer from a dictionary; 102 | * Dictionary should contain "name" and "title" keys 103 | * @param layerDictionary Layer dictionary 104 | */ 105 | + (SGLayer *)layerWithDictionary:(NSDictionary *)layerDictionary; 106 | 107 | /** 108 | * Construct an SGLayer from a dictionary; 109 | * Dictionary should contain "name" and "title" keys 110 | * @param layerDictionary Layer dictionary 111 | */ 112 | - (id)initWithDictionary:(NSDictionary *)layerDictionary; 113 | 114 | #pragma mark - 115 | #pragma mark Convenience 116 | 117 | /** 118 | * Dictionary representation of the layer 119 | */ 120 | - (NSDictionary *)asDictionary; 121 | 122 | @end 123 | -------------------------------------------------------------------------------- /Project/Shared/Classes/Utility/SGPreprocessorMacros.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGPreprocessorMacros.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2010, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #define SG_CATEGORY(name) @interface SG_CATEGORY_##name @end @implementation SG_CATEGORY_##name @end 32 | 33 | #define SG_RELEASE(a) [a release] 34 | #define SG_RETAIN(a) [a retain] 35 | #define SG_AUTORELEASE(a) [a autorelease] 36 | -------------------------------------------------------------------------------- /Project/Shared/Config/Global.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // Global.xcconfig 3 | // SimpleGeo 4 | // 5 | 6 | DYLIB_COMPATIBILITY_VERSION = 2 7 | DYLIB_CURRENT_VERSION = 2.2.3 8 | 9 | PRODUCT_NAME = SimpleGeo 10 | WRAPPER_EXTENSION = framework 11 | FRAMEWORK_VERSION = A 12 | GCC_MODEL_TUNING = G5 13 | GCC_PRECOMPILE_PREFIX_HEADER = YES 14 | ALWAYS_SEARCH_USER_PATHS = NO 15 | -------------------------------------------------------------------------------- /Project/iOS/Classes/Mapkit/SGEnvelope+Mapkit.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGEnvelope+Mapkit.h 3 | // SimpleGeo 4 | // 5 | // Copyright (c) 2010-2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import 32 | #import "SGEnvelope.h" 33 | 34 | /*! 35 | * Category for SGEnvelope. 36 | * Adds Mapkit features for iOS 37 | */ 38 | @interface SGEnvelope (Mapkit) 39 | 40 | #pragma mark - 41 | #pragma mark Instantiation 42 | 43 | /** 44 | * Create a bounding box from an MKMapRect 45 | * @param mapRect Map rectangle 46 | */ 47 | + (SGEnvelope *)envelopeWithMapRect:(MKMapRect)mapRect; 48 | 49 | /** 50 | * Construct a bounding box from an MKMapRect 51 | * @param mapRect Map rectangle 52 | */ 53 | - (id)initWithMapRect:(MKMapRect)mapRect; 54 | 55 | #pragma mark - 56 | #pragma mark Convenience 57 | 58 | - (MKMapRect)mapRect; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Project/iOS/Classes/Mapkit/SGEnvelope+Mapkit.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGEnvelope+Mapkit.m 3 | // SimpleGeo 4 | // 5 | // Copyright (c) 2010-2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import 32 | #import "SGEnvelope+Mapkit.h" 33 | 34 | #import "SGPreprocessorMacros.h" 35 | 36 | @implementation SGEnvelope (Mapkit) 37 | 38 | #pragma mark - 39 | #pragma mark Instantiation 40 | 41 | + (SGEnvelope *)envelopeWithMapRect:(MKMapRect)mapRect 42 | { 43 | return [[[SGEnvelope alloc] initWithMapRect:mapRect] autorelease]; 44 | } 45 | 46 | - (id)initWithMapRect:(MKMapRect)mapRect 47 | { 48 | MKMapPoint nwMapPoint = MKMapPointMake(mapRect.origin.x, mapRect.origin.y); 49 | MKMapPoint seMapPoint = MKMapPointMake(mapRect.origin.x + mapRect.size.width, mapRect.origin.y + mapRect.size.height); 50 | CLLocationCoordinate2D nwCoord = MKCoordinateForMapPoint(nwMapPoint); 51 | CLLocationCoordinate2D seCoord = MKCoordinateForMapPoint(seMapPoint); 52 | return [self initWithWithNorth:nwCoord.latitude 53 | west:nwCoord.longitude 54 | south:seCoord.latitude 55 | east:seCoord.longitude]; 56 | } 57 | 58 | #pragma mark - 59 | #pragma mark Convenience 60 | 61 | - (MKMapRect)mapRect 62 | { 63 | MKMapPoint nw = MKMapPointForCoordinate(CLLocationCoordinate2DMake(north, west)); 64 | MKMapPoint se = MKMapPointForCoordinate(CLLocationCoordinate2DMake(south, east)); 65 | MKMapRect mapBounds = MKMapRectMake(nw.x, nw.y, (se.x-nw.x), (se.y-nw.y)); 66 | return mapBounds; 67 | } 68 | 69 | - (MKPolygon *)asMKPolygon 70 | { 71 | CLLocationCoordinate2D coordinates[5] = { 72 | CLLocationCoordinate2DMake(north, west), 73 | CLLocationCoordinate2DMake(north, east), 74 | CLLocationCoordinate2DMake(south, east), 75 | CLLocationCoordinate2DMake(south, west), 76 | CLLocationCoordinate2DMake(north, west)}; 77 | MKPolygon *polygon = [MKPolygon polygonWithCoordinates:coordinates count:5 interiorPolygons:nil]; 78 | free(coordinates); 79 | return polygon; 80 | } 81 | 82 | - (NSArray *)overlays 83 | { 84 | return [NSArray arrayWithObject:[self asMKPolygon]]; 85 | } 86 | 87 | @end 88 | 89 | SG_CATEGORY(SGEnvelopeMapkit) 90 | -------------------------------------------------------------------------------- /Project/iOS/Classes/Mapkit/SGGeometry+Mapkit.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGGeometry+Mapkit.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGGeometry.h" 32 | 33 | /*! 34 | * Category for SGGeometry. 35 | * Adds Mapkit features for iOS 36 | */ 37 | @interface SGGeometry (Mapkit) 38 | 39 | /*! 40 | * The Geometry as an array of MKOverlays 41 | */ 42 | - (NSArray *)overlays; 43 | 44 | @end -------------------------------------------------------------------------------- /Project/iOS/Classes/Mapkit/SGGeometry+Mapkit.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGGeometry+Mapkit.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGGeometry+Mapkit.h" 32 | 33 | #import "SGPreprocessorMacros.h" 34 | 35 | @implementation SGGeometry (Mapkit) 36 | 37 | - (NSArray *)overlays 38 | { 39 | return nil; 40 | // subclasses must implement 41 | } 42 | 43 | @end 44 | 45 | SG_CATEGORY(SGGeometryMapKit) -------------------------------------------------------------------------------- /Project/iOS/Classes/Mapkit/SGMultiPolygon+Mapkit.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGMultiPolygon+Mapkit.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGMultiPolygon.h" 32 | 33 | /*! 34 | * Category for SGMultiPolygon. 35 | * Adds Mapkit features for iOS 36 | */ 37 | @interface SGMultiPolygon (Mapkit) 38 | 39 | /*! 40 | * An equivalent array of MKPolygons 41 | */ 42 | - (NSArray *)asMKPolygons; 43 | 44 | @end -------------------------------------------------------------------------------- /Project/iOS/Classes/Mapkit/SGMultiPolygon+Mapkit.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGMultiPolygon+Mapkit.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGMultiPolygon+Mapkit.h" 32 | #import "SGPolygon+Mapkit.h" 33 | 34 | #import "SGPreprocessorMacros.h" 35 | 36 | @implementation SGMultiPolygon (Mapkit) 37 | 38 | - (NSArray *)asMKPolygons 39 | { 40 | NSMutableArray *mkPolygons = [NSMutableArray array]; 41 | // for each polygon, get the MKPolygon and add it to the array 42 | for (SGPolygon *polygon in polygons) { 43 | [mkPolygons addObject:[polygon asMKPolygon]]; 44 | } 45 | return mkPolygons; 46 | } 47 | 48 | - (NSArray *)overlays 49 | { 50 | return [self asMKPolygons]; 51 | } 52 | 53 | @end 54 | 55 | SG_CATEGORY(SGMultiPolygonMapKit) -------------------------------------------------------------------------------- /Project/iOS/Classes/Mapkit/SGPoint+Mapkit.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGPoint+Mapkit.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import 32 | #import "SGPoint.h" 33 | 34 | /*! 35 | * Category for SGPoint. 36 | * Adds Mapkit features for iOS 37 | */ 38 | @interface SGPoint (Mapkit) 39 | 40 | /*! 41 | * An equivalent Core Location coordinate 42 | */ 43 | - (CLLocationCoordinate2D)coordinate; 44 | 45 | @end -------------------------------------------------------------------------------- /Project/iOS/Classes/Mapkit/SGPoint+Mapkit.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGPoint+Mapkit.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import "SGPoint+Mapkit.h" 32 | 33 | #import "SGPreprocessorMacros.h" 34 | 35 | @implementation SGPoint (Mapkit) 36 | 37 | - (CLLocationCoordinate2D)coordinate 38 | { 39 | return CLLocationCoordinate2DMake(self.latitude, self.longitude); 40 | } 41 | 42 | @end 43 | 44 | SG_CATEGORY(SGPointMapkit) -------------------------------------------------------------------------------- /Project/iOS/Classes/Mapkit/SGPolygon+Mapkit.h: -------------------------------------------------------------------------------- 1 | // 2 | // SGPolygon+Mapkit.h 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import 32 | #import "SGPolygon.h" 33 | 34 | /*! 35 | * Category for SGPolygon. 36 | * Adds Mapkit features for iOS 37 | */ 38 | @interface SGPolygon (Mapkit) 39 | 40 | /*! 41 | * An equivalent MKPolygon 42 | */ 43 | - (MKPolygon *)asMKPolygon; 44 | 45 | @end -------------------------------------------------------------------------------- /Project/iOS/Classes/Mapkit/SGPolygon+Mapkit.m: -------------------------------------------------------------------------------- 1 | // 2 | // SGPolygon+Mapkit.m 3 | // SimpleGeo.framework 4 | // 5 | // Copyright (c) 2011, SimpleGeo Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are met: 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // * Neither the name of the nor the 16 | // names of its contributors may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #import 32 | #import "SGPolygon+Mapkit.h" 33 | #import "SGPoint.h" 34 | 35 | #import "SGPreprocessorMacros.h" 36 | 37 | @interface SGPolygon (Private) 38 | + (MKPolygon *)makeMKPolygon:(NSArray *)points 39 | withInteriorRegions:(NSArray *)holes; 40 | @end 41 | 42 | @implementation SGPolygon (Mapkit) 43 | 44 | - (MKPolygon *)asMKPolygon 45 | { 46 | NSMutableArray *holePolygons = [NSMutableArray array]; 47 | for (NSArray *hole in [self holes]) 48 | [holePolygons addObject:[SGPolygon makeMKPolygon:hole withInteriorRegions:nil]]; 49 | return [SGPolygon makeMKPolygon:[self boundary] withInteriorRegions:holePolygons]; 50 | } 51 | 52 | - (NSArray *)overlays 53 | { 54 | return [NSArray arrayWithObject:[self asMKPolygon]]; 55 | } 56 | 57 | + (MKPolygon*)makeMKPolygon:(NSArray*)points 58 | withInteriorRegions:(NSArray*)holes 59 | { 60 | // convert SGPoints to CLCoordinates 61 | int numPoints = [points count]; 62 | CLLocationCoordinate2D* coordinates = malloc(sizeof(CLLocationCoordinate2D) * numPoints); 63 | for (int i=0; i 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.simplegeo.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Project/iOS/SimpleGeo-Prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #import 4 | #endif 5 | 6 | #define SGLog NSLog -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SimpleGeo.framework 2 | 3 | `SimpleGeo.framework` is an Objective-C client library for the SimpleGeo API, suitable for use in both Mac OS X and iOS applications. 4 | 5 | ## Downloading the Framework 6 | 7 | `SimpleGeo.framework` is available as a branch suitable for use as a [git submodule](http://book.git-scm.com/5_submodules.html). In either case, you'll want to place the framework in a subdirectory beneath your app. 8 | 9 | Here's an example of adding `SimpleGeo.framework` as a submodule: 10 | 11 | $ git submodule add -b framework-ios git://github.com/simplegeo/SimpleGeo.framework.git Resources/SimpleGeo.framework 12 | 13 | You may also choose to simply download the ios-framework branch and drag the SimpleGeo.framework folder into your Xcode project: 14 | 15 | $ git clone -b framework-ios git://github.com/simplegeo/SimpleGeo.framework.git Resources/SimpleGeo.framework 16 | 17 | ## Embedding in an iOS Application 18 | 19 | Once `SimpleGeo.framework` has been placed in a subdirectory beneath your app, drag it into your Xcode project; it will show up as a linked framework. 20 | 21 | Add the following additional frameworks to your project by clicking on your Target, choosing the "Build Phases" tab, and using the `+` button at the bottom of the "Linked Libraries" section: 22 | 23 | * Foundation 24 | * UIKit 25 | * CoreGraphics 26 | * CFNetwork 27 | * SystemConfiguration 28 | * MobileCoreServices 29 | * CoreLocation 30 | * MapKit 31 | * libz 32 | * SimpleGeo (if it's not already present) 33 | 34 | 35 | [SimpleGeo-iOS](https://github.com/simplegeo/SimpleGeo-iOS) is an example of an iOS application built using `SimpleGeo.framework`. 36 | 37 | ## Embedding in a Cocoa Application 38 | 39 | Once `SimpleGeo.framework` has been placed in a subdirectory beneath your app, drag it into your Xcode project; it will show up as a linked framework. 40 | 41 | Add the following additional frameworks to your project by clicking on your Target, choosing the "Build Phases" tab, and using the `+` button at the bottom of the "Linked Libraries" section: 42 | 43 | * CoreServices 44 | * SystemConfiguration 45 | * libz 46 | * SimpleGeo (if it's not already present) 47 | 48 | [SimpleGeo-Mac](https://github.com/simplegeo/SimpleGeo-Mac) is an example of a Cocoa application built using `SimpleGeo.framework`. 49 | 50 | ## Getting Started 51 | 52 | If you'd like help getting started with some basic tutorials, visit our [Objective-C tutorials](https://simplegeo.com/docs/tutorials/objective-c) page. 53 | 54 | ## Working from Source 55 | 56 | You may download and modify the `SimpleGeo.framework` source code to meet custom needs. If you make edits that may be appreciated by others, please submit a GitHub pull request. 57 | 58 | ### Downloading Dependencies 59 | 60 | `SimpleGeo.framework` depends on the following codebases: 61 | 62 | * [`SGObjCHTTP`](https://github.com/simplegeo/SGObjCHTTP) (a git submodule) 63 | * [`GHUnit.framework`](https://github.com/gabriel/gh-unit/downloads) (a testing framework) 64 | 65 | An included script can get you up and running quickly. To download and update dependencies, simply run: 66 | 67 | ./Scripts/update-dependencies 68 | 69 | The script does the following: 70 | 71 | * Downloads [`GHUnit.framework`](https://github.com/gabriel/gh-unit/downloads) into the framework's Project/Mac/Tests/Resources/ directory 72 | * Runs `$ git submodule update --init` to download and update the [`SGObjCHTTP`](https://github.com/simplegeo/SGObjCHTTP) submodule. 73 | * Runs `$ git submodule update --init` for [`SGObjCHTTP`](https://github.com/simplegeo/SGObjCHTTP) sub-dependencies. 74 | 75 | ### Building for iOS 76 | 77 | To generate a usable `SimpleGeo.framework` for iOS from the command-line: 78 | 79 | $ cd Project/iOS 80 | $ make 81 | 82 | The resulting framework will appear in `Project/iOS/Build/Release-iphoneos`. 83 | 84 | Building from the command-line will create an über-Universal framework, built for `armv6` and `armv7` devices as well as the iOS Simulator. 85 | 86 | ### Building for OS X 87 | 88 | To generate a usable `SimpleGeo.framework` for OS X from the command-line: 89 | 90 | $ cd Project/Mac 91 | $ make 92 | 93 | The resulting framework will appear in `Project/Build/Release`. 94 | 95 | ### Docs 96 | 97 | To generate html docs and install a handy Xcode docset: 98 | 99 | $ cd Documentation 100 | $ make 101 | 102 | ## Support 103 | 104 | `SimpleGeo.framework` is fully supported by SimpleGeo. If you have any questions, comments, or bug reports, please contact us via our Google Groups [support page.](https://groups.google.com/forum/#!forum/simplegeo) 105 | -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # Release Checklist 2 | 3 | ## Prep 4 | 5 | * run tests 6 | * make sure framework, framework-ios, and gh-pages branches are up to date 7 | * update version numbers in `Global.xcconfig` 8 | * update `CHANGELOG.md` and add release date 9 | * commit the master branch 10 | 11 | ## Build and Deploy 12 | 13 | * ./scripts/deploy 14 | -------------------------------------------------------------------------------- /scripts/deploy: -------------------------------------------------------------------------------- 1 | # !/bin/bash 2 | # 3 | # This script will create and tag the Mac OS X 4 | # and iOS frameworks for the passed in version. 5 | # 6 | # Note: This script should only be executed when 7 | # it is necessary to generate a new release. 8 | 9 | VERSION=$1 10 | DEBUG=$2 11 | 12 | if [ -z "$VERSION" ] 13 | then 14 | echo "Please specify a version" 15 | exit 1 16 | fi 17 | 18 | echo "Using ${VERSION} for building..." 19 | 20 | TOP_DIR=`pwd` 21 | 22 | TMP_IOS_FILE=/tmp/SimpleGeo-$VERSION.tgz 23 | TMP_MAC_FILE=/tmp/SimpleGeo-iOS-$VERSION.tgz 24 | TMP_DOC_FILE=/tmp/SimpleGeo-$VERSION-docset.tgz 25 | 26 | # Build Mac OS X Framework 27 | ./scripts/update-dependencies 28 | cd Project/Mac 29 | make 30 | if [ $? != 0 ]; then 31 | echo "Failed to make Mac OS X framework" 32 | exit 1 33 | fi 34 | cd build/Release 35 | tar zcf $TMP_MAC_FILE SimpleGeo.framework 36 | cd $TOP_DIR 37 | 38 | # Build iOS Framework 39 | ./scripts/update-dependencies 40 | cd Project/iOS 41 | make dist 42 | if [ $? != 0 ]; then 43 | echo "Failed to make iOS framework" 44 | exit 1 45 | fi 46 | mv SimpleGeo-iOS.tgz $TMP_IOS_FILE 47 | cd $TOP_DIR 48 | 49 | # Documentation 50 | #cd Documentation 51 | #make 52 | #if [ $? != 0 ]; then 53 | # echo "Failed to make documentation for framework" 54 | # exit 1 55 | #fi 56 | #cd html 57 | #tar zcf $TM_DOC_FILE 58 | #cd $TOP_DIR 59 | #git checkout gh-pages 60 | #mkdir $VERSION 61 | #cp -R Documentation/html/* $VERSION/ 62 | #git add $VERSION/ 63 | #git commit -m "Docs for ${VERSION}" 64 | 65 | # Update Mac OS X Framework 66 | git checkout framework 67 | rm -rf * 68 | tar zxf $TMP_MAC_FILE 69 | mv SimpleGeo.framework/* . 70 | rmdir SimpleGeo.framework 71 | git add * 72 | git commit -am "Version $VERSION" 73 | git tag -f $VERSION-framework 74 | 75 | # Update iOS Framework 76 | git checkout framework-ios 77 | rm -rf * 78 | tar zxf $TMP_IOS_FILE 79 | mv SimpleGeo.framework/* . 80 | rmdir SimpleGeo.framework 81 | git add * 82 | git commit -am "Version $VERSION" 83 | git tag -f $VERSION-framework-ios 84 | 85 | # Push it out to the remote repository 86 | git checkout master 87 | git push 88 | git push --tags 89 | -------------------------------------------------------------------------------- /scripts/update-dependencies: -------------------------------------------------------------------------------- 1 | DIR=$(dirname $0) 2 | cd $DIR 3 | 4 | # Download Mac dependencies 5 | 6 | curl -s http://cloud.github.com/downloads/gabriel/gh-unit/GHUnit-0.4.30.zip > GHUnit.zip 7 | unzip GHUnit -d ../Project/Mac/Tests/Resources/ 8 | rm GHUnit.zip 9 | 10 | # Download iOS dependencies 11 | 12 | #curl -s http://cloud.github.com/downloads/gabriel/gh-unit/GHUnitIOS-0.4.30.zip > GHUnitIOS.zip 13 | #unzip GHUnitIOS -d ../iOS/ext/ 14 | #rm GHUnitIOS.zip 15 | 16 | # Download & update git submodules 17 | 18 | command -v git >/dev/null && cd ../ && git submodule update --init && cd Project/Shared/Resources/SGObjCHTTP && git submodule update --init && exit 19 | 20 | # If git not installed, just download the repos 21 | 22 | echo 'Error: Please install git to download dependencies.' 23 | exit 24 | 25 | #curl -s https://download.github.com/pokeb-asi-http-request-v1.8.1-0-g404bbfe.zip > asi-http-request.zip 26 | #unzip asi-http-request -d ../Resources/ 27 | #rm asi-http-request.zip 28 | 29 | #curl -s https://download.github.com/AlterTap-asi-http-request-oauth-3179c3a.zip > asi-http-request-oauth.zip 30 | #unzip asi-http-request-oauth -d ../Resources/ 31 | #rm asi-http-request-oauth.zip 32 | 33 | #curl -s https://nodeload.github.com/johnezang/JSONKit/zipball/master 34 | #unzip JSONKit -d ../Resources/ 35 | #rm JSONKit.zip 36 | -------------------------------------------------------------------------------- /scripts/update-factual-categories.py: -------------------------------------------------------------------------------- 1 | import os 2 | import urllib2 3 | import csv 4 | import re 5 | 6 | ##### Convert a name to a variable name 7 | 8 | def cleanName(name): 9 | return re.sub('[\W_]+', '', name.replace('&','And')) 10 | 11 | ##### Load the categories endpoint 12 | 13 | file = urllib2.urlopen('http://wiki.developer.factual.com/f/Categories.csv') 14 | r = csv.reader(file) 15 | 16 | ##### Form the list 17 | 18 | cats = [] 19 | 20 | for entry in r: 21 | this_cat = entry[0].split(' > ').pop() 22 | try: 23 | cats.index(this_cat) 24 | except: 25 | cats.append(this_cat) 26 | 27 | ##### Generate the file 28 | 29 | output = '' 30 | 31 | output += '\n#pragma mark Factual Categories (Places >= 1.2)\n\n' 32 | for cat in cats: 33 | output += '#define FactualCategory' + cleanName(cat) + ' @\"' + cat + '\"\n' 34 | 35 | ##### Write file 36 | 37 | output = '\ 38 | //\n\ 39 | // FactualCategories.h\n\ 40 | // SimpleGeo.framework\n\ 41 | //\n\ 42 | // Copyright (c) 2010, SimpleGeo Inc.\n\ 43 | // All rights reserved.\n\ 44 | //\n\ 45 | // Redistribution and use in source and binary forms, with or without\n\ 46 | // modification, are permitted provided that the following conditions are met:\n\ 47 | // * Redistributions of source code must retain the above copyright\n\ 48 | // notice, this list of conditions and the following disclaimer.\n\ 49 | // * Redistributions in binary form must reproduce the above copyright\n\ 50 | // notice, this list of conditions and the following disclaimer in the\n\ 51 | // documentation and/or other materials provided with the distribution.\n\ 52 | // * Neither the name of the nor the\n\ 53 | // names of its contributors may be used to endorse or promote products\n\ 54 | // derived from this software without specific prior written permission.\n\ 55 | //\n\ 56 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\n\ 57 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n\ 58 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n\ 59 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n\ 60 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n\ 61 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n\ 62 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n\ 63 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\ 64 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n\ 65 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\ 66 | //\n\n' + output 67 | 68 | script_path = os.path.realpath(__file__) 69 | base_path = script_path.split('Scripts')[0] 70 | output_path = base_path + 'Project/Shared/Classes/Client/Params/FactualCategories.h' 71 | 72 | outputFile = open(output_path,'w+') 73 | outputFile.write(output) 74 | outputFile.close() 75 | -------------------------------------------------------------------------------- /scripts/update-sg-categories.py: -------------------------------------------------------------------------------- 1 | import os 2 | import urllib2 3 | import json 4 | import re 5 | 6 | ##### Convert a name to a variable name 7 | 8 | def cleanName(name): 9 | return re.sub('[\W_]+', '', name.replace('&','And')) 10 | 11 | ##### Load the categories endpoint 12 | 13 | file = urllib2.urlopen('http://api.simplegeo.com/1.0/features/categories.json') 14 | contents = json.loads(file.read()) 15 | 16 | ##### Instantiate the category lists 17 | 18 | types = [] 19 | fcats = [] 20 | fsubcats = [] 21 | pcats = [] 22 | psubcats = [] 23 | 24 | ##### Form the lists 25 | 26 | for entry in contents: 27 | thisType = entry['type'] 28 | thisCat = entry['category'] 29 | thisSubcat = entry['subcategory'] 30 | 31 | if thisType and thisType != '': 32 | try: 33 | types.index(thisType) 34 | except: 35 | types.append(thisType) 36 | 37 | cats = pcats 38 | subcats = psubcats 39 | if thisType == 'Region': 40 | cats = fcats 41 | subcats = fsubcats 42 | 43 | if thisCat and thisCat != '': 44 | try: 45 | cats.index(thisCat) 46 | except: 47 | cats.append(thisCat) 48 | 49 | if thisSubcat and thisSubcat != '': 50 | try: 51 | subcats.index(thisSubcat) 52 | except: 53 | subcats.append(thisSubcat) 54 | 55 | ##### Generate the file 56 | 57 | output = 'typedef NSString * SGFeatureType;\n\ 58 | typedef NSString * SGFeatureCategory;\n\ 59 | typedef NSString * SGFeatureSubcategory;\n' 60 | 61 | # Feature types 62 | 63 | output += '\n#pragma mark Feature Types\n\n' 64 | for typ in types: 65 | output += '#define SGFeatureType' + cleanName(typ) + ' @\"' + typ + '\"\n' 66 | 67 | # Feature categories (Context) 68 | 69 | output += '\n#pragma mark Feature Categories (Context)\n\n' 70 | for cat in fcats: 71 | output += '#define SGFeatureCategory' + cleanName(cat) + ' @\"' + cat + '\"\n' 72 | 73 | output += '\n#pragma mark Feature Subcategories (Context)\n\n' 74 | for subcat in fsubcats: 75 | output += '#define SGFeatureSubcategory' + cleanName(subcat) + ' @\"' + subcat + '\"\n' 76 | 77 | # Feature categories (Places 1.0) 78 | 79 | output += '\n#pragma mark Place Categories (Places 1.0)\n\n' 80 | for cat in pcats: 81 | output += '#define SGPlaceCategory' + cleanName(cat) + ' @\"' + cat + '\"\n' 82 | for subcat in psubcats: 83 | output += '#define SGPlaceCategory' + cleanName(subcat) + ' @\"' + subcat + '\"\n' 84 | 85 | ##### Write file 86 | 87 | output = '\ 88 | //\n\ 89 | // SGCategories.h\n\ 90 | // SimpleGeo.framework\n\ 91 | //\n\ 92 | // Copyright (c) 2010, SimpleGeo Inc.\n\ 93 | // All rights reserved.\n\ 94 | //\n\ 95 | // Redistribution and use in source and binary forms, with or without\n\ 96 | // modification, are permitted provided that the following conditions are met:\n\ 97 | // * Redistributions of source code must retain the above copyright\n\ 98 | // notice, this list of conditions and the following disclaimer.\n\ 99 | // * Redistributions in binary form must reproduce the above copyright\n\ 100 | // notice, this list of conditions and the following disclaimer in the\n\ 101 | // documentation and/or other materials provided with the distribution.\n\ 102 | // * Neither the name of the nor the\n\ 103 | // names of its contributors may be used to endorse or promote products\n\ 104 | // derived from this software without specific prior written permission.\n\ 105 | //\n\ 106 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\n\ 107 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n\ 108 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n\ 109 | // DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n\ 110 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n\ 111 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n\ 112 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n\ 113 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\ 114 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n\ 115 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\ 116 | //\n\n' + output 117 | 118 | script_path = os.path.realpath(__file__) 119 | base_path = script_path.split('Scripts')[0] 120 | output_path = base_path + 'Project/Shared/Classes/Client/Params/SGCategories.h' 121 | 122 | outputFile = open(output_path,'w+') 123 | outputFile.write(output) 124 | outputFile.close() 125 | --------------------------------------------------------------------------------