Coder Social home page Coder Social logo

geolib's Introduction

GeoLib

Introduction

This library provides functions for calculating the geographical distance between two points on the Earth's surface.

The user has the ability to define their custom point type to be used for distance computation. We employ traits for accessing structure elements. Therefore, these have to be specialized by the library user. An example structure is shown below:

struct CustomPoint
{
  CustomPoint(double latitude, double longitude) :
    latitude(latitude),
    longitude(longitude) {}
  double latitude, longitude;
 };

This then has to be specialized with the generic functions getRadian and getDegree. We have to implement these in the PointTrait namespace. An example specialization is provided below:

namespace PointTrait
{
    template <>
    struct AccessPoint<CustomPoint, 0>
    {
        static double getRadian(CustomPoint const& p)
        { return p.latitude * M_PI / 180; }

        static double getDegree(CustomPoint const& p)
        { return p.latitude; }
    };
    template <>
    struct AccessPoint<CustomPoint, 1>
    {
        static double getRadian(CustomPoint const& p)
        { return p.longitude * M_PI / 180; }

        static double getDegree(CustomPoint const& p)
        { return p.longitude; }
    };
}

To see this in action, please refer to the tests/geodistance_test.cpp file.

Build instructions

First clone the repository with the following command:

$ git clone https://github.com/adl1995/boost-geometry-proposal.git

Then, cd into the cloned repository by:

$ cd boost-geometry-proposal
$ cd geolib

To compile the library, first create a build directory:

$ mkdir build
$ cd build

The next step is to run CMake to configure the project:

$ cmake ../

Once CMake is configured, the library can be built by typing make. This will build the 'geolib_tests' component:

$ make

The tests can be run by typing:

$ make tests

To build the documentation using Doxygen, type:

$ make docs

Finally, the HTML documentation can be opened with Firefox by typing:

$ firefox docs/html/index.html

Results

For benchmarking, we calculate the average execution time over all the distance algorithms. The dataset used is: Test set for geodesics, by Karney, Charles. For the purpose of this demonstration, only 15000 entries are used for testing.

The bar chart below tries to visually compare the average execution time for each distance formula. This was calculated using the g++ compiler (version 7.2.0 on Ubuntu 14.04) with the O1 optimization level:

execution-times

geolib's People

Contributors

adl1995 avatar

Watchers

 avatar  avatar  avatar

geolib's Issues

Review 1

Hi, thanks for sharing this! I have some comments. The more you address the more competitive your application will be.

Regarding the code, first, the requirements state that it should fit in one header file. Moreover, that it should be as generic as possible. There is a lot of space for improvement here. Tip: use templates and look at Boost.Geometry source code.

Regarding algorithms: interesting formulas but none of them is very accurate Cf. Vincenty formula.

Regarding tests: could you test against Boost.Geometry algorithms for distance? Also make them more generic (there is a lot of repentance). You could also have cases of tests for short, medium and long distances. If you like you can use this dataset for extensive tests: https://zenodo.org/record/32156#.WOyaMrUmv7C

Build

mkdir build and cmake .. should be run in geolib folder

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.