itinero / routing

The routing core of itinero.
Apache License 2.0
222 stars 71 forks source link

Contracted Serialization problem #21

Closed vastafev closed 8 years ago

vastafev commented 8 years ago

Hi! I have a problem with serialization/deserialisation routerdb. After i serialize/deserialize routerdb with contracted db, i get multiple exceptions "Cannot build vertex path, edge {0} -> {1} not found." from public static EdgePath BuildEdgePath. Exception does not appear when graph is build from osm.pbf file. It does not matter is ContractedDb vertex-based or edge-based. If i build routerdb from osm.pbf then serialize/deserialize and AddContracted - Exception appears also. I noticed that most of vertexes are neighbours: Cannot build vertex path, edge 506196 -> 506197 not found. Cannot build vertex path, edge 233711 -> 233710 not found. Cannot build vertex path, edge 327184 -> 327183 not found. Cannot build vertex path, edge 246937 -> 246936 not found. Cannot build vertex path, edge 17285 -> 17284 not found. Cannot build vertex path, edge 127953 -> 127952 not found. Cannot build vertex path, edge 342934 -> 342933 not found. Cannot build vertex path, edge 390288 -> 81578 not found. Cannot build vertex path, edge 327184 -> 327183 not found. Cannot build vertex path, edge 127953 -> 127952 not found. Cannot build vertex path, edge 382741 -> 382740 not found. Cannot build vertex path, edge 368624 -> 368656 not found. Cannot build vertex path, edge 49462 -> 49461 not found. Cannot build vertex path, edge 493653 -> 493654 not found.

xivk commented 8 years ago

I'll try to tests this; make sure you are using the latest version of Itinero both when creating the routerdb and when routing using it.

I recently fixed a bug that caused this kind of errors...

vastafev commented 8 years ago

I got the latest version and get the same effect. using (var _stream = File.Open(new FileInfo(filename).FullName, FileMode.Create, FileAccess.ReadWrite)) { routerDb.Serialize(_stream); _stream.Close(); }

            using (var stream = File.Open(file.FullName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                routerDb = RouterDb.Deserialize(stream);
            }
xivk commented 8 years ago

Ok, I just updated the functional test project with these lines and ran the routing tests after without errors.

Perhaps it depends on the source data? What country/data are you loading?

xivk commented 8 years ago

For reference, this is what I did:

            using (var stream = File.Open("temp.routerdb", FileMode.Create, FileAccess.ReadWrite))
            {
                routerDb.Serialize(stream);
                stream.Flush();
                stream.Close();
            }

            using (var stream = File.Open("temp.routerdb", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                routerDb = RouterDb.Deserialize(stream);
            }
            router = new Router(routerDb);
vastafev commented 8 years ago

Russia, Novosibirsk region I've just downloaded develop branch build it and got same error. Are yours test contain contracted db?

xivk commented 8 years ago

Yes, it has a contracted db, I added the code above right after this line:

https://github.com/itinero/routing/blob/develop/test/Itinero.Test.Functional/Program.cs#L77

After that 100 random routes are tested. Where can I download this region?

vastafev commented 8 years ago

http://be.gis-lab.info/data/osm_dump/dump/latest/RU-NVS.osm.pbf

vastafev commented 8 years ago

Is there any progress? Can I do something to help?