Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (2)
New upstream version 2.5.4
· f3ceaff6
Bas Couwenberg
authored
Jan 28, 2018
f3ceaff6
New upstream version 2.5.5
· 248b6ee6
Bas Couwenberg
authored
Jan 28, 2018
248b6ee6
Show whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
248b6ee6
# Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
# Copyright (C) 2014-201
7
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.
...
...
NOTICE
View file @
248b6ee6
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-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
Copyright (C) 2014-201
7
Stichting Mapcode Foundation (http://www.mapcode.com)
README.md
View file @
248b6ee6
# Mapcode Library for C/C++
[

](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)
[

]()
**Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)**
**Copyright (C) 2014-201
7
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-201
6
Stichting Mapcode Foundation
Copyright (C) 2014-201
7
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".
...
...
mapcodelib/internal_alphabet_recognizer.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_data.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
mapcodelib/internal_iso3166_data.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_alphabets.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_af.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_ar.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_be.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_cn.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_cs.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_da.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_de.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_en.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_es.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_fi.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_fr.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_he.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
mapcodelib/internal_territory_names_hi.h
View file @
248b6ee6
/*
* Copyright (C) 2014-201
6
Stichting Mapcode Foundation (http://www.mapcode.com)
* Copyright (C) 2014-201
7
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.
...
...
Prev
1
2
3
Next