Code Monkey home page Code Monkey logo

shapekit's Introduction

ShapeKit

ShapeKit is a geometry library for iOS that aims to bridge GEOS with Apple's MapKit.

Requirements

ShapeKit uses the MKShape Geometries (MKPolygon, MKPointAnnotation, MKPolyline) which were added to MapKit in iOS 4.0. It has been tested on the iPhone, and will most likely just work on the iPad when iOS 4 is released for it.

ShapeKit depends on GEOS. There is a build script in lib_src which will automate downloading and building the library for both ARM and x86 (simulator) and will copy the libraries and headers to ~/Developer. To use it, simply run the build_libs.sh script in the lib_src directory to install the libraries and headers to ~/Developer. Next, drag one copy each of libgeos.a and libgeos_c.a to the Frameworks folder in your project's Xcode window. Finally, double-click on the project's Target and in the Build tab of the Info window that pops up, add $(HOME)/$(SDK_DIR)/include to the Header Search Path, and $(HOME)/$(SDK_DIR)/lib to the Library Search Path. Now Xcode should be able to find the GEOS library.

Features

  • ShapeKitGeometries are standard cocoa objects

    ShapeKitPoint *myPoint = [[ShapeKitPoint alloc] initWithCoordinate:CLLocationCoordinate2DMake(0, 0)];

  • ShapeKitGeometries have standard MKShape geometries for use with MapKit

    myPoint.geometry.title = @"Centre of the Universe";

    myPoint.geometry.subtitle = @"The most awesome place in the world";

    [myMapKitView addAnnotation:myPoint.geometry]

  • ShapeKitGeometries also have GEOS geometries for use with the GEOS C API

    GEOSGeometry *bufferedPoint = GEOSBuffer(myPoint.geosGeom, 1, 0);

    (NOTE: the plan is to eventually abstract the underlying GEOS functions away behind Objective-C wrappers)

  • GEOS functions are abstracted into Objective-C methods that operate directly on ShapeKitGeometries

    ShapeKitPolygon *polygon = [[ShapeKitPolygon alloc] initWithWKT:@"POLYGON((-1 -1, -1 1, 1 1, 1 -1, -1 -1))"];

    [polygon containsGeometry:myPoint] \\ Returns YES

Usage

After following the instructions above to set up GEOS, simply drag the ShapeKit folder into Xcode. You will also need to add the CoreLocation and MapKit frameworks to your project. See the sample Xcode project for a simple example of a ShapeKit app.

Future

The plan is to turn this into a more generic geo library for iOS with support for projections (through PROJ4) and vector data loading (though OGR).

License

This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Public Licence as published by the Free Software Foundation. See the COPYING file for more information.

shapekit's People

Contributors

mweisman avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.