SpaceGroupUCL / depthmapX

depthmapX is a multi-platform Spatial Network Analysis Software
200 stars 53 forks source link

convex map links by cli #334

Open joint-ventura opened 4 years ago

joint-ventura commented 4 years ago

Hi,

I´ve been trying to do convex map links automation in cli mode. No results, either with "coords" or "refs" flags in LINK mode, or single link or with csv file with links... Probably I'm doing something wrong... Is there somewhere an example? Thanks

JVL

pklampros commented 4 years ago

Hi JVL,

Sure, download polygons_drawing.graph, a test file that only contains a drawing map which should look like that:

Screen Shot 2020-01-21 at 21 06 05

then open your terminal (or wherever you call the cli from) and run the following commands:

First convert the drawing to a convex map, name it "convex_map" and remove the drawing map. This command will take the file polygons_drawing.graph, open it, do the operations and save a new file called "out.graph"

./depthmapXcli -f polygons_drawing.graph -o out.graph -m MAPCONVERT -co convex -con convex_map -cir

Then connect convex spaces with RefIDs 1 and 3. This command will open out.graph, execute the commands and overwrite it.

./depthmapXcli -f out.graph -o out.graph -m LINK -lmt shapegraphs -lm link -lt refs -lnk 1,3

Then connect convex spaces as if you clicked on two of them (by giving exact coordinates), specifically at 180, 240 and then at 45, 80. This command will open out.graph, execute the commands and overwrite it.

./depthmapXcli -f out.graph -o out.graph -m LINK -lmt shapegraphs -lm link -lt coords -lnk 180,240,45,80

The final result should look like this (with links visible, note that ellipses are not converted to convex spaces): Screen Shot 2020-01-21 at 21 14 05

Let me know if this works P

pklampros commented 4 years ago

Here's the python equivalent:

import subprocess;

# First convert the drawing to a convex map, name it "convex_map" and remove the drawing map.
# This command will take the file polygons_drawing.graph, open it, do the operations and save a new file called "out.graph"
subprocess.check_output(["./depthmapXcli_macos",
                         "-f", "polygons_drawing.graph",
                         "-o", "out.graph",
                         "-m", "MAPCONVERT",
                         "-co", "convex",
                         "-cir",
                         "-con", "convex_map"])

# Then connect convex spaces with RefIDs 1 and 3.
# This command will open out.graph, execute the commands and overwrite it.
subprocess.check_output(["./depthmapXcli_macos",
                         "-f", "out.graph",
                         "-o", "out.graph",
                         "-m", "LINK",
                         "-lmt", "shapegraphs",
                         "-lm", "link",
                         "-lt", "refs",
                         "-lnk", "1,3"])

# Then connect convex spaces as if you clicked on two of them (by giving exact coordinates), specifically at 180, 240 and then at 45, 80.
# This command will open out.graph, execute the commands and overwrite it.
subprocess.check_output(["./depthmapXcli_macos",
                         "-f", "out.graph",
                         "-o", "out.graph",
                         "-m", "LINK",
                         "-lmt", "shapegraphs",
                         "-lm", "link",
                         "-lt", "coords",
                         "-lnk", "180,240,45,80"])

Note, I use a mac, so the cli I use is depthmapXcli_macos. If you are on windows it's probably depthmapXcli_win64.exe if on linux then depthmapXcli_linux64 - make sure you also change the python script where appropriate.

P

joint-ventura commented 4 years ago

Hi P,

sorry for the late reply. Yes it ran smoothly, just a few minor adjustments for windows, without problems. Thanks,

JVL

joint-ventura commented 4 years ago

sorry to insist, I don't seen to be able to figure out how to use a "links file" ( -lf as in -lnk), with no multiple open and save the graph file. Is it possible to do it without reading the links file line by line (opening and closing the graph file each time)? Thanks, JVL

pklampros commented 4 years ago

Indeed, that specific case is not as clear as I had hoped because although the help text mentions csv (comma separated values) it seems it the application only accepts tab as a separator. Thus either a file with this content (let's call this linkCoords.txt):

x1  y1  x2  y2
180 240 45  80
74  230 300 200

or one like this (let's call this linkRefs.txt):

reffrom refto
2   0
1   3

Careful, these are not spaces but tab characters..

Then the commands from above would be:

./depthmapXcli -f out.graph -o out.graph -m LINK -lmt shapegraphs -lm link -lt refs -lf linkRefs.txt

or:

./depthmapXcli -f out.graph -o out.graph -m LINK -lmt shapegraphs -lm link -lt coords -lf linkCoords.txt

Maybe we need to put this in the wiki somwhere...