rkistner / chinese-postman

Python application to solve the Chinese postman problem
MIT License
55 stars 15 forks source link

Error: Could not find any components. Try selecting different features. #11

Closed wiltonjr closed 5 years ago

wiltonjr commented 7 years ago

I create a new project and add new layer from a delimited text and "Select Features by Polygon" tool, but dont work

peternowee commented 5 years ago

Chinese Postman Solver only works on a layer of type Vector (not Raster or Mesh) and of geometry type Line (not Point or Polygon). According to the QGIS 2.18 context help for Add Delimited Text File Layer, it can only create a layer of geometry type Line from WKT-formatted files containing fields like LINESTRING(...). Other text files will probably all create layers of geometry type Point.

For example, the example file test_graph.csv included with Chinese Postman Solver was probably meant specifically for the command-line solver and is not WKT-formatted. QGIS will import only the start nodes as points on a Point-layer and ignore the end nodes (tested with both 2.18.28 and 3.4.6). When I then select those points and run Chinese Postman Solver, I get the same error message as you got:

Error: Could not find any components. Try selecting different features.

To check what kind of layer you have (QGIS 2.18.28): Layer -> Properties... -> Metadata -> Properties -> General -> Geometry type of the features in this layer. When it says Point (WKB type: "Point"), you will get the error message you got. It needs to say Line (WKB type: "LineString") for Chinese Postman Solver to work.

I created PR https://github.com/rkistner/chinese-postman/pull/16 to provide more specific error messages.

rkistner commented 5 years ago

Fixed by #16, released in 0.2.2 and 0.3.0.