Comments (12)
The following images show what I did with red lines going around the button I clicked. If there is more than 1 line going around, there is number on the left showing the order it was clicked.
from chinese-postman.
experiencing the same on macOS🥲
from chinese-postman.
experiencing the same on macOS🥲
turns out unlike I've read somewhere qgis does install it's own python interpter. I've run pip install --force-reinstall networkx==2.3
on the pip of the qgis python installation and got one step further!
I did encounter another issue though but thankfully it was an easy fix. qgis comes with python3.9 which has moved some function called gcd from a module named fractions to math. I've changed in a file named dag.py from fractions import gcd
to from math import gcd
and it seems like everything works now.
from chinese-postman.
@MgTheProgrammer How did you run the QGIS version of PIP? I tried running in from a Windows command prompt in the directory that pip.exe is installed in under QGIS, but get a fatal python error and no module named encodings.
from chinese-postman.
@MgTheProgrammer I also tried:
import pip
pip.main(['install', '--force-reinstall', 'networkx==2.3'])
But got tons of errors. Next I tried:
pip.main(['install', '--force-reinstall networkx==2.3'])
But this crashes QGIS (I opened, re-ran the import and called it again and it crashes every time)
Another thing I tried was running this from the QGIS python directory:
python -m pip install --force-reinstall networkx==2.3
But this failed with a message pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
following which it failed to download anything due to the missing ssl module.
from chinese-postman.
@michael-ts
Sadly I don't quite remember what I did. I imagine though that I ran pip using its directory (on Mac it probably looked like that:
/Applications/QGIS.app/Contents/MacOS/bin/pip3 install networkx==2.3
).
I opened qgis now as you reminded me about this. And weirdly enough it doesn't work correctly, it gives me a path and concludes that its length is 0 km. I'm pretty sure last time I've played with it, it worked though. So I guess it's more related to something wrong with the input I give from qgis.
from chinese-postman.
Btw if what you are looking for is mostly an optimized route and less about specifically using it with qgis. This repo works without much effort from you as a user. It does give a bit less control but it's good enough imo.
from chinese-postman.
@MgTheProgrammer Thanks, I'm looking at this and it looks like it might be helpful at least until I can figure out how to get the QGIS plug-in working. I noticed a couple of issues which using QGIS may or may not solve:
-
I accidentally deleted a segment in the middle of a road I wanted to follow (not sure why; apparently it tries to find the closest segment to the mouse and despite the segment it deleted being some distance away it must have been the closest) and couldn't figure out how to add it back, so all the clicking I had done so far was wasted. It seems to be a LOT of clicking as there are lots of tiny line segments making up a single stretch of road.
-
There doesn't seem to be any way of specifying that you can take a segment if needed, but don't have to. In this case I had two disconnected networks of roads I wanted to reach in one trip, and it would be nice if it could find them minimal distance way to get between the two. But as soon as I the two networks became disconnected, the one not attached to my starting point was automatically erased.
from chinese-postman.
@MgTheProgrammer Also, it seems to be brute-forcing the solution. I thought there was a polynomial time solution; this isn't the travelling salesman problem...
from chinese-postman.
@MgTheProgrammer It's also not clear to me how to find the actual route... I downloaded the GPX file (was the only option offered). I tried to download it into Google Maps but it claimed (wrongly) that the GPX file was bad. I found a GPX to KML convertor but when I look at the route on the map it shows all the streets reached but I can't tell in what order to visit them. I found an online GPX editor and I can tell the route but only by dragging a slider and this would be a pain to try to manually transcribe into something like turn by turn directions. What method do you use?
from chinese-postman.
This is how I make the plugin work on a newly installed Fedora Workstation that have been updated, and have its graphic driver and related software installed.
After opening , I install the plugin.
I somehow see the information about error.
I do something to pip.
pip install --upgrade pip
pip install --force-reinstall networkx==2.3
This is how i run QGIS Desktop.
I see there is still error and click there to see more information.
I can see above the line mentioning the Python version an error. Above that error I see it says it is in a file called dag.py in line 23.
I click on the option to show hidden files and then go to that file so I can edit it.
I click on the thing to shows the line number..
I change the writing in line 23 to
from math import gcd
I click on the thing that looks the letter x on the top right.
I run QGIS Desktop again and see that error is gone.
I click that so the hidden file is not shown anymore.
from chinese-postman.
Following modification to postman.py
also fixes the error. nx.connected_component_subgraphs()
is deprecated, thus causing the error.
def graph_components(graph):
# The graph may contain multiple components, but we can only handle one connected component. If the graph contains
# more than one connected component, we only use the largest one.
components = list((graph.subgraph(c) for c in nx.connected_components(graph))) #list(nx.connected_component_subgraphs(graph)) <-- this is deprecated
components.sort(key=lambda c: c.size(), reverse=True)
return components
from chinese-postman.
Related Issues (18)
- failed by: AttributeError: 'generator' object has no attribute 'sort' HOT 3
- Turn-by-Turn? HOT 2
- Error: Could not find any components. Try selecting different features. HOT 2
- Error postman.py HOT 1
- Inaccurate results for trivial problems HOT 4
- AttributeError: 'set' object has no attribute 'items' HOT 2
- cant export from qgis HOT 2
- Incompatible with QGIS 2 HOT 7
- AttributeError: module 'networkx' has no attribute 'connected_component_subgraphs' HOT 8
- Unable to install plugin in QGIS 3.14.0-Pi HOT 1
- "Chinese Postman Solver" not found in QGIS plugin manager. HOT 5
- Tips for using the Chinese Postman plugin HOT 1
- Cannot import gcd from fractions HOT 1
- icon.png HOT 4
- No module named resources HOT 1
- Slightly off topic - CRS? HOT 7
- Windy Chinese Postman HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chinese-postman.