Skip to content
Commits on Source (2)
# Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
# Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......
Original C library created by Pieter Geelen. Work on Java version
of the Mapcode library by Rijn Buve (original port by Matthew Lowden).
Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
# Mapcode Library for C/C++
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d2e3d7a469484bfd8b801ce94d3f1737)](https://www.codacy.com/app/rijnb/mapcode-cpp?utm_source=github.com&utm_medium=referral&utm_content=mapcode-foundation/mapcode-cpp&utm_campaign=Badge_Grade)
[![License](http://img.shields.io/badge/license-APACHE2-blue.svg)]()
**Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)**
**Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)**
**Online documentation: http://mapcode-foundation.github.io/mapcode-cpp/**
......@@ -64,7 +65,7 @@ decode Mapcodes.
This produces the following help text:
MAPCODE (version 2.5.2)
Copyright (C) 2014-2016 Stichting Mapcode Foundation
Copyright (C) 2014-2017 Stichting Mapcode Foundation
Usage:
mapcode [-d| --decode] <default-territory> <mapcode> [<mapcode> ...]
......@@ -176,8 +177,83 @@ To add individual support support for other languages (of all territory names),
The list of support languages may grow over time.
## Using the C Library in an Xcode iOS Swift project
You can use this C library in an iOS application, built with Swift in Xcode, fairly easily.
All you need to do is:
First, copy the directory `mapcodelib` to the source directory of your iOS application.
Then, add a text file called `module.modulemap` in the directory `mapcodelib` to export all symbols
from the C library to Swift (note that `#defines` are not exported):
```
module mapcodelib [system][extern_c]{
header "mapcode_alphabets.h"
header "mapcode_territories.h"
header "mapcoder.h"
export *
}
```
Now, you can access the C library methods like this in a Swift project:
```
// Example of decoding a full mapcode to a lat/lon:
let territory = getTerritoryCode(context, TERRITORY_NONE)
var lat: Double = 0.0
var lon: Double = 0.0
let mapcodeError = decodeMapcodeToLatLonUtf8(&lat, &lon, fullMapcode, territory, nil)
if mapcodeError == ERR_OK {
// Use the decoded lat and lon.
} else {
// Something went wrong decoding the full mapcode string.
}
```
Or encode a latitude, longitude pair to a set of Mapcodes like this:
```
let buffer = UnsafeMutablePointer<Int8>.allocate(capacity: Int(_MAX_MAPCODE_RESULT_ASCII_LEN))
buffer.initialize(to: 0, count: Int(_MAX_MAPCODE_RESULT_ASCII_LEN))
var total: Int32 = 0;
var i: Int32 = 0
repeat {
total = encodeLatLonToSelectedMapcode(buffer, lat, lon, TERRITORY_NONE, 0, i)
if (total > 0) {
let mapcode = String.init(cString: buffer);
}
i = i + 1
} while (i < total)
```
Or get a territory name like this:
```
let buffer = UnsafeMutablePointer<CChar>.allocate(capacity: Int(MAX_TERRITORY_FULLNAME_UTF8_LEN + 1))
buffer.initialize(to: 0, count: Int(_MAX_TERRITORY_FULLNAME_UTF8_LEN + 1))
// Get alpha code.
getTerritoryIsoName(buffer, TERRITORY_NLD, 0)
let alphaCode = String.init(cString: buffer)
// Get full name.
getFullTerritoryNameEnglish(buffer, TERRITORY_NLD, 0)
let fullName = String.init(cString: buffer)
```
## Release Notes
### 2.5.4 - 2.5.5
* Added `encodeLatLonToSelectedMapcode` as a convenience for languages that use the
C library, but have difficulties dealing with multi-dimensional arrays (like Swift).
### 2.5.3
* Cleaned up code after running Codacy code reviews.
* Fixed copyright message.
### 2.5.2
* Added unit test for floating point error with code "40822.schol".
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-2017 Stichting Mapcode Foundation (http://www.mapcode.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......