libosmscout 0.1
|
General utility stuff like enhanced string operations, special data structures... More...
Classes | |
class | osmscout::Breaker |
A breaker object instance allows to trigger cancelation of long running processes. More... | |
class | osmscout::Cache< K, V, IK > |
Generic FIFO cache implementation with O(n log n) semantic. More... | |
class | osmscout::NodeUseMap |
The NodeUseMap can be used to efficiently check if an id used at least twice. More... | |
class | osmscout::NumberSet |
class | osmscout::StopClock |
Simple stop clock implementation. More... | |
Typedefs | |
using | osmscout::FileOffset = uint64_t |
Type for describing the position of data within a file. | |
using | osmscout::Id = uint64_t |
Type to be used for libosmscout internal ids (unsigned numbers with 64 bit size). | |
using | osmscout::OSMId = int64_t |
Type to be used for OSM ids (signed numbers with 64 bit size). | |
using | osmscout::TypeId = uint16_t |
Type for describing a type of an way, area or node. | |
Functions | |
template<typename N > | |
uint8_t | osmscout::BitsNeededToEncodeNumber (N number) |
Returns the number of bytes needed to encode the number. | |
template<typename N > | |
N | osmscout::BitsToBytes (N bits) |
Returns the number of bytes needed to encode the given number of bits. | |
std::string | osmscout::ByteSizeToString (FileOffset size, const Locale &locale=Locale::ByEnvironmentSafe()) |
Prints byte size with short, human readable form by ISO/IEC 80000 standard. | |
template<typename N > | |
uint8_t | osmscout::BytesNeededToEncodeNumber (N number) |
Returns the number of bytes needed to encode the number. | |
size_t | osmscout::CountWords (const std::string &text) |
template<typename N > | |
unsigned int | osmscout::DecodeNumber (const char *buffer, N &number) |
Decode a variable length encoded number from the buffer back to the variable. | |
template<typename N > | |
unsigned int | osmscout::DecodeNumberSigned (const char *buffer, N &number) |
Decode a signed variable length encoded number from the buffer back to the variable. | |
template<typename N > | |
unsigned int | osmscout::DecodeNumberUnsigned (const char *buffer, N &number) |
Decode an unsigned variable length encoded number from the buffer back to the variable. | |
template<typename N > | |
unsigned int | osmscout::EncodeNumber (N number, char *buffer) |
Encode a number into the given buffer using some variable length encoding. | |
template<typename N , size_t S> | |
unsigned int | osmscout::EncodeNumber (N number, std::array< char, S > &buffer) |
Encode a number into the given buffer using some variable length encoding. | |
template<typename N > | |
unsigned int | osmscout::EncodeNumberSigned (N number, char *buffer) |
Encode a signed number into the given buffer using some variable length encoding. | |
template<typename N > | |
unsigned int | osmscout::EncodeNumberUnsigned (N number, char *buffer) |
Encode an unsigned number into the given buffer using some variable length encoding. | |
bool | osmscout::GetDigitValue (char digit, size_t &result) |
Returns the numerical value of the given character, if the character is a digit in a numerical value. | |
std::string | osmscout::GetFirstInStringList (const std::string &stringList, const std::string ÷r) |
Assumes that the string consists of a number of values separated by one of the given divider. | |
void | osmscout::GroupStringListToStrings (std::list< std::string >::const_iterator token, size_t listSize, size_t parts, std::list< std::list< std::string > > &lists) |
Given a list of strings, individual strings will be combined into a given number of sub groups (individual string concatenated and separated by a space). | |
uint64_t | osmscout::InterleaveNumbers (uint32_t a, uint32_t b) |
Encodes the given numbers into a new number of twice the size that has the bits of each number alternating interleaved. | |
std::string | osmscout::LocaleStringToUTF8String (const std::string &text) |
Convert the given std::string in the current locale to a std::string containing a corresponding UTF8 character sequence. | |
std::wstring | osmscout::LocaleStringToWString (const std::string &text) |
Converts the given std::string with content in the current locale to a std::wstring. | |
GeoCoord | osmscout::PolygonCenter (const Area &area, double precision=1) |
A fast algorithm for finding polygon pole of inaccessibility, the most distant internal point from the polygon outline (not to be confused with centroid). | |
std::string | osmscout::ReplaceString (const std::string &in, const std::string &search, const std::string &replacement) |
Replace all occurrences of search in input string by some other string. | |
void | osmscout::SimplifyTokenList (std::list< std::string > &tokens) |
Simplifying a token list by merging tokens that start with an upper case letter followed by a token starting with a lower case letter. | |
std::list< std::string > | osmscout::SplitString (const std::string &stringList, const std::string &separator, int maxSize=-1) |
Split string by separator. | |
std::list< std::string > | osmscout::SplitStringAtSpace (const std::string &input) |
Converts the given string into a list of whitespace separated (std::isspace()) strings. | |
bool | osmscout::StringToBool (const char *string, bool &value) |
Convert the given string to a boolean value. | |
bool | osmscout::StringToNumber (const char *string, double &value) |
bool | osmscout::StringToNumber (const std::string &string, double &value) |
template<typename N > | |
bool | osmscout::StringToNumber (const std::string &string, N &number, size_t base=10) |
Converts a string holding a (possibly negative) numerical value of the given base to the numerical value itself. | |
void | osmscout::TokenizeString (const std::string &input, std::list< std::string > &tokens) |
Converts the given string into a list of whitespace or colon-separated strings. | |
std::string | osmscout::UTF8StringToLocaleString (const std::string &text) |
Convert the given std::string in UTF-8 a std::string containing to corresponding string in the current locale. | |
std::u32string | osmscout::UTF8StringToU32String (const std::string &text) |
Convert the given std::string containign a UTF8 character sequence to a std::u32string. | |
std::wstring | osmscout::UTF8StringToWString (const std::string &text) |
Convert the given std::string containign a UTF8 character sequence to a std::wstring. | |
std::string | osmscout::WStringToLocaleString (const std::wstring &text) |
Converts the given std::wstring to a std::string with content in the current locale. | |
std::string | osmscout::WStringToUTF8String (const std::wstring &text) |
Convert the given std::wstring to a std::string containing a corresponding UTF8 character sequence. | |
Variables | |
const size_t | osmscout::coordByteSize =7 |
Number of bytes needed to store a lat,lon coordinate pair. | |
const double | osmscout::latConversionFactor =(double)maxRawCoordValue/180.0 |
Coordinates will be stored as unsigned long values in file. | |
const double | osmscout::lonConversionFactor =(double)maxRawCoordValue/360.0 |
Coordinates will be stored as unsigned long values in file. | |
General utility stuff like enhanced string operations, special data structures...
using osmscout::FileOffset = typedef uint64_t |
Type for describing the position of data within a file.
using osmscout::Id = typedef uint64_t |
Type to be used for libosmscout internal ids (unsigned numbers with 64 bit size).
using osmscout::OSMId = typedef int64_t |
Type to be used for OSM ids (signed numbers with 64 bit size).
using osmscout::TypeId = typedef uint16_t |
Type for describing a type of an way, area or node.
uint8_t osmscout::BitsNeededToEncodeNumber | ( | N | number | ) |
Returns the number of bytes needed to encode the number.
The function calculates the number of bytes that contain information, dropping leading bytes that only contain zero.
Referenced by osmscout::TypeConfig::RegisterType().
|
inline |
Returns the number of bytes needed to encode the given number of bits.
Referenced by osmscout::TypeInfo::AddFeature(), osmscout::Route::Read(), osmscout::FeatureValueBuffer::Read(), osmscout::Route::Write(), and osmscout::FeatureValueBuffer::Write().
|
extern |
Prints byte size with short, human readable form by ISO/IEC 80000 standard.
It means that KiB stands for 1024 bytes, MiB for 1024^2, GiB 1024^3...
Returned string is locale aware, UTF-8 encoded
References osmscout::ByteSizeToString().
Referenced by osmscout::ByteSizeToString(), osmscout::InstalledMapsModel::data(), and osmscout::AvailableMapsModelMap::getSizeHuman().
uint8_t osmscout::BytesNeededToEncodeNumber | ( | N | number | ) |
Returns the number of bytes needed to encode the number.
The function calculates the number of bytes that contain information, dropping leading bytes that only contain zero.
Referenced by osmscout::BytesNeededToAddressFileData(), and osmscout::TypeConfig::RegisterType().
|
extern |
|
inline |
Decode a variable length encoded number from the buffer back to the variable.
The methods returns the number of bytes read.
Referenced by osmscout::FileScanner::ReadInt16Number(), osmscout::FileScanner::ReadInt32Number(), and osmscout::FileScanner::ReadInt64Number().
|
inline |
Decode a signed variable length encoded number from the buffer back to the variable.
The methods returns the number of bytes read.
|
inline |
Decode an unsigned variable length encoded number from the buffer back to the variable.
The methods returns the number of bytes read.
|
inline |
Encode a number into the given buffer using some variable length encoding.
The current implementation requires the buffer to have at least space for sizeof(N)*8/7 bytes for an unsigned number and sizeof(N)*8/7 + 1/8 bytes for a signed number
This are 5 bytes for a 32bit value and 10 bytes for a 64bit value.
The methods returns the number of bytes written.
Referenced by osmscout::FileWriter::WriteNumber(), osmscout::FileWriter::WriteNumber(), osmscout::FileWriter::WriteNumber(), osmscout::FileWriter::WriteNumber(), osmscout::FileWriter::WriteNumber(), and osmscout::FileWriter::WriteNumber().
|
inline |
Encode a number into the given buffer using some variable length encoding.
The current implementation requires the buffer to have at least space for sizeof(N)*8/7 bytes for an unsigned number and sizeof(N)*8/7 + 1/8 bytes for a signed number
This are 5 bytes for a 32bit value and 10 bytes for a 64bit value.
The methods returns the number of bytes written.
|
inline |
Encode a signed number into the given buffer using some variable length encoding.
The first bit (if set) signals a negative number. The highest bit in a byte is set, if there is an additional byte following. So we use one bit for signaling signess and use 7 of 8 bytes per byte for data.
The current implementation thus requires the buffer to have at least space for sizeof(N)*8/7 + 1/8 bytes:
This are 5 bytes for a 32bit value and 10 bytes for a 64bit value.
The methods returns the number of bytes written.
|
inline |
Encode an unsigned number into the given buffer using some variable length encoding.
The highest bit in a byte is set, if there is an additional byte following. So we use 7 of 8 bytes per byte for data.
The current implementation requires the buffer to have at least space for sizeof(N)*8/7 bytes:
This are 5 bytes for a 32bit value and 10 bytes for a 64bit value.
The methods returns the number of bytes written.
|
extern |
Returns the numerical value of the given character, if the character is a digit in a numerical value.
The current code allows digits in the range from 0-9 and a-f and A-F. And thus supports numerical bases from 1-16.
Referenced by osmscout::StringToNumberSigned(), and osmscout::StringToNumberUnsigned().
|
extern |
Assumes that the string consists of a number of values separated by one of the given divider.
If the list consists of one entry, no divider is used.
Returns the first entry in the list
Referenced by osmscout::ColorFeature::Parse().
|
extern |
Given a list of strings, individual strings will be combined into a given number of sub groups (individual string concatenated and separated by a space).
If you pass a list of 5 strings to be divided into 3 parts, a list of string-list will be returned, where each list contains exactly 3 strings.
References osmscout::GroupStringListToStrings().
Referenced by osmscout::GroupStringListToStrings().
|
extern |
Encodes the given numbers into a new number of twice the size that has the bits of each number alternating interleaved.
This can be used to convert two dimensional coordinates into one number, where coordinates close in 2D are close in the one dimensional projection, too.
Referenced by osmscout::Pixel::GetId().
|
extern |
Convert the given std::string in the current locale to a std::string containing a corresponding UTF8 character sequence.
text | the std::wstring to get converted |
References osmscout::LocaleStringToWString(), and osmscout::WStringToUTF8String().
|
extern |
Converts the given std::string with content in the current locale to a std::wstring.
text | String to get converted |
Referenced by osmscout::LocaleStringToUTF8String().
A fast algorithm for finding polygon pole of inaccessibility, the most distant internal point from the polygon outline (not to be confused with centroid).
Useful for optimal placement of a text label on a polygon.
Based on PolyLabel algorithm from Mapbox
References osmscout::Area::GetBoundingBox(), osmscout::Area::Ring::nodes, osmscout::PolygonCenter(), and osmscout::Area::VisitRings().
Referenced by osmscout::PolygonCenter(), and osmscout::PolygonCenter().
|
extern |
Replace all occurrences of search in input string by some other string.
When search is empty, unchanged input string is returned.
in | - input string |
search | |
replacement |
|
extern |
Simplifying a token list by merging tokens that start with an upper case letter followed by a token starting with a lower case letter.
|
extern |
Split string by separator.
For arguments "asphalt;ground;gravel" and ";" return list of three...
Referenced by osmscout::TagRegistry::GetGradeForSurface(), osmscout::OpeningHours::Parse(), osmscout::LanesFeature::Parse(), and osmscout::SplitDestinations().
|
extern |
Converts the given string into a list of whitespace separated (std::isspace()) strings.
|
extern |
Convert the given string to a boolean value.
string | string with a potential boolean value (either 'true' or 'false') |
value | value to copy the result to if no error occurred |
Referenced by osmscout::ParseBoolArgument().
|
extern |
|
extern |
|
inline |
Converts a string holding a (possibly negative) numerical value of the given base to the numerical value itself.
Example: "-13" => -13
References osmscout::base.
Referenced by osmscout::oss::Parser::ATTRIBUTEVALUE(), osmscout::TagBinaryCondition::Evaluate(), osmscout::oss::Parser::MAG(), osmscout::CmdLineNumberArgParser< N >::Parse(), osmscout::CmdLineGeoCoordArgParser::Parse(), osmscout::AdminLevelFeature::Parse(), osmscout::ChargingStationFeature::Parse(), osmscout::ConstructionYearFeature::Parse(), osmscout::EleFeature::Parse(), osmscout::LanesFeature::Parse(), osmscout::LayerFeature::Parse(), osmscout::WidthFeature::Parse(), osmscout::ParseSizeTArgument(), osmscout::ParseUInt32Argument(), osmscout::oss::Parser::UINT(), osmscout::ost::Parser::UINT(), and osmscout::ost::Parser::UINT8().
|
extern |
Converts the given string into a list of whitespace or colon-separated strings.
Referenced by osmscout::LocationService::SearchForLocationByString().
|
extern |
Convert the given std::string in UTF-8 a std::string containing to corresponding string in the current locale.
text | the std::wstring to get converted |
References osmscout::UTF8StringToWString(), and osmscout::WStringToLocaleString().
Referenced by osmscout::Place::GetDisplayString().
|
extern |
Convert the given std::string containign a UTF8 character sequence to a std::u32string.
text | String to get converted |
Referenced by osmscout::TextLoader::AddCharactersToTextureAtlas().
|
extern |
Convert the given std::string containign a UTF8 character sequence to a std::wstring.
text | String to get converted |
Referenced by osmscout::MapPainterAgg::Layout(), osmscout::MapPainterCairo::Layout(), and osmscout::UTF8StringToLocaleString().
|
extern |
Converts the given std::wstring to a std::string with content in the current locale.
text | String to get converted |
Referenced by osmscout::UTF8StringToLocaleString().
|
extern |
Convert the given std::wstring to a std::string containing a corresponding UTF8 character sequence.
text | the std::wstring to get converted |
Referenced by osmscout::Locale::FromStdLocale(), and osmscout::LocaleStringToUTF8String().
const size_t osmscout::coordByteSize =7 |
Number of bytes needed to store a lat,lon coordinate pair.
Referenced by osmscout::CoordDataFile::Get(), osmscout::FileScanner::ReadConditionalCoord(), osmscout::FileScanner::ReadCoord(), osmscout::FileWriter::WriteCoord(), and osmscout::FileWriter::WriteInvalidCoord().
const double osmscout::latConversionFactor =(double)maxRawCoordValue/180.0 |
Coordinates will be stored as unsigned long values in file.
For the conversion the float value is shifted to positive value and afterwards multiplied by conversion factor to get long values without significant values after colon.
Referenced by osmscout::GeoCoord::EncodeToBuffer(), osmscout::Point::GetCoordFromId(), osmscout::GeoCoord::GetHash(), osmscout::GeoCoord::GetId(), osmscout::Point::GetId(), osmscout::IsValidToWrite(), osmscout::FileScanner::Read(), osmscout::FileWriter::Write(), osmscout::FileWriter::Write(), and osmscout::FileWriter::WriteCoord().
const double osmscout::lonConversionFactor =(double)maxRawCoordValue/360.0 |
Coordinates will be stored as unsigned long values in file.
For the conversion the float value is shifted to positive value and afterwards multiplied by conversion factor to get long values without significant values after colon.
Referenced by osmscout::GeoCoord::EncodeToBuffer(), osmscout::Point::GetCoordFromId(), osmscout::GeoCoord::GetHash(), osmscout::GeoCoord::GetId(), osmscout::Point::GetId(), osmscout::IsValidToWrite(), osmscout::FileScanner::Read(), osmscout::FileWriter::Write(), osmscout::FileWriter::Write(), and osmscout::FileWriter::WriteCoord().