anitagraser / QGIS-Processing-tools

This is a collection of scripts and models for QGIS Processing
89 stars 55 forks source link

[test] point_layer_to_route_with_oneways.py #8

Open brylie opened 9 years ago

brylie commented 9 years ago

Test point_layer_to_route_with_oneways.py with QGIS 2.6.

brylie commented 9 years ago

I am looking in the sample data (testdata.sqlite) for a network with direction field. There are two network tables (network, network2), but neither seems to have a direction field.

Is there some sample data that I can use to test this script?

brylie commented 9 years ago

I have updated the import, and the script runs successfully. However, I cannot produce any output.

I have tried:

anitagraser commented 9 years ago

The topology of the network table is broken in your sqlite (check the intersection in the north east). Also, the order of points is from the east to the west, while the one way in the middle runs from west to east.

brylie commented 9 years ago

Alright, as far as I recall, the only modification I have made to the network table was to add another column. Would this possibly have broken the topology?

anitagraser commented 9 years ago

No, I don't see how that would have happened by only editing the attributes.

brylie commented 9 years ago

Hm, alright. I needed a table with direction attributes, so that I could test the oneways. How was the original topology created?

anitagraser commented 9 years ago

All that matters for the network analysis library is that the start and end nodes are properly snapped together, i.e. have exactly the same coordinates.

brylie commented 9 years ago

I am thinking that it might be good create a very basic set of tables to test the scripts. E.g.

The more complex tables can be eliminated, while the simple three could be used for automated testing.

anitagraser commented 9 years ago

Sure, that was the idea behind testdata.sqlite. Do you mean that the current tables are too complex?

brylie commented 9 years ago

Well, slightly yes. I am just thinking

anitagraser commented 9 years ago

I disagree that two points would be enough: it has to be tested that the result is a consecutive route. Imho this cannot be ensured by only testing between one start and end point. There can be errors in the code which could cause to route to end up jumbled or broken.

I'm not sure if using the same coordinates for route lines and points really makes a difference ... Isn't the idea of testing to test different scenarios? Why make everything so same?

brylie commented 9 years ago

Here is a first attempt at visualizing a simple topology.

simplenetworgeometry

brylie commented 9 years ago

I am just proposing to reduce the problem to the minimum number of components and test on that. As additional bugs are found additional tests can be built with complexity needed.

E.g. for the sequential routing you mention, three points may be sufficient to demonstrate that the algorithm is working at a basic level for automated testing.

anitagraser commented 9 years ago

I appreciate the approach and please do feel free to write tests and have an sqlite file with data for these tests. For my manual tests during method development I prefer to have a little more complex test data in order to be able to discover issues.

brylie commented 9 years ago

Thanks Anita. I will take a look at how to create sqlite files and unit test python scripts.