Beispiel #1
0
        /// <summary>
        /// Builds a guid for the given face.
        /// </summary>
        /// <param name="graph">The graph.</param>
        /// <param name="face">The face.</param>
        public static Guid?GetFaceGuid(this TiledBarrierGraph graph, int face)
        {
            var locations = graph.FaceToClockwiseCoordinates(face).Select(x =>
                                                                          TileStatic.ToLocalTileCoordinates(14, x, 16384)).ToArray();

            return(GetFaceGuidFor(locations));
        }
Beispiel #2
0
        public static void WriteToStream(this TiledBarrierGraph.BarrierGraphEnumerator enumerator, Stream stream)
        {
            var graph = enumerator.Graph;

            stream.Write(enumerator.GetEdgeGuid().ToByteArray());

            var vertex2Guid = graph.GetVertexGuid(enumerator.Vertex2);

            stream.Write(vertex2Guid.ToByteArray());

            var shape = enumerator.Shape;

            stream.Write(BitConverter.GetBytes(shape.Length));
            for (var s = 0; s < shape.Length; s++)
            {
                stream.Write(TileStatic.ToLocalTileCoordinates(graph.Zoom, shape[s], 16384).GetBytes());
            }

            var tags = enumerator.Tags;

            stream.Write(BitConverter.GetBytes(tags.Count));
            foreach (var tag in tags)
            {
                stream.WriteWithSize(tag.Key);
                stream.WriteWithSize(tag.Value);
            }
        }
        /// <summary>
        /// Builds a guid for the given vertex.
        /// </summary>
        /// <param name="graph">The graph.</param>
        /// <param name="vertex">The vertex.</param>
        public static Guid GetVertexGuid(this TiledBarrierGraph graph, int vertex)
        {
            // we have a planar graph so location <-> guid.
            // we generate an id based on the vertex location relative in a tile.

            var location     = graph.GetVertex(vertex);
            var tileLocation = TileStatic.ToLocalTileCoordinates(graph.Zoom, location, 16384);

            return(GuidUtility.Create(Namespace, tileLocation.GetBytes()));
        }
        /// <summary>
        /// Builds a guid for the given edge.
        /// </summary>
        /// <param name="enumerator">The enumerator moved to the edge.</param>
        public static Guid GetEdgeGuid(this TiledBarrierGraph.BarrierGraphEnumerator enumerator)
        {
            var bytes = new List <byte>();

            if (!enumerator.Forward)
            {
                var otherEnumerator = enumerator.Graph.GetEnumerator();
                otherEnumerator.MoveTo(enumerator.Vertex2);
                otherEnumerator.MoveNextUntil(enumerator.Edge);
                enumerator = otherEnumerator;
            }

            foreach (var c in enumerator.CompleteShape())
            {
                var tiledLocation = TileStatic.ToLocalTileCoordinates(enumerator.Graph.Zoom, c, 16384);
                bytes.AddRange(tiledLocation.GetBytes());
            }

            return(GuidUtility.Create(Namespace, bytes));
        }
Beispiel #5
0
 private static byte[] GetVertexLocationBytes(this TiledBarrierGraph graph, int v)
 {
     return(TileStatic.ToLocalTileCoordinates(graph.Zoom, graph.GetVertex(v), 16384).GetBytes());
 }