Ejemplo n.º 1
0
        private void decodeWayNodesDoubleDelta(LatLong[] waySegment, double tileLatitude, double tileLongitude)
        {
            // get the first way node latitude offset (VBE-S)
            double wayNodeLatitude = tileLatitude + LatLongUtils.MicrodegreesToDegrees(this.readBuffer.ReadSignedInt());

            // get the first way node longitude offset (VBE-S)
            double wayNodeLongitude = tileLongitude + LatLongUtils.MicrodegreesToDegrees(this.readBuffer.ReadSignedInt());

            // store the first way node
            waySegment[0] = new LatLong(wayNodeLatitude, wayNodeLongitude);

            double previousSingleDeltaLatitude  = 0;
            double previousSingleDeltaLongitude = 0;

            for (int wayNodesIndex = 1; wayNodesIndex < waySegment.Length; ++wayNodesIndex)
            {
                // get the way node latitude double-delta offset (VBE-S)
                double doubleDeltaLatitude = LatLongUtils.MicrodegreesToDegrees(this.readBuffer.ReadSignedInt());

                // get the way node longitude double-delta offset (VBE-S)
                double doubleDeltaLongitude = LatLongUtils.MicrodegreesToDegrees(this.readBuffer.ReadSignedInt());

                double singleDeltaLatitude  = doubleDeltaLatitude + previousSingleDeltaLatitude;
                double singleDeltaLongitude = doubleDeltaLongitude + previousSingleDeltaLongitude;

                wayNodeLatitude  = wayNodeLatitude + singleDeltaLatitude;
                wayNodeLongitude = wayNodeLongitude + singleDeltaLongitude;

                waySegment[wayNodesIndex] = new LatLong(wayNodeLatitude, wayNodeLongitude);

                previousSingleDeltaLatitude  = singleDeltaLatitude;
                previousSingleDeltaLongitude = singleDeltaLongitude;
            }
        }
Ejemplo n.º 2
0
        private LatLong ReadOptionalLabelPosition(double tileLatitude, double tileLongitude, bool featureLabelPosition)
        {
            if (featureLabelPosition)
            {
                // get the label position latitude offset (VBE-S)
                double latitude = tileLatitude + LatLongUtils.MicrodegreesToDegrees(this.readBuffer.ReadSignedInt());

                // get the label position longitude offset (VBE-S)
                double longitude = tileLongitude + LatLongUtils.MicrodegreesToDegrees(this.readBuffer.ReadSignedInt());

                return(new LatLong(latitude, longitude));
            }

            return(null);
        }
Ejemplo n.º 3
0
        internal static void ReadBoundingBox(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder)
        {
            double minLatitude  = LatLongUtils.MicrodegreesToDegrees(readBuffer.ReadInt());
            double minLongitude = LatLongUtils.MicrodegreesToDegrees(readBuffer.ReadInt());
            double maxLatitude  = LatLongUtils.MicrodegreesToDegrees(readBuffer.ReadInt());
            double maxLongitude = LatLongUtils.MicrodegreesToDegrees(readBuffer.ReadInt());

            try
            {
                mapFileInfoBuilder.boundingBox = new BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude);
            }
            catch (System.ArgumentException e)
            {
                throw new MapFileException(e.Message);
            }
        }
Ejemplo n.º 4
0
 private void ReadMapStartPosition(ReadBuffer readBuffer)
 {
     if (this.HasStartPosition)
     {
         double mapStartLatitude  = LatLongUtils.MicrodegreesToDegrees(readBuffer.ReadInt());
         double mapStartLongitude = LatLongUtils.MicrodegreesToDegrees(readBuffer.ReadInt());
         try
         {
             this.StartPosition = new LatLong(mapStartLatitude, mapStartLongitude, true);
         }
         catch (System.ArgumentException e)
         {
             throw new MapFileException(e.Message);
         }
     }
 }
Ejemplo n.º 5
0
        private IList <PointOfInterest> ProcessPOIs(double tileLatitude, double tileLongitude, int numberOfPois, BoundingBox boundingBox, bool filterRequired)
        {
            IList <PointOfInterest> pois = new List <PointOfInterest>();

            Tag[] poiTags = this.mapFileHeader.MapFileInfo.PoiTags;

            for (int elementCounter = numberOfPois; elementCounter != 0; --elementCounter)
            {
                if (this.mapFileHeader.MapFileInfo.DebugFile)
                {
                    // get and check the POI signature
                    string signaturePoi = this.readBuffer.ReadUTF8EncodedString(SIGNATURE_LENGTH_POI);
                    if (!signaturePoi.StartsWith("***POIStart", StringComparison.Ordinal))
                    {
                        LOGGER.Warn("invalid POI signature: " + signaturePoi);
                        return(null);
                    }
                }

                // get the POI latitude offset (VBE-S)
                double latitude = tileLatitude + LatLongUtils.MicrodegreesToDegrees(this.readBuffer.ReadSignedInt());

                // get the POI longitude offset (VBE-S)
                double longitude = tileLongitude + LatLongUtils.MicrodegreesToDegrees(this.readBuffer.ReadSignedInt());

                // get the special byte which encodes multiple flags
                sbyte specialByte = this.readBuffer.ReadByte();

                // bit 1-4 represent the layer
                sbyte layer = (sbyte)((int)((uint)(specialByte & POI_LAYER_BITMASK) >> POI_LAYER_SHIFT));
                // bit 5-8 represent the number of tag IDs
                sbyte numberOfTags = (sbyte)(specialByte & POI_NUMBER_OF_TAGS_BITMASK);

                IList <Tag> tags = new List <Tag>();

                // get the tag IDs (VBE-U)
                for (sbyte tagIndex = numberOfTags; tagIndex != 0; --tagIndex)
                {
                    int tagId = this.readBuffer.ReadUnsignedInt();
                    if (tagId < 0 || tagId >= poiTags.Length)
                    {
                        LOGGER.Warn("invalid POI tag ID: " + tagId);
                        return(null);
                    }
                    tags.Add(poiTags[tagId]);
                }

                // get the feature bitmask (1 byte)
                sbyte featureByte = this.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(new Tag(TAG_KEY_NAME, ExtractLocalized(this.readBuffer.ReadUTF8EncodedString())));
                }

                // check if the POI has a house number
                if (featureHouseNumber)
                {
                    tags.Add(new Tag(TAG_KEY_HOUSE_NUMBER, this.readBuffer.ReadUTF8EncodedString()));
                }

                // check if the POI has an elevation
                if (featureElevation)
                {
                    tags.Add(new Tag(TAG_KEY_ELE, Convert.ToString(this.readBuffer.ReadSignedInt())));
                }

                LatLong position = new LatLong(latitude, longitude);
                // depending on the zoom level configuration the poi can lie outside
                // the tile requested, we filter them out here
                if (!filterRequired || boundingBox.Contains(position))
                {
                    pois.Add(new PointOfInterest(layer, tags, position));
                }
            }

            return(pois);
        }