Git Product home page Git Product logo

dopenlocationcode's Introduction

DOpenLocationCode

Port of the open-location-code library (also known as plus codes) for identifying geo areas.

This ports commit a6eb95b.

Example

normal usage:

import openlocationcode;

double lat = 54;
double lon = 4;

// get geo coordinates from plus code string
OpenLocationCode plusCode = OpenLocationCode.fromString("8FVC2222+22GCCCC");
writeln(plusCode.decode());
// -> OpenLocationCodeArea(47.0001, 8.00006, 47.0001, 8.00006, 15)

// get plus code string from geo coordinates
OpenLocationCode generatedPlusCode = OpenLocationCode.encode(lat, lon);
writeln(generatedPlusCode.code);
// -> 9F662222+22

nothrow @nogc usage:

import openlocationcode;

double lat = 54;
double lon = 4;

// get geo coordinates from plus code string
string input = "8FVC2222+22GCCCC";
// make sure to only use uppercase characters in your input!
if (!input.isValidUppercaseCode)
	return error;
OpenLocationCode plusCode = OpenLocationCode.fromTrustedString(input);

if (!plusCode.isFull)
	return error;
OpenLocationCodeArea area = plusCode.decodeTrustedFull();
printf("area around %f, %f\n", area.centerLatitude, area.centerLongitude);
// -> area around 47.000062, 8.000063

// get plus code string from geo coordinates
ubyte[maxOLCLength] buffer;
scope ubyte[] generatedPlusCodeString = OpenLocationCode.encode(buffer, lat, lon);
printf("%.*s\n", generatedPlusCodeString.length, &generatedPlusCodeString[0]);
// -> 9F662222+22

dopenlocationcode's People

Contributors

webfreak001 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.