read1Poi method
PointOfInterest
read1Poi()
Reads a single Point of Interest (POI) from the given readBuffer.
Implementation
PointOfInterest read1Poi(Readbuffer readBuffer, double tileLatitude, double tileLongitude, MapDatastore mapDataStore, List<Tag> poiTags) {
if (_mapFileHeader.getMapHeaderInfo().debugFile) {
// get and check the POI signature
String signaturePoi = readBuffer.readUTF8EncodedString2(SIGNATURE_LENGTH_POI);
if (!signaturePoi.startsWith("***POIStart")) {
throw MapFileException("invalid POI signature: $signaturePoi");
}
}
// get the POI latitude offset (VBE-S)
double latitude = tileLatitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt());
// get the POI longitude offset (VBE-S)
double longitude = tileLongitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt());
// get the special int which encodes multiple flags
int specialByte = readBuffer.readByte();
// bit 1-4 represent the layer
int layer = ((specialByte & POI_LAYER_BITMASK) >> POI_LAYER_SHIFT);
// bit 5-8 represent the number of tag IDs
int numberOfTags = (specialByte & POI_NUMBER_OF_TAGS_BITMASK);
// get the tags from IDs (VBE-U)
List<Tag> tags = readBuffer.readTags(poiTags, numberOfTags);
// get the feature bitmask (1 byte)
int featureByte = readBuffer.readByte();
// bit 1-3 enable optional features
bool featureName = (featureByte & POI_FEATURE_NAME) != 0;
bool featureHouseNumber = (featureByte & POI_FEATURE_HOUSE_NUMBER) != 0;
bool featureElevation = (featureByte & POI_FEATURE_ELEVATION) != 0;
// check if the POI has a name
if (featureName) {
tags.add(Tag(TAG_KEY_NAME, mapDataStore.extractLocalized(readBuffer.readUTF8EncodedString())!));
}
// check if the POI has a house number
if (featureHouseNumber) {
tags.add(Tag(TAG_KEY_HOUSE_NUMBER, readBuffer.readUTF8EncodedString()));
}
// check if the POI has an elevation
if (featureElevation) {
tags.add(Tag(TAG_KEY_ELE, readBuffer.readSignedInt().toString()));
}
LatLong position = LatLong(latitude, longitude);
return PointOfInterest(layer, TagCollection(tags: tags), position);
}