示例#1
0
    public static void SaveBin(this MultiGridData multigrid, string filename)
    {
        using (var bw = new BinaryWriter(File.Open(filename, FileMode.Create)))
        {
            PatchDataIO.WriteBinVersion(bw);
            PatchDataIO.WriteBinBoundsHeader(bw, multigrid);

            // Write Metadata (if available)
            PatchDataIO.WriteBinMetadata(bw, multigrid.metadata);

            bw.Write((byte)multigrid.coloring);

            int categoriesCount = multigrid.categories == null ? 0 : multigrid.categories.Length;
            bw.Write(categoriesCount);

            if (multigrid.categories != null)
            {
                // Write categories (without values)
                foreach (var c in multigrid.categories)
                {
                    bw.Write(c.name);
                }

                // Write Grids
                foreach (var c in multigrid.categories)
                {
                    GridDataIO.WriteBinProperties(bw, c.grid);
                    GridDataIO.WriteBinValues(bw, c.grid);
                }
            }
        }
    }
示例#2
0
    private static void WriteBinHeader(BinaryWriter bw, GridData grid)
    {
        PatchDataIO.WriteBinVersion(bw);
        PatchDataIO.WriteBinBoundsHeader(bw, grid);

        // Write Categories count
        bw.Write(grid.categories == null ? 0 : grid.categories.Length);
    }
示例#3
0
    private static void WriteBinHeader(BinaryWriter bw, PointData pointData)
    {
        PatchDataIO.WriteBinVersion(bw);
        PatchDataIO.WriteBinBoundsHeader(bw, pointData);

        // Write Categories count
        bw.Write(pointData.categories == null ? 0 : pointData.categories.Length);
    }
示例#4
0
    public static void SaveBin(this GraphData graph, string filename)
    {
        using (var bw = new BinaryWriter(File.Open(filename, FileMode.Create)))
        {
            PatchDataIO.WriteBinVersion(bw);
            PatchDataIO.WriteBinBoundsHeader(bw, graph);

            bw.Write(graph.cellSizeX);
            bw.Write(graph.cellSizeY);

            int count = graph.nodes.Count;
            bw.Write(count);
            for (int n = 0; n < count; n++)
            {
                GraphNode node = graph.nodes[n];
                bw.Write(node.longitude);
                bw.Write(node.latitude);
                bw.Write(node.classifications);
                bw.Write(node.index);
            }

            for (int n = 0; n < count; n++)
            {
                GraphNode node = graph.nodes[n];
                for (int l = 0; l < node.links.Count; l++)
                {
                    var link      = node.links[l];
                    int index     = node.index;
                    int linkIndex = link.index;
                    if (linkIndex > index)
                    {
                        bw.Write(index);
                        bw.Write(linkIndex);
                        bw.Write(node.linkDistances[l]);
                        bw.Write(node.linkClassifications[l]);
                    }
                }
            }
        }
    }